From 73af68dce5c82a6e7e7e782a0060d34613ede2e2 Mon Sep 17 00:00:00 2001 From: Matthew Messinger Date: Mon, 29 Feb 2016 23:38:13 -0500 Subject: [PATCH] remove the liteloader, jenkins ivy --- build.gradle | 32 +- liteloader/.factorypath | 3 - liteloader/.gitignore | 78 - liteloader/build.gradle | 291 ---- liteloader/checkstyle.xml | 109 -- liteloader/extra/formatter.xml | 295 ---- liteloader/extra/liteloader.importorder | 7 - liteloader/gradle.properties | 10 - .../com/mumfrey/liteloader/ChatFilter.java | 27 - .../com/mumfrey/liteloader/ChatListener.java | 20 - .../liteloader/ChatRenderListener.java | 15 - .../liteloader/EntityRenderListener.java | 39 - .../liteloader/FrameBufferListener.java | 34 - .../mumfrey/liteloader/GameLoopListener.java | 18 - .../mumfrey/liteloader/HUDRenderListener.java | 13 - .../liteloader/InitCompleteListener.java | 24 - .../mumfrey/liteloader/JoinGameListener.java | 29 - .../liteloader/OutboundChatFilter.java | 17 - .../liteloader/OutboundChatListener.java | 20 - .../mumfrey/liteloader/PostLoginListener.java | 21 - .../liteloader/PostRenderListener.java | 23 - .../mumfrey/liteloader/PreRenderListener.java | 57 - .../mumfrey/liteloader/RenderListener.java | 36 - .../liteloader/ScreenshotListener.java | 28 - .../java/com/mumfrey/liteloader/Tickable.java | 22 - .../mumfrey/liteloader/ViewportListener.java | 10 - .../client/ClientPluginChannelsClient.java | 121 -- .../liteloader/client/ClientProxy.java | 183 --- .../liteloader/client/GameEngineClient.java | 159 -- .../client/LiteLoaderCoreProviderClient.java | 111 -- .../client/LiteLoaderEventBrokerClient.java | 567 -------- .../client/LiteLoaderPanelManager.java | 294 ---- .../liteloader/client/PacketEventsClient.java | 262 ---- .../liteloader/client/ResourceObserver.java | 117 -- .../liteloader/client/ResourcesClient.java | 95 -- .../client/SoundHandlerReloadInhibitor.java | 129 -- .../mumfrey/liteloader/client/Translator.java | 30 - .../api/LiteLoaderBrandingProvider.java | 141 -- .../client/api/LiteLoaderCoreAPIClient.java | 161 -- .../api/LiteLoaderModInfoDecorator.java | 138 -- .../client/api/ObjectFactoryClient.java | 164 --- .../client/ducks/IClientNetLoginHandler.java | 8 - .../liteloader/client/ducks/IFramebuffer.java | 8 - .../client/ducks/INamespacedRegistry.java | 6 - .../client/ducks/IObjectIntIdentityMap.java | 11 - .../client/ducks/IRegistrySimple.java | 8 - .../liteloader/client/ducks/IReloadable.java | 10 - .../client/ducks/IRenderManager.java | 11 - .../ducks/ITileEntityRendererDispatcher.java | 11 - .../liteloader/client/gui/GuiCheckbox.java | 51 - .../liteloader/client/gui/GuiHoverLabel.java | 55 - .../client/gui/GuiLiteLoaderPanel.java | 815 ----------- .../liteloader/client/gui/GuiPanel.java | 209 --- .../liteloader/client/gui/GuiPanelAbout.java | 251 ---- .../client/gui/GuiPanelConfigContainer.java | 274 ---- .../liteloader/client/gui/GuiPanelError.java | 161 -- .../client/gui/GuiPanelLiteLoaderLog.java | 406 ------ .../liteloader/client/gui/GuiPanelMods.java | 295 ---- .../client/gui/GuiPanelSettings.java | 152 -- .../client/gui/GuiPanelUpdateCheck.java | 232 --- .../liteloader/client/gui/GuiScrollPanel.java | 208 --- .../client/gui/GuiSimpleScrollBar.java | 153 -- .../client/gui/ScrollPanelContent.java | 14 - .../client/gui/modlist/GuiModInfoPanel.java | 155 -- .../client/gui/modlist/GuiModListPanel.java | 271 ---- .../gui/modlist/GuiModListPanelInvalid.java | 53 - .../client/gui/modlist/ModList.java | 273 ---- .../client/gui/modlist/ModListContainer.java | 18 - .../client/gui/modlist/ModListEntry.java | 334 ----- .../client/gui/startup/LoadingBar.java | 440 ------ .../client/mixin/MixinEntityPlayerSP.java | 26 - .../client/mixin/MixinEntityRenderer.java | 115 -- .../client/mixin/MixinFramebuffer.java | 43 - .../client/mixin/MixinGuiIngame.java | 39 - .../client/mixin/MixinIntegratedServer.java | 39 - .../client/mixin/MixinMinecraft.java | 85 -- .../mixin/MixinNetHandlerLoginClient.java | 21 - .../mixin/MixinObjectIntIdentityMap.java | 32 - .../client/mixin/MixinRealmsMainScreen.java | 26 - .../client/mixin/MixinRegistryNamespaced.java | 23 - .../client/mixin/MixinRegistrySimple.java | 23 - .../client/mixin/MixinRenderManager.java | 39 - .../client/mixin/MixinScreenShotHelper.java | 32 - .../liteloader/client/mixin/MixinSession.java | 31 - .../MixinSimpleReloadableResourceManager.java | 23 - .../MixinTileEntityRendererDispatcher.java | 24 - .../client/overlays/IEntityRenderer.java | 29 - .../client/overlays/IGuiTextField.java | 36 - .../client/overlays/IMinecraft.java | 60 - .../client/overlays/ISoundHandler.java | 14 - .../transformers/CrashReportTransformer.java | 75 - .../transformers/MinecraftTransformer.java | 91 -- .../client/util/PrivateFieldsClient.java | 22 - .../client/util/render/IconAbsolute.java | 128 -- .../util/render/IconAbsoluteClickable.java | 20 - .../client/util/render/IconTiled.java | 140 -- .../java/com/mumfrey/liteloader/gl/GL.java | 1296 ----------------- .../liteloader/gl/GLClippingPlanes.java | 193 --- .../resources/InternalResourcePack.java | 119 -- .../liteloader/resources/ModResourcePack.java | 59 - .../resources/ModResourcePackDir.java | 59 - .../mumfrey/liteloader/util/InputManager.java | 361 ----- .../mumfrey/liteloader/util/ModUtilities.java | 253 ---- .../resources/mixins.liteloader.client.json | 23 - .../liteloader/debug/LoginManager.java | 458 ------ .../mumfrey/liteloader/debug/LoginPanel.java | 366 ----- .../debug/resources/obfuscation.properties | 69 - .../com/mumfrey/liteloader/Configurable.java | 20 - .../java/com/mumfrey/liteloader/LiteMod.java | 40 - .../com/mumfrey/liteloader/PacketHandler.java | 32 - .../com/mumfrey/liteloader/Permissible.java | 55 - .../liteloader/PlayerInteractionListener.java | 58 - .../liteloader/PlayerMoveListener.java | 27 - .../liteloader/PluginChannelListener.java | 22 - .../liteloader/PreJoinGameListener.java | 24 - .../java/com/mumfrey/liteloader/Priority.java | 22 - .../mumfrey/liteloader/ServerChatFilter.java | 22 - .../liteloader/ServerCommandProvider.java | 21 - .../liteloader/ServerPlayerListener.java | 51 - .../ServerPluginChannelListener.java | 25 - .../mumfrey/liteloader/ServerTickable.java | 18 - .../mumfrey/liteloader/ShutdownListener.java | 13 - .../liteloader/api/BrandingProvider.java | 116 -- .../liteloader/api/ContainerRegistry.java | 98 -- .../mumfrey/liteloader/api/CoreProvider.java | 63 - .../liteloader/api/CustomisationProvider.java | 11 - .../liteloader/api/EnumerationObserver.java | 64 - .../liteloader/api/EnumeratorModule.java | 68 - .../liteloader/api/EnumeratorPlugin.java | 37 - .../liteloader/api/GenericObserver.java | 13 - .../liteloader/api/InterfaceObserver.java | 11 - .../liteloader/api/InterfaceProvider.java | 32 - .../com/mumfrey/liteloader/api/Listener.java | 22 - .../com/mumfrey/liteloader/api/LiteAPI.java | 120 -- .../liteloader/api/MixinConfigProvider.java | 27 - .../liteloader/api/ModClassValidator.java | 14 - .../liteloader/api/ModInfoDecorator.java | 53 - .../liteloader/api/ModLoadObserver.java | 65 - .../com/mumfrey/liteloader/api/Observer.java | 15 - .../liteloader/api/PostRenderObserver.java | 14 - .../liteloader/api/ShutdownObserver.java | 15 - .../mumfrey/liteloader/api/TickObserver.java | 13 - .../liteloader/api/TranslationProvider.java | 21 - .../mumfrey/liteloader/api/WorldObserver.java | 16 - .../api/exceptions/APIException.java | 27 - .../api/exceptions/InvalidAPIException.java | 16 - .../exceptions/InvalidAPIStateException.java | 11 - .../exceptions/InvalidProviderException.java | 16 - .../liteloader/api/manager/APIAdapter.java | 86 -- .../liteloader/api/manager/APIProvider.java | 50 - .../api/manager/APIProviderBasic.java | 340 ----- .../liteloader/api/manager/APIRegistry.java | 182 --- .../mumfrey/liteloader/common/GameEngine.java | 78 - .../liteloader/common/LoadingProgress.java | 66 - .../mumfrey/liteloader/common/Resources.java | 28 - .../liteloader/common/ducks/IChatPacket.java | 10 - .../common/ducks/IPacketClientSettings.java | 6 - .../mixin/MixinC15PacketClientSettings.java | 20 - .../common/mixin/MixinItemInWorldManager.java | 42 - .../common/mixin/MixinMinecraftServer.java | 20 - .../common/mixin/MixinS02PacketChat.java | 27 - .../MixinServerConfigurationManager.java | 68 - .../LiteLoaderPacketTransformer.java | 24 - .../common/transformers/PacketEvent.java | 65 - .../common/transformers/PacketEventInfo.java | 23 - .../liteloader/core/BadContainerInfo.java | 64 - .../liteloader/core/ClientPluginChannels.java | 196 --- .../core/CommonPluginChannelListener.java | 22 - .../mumfrey/liteloader/core/Containers.java | 172 --- .../liteloader/core/EnabledModsList.java | 252 ---- .../mumfrey/liteloader/core/IEventState.java | 9 - .../core/InterfaceRegistrationDelegate.java | 93 -- .../mumfrey/liteloader/core/LiteLoader.java | 1023 ------------- .../liteloader/core/LiteLoaderBootstrap.java | 775 ---------- .../liteloader/core/LiteLoaderEnumerator.java | 838 ----------- .../core/LiteLoaderEventBroker.java | 548 ------- .../core/LiteLoaderInterfaceManager.java | 526 ------- .../liteloader/core/LiteLoaderMods.java | 795 ---------- .../liteloader/core/LiteLoaderUpdateSite.java | 171 --- .../liteloader/core/LiteLoaderVersion.java | 138 -- .../java/com/mumfrey/liteloader/core/Mod.java | 205 --- .../com/mumfrey/liteloader/core/ModInfo.java | 230 --- .../com/mumfrey/liteloader/core/NonMod.java | 57 - .../mumfrey/liteloader/core/PacketEvents.java | 317 ---- .../liteloader/core/PlayerEventState.java | 139 -- .../liteloader/core/PluginChannels.java | 237 --- .../com/mumfrey/liteloader/core/Proxy.java | 140 -- .../liteloader/core/ServerPluginChannels.java | 262 ---- .../core/api/DefaultClassValidator.java | 48 - .../core/api/DefaultEnumeratorPlugin.java | 190 --- .../core/api/EnumeratorModuleClassPath.java | 143 -- .../core/api/EnumeratorModuleFolder.java | 411 ------ .../core/api/LiteLoaderCoreAPI.java | 176 --- .../core/api/LoadableModClassPath.java | 91 -- .../liteloader/core/api/LoadableModFile.java | 598 -------- .../liteloader/core/event/Cancellable.java | 28 - .../event/EventCancellationException.java | 25 - .../liteloader/core/event/EventProxy.java | 212 --- .../liteloader/core/event/HandlerList.java | 1112 -------------- .../core/event/IHandlerListDecorator.java | 63 - .../core/event/ProfilingHandlerList.java | 237 --- .../exceptions/OutdatedLoaderException.java | 21 - .../ProfilerCrossThreadAccessException.java | 18 - .../ProfilerStackCorruptionException.java | 17 - .../UnregisteredChannelException.java | 11 - .../liteloader/core/runtime/Methods.java | 91 -- .../mumfrey/liteloader/core/runtime/Obf.java | 432 ------ .../liteloader/core/runtime/Packets.java | 321 ---- .../crashreport/CallableLaunchWrapper.java | 47 - .../crashreport/CallableLiteLoaderBrand.java | 35 - .../crashreport/CallableLiteLoaderMods.java | 33 - .../liteloader/interfaces/FastIterable.java | 29 - .../interfaces/FastIterableDeque.java | 14 - .../liteloader/interfaces/Injectable.java | 40 - .../interfaces/InterfaceRegistry.java | 20 - .../liteloader/interfaces/Loadable.java | 100 -- .../liteloader/interfaces/LoadableFile.java | 507 ------- .../liteloader/interfaces/LoadableMod.java | 355 ----- .../interfaces/LoaderEnumerator.java | 97 -- .../liteloader/interfaces/MixinContainer.java | 42 - .../interfaces/ModularEnumerator.java | 56 - .../liteloader/interfaces/ObjectFactory.java | 45 - .../liteloader/interfaces/PanelManager.java | 86 -- .../liteloader/interfaces/TweakContainer.java | 47 - .../liteloader/launch/ClassPathUtilities.java | 478 ------ .../launch/ClassTransformerManager.java | 235 --- .../liteloader/launch/GameEnvironment.java | 28 - .../liteloader/launch/InjectionStrategy.java | 145 -- .../launch/InvalidTransformerException.java | 25 - .../launch/LiteLoaderTransformer.java | 65 - .../liteloader/launch/LiteLoaderTweaker.java | 692 --------- .../launch/LiteLoaderTweakerServer.java | 42 - .../liteloader/launch/LoaderBootstrap.java | 48 - .../liteloader/launch/LoaderEnvironment.java | 83 -- .../liteloader/launch/LoaderProperties.java | 103 -- .../launch/NonDelegatingClassLoader.java | 145 -- .../liteloader/launch/StartupEnvironment.java | 235 --- .../mumfrey/liteloader/messaging/Message.java | 184 --- .../liteloader/messaging/MessageBus.java | 269 ---- .../liteloader/messaging/Messenger.java | 62 - .../modconfig/AdvancedExposable.java | 39 - .../liteloader/modconfig/ConfigManager.java | 234 --- .../liteloader/modconfig/ConfigPanel.java | 95 -- .../liteloader/modconfig/ConfigPanelHost.java | 42 - .../liteloader/modconfig/ConfigStrategy.java | 33 - .../liteloader/modconfig/Exposable.java | 10 - .../modconfig/ExposableConfigWriter.java | 305 ---- .../modconfig/ExposableOptions.java | 32 - .../permissions/LocalPermissions.java | 24 - .../permissions/PermissibleAllMods.java | 70 - .../liteloader/permissions/Permission.java | 219 --- .../liteloader/permissions/Permissions.java | 38 - .../permissions/PermissionsManager.java | 51 - .../permissions/PermissionsManagerClient.java | 526 ------- .../permissions/PermissionsManagerServer.java | 66 - .../permissions/ReplicatedPermissions.java | 32 - .../permissions/ServerPermissions.java | 154 -- .../liteloader/transformers/AppendInsns.java | 19 - .../transformers/ByteCodeUtilities.java | 864 ----------- .../liteloader/transformers/Callback.java | 281 ---- .../CallbackInjectionTransformer.java | 361 ----- .../transformers/ClassOverlayTransformer.java | 537 ------- .../transformers/ClassTransformer.java | 63 - .../InjectedCallbackCollisionError.java | 26 - .../transformers/InvalidOverlayException.java | 25 - .../transformers/IsolatedClassWriter.java | 22 - .../liteloader/transformers/ObfProvider.java | 21 - .../liteloader/transformers/Obfuscated.java | 19 - .../transformers/PacketHandlerException.java | 30 - .../mumfrey/liteloader/transformers/Stub.java | 18 - .../transformers/access/Accessor.java | 19 - .../access/AccessorTransformer.java | 584 -------- .../transformers/access/Invoker.java | 18 - .../transformers/access/ObfTableClass.java | 21 - .../liteloader/transformers/event/Event.java | 728 --------- .../event/EventAlreadyInjectedException.java | 21 - .../transformers/event/EventInfo.java | 133 -- .../event/EventInjectionTransformer.java | 114 -- .../event/EventProxyTransformer.java | 77 - .../transformers/event/EventTransformer.java | 417 ------ .../transformers/event/InjectionPoint.java | 331 ----- .../liteloader/transformers/event/Jump.java | 54 - .../transformers/event/MethodInfo.java | 375 ----- .../transformers/event/ReadOnlyInsnList.java | 147 -- .../transformers/event/ReturnEventInfo.java | 140 -- .../event/inject/BeforeFieldAccess.java | 99 -- .../event/inject/BeforeInvoke.java | 387 ----- .../transformers/event/inject/BeforeNew.java | 83 -- .../event/inject/BeforeReturn.java | 61 - .../event/inject/BeforeStringInvoke.java | 77 - .../event/inject/JumpInsnPoint.java | 69 - .../transformers/event/inject/MethodHead.java | 28 - .../event/json/InvalidEventJsonException.java | 25 - .../event/json/JsonDescriptor.java | 93 -- .../transformers/event/json/JsonEvent.java | 159 -- .../transformers/event/json/JsonEvents.java | 205 --- .../event/json/JsonInjection.java | 188 --- .../event/json/JsonInjectionShiftType.java | 7 - .../event/json/JsonInjectionType.java | 11 - .../transformers/event/json/JsonMethods.java | 87 -- .../transformers/event/json/JsonObf.java | 61 - .../event/json/JsonObfuscationTable.java | 182 --- .../json/ModEventInjectionTransformer.java | 87 -- .../transformers/event/json/ModEvents.java | 104 -- .../mumfrey/liteloader/update/UpdateSite.java | 421 ------ .../liteloader/util/ChatUtilities.java | 132 -- .../liteloader/util/EntityUtilities.java | 29 - .../com/mumfrey/liteloader/util/Input.java | 93 -- .../mumfrey/liteloader/util/InputEvent.java | 136 -- .../mumfrey/liteloader/util/InputHandler.java | 36 - .../liteloader/util/ObfuscationUtilities.java | 87 -- .../com/mumfrey/liteloader/util/Position.java | 58 - .../liteloader/util/PrivateFields.java | 125 -- .../liteloader/util/SortableValue.java | 46 - .../util/jinput/ComponentRegistry.java | 285 ---- .../liteloader/util/log/LiteLoaderLogger.java | 314 ---- .../util/net/HttpStringRetriever.java | 232 --- .../util/net/LiteLoaderLogUpload.java | 126 -- .../liteloader/util/net/PastebinUpload.java | 135 -- .../mumfrey/liteloader/util/render/Icon.java | 14 - .../liteloader/util/render/IconClickable.java | 16 - .../liteloader/util/render/IconTextured.java | 31 - .../ReplicatedPermissionsContainer.java | 129 -- .../assets/liteloader/lang/en_US.lang | 89 -- .../assets/liteloader/lang/pt_BR.lang | 67 - .../assets/liteloader/textures/gui/about.png | Bin 43567 -> 0 bytes .../src/main/resources/liteloader.properties | 5 - .../resources/mixins.liteloader.core.json | 14 - settings.gradle | 2 - .../mixin/MixinNetHandlerPlayServer.java | 2 + .../com/mumfrey/liteloader/debug/Start.java | 27 +- 331 files changed, 37 insertions(+), 43806 deletions(-) delete mode 100644 liteloader/.factorypath delete mode 100644 liteloader/.gitignore delete mode 100644 liteloader/build.gradle delete mode 100644 liteloader/checkstyle.xml delete mode 100644 liteloader/extra/formatter.xml delete mode 100644 liteloader/extra/liteloader.importorder delete mode 100644 liteloader/gradle.properties delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/ChatFilter.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/ChatListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/ChatRenderListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/EntityRenderListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/FrameBufferListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/GameLoopListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/HUDRenderListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/InitCompleteListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/JoinGameListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/OutboundChatFilter.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/OutboundChatListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/PostLoginListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/PostRenderListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/PreRenderListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/RenderListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/ScreenshotListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/Tickable.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/ViewportListener.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/ClientPluginChannelsClient.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/ClientProxy.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/GameEngineClient.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/LiteLoaderCoreProviderClient.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/LiteLoaderEventBrokerClient.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/LiteLoaderPanelManager.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/PacketEventsClient.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/ResourceObserver.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/ResourcesClient.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/SoundHandlerReloadInhibitor.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/Translator.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/api/LiteLoaderBrandingProvider.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/api/LiteLoaderCoreAPIClient.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/api/LiteLoaderModInfoDecorator.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/api/ObjectFactoryClient.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IClientNetLoginHandler.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IFramebuffer.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/INamespacedRegistry.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IObjectIntIdentityMap.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IRegistrySimple.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IReloadable.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IRenderManager.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/ITileEntityRendererDispatcher.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiCheckbox.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiHoverLabel.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiLiteLoaderPanel.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanel.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelAbout.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelConfigContainer.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelError.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelLiteLoaderLog.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelMods.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelSettings.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelUpdateCheck.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiScrollPanel.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiSimpleScrollBar.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/ScrollPanelContent.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/GuiModInfoPanel.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/GuiModListPanel.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/GuiModListPanelInvalid.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/ModList.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/ModListContainer.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/ModListEntry.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/gui/startup/LoadingBar.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinEntityPlayerSP.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinEntityRenderer.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinFramebuffer.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinGuiIngame.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinIntegratedServer.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinMinecraft.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinNetHandlerLoginClient.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinObjectIntIdentityMap.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRealmsMainScreen.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRegistryNamespaced.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRegistrySimple.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRenderManager.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinScreenShotHelper.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinSession.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinSimpleReloadableResourceManager.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinTileEntityRendererDispatcher.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/IEntityRenderer.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/IGuiTextField.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/IMinecraft.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/ISoundHandler.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/transformers/CrashReportTransformer.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/transformers/MinecraftTransformer.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/util/PrivateFieldsClient.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/util/render/IconAbsolute.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/util/render/IconAbsoluteClickable.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/client/util/render/IconTiled.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/gl/GL.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/gl/GLClippingPlanes.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/resources/InternalResourcePack.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/resources/ModResourcePack.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/resources/ModResourcePackDir.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/util/InputManager.java delete mode 100644 liteloader/src/client/java/com/mumfrey/liteloader/util/ModUtilities.java delete mode 100644 liteloader/src/client/resources/mixins.liteloader.client.json delete mode 100644 liteloader/src/debug/java/com/mumfrey/liteloader/debug/LoginManager.java delete mode 100644 liteloader/src/debug/java/com/mumfrey/liteloader/debug/LoginPanel.java delete mode 100644 liteloader/src/debug/resources/obfuscation.properties delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/Configurable.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/LiteMod.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/PacketHandler.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/Permissible.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/PlayerInteractionListener.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/PlayerMoveListener.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/PluginChannelListener.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/PreJoinGameListener.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/Priority.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/ServerChatFilter.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/ServerCommandProvider.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/ServerPlayerListener.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/ServerPluginChannelListener.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/ServerTickable.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/ShutdownListener.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/BrandingProvider.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/ContainerRegistry.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/CoreProvider.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/CustomisationProvider.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/EnumerationObserver.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/EnumeratorModule.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/EnumeratorPlugin.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/GenericObserver.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/InterfaceObserver.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/InterfaceProvider.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/Listener.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/LiteAPI.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/MixinConfigProvider.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/ModClassValidator.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/ModInfoDecorator.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/ModLoadObserver.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/Observer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/PostRenderObserver.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/ShutdownObserver.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/TickObserver.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/TranslationProvider.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/WorldObserver.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/APIException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/InvalidAPIException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/InvalidAPIStateException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/InvalidProviderException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIAdapter.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIProvider.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIProviderBasic.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIRegistry.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/GameEngine.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/LoadingProgress.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/Resources.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/ducks/IChatPacket.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/ducks/IPacketClientSettings.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinC15PacketClientSettings.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinItemInWorldManager.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinMinecraftServer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinS02PacketChat.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinServerConfigurationManager.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/transformers/LiteLoaderPacketTransformer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/transformers/PacketEvent.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/common/transformers/PacketEventInfo.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/BadContainerInfo.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/ClientPluginChannels.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/CommonPluginChannelListener.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/Containers.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/EnabledModsList.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/IEventState.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/InterfaceRegistrationDelegate.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoader.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderBootstrap.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderEnumerator.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderEventBroker.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderInterfaceManager.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderMods.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderUpdateSite.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderVersion.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/Mod.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/ModInfo.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/NonMod.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/PacketEvents.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/PlayerEventState.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/PluginChannels.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/Proxy.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/ServerPluginChannels.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/api/DefaultClassValidator.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/api/DefaultEnumeratorPlugin.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/api/EnumeratorModuleClassPath.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/api/EnumeratorModuleFolder.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/api/LiteLoaderCoreAPI.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/api/LoadableModClassPath.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/api/LoadableModFile.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/event/Cancellable.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/event/EventCancellationException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/event/EventProxy.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/event/HandlerList.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/event/IHandlerListDecorator.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/event/ProfilingHandlerList.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/OutdatedLoaderException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/ProfilerCrossThreadAccessException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/ProfilerStackCorruptionException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/UnregisteredChannelException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/runtime/Methods.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/runtime/Obf.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/core/runtime/Packets.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/crashreport/CallableLaunchWrapper.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/crashreport/CallableLiteLoaderBrand.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/crashreport/CallableLiteLoaderMods.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/FastIterable.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/FastIterableDeque.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/Injectable.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/InterfaceRegistry.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/Loadable.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/LoadableFile.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/LoadableMod.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/LoaderEnumerator.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/MixinContainer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/ModularEnumerator.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/ObjectFactory.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/PanelManager.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/interfaces/TweakContainer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/ClassPathUtilities.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/ClassTransformerManager.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/GameEnvironment.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/InjectionStrategy.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/InvalidTransformerException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/LiteLoaderTransformer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/LiteLoaderTweaker.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/LiteLoaderTweakerServer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/LoaderBootstrap.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/LoaderEnvironment.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/LoaderProperties.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/NonDelegatingClassLoader.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/launch/StartupEnvironment.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/messaging/Message.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/messaging/MessageBus.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/messaging/Messenger.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/modconfig/AdvancedExposable.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigManager.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigPanel.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigPanelHost.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigStrategy.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/modconfig/Exposable.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ExposableConfigWriter.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ExposableOptions.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/permissions/LocalPermissions.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissibleAllMods.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/permissions/Permission.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/permissions/Permissions.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissionsManager.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissionsManagerClient.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissionsManagerServer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/permissions/ReplicatedPermissions.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/permissions/ServerPermissions.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/AppendInsns.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/ByteCodeUtilities.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/Callback.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/CallbackInjectionTransformer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/ClassOverlayTransformer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/ClassTransformer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/InjectedCallbackCollisionError.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/InvalidOverlayException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/IsolatedClassWriter.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/ObfProvider.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/Obfuscated.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/PacketHandlerException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/Stub.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/Accessor.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/AccessorTransformer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/Invoker.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/ObfTableClass.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/Event.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventAlreadyInjectedException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventInfo.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventInjectionTransformer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventProxyTransformer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventTransformer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/InjectionPoint.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/Jump.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/MethodInfo.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/ReadOnlyInsnList.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/ReturnEventInfo.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeFieldAccess.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeInvoke.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeNew.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeReturn.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeStringInvoke.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/JumpInsnPoint.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/MethodHead.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/InvalidEventJsonException.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonDescriptor.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonEvent.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonEvents.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonInjection.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonInjectionShiftType.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonInjectionType.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonMethods.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonObf.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonObfuscationTable.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/ModEventInjectionTransformer.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/ModEvents.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/update/UpdateSite.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/ChatUtilities.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/EntityUtilities.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/Input.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/InputEvent.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/InputHandler.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/ObfuscationUtilities.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/Position.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/PrivateFields.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/SortableValue.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/jinput/ComponentRegistry.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/log/LiteLoaderLogger.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/net/HttpStringRetriever.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/net/LiteLoaderLogUpload.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/net/PastebinUpload.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/render/Icon.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/render/IconClickable.java delete mode 100644 liteloader/src/main/java/com/mumfrey/liteloader/util/render/IconTextured.java delete mode 100644 liteloader/src/main/java/net/eq2online/permissions/ReplicatedPermissionsContainer.java delete mode 100644 liteloader/src/main/resources/assets/liteloader/lang/en_US.lang delete mode 100644 liteloader/src/main/resources/assets/liteloader/lang/pt_BR.lang delete mode 100644 liteloader/src/main/resources/assets/liteloader/textures/gui/about.png delete mode 100644 liteloader/src/main/resources/liteloader.properties delete mode 100644 liteloader/src/main/resources/mixins.liteloader.core.json rename {liteloader/src/main => src/api}/java/com/mumfrey/liteloader/common/mixin/MixinNetHandlerPlayServer.java (99%) rename {liteloader/src/debug => src/api}/java/com/mumfrey/liteloader/debug/Start.java (89%) diff --git a/build.gradle b/build.gradle index 4d2675f8..f78a1055 100644 --- a/build.gradle +++ b/build.gradle @@ -28,13 +28,13 @@ archivesBaseName = "MineLittlePony" group = 'com.brohoof.minelp' version = '1.8' +ext.startClass = 'com.mumfrey.liteloader.debug.Start' minecraft { version = "1.8" mappings = 'stable_18' runDir = 'run' replace '@VERSION@',project.version tweakClass = 'com.mumfrey.liteloader.launch.LiteLoaderTweaker' - clientJvmArgs += '-Dmcpenv=true' } sourceSets { def deps = [ @@ -54,9 +54,9 @@ sourceSets { compileClasspath += files(deps + [ main.output, api.output ]) } } -project('LiteLoader'){ - mcMappings = rootProject.minecraft.mappings -} +//project('LiteLoader'){ +// mcMappings = rootProject.minecraft.mappings +//} processResources { def props = [ version: version, @@ -77,10 +77,21 @@ repositories{ name 'sponge' url 'http://repo.spongepowered.org/maven' } + ivy { + name 'liteloader jenkins' + url 'http://jenkins.liteloader.com/job/LiteLoader%20Gradle' + layout('pattern') { + artifact '[organization]/artifact/build/libs/[artifact]-[revision](-[classifier]).[ext]' + } + } } dependencies { - compile project('LiteLoader') +// compile project('LiteLoader') + deobfCompile '1:liteloader:1.8-SNAPSHOT' + compile 'org.spongepowered:mixin:0.5.2-SNAPSHOT' + compile 'org.ow2.asm:asm-debug-all:5.0.3' + compile 'net.minecraft:launchwrapper:1.12' } jar { afterEvaluate { manifest.attributes.remove 'TweakClass'} @@ -95,3 +106,14 @@ task deploy(type: Copy, dependsOn: build) { from jar.archivePath into file("$System.env.APPDATA/.minecraft/mods") } +afterEvaluate { + minecraft { + clientRunArgs = [""] + clientJvmArgs += "-Dmixin.debug.verify=true" + } + // hacks for run configs + // TODO user makeStart configs + def mc = plugins['net.minecraftforge.gradle.tweaker-client'] + mc.replacer.putReplacement '{RUN_CLIENT_MAIN}', project.startClass + mc.replacer.putReplacement '{RUN_CLIENT_TWEAKER}', minecraft.tweakClass +} diff --git a/liteloader/.factorypath b/liteloader/.factorypath deleted file mode 100644 index 470f864b..00000000 --- a/liteloader/.factorypath +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/liteloader/.gitignore b/liteloader/.gitignore deleted file mode 100644 index 63e8c15f..00000000 --- a/liteloader/.gitignore +++ /dev/null @@ -1,78 +0,0 @@ -# Build # -######### -MANIFEST.MF -dependency-reduced-pom.xml - -# Compiled # -############ -bin -build -dist -lib -out -run -target -*.com -*.class -*.dll -*.exe -*.o -*.so - -# Databases # -############# -*.db -*.sql -*.sqlite - -# Packages # -############ -*.7z -*.dmg -*.gz -*.iso -*.rar -*.tar -*.zip - -# Repository # -############## -.git - -# Logging # -########### -/logs -*.log - -# Misc # -######## -*.bak - -# System # -########## -.DS_Store -ehthumbs.db -Thumbs.db -*.bat -*.sh - -# Project # -########### -.checkstyle -.classpath -.externalToolBuilders -.gradle -.nb-gradle -.idea -.project -.settings -eclipse -nbproject -atlassian-ide-plugin.xml -build.xml -nb-configuration.xml -*.iml -*.ipr -*.iws -*.launch - diff --git a/liteloader/build.gradle b/liteloader/build.gradle deleted file mode 100644 index c09b9e0e..00000000 --- a/liteloader/build.gradle +++ /dev/null @@ -1,291 +0,0 @@ -buildscript { - repositories { - jcenter() - mavenLocal() - mavenCentral() - maven { - name = "forge" - url = "http://files.minecraftforge.net/maven" - } - maven { - name = "sonatype" - url = "https://oss.sonatype.org/content/repositories/snapshots/" - } - maven { - name = 'sponge' - url = 'http://repo.spongepowered.org/maven' - } - } - dependencies { - classpath 'net.minecraftforge.gradle:ForgeGradle:2.0-SNAPSHOT' - classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.0' - classpath 'org.spongepowered:mixingradle:0.3-SNAPSHOT' - } -} - -apply plugin: 'net.minecraftforge.gradle.tweaker-client' -apply plugin: 'checkstyle' -apply plugin: 'maven' -apply plugin: 'com.github.johnrengelman.shadow' -apply plugin: 'org.spongepowered.mixin' - -// Default tasks -defaultTasks 'build' - -ext { - // Artefact details - buildNumber = project.hasProperty("buildNumber") ? buildNumber : '0' - buildVersion = project.hasProperty("buildVersion") ? buildVersion : '0.0' - ciSystem = project.hasProperty("ciSystem") ? ciSystem : 'unknown' - commit = project.hasProperty("commit") ? commit : 'unknown' - classifier = project.hasProperty("buildType") ? buildType : 'SNAPSHOT' - isReleaseBuild = "RELEASE".equals(project.classifier.toUpperCase()) - mavenRepo = project.isReleaseBuild ? "mavenUrl" : "mavenSnapshotUrl" - - // Extended project information - projectName = 'LiteLoader' - inceptionYear = '2012' - packaging = 'jar' - - startClass = 'com.mumfrey.liteloader.debug.Start' - tweakClass = 'com.mumfrey.liteloader.launch.LiteLoaderTweaker' -} - -// Basic project information -group = "com.mumfrey" -archivesBaseName = "liteloader" -version = buildVersion + (project.isReleaseBuild ? '' : '-' + project.classifier) - -// Minimum version of Java required -sourceCompatibility = '1.6' -targetCompatibility = '1.6' - -repositories { - maven { - name = 'sponge' - url = 'https://repo.spongepowered.org/maven/' - } -} - -dependencies { - compile 'org.spongepowered:mixin:0.4.17-SNAPSHOT' - compile 'org.ow2.asm:asm-debug-all:5.0.3' - compile 'com.google.guava:guava:17.0' - compile 'com.google.code.gson:gson:2.2.4' -} - -minecraft { - version = project.mcVersion - mappings = project.mcMappings - runDir = "run" - tweakClass = project.tweakClass -} - -sourceSets { - main { - refMap = "mixins.liteloader.core.refmap.json" - } - client { - compileClasspath += main.compileClasspath + main.output - refMap = "mixins.liteloader.client.refmap.json" - } - debug { - compileClasspath += client.compileClasspath + client.output - } -} - -mixin { - defaultObfuscationEnv notch -} - -checkstyle { - configProperties = [ - "name" : project.name, - "organization": project.organization, - "url" : project.url, - "year" : project.inceptionYear - ] - configFile = file("checkstyle.xml") - toolVersion = '6.13' -} - -javadoc { - source sourceSets.client.allJava - source sourceSets.debug.allJava -} - -afterEvaluate { - logger.lifecycle '=================================================' - logger.lifecycle ' LiteLoader' - logger.lifecycle ' Copyright (C) 2011-2016 Adam Mummery-Smith' - logger.lifecycle ' Running in {} mode', (project.isReleaseBuild ? "RELEASE" : "SNAPSHOT") - logger.lifecycle '=================================================' - allprojects { - makeEclipseCleanRunClient { - arguments = "" - jvmArguments = "-Dliteloader.debug=true -Dmixin.debug.verbose=true -Dmixin.debug.verify=true" - } - } - // hacks for run configs - def mc = plugins.getPlugin 'net.minecraftforge.gradle.tweaker-client' - mc.replacer.putReplacement '{RUN_CLIENT_MAIN}', project.startClass - mc.replacer.putReplacement '{RUN_CLIENT_TWEAKER}', minecraft.tweakClass -} - -// manifest entries for all jars -def jarManifest = { - mainAttributes ( - 'Built-By': System.properties['user.name'], - 'Created-By': System.properties['java.vm.version'] + " (" + System.properties['java.vm.vendor'] + ")", - 'Implementation-Title': name, - 'Implementation-Version': version + "+" + ciSystem + "-b" + buildNumber + ".git-" + commit, - 'Implementation-Vendor': url - ) -} - -jar { - doFirst { - // Seriously forge? - ant.replace( - file: sourceSets.main.refMapFile, - token: "func_72355_a(Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/EntityPlayerMP;)V", - value: "initializeConnectionToPlayer(Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/EntityPlayerMP;Lnet/minecraft/network/NetHandlerPlayServer;)V" - ) - } - from sourceSets.client.output - from sourceSets.debug.output - manifest jarManifest -} - -task releaseJar(type: Jar) { - from sourceSets.main.output - from sourceSets.client.output - - manifest jarManifest - classifier = 'staging' -} - -shadowJar { - manifest jarManifest - dependsOn 'reobfReleaseJar' - - from sourceSets.main.output - from sourceSets.client.output - - exclude 'META-INF/*.DSA' - exclude 'META-INF/*.RSA' - exclude 'dummyThing' - exclude 'LICENSE.txt' - - dependencies { - include(dependency('org.spongepowered:mixin')) - } - - classifier = 'release' -} - -sourceJar { - dependsOn retromapReplacedDebug - dependsOn retromapReplacedClient - - from zipTree(tasks.retromapReplacedDebug.out) - from zipTree(tasks.retromapReplacedClient.out) -} - -task javadocJar(type: Jar, dependsOn: javadoc) { - from javadoc.destinationDir - classifier = 'javadoc' -} - -// Hey @AbrarSyed why can't we just turn this off >:( -task runClient(type: JavaExec, overwrite: true) { - doFirst { - println "Do not use runClient, it is not compatible with Mixin" - System.exit(-1) - } -} - -tasks.withType(JavaCompile) { - options.compilerArgs += [ - '-Xlint:all', - '-Xlint:-path', - '-Xlint:-rawtypes', - '-Xlint:-processing' - ] - options.deprecation = true - options.encoding = 'utf8' -} - -if (JavaVersion.current().isJava8Compatible()) { - tasks.withType(Javadoc) { - // disable the crazy super-strict doclint tool in Java 8 - options.addStringOption('Xdoclint:none', '-quiet') - } -} - -reobf { - jar { - mappingType = 'SEARGE' - } - releaseJar { - mappingType = 'NOTCH' - classpath = sourceSets.main.compileClasspath - } - shadowJar { - mappingType = 'NOTCH' - classpath = sourceSets.main.compileClasspath - } -} - -build.dependsOn {[ - 'reobfReleaseJar', - 'reobfShadowJar' -]} - -artifacts { - if (project.isReleaseBuild) { - archives jar - } - archives shadowJar - archives sourceJar - archives javadocJar -} - -task deploy(type: Copy, dependsOn: build) { - def libraryDir = new File(new File(System.env.APPDATA), ".minecraft/libraries") - from shadowJar.outputs.files[0] - into new File(libraryDir, sprintf('%1$s%4$s%2$s%4$s%3$s', project.group.replace('.', File.separator), archivesBaseName, buildVersion, File.separatorChar)) - rename shadowJar.outputs.files[0].name, sprintf("%s-%s.jar", archivesBaseName, buildVersion) -} - -uploadArchives { - repositories { - mavenDeployer { - if (project.hasProperty(project.mavenRepo)) { - repository(url: project.getProperty(project.mavenRepo)) { - authentication(userName: project.mavenUsername, password: project.mavenPassword) - } - } - pom { - groupId = project.group - version = project.version - artifactId = project.archivesBaseName - project { - name project.archivesBaseName - packaging 'jar' - description 'LiteLoader' - url 'http://www.liteloader.com/' - scm { - url 'http://develop.liteloader.com/liteloader/LiteLoader' - connection 'scm:git:http://develop.liteloader.com/liteloader/LiteLoader.git' - developerConnection 'scm:git:http://develop.liteloader.com/liteloader/LiteLoader.git' - } - issueManagement { - system 'GitLab Issues' - url 'http://develop.liteloader.com/liteloader/LiteLoader/issues' - } - } - } - } - } -} diff --git a/liteloader/checkstyle.xml b/liteloader/checkstyle.xml deleted file mode 100644 index 12c30c37..00000000 --- a/liteloader/checkstyle.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/liteloader/extra/formatter.xml b/liteloader/extra/formatter.xml deleted file mode 100644 index 9f60f653..00000000 --- a/liteloader/extra/formatter.xml +++ /dev/null @@ -1,295 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/liteloader/extra/liteloader.importorder b/liteloader/extra/liteloader.importorder deleted file mode 100644 index 5189fd16..00000000 --- a/liteloader/extra/liteloader.importorder +++ /dev/null @@ -1,7 +0,0 @@ -#Organize Import Order -#Wed Dec 02 11:57:04 GMT 2015 -4=com -3=org -2=javax -1=java -0=\# diff --git a/liteloader/gradle.properties b/liteloader/gradle.properties deleted file mode 100644 index 6de692c9..00000000 --- a/liteloader/gradle.properties +++ /dev/null @@ -1,10 +0,0 @@ -name=LiteLoader -inceptionYear=2012 -packaging=jar -description=LiteLoader -url=http://www.liteloader.com -organization=LiteLoader -buildType=SNAPSHOT -buildVersion=1.8 -mcVersion=1.8 -mcMappings=snapshot_20151124 \ No newline at end of file diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/ChatFilter.java b/liteloader/src/client/java/com/mumfrey/liteloader/ChatFilter.java deleted file mode 100644 index 31d54f7c..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/ChatFilter.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.mumfrey.liteloader; - -import com.mumfrey.liteloader.core.LiteLoaderEventBroker.ReturnValue; - -import net.minecraft.util.IChatComponent; - - -/** - * Interface for mods which can filter inbound chat - * - * @author Adam Mummery-Smith - */ -public interface ChatFilter extends LiteMod -{ - /** - * Chat filter function, return false to filter this packet, true to pass - * the packet. - * - * @param chat ChatMessageComponent parsed from the chat packet - * @param message Chat message parsed from the chat message component - * @param newMessage If you wish to mutate the message, set the value using - * newMessage.set() - * - * @return True to keep the packet, false to discard - */ - public abstract boolean onChat(IChatComponent chat, String message, ReturnValue newMessage); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/ChatListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/ChatListener.java deleted file mode 100644 index dd631c46..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/ChatListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.util.IChatComponent; - - -/** - * Interface for mods which receive inbound chat - * - * @author Adam Mummery-Smith - */ -public interface ChatListener extends LiteMod -{ - /** - * Handle an inbound message - * - * @param chat IChatComponent parsed from the chat packet - * @param message Chat message parsed from the chat message component - */ - public abstract void onChat(IChatComponent chat, String message); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/ChatRenderListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/ChatRenderListener.java deleted file mode 100644 index 3e1d89ca..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/ChatRenderListener.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.client.gui.GuiNewChat; - -/** - * Interface for mods which want to alter the chat display - * - * @author Adam Mummery-Smith - */ -public interface ChatRenderListener extends LiteMod -{ - public abstract void onPreRenderChat(int screenWidth, int screenHeight, GuiNewChat chat); - - public abstract void onPostRenderChat(int screenWidth, int screenHeight, GuiNewChat chat); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/EntityRenderListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/EntityRenderListener.java deleted file mode 100644 index bb2c3c93..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/EntityRenderListener.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.entity.Entity; - -/** - * Interface for mods which want to receive callbacks when entities are rendered - * into the world. - * - * @author Adam Mummery-Smith - */ -public interface EntityRenderListener extends LiteMod -{ - /** - * Called immediately prior to an entity being rendered - * - * @param render - * @param entity - * @param xPos - * @param yPos - * @param zPos - * @param yaw - * @param partialTicks - */ - public abstract void onRenderEntity(Render render, Entity entity, double xPos, double yPos, double zPos, float yaw, float partialTicks); - - /** - * Called immediately following an entity being rendered - * - * @param render - * @param entity - * @param xPos - * @param yPos - * @param zPos - * @param yaw - * @param partialTicks - */ - public abstract void onPostRenderEntity(Render render, Entity entity, double xPos, double yPos, double zPos, float yaw, float partialTicks); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/FrameBufferListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/FrameBufferListener.java deleted file mode 100644 index a8b8caf6..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/FrameBufferListener.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.client.shader.Framebuffer; - -/** - * Interface for mods which want to interact with Minecraft's main Frame Buffer - * Object. - * - * @author Adam Mummery-Smith - */ -public interface FrameBufferListener extends LiteMod -{ - /** - * Called before the FBO is rendered. Useful if you want to interact with - * the FBO before it is drawn to the screen. - */ - public abstract void preRenderFBO(Framebuffer fbo); - - /** - * Called immediately before the FBO is rendered to the screen, after the - * appropriate IGL modes and matrix transforms have been set but before the - * FBO is actually rendered into the main output buffer. - * - * @param fbo FBO instance - * @param width FBO width - * @param height FBO height - */ - public abstract void onRenderFBO(Framebuffer fbo, int width, int height); - - /** - * Called after the FBO is rendered whilst still inside the FBO transform - */ - public abstract void postRenderFBO(Framebuffer fbo); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/GameLoopListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/GameLoopListener.java deleted file mode 100644 index d2a848ad..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/GameLoopListener.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.client.Minecraft; - -/** - * Interface for mods which want a frame notification every single game loop - * - * @author Adam Mummery-Smith - */ -public interface GameLoopListener extends LiteMod -{ - /** - * Called every frame, before the world is ticked - * - * @param minecraft - */ - public abstract void onRunGameLoop(Minecraft minecraft); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/HUDRenderListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/HUDRenderListener.java deleted file mode 100644 index e1a69257..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/HUDRenderListener.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.mumfrey.liteloader; - -/** - * Interface for mods which want callbacks when the HUD is rendered - * - * @author Adam Mummery-Smith - */ -public interface HUDRenderListener extends LiteMod -{ - public abstract void onPreRenderHUD(int screenWidth, int screenHeight); - - public abstract void onPostRenderHUD(int screenWidth, int screenHeight); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/InitCompleteListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/InitCompleteListener.java deleted file mode 100644 index 23cde02d..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/InitCompleteListener.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.client.Minecraft; - -import com.mumfrey.liteloader.core.LiteLoader; - -/** - * Interface for mods which need to initialise stuff once the game - * initialisation is completed, for example mods which need to register new - * renderers. - * - * @author Adam Mummery-Smith - */ -public interface InitCompleteListener extends Tickable -{ - /** - * Called as soon as the game is initialised and the main game loop is - * running. - * - * @param minecraft Minecraft instance - * @param loader LiteLoader instance - */ - public abstract void onInitCompleted(Minecraft minecraft, LiteLoader loader); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/JoinGameListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/JoinGameListener.java deleted file mode 100644 index 6ab33808..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/JoinGameListener.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.client.multiplayer.ServerData; -import net.minecraft.network.INetHandler; -import net.minecraft.network.play.server.S01PacketJoinGame; - -import com.mojang.realmsclient.dto.RealmsServer; - - -/** - * Interface for mods which wish to be notified when the player connects to a - * server (or local game). - * - * @author Adam Mummery-Smith - */ -public interface JoinGameListener extends LiteMod -{ - /** - * Called on join game - * - * @param netHandler Net handler - * @param joinGamePacket Join game packet - * @param serverData ServerData object representing the server being - * connected to - * @param realmsServer If connecting to a realm, a reference to the - * RealmsServer object - */ - public abstract void onJoinGame(INetHandler netHandler, S01PacketJoinGame joinGamePacket, ServerData serverData, RealmsServer realmsServer); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/OutboundChatFilter.java b/liteloader/src/client/java/com/mumfrey/liteloader/OutboundChatFilter.java deleted file mode 100644 index 266d3c96..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/OutboundChatFilter.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.mumfrey.liteloader; - -/** - * Interface for mods which want to filter outbound chat - * - * @author Adam Mummery-Smith - */ -public interface OutboundChatFilter extends LiteMod -{ - /** - * Raised when a chat message is being sent, return false to filter this - * message or true to allow it to be sent. - * - * @param message - */ - public abstract boolean onSendChatMessage(String message); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/OutboundChatListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/OutboundChatListener.java deleted file mode 100644 index f575cf9c..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/OutboundChatListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.network.play.client.C01PacketChatMessage; - -/** - * Interface for mods which want to monitor outbound chat - * - * @author Adam Mummery-Smith - */ -public interface OutboundChatListener extends LiteMod -{ - /** - * Raised when a new chat packet is created (not necessarily transmitted, - * something could be trolling us). - * - * @param packet - * @param message - */ - public abstract void onSendChatMessage(C01PacketChatMessage packet, String message); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/PostLoginListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/PostLoginListener.java deleted file mode 100644 index 952343d5..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/PostLoginListener.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.network.login.INetHandlerLoginClient; -import net.minecraft.network.login.server.S02PacketLoginSuccess; - -/** - * - * @author Adam Mummery-Smith - */ -public interface PostLoginListener extends LiteMod -{ - /** - * Called immediately after login, before the player has properly joined the - * game. Note that this event is raised in the network thread and is - * not marshalled to the main thread as other packet-generated events are. - * - * @param netHandler - * @param packet - */ - public abstract void onPostLogin(INetHandlerLoginClient netHandler, S02PacketLoginSuccess packet); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/PostRenderListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/PostRenderListener.java deleted file mode 100644 index 2a872f01..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/PostRenderListener.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.mumfrey.liteloader; - -/** - * Render callback that gets called AFTER entities are rendered - * - * @author Adam Mummery-Smith - */ -public interface PostRenderListener extends LiteMod -{ - /** - * Called after entities are rendered but before particles - * - * @param partialTicks - */ - public abstract void onPostRenderEntities(float partialTicks); - - /** - * Called after all world rendering is completed - * - * @param partialTicks - */ - public abstract void onPostRender(float partialTicks); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/PreRenderListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/PreRenderListener.java deleted file mode 100644 index 20cf9c6b..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/PreRenderListener.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.client.renderer.RenderGlobal; - -/** - * Render callbacks that get called before certain render events - * - * @author Adam Mummery-Smith - */ -public interface PreRenderListener extends LiteMod -{ - /** - * Called immediately before rendering of the world (including the sky) is - * started. - * - * @param partialTicks - */ - public abstract void onRenderWorld(float partialTicks); - - /** - * Called after the world camera transform is initialised, may be - * called more than once per frame if anaglyph is enabled. - * - * @param partialTicks - * @param pass - * @param timeSlice - */ - public abstract void onSetupCameraTransform(float partialTicks, int pass, long timeSlice); - - /** - * Called when the sky is rendered, may be called more than once per frame - * if anaglyph is enabled. - * - * @param partialTicks - * @param pass - */ - public abstract void onRenderSky(float partialTicks, int pass); - - /** - * Called immediately before the clouds are rendered, may be called more - * than once per frame if anaglyph is enabled. - * - * @param renderGlobal - * @param partialTicks - * @param pass - */ - public abstract void onRenderClouds(float partialTicks, int pass, RenderGlobal renderGlobal); - - /** - * Called before the terrain is rendered, may be called more than once per - * frame if anaglyph is enabled. - * - * @param partialTicks - * @param pass - */ - public abstract void onRenderTerrain(float partialTicks, int pass); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/RenderListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/RenderListener.java deleted file mode 100644 index a39953da..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/RenderListener.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.client.gui.GuiScreen; - -/** - * Interface for objects which want a pre-render callback - * - * @author Adam Mummery-Smith - */ -public interface RenderListener extends LiteMod -{ - /** - * Callback when a frame is rendered - */ - public abstract void onRender(); - - /** - * Called immediately before the current GUI is rendered - * - * @param currentScreen Current screen (if any) - */ - public abstract void onRenderGui(GuiScreen currentScreen); - - /** - * Called when the world is rendered - * - * @deprecated Use PreRenderListener::onRenderWorld(F)V instead - */ - @Deprecated - public abstract void onRenderWorld(); - - /** - * Called immediately after the world/camera transform is initialised - */ - public abstract void onSetupCameraTransform(); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/ScreenshotListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/ScreenshotListener.java deleted file mode 100644 index 0ea38fc7..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/ScreenshotListener.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.util.IChatComponent; - -import com.mumfrey.liteloader.core.LiteLoaderEventBroker.ReturnValue; - -/** - * Interface for mods which want to handle or inhibit the saving of screenshots - * - * @author Adam Mummery-Smith - */ -public interface ScreenshotListener extends LiteMod -{ - /** - * Called when a screenshot is taken, mods should return FALSE to suspend - * further processing, or TRUE to allow processing to continue normally - * - * @param screenshotName - * @param width - * @param height - * @param fbo - * @param message Message to return if the event is cancelled - * @return FALSE to suspend further processing, or TRUE to allow processing - * to continue normally - */ - public boolean onSaveScreenshot(String screenshotName, int width, int height, Framebuffer fbo, ReturnValue message); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/Tickable.java b/liteloader/src/client/java/com/mumfrey/liteloader/Tickable.java deleted file mode 100644 index 21eca4f9..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/Tickable.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.client.Minecraft; - -/** - * Interface for mods which want tick events - * - * @author Adam Mummery-Smith - */ -public interface Tickable extends LiteMod -{ - /** - * Called every frame - * - * @param minecraft Minecraft instance - * @param partialTicks Partial tick value - * @param inGame True if in-game, false if in the menu - * @param clock True if this is a new tick, otherwise false if it's a - * regular frame - */ - public abstract void onTick(Minecraft minecraft, float partialTicks, boolean inGame, boolean clock); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/ViewportListener.java b/liteloader/src/client/java/com/mumfrey/liteloader/ViewportListener.java deleted file mode 100644 index 73c44171..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/ViewportListener.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.client.gui.ScaledResolution; - -public interface ViewportListener extends LiteMod -{ - public abstract void onViewportResized(ScaledResolution resolution, int displayWidth, int displayHeight); - - public abstract void onFullScreenToggled(boolean fullScreen); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/ClientPluginChannelsClient.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/ClientPluginChannelsClient.java deleted file mode 100644 index 9f2371f0..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/ClientPluginChannelsClient.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.mumfrey.liteloader.client; - -import com.mumfrey.liteloader.client.ducks.IClientNetLoginHandler; -import com.mumfrey.liteloader.core.ClientPluginChannels; -import com.mumfrey.liteloader.core.exceptions.UnregisteredChannelException; - -import net.minecraft.client.Minecraft; -import net.minecraft.network.INetHandler; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.login.INetHandlerLoginClient; -import net.minecraft.network.login.server.S02PacketLoginSuccess; -import net.minecraft.network.play.INetHandlerPlayClient; -import net.minecraft.network.play.client.C17PacketCustomPayload; -import net.minecraft.network.play.server.S01PacketJoinGame; -import net.minecraft.network.play.server.S3FPacketCustomPayload; - -/** - * Handler for client plugin channels - * - * @author Adam Mummery-Smith - */ -public class ClientPluginChannelsClient extends ClientPluginChannels -{ - /** - * @param netHandler - * @param loginPacket - */ - void onPostLogin(INetHandlerLoginClient netHandler, S02PacketLoginSuccess loginPacket) - { - this.clearPluginChannels(netHandler); - } - - /** - * @param netHandler - * @param loginPacket - */ - void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket) - { - this.sendRegisteredPluginChannels(netHandler); - } - - /** - * Callback for the plugin channel hook - * - * @param customPayload - */ - @Override - public void onPluginChannelMessage(S3FPacketCustomPayload customPayload) - { - if (customPayload != null && customPayload.getChannelName() != null) - { - String channel = customPayload.getChannelName(); - PacketBuffer data = customPayload.getBufferData(); - - this.onPluginChannelMessage(channel, data); - } - } - - /** - * @param netHandler - * @param registrationData - */ - @Override - protected void sendRegistrationData(INetHandler netHandler, PacketBuffer registrationData) - { - if (netHandler instanceof INetHandlerLoginClient) - { - NetworkManager networkManager = ((IClientNetLoginHandler)netHandler).getNetMgr(); - networkManager.sendPacket(new C17PacketCustomPayload(CHANNEL_REGISTER, registrationData)); - } - else if (netHandler instanceof INetHandlerPlayClient) - { - ClientPluginChannelsClient.dispatch(new C17PacketCustomPayload(CHANNEL_REGISTER, registrationData)); - } - } - - /** - * Send a message to the server on a plugin channel - * - * @param channel Channel to send, must not be a reserved channel name - * @param data - */ - @Override - protected boolean send(String channel, PacketBuffer data, ChannelPolicy policy) - { - if (channel == null || channel.length() > 16 || CHANNEL_REGISTER.equals(channel) || CHANNEL_UNREGISTER.equals(channel)) - { - throw new RuntimeException("Invalid channel name specified"); - } - - if (!policy.allows(this, channel)) - { - if (policy.isSilent()) return false; - throw new UnregisteredChannelException(channel); - } - - C17PacketCustomPayload payload = new C17PacketCustomPayload(channel, data); - return ClientPluginChannelsClient.dispatch(payload); - } - - /** - * @param payload - */ - static boolean dispatch(C17PacketCustomPayload payload) - { - try - { - Minecraft minecraft = Minecraft.getMinecraft(); - - if (minecraft.thePlayer != null && minecraft.thePlayer.sendQueue != null) - { - minecraft.thePlayer.sendQueue.addToSendQueue(payload); - return true; - } - } - catch (Exception ex) {} - - return false; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/ClientProxy.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/ClientProxy.java deleted file mode 100644 index a3eca16a..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/ClientProxy.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.mumfrey.liteloader.client; - -import java.io.File; - -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import com.mumfrey.liteloader.client.ducks.IFramebuffer; -import com.mumfrey.liteloader.core.Proxy; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiNewChat; -import net.minecraft.client.renderer.RenderGlobal; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.entity.Entity; -import net.minecraft.server.integrated.IntegratedServer; -import net.minecraft.util.IChatComponent; -import net.minecraft.world.WorldSettings; - -/** - * Proxy class which handles the redirected calls from the injected callbacks - * and routes them to the relevant liteloader handler classes. We do this rather - * than patching a bunch of bytecode into the packet classes themselves because - * this is easier to maintain. - * - * @author Adam Mummery-Smith - */ -public abstract class ClientProxy extends Proxy -{ - private static LiteLoaderEventBrokerClient broker; - - private ClientProxy() {} - - public static void onStartupComplete() - { - Proxy.onStartupComplete(); - - ClientProxy.broker = LiteLoaderEventBrokerClient.getInstance(); - - if (ClientProxy.broker == null) - { - throw new RuntimeException("LiteLoader failed to start up properly." - + " The game is in an unstable state and must shut down now. Check the developer log for startup errors"); - } - - ClientProxy.broker.onStartupComplete(); - } - - public static void onTimerUpdate() - { - ClientProxy.broker.onTimerUpdate(); - } - - public static void newTick() - { - } - - public static void onTick() - { - ClientProxy.broker.onTick(); - } - - public static void onRender() - { - ClientProxy.broker.onRender(); - } - - public static void preRenderGUI(float partialTicks) - { - ClientProxy.broker.preRenderGUI(partialTicks); - } - - public static void onSetupCameraTransform(int pass, float partialTicks, long timeSlice) - { - ClientProxy.broker.onSetupCameraTransform(pass, partialTicks, timeSlice); - } - - public static void postRenderEntities(int pass, float partialTicks, long timeSlice) - { - ClientProxy.broker.postRenderEntities(partialTicks, timeSlice); - } - - public static void postRender(float partialTicks, long timeSlice) - { - ClientProxy.broker.postRender(partialTicks, timeSlice); - } - - public static void onRenderHUD(float partialTicks) - { - ClientProxy.broker.onRenderHUD(partialTicks); - } - - public static void onRenderChat(GuiNewChat chatGui, float partialTicks) - { - ClientProxy.broker.onRenderChat(chatGui, partialTicks); - } - - public static void postRenderChat(GuiNewChat chatGui, float partialTicks) - { - ClientProxy.broker.postRenderChat(chatGui, partialTicks); - } - - public static void postRenderHUD(float partialTicks) - { - ClientProxy.broker.postRenderHUD(partialTicks); - } - - public static void onCreateIntegratedServer(IntegratedServer server, String folderName, String worldName, WorldSettings worldSettings) - { - ClientProxy.broker.onStartServer(server, folderName, worldName, worldSettings); - } - - public static void onOutboundChat(CallbackInfo e, String message) - { - ClientProxy.broker.onSendChatMessage(e, message); - } - - public static void onResize(Minecraft mc) - { - if (ClientProxy.broker == null) return; - ClientProxy.broker.onResize(mc); - } - - public static void preRenderFBO(Framebuffer frameBufferMc) - { - if (ClientProxy.broker == null) return; - if (frameBufferMc instanceof IFramebuffer) - { - ((IFramebuffer)frameBufferMc).setDispatchRenderEvent(true); - } - ClientProxy.broker.preRenderFBO(frameBufferMc); - } - - public static void postRenderFBO(Framebuffer frameBufferMc) - { - if (ClientProxy.broker == null) return; - ClientProxy.broker.postRenderFBO(frameBufferMc); - } - - public static void renderFBO(Framebuffer frameBufferMc, int width, int height, boolean flag) - { - if (ClientProxy.broker == null) return; - ClientProxy.broker.onRenderFBO(frameBufferMc, width, height); - } - - public static void onRenderWorld(float partialTicks, long timeSlice) - { - ClientProxy.broker.onRenderWorld(partialTicks, timeSlice); - } - - public static void onRenderSky(int pass, float partialTicks, long timeSlice) - { - ClientProxy.broker.onRenderSky(partialTicks, pass, timeSlice); - } - - public static void onRenderClouds(RenderGlobal renderGlobalIn, float partialTicks, int pass) - { - ClientProxy.broker.onRenderClouds(partialTicks, pass, renderGlobalIn); - } - - public static void onRenderTerrain(int pass, float partialTicks, long timeSlice) - { - ClientProxy.broker.onRenderTerrain(partialTicks, pass, timeSlice); - } - - public static void onSaveScreenshot(CallbackInfoReturnable ci, File gameDir, String name, int width, int height, - Framebuffer fbo) - { - ClientProxy.broker.onScreenshot(ci, name, width, height, fbo); - } - - public static void onRenderEntity(RenderManager source, Render render, Entity entity, double x, double y, double z, float yaw, float pTicks) - { - ClientProxy.broker.onRenderEntity(source, entity, x, y, z, yaw, pTicks, render); - } - - public static void onPostRenderEntity(RenderManager source, Render render, Entity entity, double x, double y, double z, float yaw, float pTicks) - { - ClientProxy.broker.onPostRenderEntity(source, entity, x, y, z, yaw, pTicks, render); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/GameEngineClient.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/GameEngineClient.java deleted file mode 100644 index 72f19ba3..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/GameEngineClient.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.mumfrey.liteloader.client; - -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.audio.SoundHandler; -import net.minecraft.client.gui.GuiNewChat; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.settings.GameSettings; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.profiler.Profiler; -import net.minecraft.server.integrated.IntegratedServer; - -import com.mumfrey.liteloader.client.overlays.IMinecraft; -import com.mumfrey.liteloader.common.GameEngine; -import com.mumfrey.liteloader.common.Resources; - -/** - * - * @author Adam Mummery-Smith - */ -public class GameEngineClient implements GameEngine -{ - private final Minecraft engine = Minecraft.getMinecraft(); - - private final Resources resources = new ResourcesClient(); - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#getProfiler() - */ - @Override - public Profiler getProfiler() - { - return this.engine.mcProfiler; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#isClient() - */ - @Override - public boolean isClient() - { - return true; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#isServer() - */ - @Override - public boolean isServer() - { - return this.isSinglePlayer(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#isInGame() - */ - @Override - public boolean isInGame() - { - return this.engine.thePlayer != null && this.engine.theWorld != null && this.engine.theWorld.isRemote; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#isRunning() - */ - @Override - public boolean isRunning() - { - return ((IMinecraft)this.engine).isRunning(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#isSingleplayer() - */ - @Override - public boolean isSinglePlayer() - { - return this.engine.isSingleplayer(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#getClient() - */ - @Override - public Minecraft getClient() - { - return this.engine; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#getServer() - */ - @Override - public IntegratedServer getServer() - { - return this.engine.getIntegratedServer(); - } - - @Override - public Resources getResources() - { - return this.resources; - } - - public GameSettings getGameSettings() - { - return this.engine.gameSettings; - } - - public ScaledResolution getScaledResolution() - { - return new ScaledResolution(this.engine, this.engine.displayWidth, this.engine.displayHeight); - } - - public GuiNewChat getChatGUI() - { - return this.engine.ingameGUI.getChatGUI(); - } - - public GuiScreen getCurrentScreen() - { - return this.engine.currentScreen; - } - - public boolean hideGUI() - { - return this.engine.gameSettings.hideGUI; - } - - public SoundHandler getSoundHandler() - { - return this.engine.getSoundHandler(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#getKeyBindings() - */ - @Override - public List getKeyBindings() - { - LinkedList keyBindings = new LinkedList(); - keyBindings.addAll(Arrays.asList(this.engine.gameSettings.keyBindings)); - return keyBindings; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine - * #setKeyBindings(java.util.List) - */ - @Override - public void setKeyBindings(List keyBindings) - { - this.engine.gameSettings.keyBindings = keyBindings.toArray(new KeyBinding[0]); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/LiteLoaderCoreProviderClient.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/LiteLoaderCoreProviderClient.java deleted file mode 100644 index 7c1bd03d..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/LiteLoaderCoreProviderClient.java +++ /dev/null @@ -1,111 +0,0 @@ -package com.mumfrey.liteloader.client; - -import net.minecraft.client.audio.SoundHandler; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourcePack; -import net.minecraft.client.resources.SimpleReloadableResourceManager; -import net.minecraft.network.INetHandler; -import net.minecraft.network.play.server.S01PacketJoinGame; -import net.minecraft.world.World; - -import com.mumfrey.liteloader.api.CoreProvider; -import com.mumfrey.liteloader.common.GameEngine; -import com.mumfrey.liteloader.common.Resources; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.core.LiteLoaderMods; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.resources.InternalResourcePack; - -/** - * CoreProvider which fixes SoundManager derping up at startup - * - * @author Adam Mummery-Smith - */ -public class LiteLoaderCoreProviderClient implements CoreProvider -{ - /** - * Loader Properties adapter - */ - private final LoaderProperties properties; - - /** - * Read from the properties file, if true we will inhibit the sound manager - * reload during startup to avoid getting in trouble with OpenAL. - */ - private boolean inhibitSoundManagerReload = true; - - /** - * If inhibit is enabled, this object is used to reflectively inhibit the - * sound manager's reload process during startup by removing it from the - * reloadables list. - */ - private SoundHandlerReloadInhibitor soundHandlerReloadInhibitor; - - public LiteLoaderCoreProviderClient(LoaderProperties properties) - { - this.properties = properties; - } - - @Override - public void onInit() - { - this.inhibitSoundManagerReload = this.properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_SOUND_MANAGER_FIX, true); - } - - @SuppressWarnings("unchecked") - @Override - public void onPostInit(GameEngine engine) - { - SimpleReloadableResourceManager resourceManager = (SimpleReloadableResourceManager)engine.getResources().getResourceManager(); - SoundHandler soundHandler = ((GameEngineClient)engine).getSoundHandler(); - this.soundHandlerReloadInhibitor = new SoundHandlerReloadInhibitor(resourceManager, soundHandler); - - if (this.inhibitSoundManagerReload) - { - this.soundHandlerReloadInhibitor.inhibit(); - } - - // Add self as a resource pack for texture/lang resources - Resources resources = (Resources)LiteLoader.getGameEngine().getResources(); - resources.registerResourcePack(new InternalResourcePack("LiteLoader", LiteLoader.class, "liteloader")); - } - - @Override - public void onPostInitComplete(LiteLoaderMods mods) - { - } - - @Override - public void onStartupComplete() - { - if (this.soundHandlerReloadInhibitor != null && this.soundHandlerReloadInhibitor.isInhibited()) - { - this.soundHandlerReloadInhibitor.unInhibit(true); - } - } - - @Override - public void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket) - { - } - - @Override - public void onPostRender(int mouseX, int mouseY, float partialTicks) - { - } - - @Override - public void onTick(boolean clock, float partialTicks, boolean inGame) - { - } - - @Override - public void onWorldChanged(World world) - { - } - - @Override - public void onShutDown() - { - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/LiteLoaderEventBrokerClient.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/LiteLoaderEventBrokerClient.java deleted file mode 100644 index 7eab71f3..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/LiteLoaderEventBrokerClient.java +++ /dev/null @@ -1,567 +0,0 @@ -package com.mumfrey.liteloader.client; - -import org.lwjgl.input.Mouse; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import com.mumfrey.liteloader.*; -import com.mumfrey.liteloader.client.overlays.IEntityRenderer; -import com.mumfrey.liteloader.client.overlays.IMinecraft; -import com.mumfrey.liteloader.common.LoadingProgress; -import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.core.LiteLoaderEventBroker; -import com.mumfrey.liteloader.core.event.HandlerList; -import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp; -import com.mumfrey.liteloader.core.event.ProfilingHandlerList; -import com.mumfrey.liteloader.interfaces.FastIterableDeque; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiNewChat; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.RenderGlobal; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourceManagerReloadListener; -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.entity.Entity; -import net.minecraft.network.play.client.C01PacketChatMessage; -import net.minecraft.server.integrated.IntegratedServer; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.Timer; - -public class LiteLoaderEventBrokerClient extends LiteLoaderEventBroker implements IResourceManagerReloadListener -{ - /** - * Singleton - */ - private static LiteLoaderEventBrokerClient instance; - - /** - * Reference to the game - */ - protected final GameEngineClient engineClient; - - /** - * Current screen width - */ - private int screenWidth = 854; - - /** - * Current screen height - */ - private int screenHeight = 480; - - /** - * - */ - private boolean wasFullScreen = false; - - /** - * Hash code of the current world. We don't store the world reference - * here because we don't want to mess with world GC by mistake. - */ - private int worldHashCode = 0; - - private FastIterableDeque tickListeners; - private FastIterableDeque loopListeners = new HandlerList(GameLoopListener.class); - private FastIterableDeque renderListeners = new HandlerList(RenderListener.class); - private FastIterableDeque preRenderListeners = new HandlerList(PreRenderListener.class); - private FastIterableDeque postRenderListeners = new HandlerList(PostRenderListener.class); - private FastIterableDeque hudRenderListeners = new HandlerList(HUDRenderListener.class); - private FastIterableDeque chatRenderListeners = new HandlerList(ChatRenderListener.class); - private FastIterableDeque outboundChatListeners = new HandlerList(OutboundChatListener.class); - private FastIterableDeque viewportListeners = new HandlerList(ViewportListener.class); - private FastIterableDeque frameBufferListeners = new HandlerList(FrameBufferListener.class); - private FastIterableDeque initListeners = new HandlerList(InitCompleteListener.class); - private FastIterableDeque outboundChatFilters = new HandlerList(OutboundChatFilter.class, - ReturnLogicOp.AND); - private FastIterableDeque screenshotListeners = new HandlerList(ScreenshotListener.class, - ReturnLogicOp.AND_BREAK_ON_FALSE); - private FastIterableDeque entityRenderListeners = new HandlerList(EntityRenderListener.class); - - @SuppressWarnings("cast") - public LiteLoaderEventBrokerClient(LiteLoader loader, GameEngineClient engine, LoaderProperties properties) - { - super(loader, engine, properties); - - LiteLoaderEventBrokerClient.instance = this; - - this.engineClient = (GameEngineClient)engine; - this.tickListeners = new ProfilingHandlerList(Tickable.class, this.engineClient.getProfiler()); - } - - public static LiteLoaderEventBrokerClient getInstance() - { - return LiteLoaderEventBrokerClient.instance; - } - - @Override - public void onResourceManagerReload(IResourceManager resourceManager) - { - LoadingProgress.setMessage("Reloading Resources..."); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider#registerInterfaces( - * com.mumfrey.liteloader.core.InterfaceRegistrationDelegate) - */ - @Override - public void registerInterfaces(InterfaceRegistrationDelegate delegate) - { - super.registerInterfaces(delegate); - - delegate.registerInterface(Tickable.class); - delegate.registerInterface(GameLoopListener.class); - delegate.registerInterface(RenderListener.class); - delegate.registerInterface(PreRenderListener.class); - delegate.registerInterface(PostRenderListener.class); - delegate.registerInterface(HUDRenderListener.class); - delegate.registerInterface(ChatRenderListener.class); - delegate.registerInterface(OutboundChatListener.class); - delegate.registerInterface(ViewportListener.class); - delegate.registerInterface(FrameBufferListener.class); - delegate.registerInterface(InitCompleteListener.class); - delegate.registerInterface(OutboundChatFilter.class); - delegate.registerInterface(ScreenshotListener.class); - delegate.registerInterface(EntityRenderListener.class); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider#initProvider() - */ - @Override - public void initProvider() - { - } - - /** - * @param tickable - */ - public void addTickListener(Tickable tickable) - { - this.tickListeners.add(tickable); - } - - /** - * @param loopListener - */ - public void addLoopListener(GameLoopListener loopListener) - { - this.loopListeners.add(loopListener); - } - - /** - * @param initCompleteListener - */ - public void addInitListener(InitCompleteListener initCompleteListener) - { - this.initListeners.add(initCompleteListener); - } - - /** - * @param renderListener - */ - public void addRenderListener(RenderListener renderListener) - { - this.renderListeners.add(renderListener); - } - - /** - * @param preRenderListener - */ - public void addPreRenderListener(PreRenderListener preRenderListener) - { - this.preRenderListeners.add(preRenderListener); - } - - /** - * @param postRenderListener - */ - public void addPostRenderListener(PostRenderListener postRenderListener) - { - this.postRenderListeners.add(postRenderListener); - } - - /** - * @param chatRenderListener - */ - public void addChatRenderListener(ChatRenderListener chatRenderListener) - { - this.chatRenderListeners.add(chatRenderListener); - } - - /** - * @param hudRenderListener - */ - public void addHUDRenderListener(HUDRenderListener hudRenderListener) - { - this.hudRenderListeners.add(hudRenderListener); - } - - /** - * @param outboundChatListener - */ - public void addOutboundChatListener(OutboundChatListener outboundChatListener) - { - this.outboundChatListeners.add(outboundChatListener); - } - - /** - * @param outboundChatFilter - */ - public void addOutboundChatFiler(OutboundChatFilter outboundChatFilter) - { - this.outboundChatFilters.add(outboundChatFilter); - } - - /** - * @param viewportListener - */ - public void addViewportListener(ViewportListener viewportListener) - { - this.viewportListeners.add(viewportListener); - } - - /** - * @param frameBufferListener - */ - public void addFrameBufferListener(FrameBufferListener frameBufferListener) - { - this.frameBufferListeners.add(frameBufferListener); - } - - /** - * @param screenshotListener - */ - public void addScreenshotListener(ScreenshotListener screenshotListener) - { - this.screenshotListeners.add(screenshotListener); - } - - /** - * @param entityRenderListener - */ - public void addEntityRenderListener(EntityRenderListener entityRenderListener) - { - this.entityRenderListeners.add(entityRenderListener); - } - - /** - * Late initialisation callback - */ - @Override - protected void onStartupComplete() - { - this.engine.getResources().refreshResources(false); - - for (InitCompleteListener initMod : this.initListeners) - { - try - { - LoadingProgress.setMessage("Calling late init for mod %s...", initMod.getName()); - LiteLoaderLogger.info("Calling late init for mod %s", initMod.getName()); - initMod.onInitCompleted(this.engine.getClient(), this.loader); - } - catch (Throwable th) - { - this.mods.onLateInitFailed(initMod, th); - LiteLoaderLogger.warning(th, "Error calling late init for mod %s", initMod.getName()); - } - } - - this.onResize(this.engineClient.getClient()); - - super.onStartupComplete(); - } - - public void onResize(Minecraft minecraft) - { - ScaledResolution currentResolution = this.engineClient.getScaledResolution(); - this.screenWidth = currentResolution.getScaledWidth(); - this.screenHeight = currentResolution.getScaledHeight(); - - if (this.wasFullScreen != minecraft.isFullScreen()) - { - this.viewportListeners.all().onFullScreenToggled(minecraft.isFullScreen()); - } - - this.wasFullScreen = minecraft.isFullScreen(); - this.viewportListeners.all().onViewportResized(currentResolution, minecraft.displayWidth, minecraft.displayHeight); - } - - /** - * Callback from the tick hook, pre render - */ - void onRender() - { - this.renderListeners.all().onRender(); - } - - /** - * Callback from the tick hook, post render entities - * - * @param partialTicks - * @param timeSlice - */ - void postRenderEntities(float partialTicks, long timeSlice) - { - this.postRenderListeners.all().onPostRenderEntities(partialTicks); - } - - /** - * Callback from the tick hook, post render - * - * @param partialTicks - * @param timeSlice - */ - void postRender(float partialTicks, long timeSlice) - { - ((IEntityRenderer)this.engineClient.getClient().entityRenderer).setupCamera(partialTicks, 0); - this.postRenderListeners.all().onPostRender(partialTicks); - } - - /** - * Called immediately before the current GUI is rendered - */ - void preRenderGUI(float partialTicks) - { - this.renderListeners.all().onRenderGui(this.engineClient.getCurrentScreen()); - } - - /** - * Called immediately after the world/camera transform is initialised - * - * @param pass - * @param timeSlice - * @param partialTicks - */ - void onSetupCameraTransform(int pass, float partialTicks, long timeSlice) - { - this.renderListeners.all().onSetupCameraTransform(); - this.preRenderListeners.all().onSetupCameraTransform(partialTicks, pass, timeSlice); - } - - /** - * Called immediately before the chat log is rendered - * - * @param chatGui - * @param partialTicks - */ - void onRenderChat(GuiNewChat chatGui, float partialTicks) - { - this.chatRenderListeners.all().onPreRenderChat(this.screenWidth, this.screenHeight, chatGui); - } - - /** - * Called immediately after the chat log is rendered - * - * @param chatGui - * @param partialTicks - */ - void postRenderChat(GuiNewChat chatGui, float partialTicks) - { - this.chatRenderListeners.all().onPostRenderChat(this.screenWidth, this.screenHeight, chatGui); - } - - /** - * Callback when about to render the HUD - */ - void onRenderHUD(float partialTicks) - { - this.hudRenderListeners.all().onPreRenderHUD(this.screenWidth, this.screenHeight); - } - - /** - * Callback when the HUD has just been rendered - */ - void postRenderHUD(float partialTicks) - { - this.hudRenderListeners.all().onPostRenderHUD(this.screenWidth, this.screenHeight); - } - - /** - * Callback from the tick hook, called every frame when the timer is updated - */ - void onTimerUpdate() - { - Minecraft minecraft = this.engine.getClient(); - this.loopListeners.all().onRunGameLoop(minecraft); - } - - /** - * Callback from the tick hook, ticks all tickable mods - */ - void onTick() - { - this.profiler.endStartSection("litemods"); - - Timer minecraftTimer = ((IMinecraft)this.engine.getClient()).getTimer(); - float partialTicks = minecraftTimer.renderPartialTicks; - boolean clock = minecraftTimer.elapsedTicks > 0; - - Minecraft minecraft = this.engine.getClient(); - - // Flag indicates whether we are in game at the moment - Entity renderViewEntity = minecraft.getRenderViewEntity(); // TODO OBF MCPTEST func_175606_aa - getRenderViewEntity - boolean inGame = renderViewEntity != null && renderViewEntity.worldObj != null; - - this.profiler.startSection("loader"); - super.onTick(clock, partialTicks, inGame); - - int mouseX = Mouse.getX() * this.screenWidth / minecraft.displayWidth; - int mouseY = this.screenHeight - Mouse.getY() * this.screenHeight / minecraft.displayHeight - 1; - this.profiler.endStartSection("postrender"); - super.onPostRender(mouseX, mouseY, partialTicks); - this.profiler.endSection(); - - // Iterate tickable mods - this.tickListeners.all().onTick(minecraft, partialTicks, inGame, clock); - - // Detected world change - int worldHashCode = (minecraft.theWorld != null) ? minecraft.theWorld.hashCode() : 0; - if (worldHashCode != this.worldHashCode) - { - this.worldHashCode = worldHashCode; - super.onWorldChanged(minecraft.theWorld); - } - } - - /** - * @param packet - * @param message - */ - void onSendChatMessage(C01PacketChatMessage packet, String message) - { - this.outboundChatListeners.all().onSendChatMessage(packet, message); - } - - /** - * @param message - */ - void onSendChatMessage(CallbackInfo e, String message) - { - if (!this.outboundChatFilters.all().onSendChatMessage(message)) - { - e.cancel(); - } - } - - /** - * @param framebuffer - */ - void preRenderFBO(Framebuffer framebuffer) - { - this.frameBufferListeners.all().preRenderFBO(framebuffer); - } - - /** - * @param framebuffer - * @param width - * @param height - */ - void onRenderFBO(Framebuffer framebuffer, int width, int height) - { - this.frameBufferListeners.all().onRenderFBO(framebuffer, width, height); - } - - /** - * @param framebuffer - */ - void postRenderFBO(Framebuffer framebuffer) - { - this.frameBufferListeners.all().postRenderFBO(framebuffer); - } - - /** - * @param partialTicks - * @param timeSlice - */ - void onRenderWorld(float partialTicks, long timeSlice) - { - this.preRenderListeners.all().onRenderWorld(partialTicks); - this.renderListeners.all().onRenderWorld(); - } - - /** - * @param partialTicks - * @param pass - * @param timeSlice - */ - void onRenderSky(float partialTicks, int pass, long timeSlice) - { - this.preRenderListeners.all().onRenderSky(partialTicks, pass); - } - - /** - * @param partialTicks - * @param pass - * @param renderGlobal - */ - void onRenderClouds(float partialTicks, int pass, RenderGlobal renderGlobal) - { - this.preRenderListeners.all().onRenderClouds(partialTicks, pass, renderGlobal); - } - - /** - * @param partialTicks - * @param pass - * @param timeSlice - */ - void onRenderTerrain(float partialTicks, int pass, long timeSlice) - { - this.preRenderListeners.all().onRenderTerrain(partialTicks, pass); - } - - /** - * @param e - * @param name - * @param width - * @param height - * @param fbo - */ - void onScreenshot(CallbackInfoReturnable ci, String name, int width, int height, Framebuffer fbo) - { - ReturnValue ret = new ReturnValue(ci.getReturnValue()); - - if (!this.screenshotListeners.all().onSaveScreenshot(name, width, height, fbo, ret)) - { - ci.setReturnValue(ret.get()); - } - } - - /** - * @param source - * @param entity - * @param xPos - * @param yPos - * @param zPos - * @param yaw - * @param partialTicks - * @param render - */ - public void onRenderEntity(RenderManager source, Entity entity, double xPos, double yPos, double zPos, float yaw, float partialTicks, - Render render) - { - this.entityRenderListeners.all().onRenderEntity(render, entity, xPos, yPos, zPos, yaw, partialTicks); - } - - /** - * @param source - * @param entity - * @param xPos - * @param yPos - * @param zPos - * @param yaw - * @param partialTicks - * @param render - */ - public void onPostRenderEntity(RenderManager source, Entity entity, double xPos, double yPos, double zPos, float yaw, float partialTicks, - Render render) - { - this.entityRenderListeners.all().onPostRenderEntity(render, entity, xPos, yPos, zPos, yaw, partialTicks); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/LiteLoaderPanelManager.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/LiteLoaderPanelManager.java deleted file mode 100644 index cf517cec..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/LiteLoaderPanelManager.java +++ /dev/null @@ -1,294 +0,0 @@ -package com.mumfrey.liteloader.client; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiIngameMenu; -import net.minecraft.client.gui.GuiMainMenu; -import net.minecraft.client.gui.GuiOptions; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.resources.I18n; - -import org.lwjgl.input.Keyboard; - -import com.mumfrey.liteloader.client.gui.GuiLiteLoaderPanel; -import com.mumfrey.liteloader.common.GameEngine; -import com.mumfrey.liteloader.core.LiteLoaderMods; -import com.mumfrey.liteloader.core.LiteLoaderUpdateSite; -import com.mumfrey.liteloader.core.LiteLoaderVersion; -import com.mumfrey.liteloader.interfaces.PanelManager; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.modconfig.ConfigManager; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Observer which handles the display of the mod panel - * - * @author Adam Mummery-Smith - */ -public class LiteLoaderPanelManager implements PanelManager -{ - private final LoaderEnvironment environment; - - /** - * Loader Properties adapter - */ - private final LoaderProperties properties; - - private LiteLoaderMods mods; - - private ConfigManager configManager; - - private Minecraft minecraft; - - /** - * Setting which determines whether we show the "mod info" screen tab in the - * main menu. - */ - private boolean displayModInfoScreenTab = true; - - /** - * Don't hide t - */ - private boolean tabAlwaysExpanded = false; - - /** - * Override for the "mod info" tab setting, so that mods which want to - * handle the mod info themselves can temporarily disable the function - * without having to change the underlying property. - */ - private boolean hideModInfoScreenTab = false; - - private boolean checkForUpdate = false; - - private String notification; - - /** - * Active "mod info" screen, drawn as an overlay when in the main menu and - * made the active screen if the user clicks the tab. - */ - private GuiLiteLoaderPanel panelHost; - - /** - * @param environment - * @param properties - */ - @SuppressWarnings("unchecked") - public LiteLoaderPanelManager(GameEngine engine, LoaderEnvironment environment, LoaderProperties properties) - { - this.environment = environment; - this.properties = properties; - this.minecraft = ((GameEngine)engine).getClient(); - - this.displayModInfoScreenTab = this.properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_MOD_INFO_SCREEN, true); - this.tabAlwaysExpanded = this.properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_NO_HIDE_TAB, false); - - if (this.properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_FORCE_UPDATE, false)) - { - int updateCheckInterval = this.properties.getIntegerProperty(LoaderProperties.OPTION_UPDATE_CHECK_INTR) + 1; - LiteLoaderLogger.debug("Force update is TRUE, updateCheckInterval = %d", updateCheckInterval); - - if (updateCheckInterval > 10) - { - LiteLoaderLogger.debug("Forcing update check!"); - this.checkForUpdate = true; - updateCheckInterval = 0; - } - - this.properties.setIntegerProperty(LoaderProperties.OPTION_UPDATE_CHECK_INTR, updateCheckInterval); - this.properties.writeProperties(); - } - } - - @Override - public void init(LiteLoaderMods mods, ConfigManager configManager) - { - this.mods = mods; - this.configManager = configManager; - } - - @Override - public void onStartupComplete() - { - if (this.checkForUpdate) - { - LiteLoaderVersion.getUpdateSite().beginUpdateCheck(); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.TickObserver - * #onTick(boolean, float, boolean) - */ - @Override - public void onTick(boolean clock, float partialTicks, boolean inGame) - { - if (clock && this.panelHost != null && this.minecraft.currentScreen != this.panelHost) - { - this.panelHost.updateScreen(); - } - - if (clock && this.checkForUpdate) - { - LiteLoaderUpdateSite updateSite = LiteLoaderVersion.getUpdateSite(); - if (!updateSite.isCheckInProgress() && updateSite.isCheckComplete()) - { - LiteLoaderLogger.debug("Scheduled update check completed, success=%s", updateSite.isCheckSucceess()); - this.checkForUpdate = false; - if (updateSite.isCheckSucceess() && updateSite.isUpdateAvailable()) - { - this.setNotification(I18n.format("gui.notifications.updateavailable")); - } - } - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.PostRenderObserver - * #onPostRender(int, int, float) - */ - @Override - public void onPostRender(int mouseX, int mouseY, float partialTicks) - { - if (this.mods == null) return; - - boolean tabHidden = this.isTabHidden() && this.minecraft.currentScreen instanceof GuiMainMenu; - - if (this.isPanelSupportedOnScreen(this.minecraft.currentScreen) - && ((this.displayModInfoScreenTab && !tabHidden) || (this.panelHost != null && this.panelHost.isOpen()))) - { - // If we're at the main menu, prepare the overlay - if (this.panelHost == null || this.panelHost.getScreen() != this.minecraft.currentScreen) - { - this.panelHost = new GuiLiteLoaderPanel(this.minecraft, this.minecraft.currentScreen, this.mods, this.environment, this.properties, - this.configManager, !tabHidden); - if (this.notification != null) - { - this.panelHost.setNotification(this.notification); - } - } - - this.minecraft.entityRenderer.setupOverlayRendering(); - this.panelHost.drawScreen(mouseX, mouseY, partialTicks, this.tabAlwaysExpanded); - } - else if (this.minecraft.currentScreen != this.panelHost && this.panelHost != null) - { - // If we're in any other screen, kill the overlay - this.panelHost.release(); - this.panelHost = null; - } - else if (this.isPanelSupportedOnScreen(this.minecraft.currentScreen) - && Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) - && Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) - && Keyboard.isKeyDown(Keyboard.KEY_TAB)) - { - this.displayLiteLoaderPanel(this.minecraft.currentScreen); - } - } - - /** - * Set the "mod info" screen tab to hidden, regardless of the property - * setting. - */ - @Override - public void hideTab() - { - this.hideModInfoScreenTab = true; - } - - private boolean isTabHidden() - { - return this.hideModInfoScreenTab && this.getStartupErrorCount() == 0 && this.notification == null; - } - - /** - * Set whether the "mod info" screen tab should be shown in the main menu - */ - @Override - public void setTabVisible(boolean show) - { - this.displayModInfoScreenTab = show; - this.properties.setBooleanProperty(LoaderProperties.OPTION_MOD_INFO_SCREEN, show); - this.properties.writeProperties(); - } - - /** - * Get whether the "mod info" screen tab is shown in the main menu - */ - @Override - public boolean isTabVisible() - { - return this.displayModInfoScreenTab; - } - - @Override - public void setTabAlwaysExpanded(boolean expand) - { - this.tabAlwaysExpanded = expand; - this.properties.setBooleanProperty(LoaderProperties.OPTION_NO_HIDE_TAB, expand); - this.properties.writeProperties(); - } - - @Override - public boolean isTabAlwaysExpanded() - { - return this.tabAlwaysExpanded; - } - - @Override - public void setForceUpdateEnabled(boolean forceUpdate) - { - this.properties.setBooleanProperty(LoaderProperties.OPTION_FORCE_UPDATE, forceUpdate); - this.properties.writeProperties(); - } - - @Override - public boolean isForceUpdateEnabled() - { - return this.properties.getBooleanProperty(LoaderProperties.OPTION_FORCE_UPDATE); - } - - /** - * Display the liteloader panel over the specified GUI - * - * @param parentScreen - */ - @Override - public void displayLiteLoaderPanel(GuiScreen parentScreen) - { - if (this.isPanelSupportedOnScreen(parentScreen)) - { - this.panelHost = new GuiLiteLoaderPanel(this.minecraft, parentScreen, this.mods, this.environment, this.properties, - this.configManager, !this.isTabHidden()); - this.minecraft.displayGuiScreen(this.panelHost); - } - } - - @Override - public int getStartupErrorCount() - { - return this.mods.getStartupErrorCount(); - } - - @Override - public int getCriticalErrorCount() - { - return this.mods.getCriticalErrorCount(); - } - - @Override - public void setNotification(String notification) - { - LiteLoaderLogger.debug("Setting notification: " + notification); - this.notification = notification; - - if (this.panelHost != null) - { - this.panelHost.setNotification(notification); - } - } - - private boolean isPanelSupportedOnScreen(GuiScreen guiScreen) - { - return (guiScreen instanceof GuiMainMenu || guiScreen instanceof GuiIngameMenu || guiScreen instanceof GuiOptions); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/PacketEventsClient.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/PacketEventsClient.java deleted file mode 100644 index fdd634c8..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/PacketEventsClient.java +++ /dev/null @@ -1,262 +0,0 @@ -package com.mumfrey.liteloader.client; - -import com.mojang.realmsclient.dto.RealmsServer; -import com.mumfrey.liteloader.*; -import com.mumfrey.liteloader.common.ducks.IChatPacket; -import com.mumfrey.liteloader.common.transformers.PacketEventInfo; -import com.mumfrey.liteloader.core.ClientPluginChannels; -import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.core.LiteLoaderEventBroker.ReturnValue; -import com.mumfrey.liteloader.core.PacketEvents; -import com.mumfrey.liteloader.core.event.EventCancellationException; -import com.mumfrey.liteloader.core.event.HandlerList; -import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp; -import com.mumfrey.liteloader.core.runtime.Packets; -import com.mumfrey.liteloader.interfaces.FastIterableDeque; -import com.mumfrey.liteloader.util.ChatUtilities; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -import net.minecraft.client.Minecraft; -import net.minecraft.network.INetHandler; -import net.minecraft.network.Packet; -import net.minecraft.network.login.INetHandlerLoginClient; -import net.minecraft.network.login.server.S02PacketLoginSuccess; -import net.minecraft.network.play.INetHandlerPlayClient; -import net.minecraft.network.play.server.S01PacketJoinGame; -import net.minecraft.network.play.server.S02PacketChat; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.IThreadListener; - -/** - * Client-side packet event handlers - * - * @author Adam Mummery-Smith - */ -public class PacketEventsClient extends PacketEvents -{ - private static RealmsServer joiningRealm; - - private FastIterableDeque joinGameListeners = new HandlerList(JoinGameListener.class); - private FastIterableDeque chatListeners = new HandlerList(ChatListener.class); - private FastIterableDeque chatFilters = new HandlerList(ChatFilter.class, - ReturnLogicOp.AND_BREAK_ON_FALSE); - private FastIterableDeque preJoinGameListeners = new HandlerList(PreJoinGameListener.class, - ReturnLogicOp.AND_BREAK_ON_FALSE); - private FastIterableDeque postLoginListeners = new HandlerList(PostLoginListener.class); - - @Override - public void registerInterfaces(InterfaceRegistrationDelegate delegate) - { - super.registerInterfaces(delegate); - - delegate.registerInterface(JoinGameListener.class); - delegate.registerInterface(ChatListener.class); - delegate.registerInterface(ChatFilter.class); - delegate.registerInterface(PreJoinGameListener.class); - delegate.registerInterface(PostLoginListener.class); - } - - /** - * @param joinGameListener - */ - public void registerJoinGameListener(JoinGameListener joinGameListener) - { - this.joinGameListeners.add(joinGameListener); - } - - /** - * @param chatFilter - */ - public void registerChatFilter(ChatFilter chatFilter) - { - this.chatFilters.add(chatFilter); - } - - /** - * @param chatListener - */ - public void registerChatListener(ChatListener chatListener) - { - if (chatListener instanceof ChatFilter) - { - LiteLoaderLogger.warning("Interface error initialising mod '%1s'. A mod implementing ChatFilter and ChatListener is not supported! " - + "Remove one of these interfaces", chatListener.getName()); - } - else - { - this.chatListeners.add(chatListener); - } - } - - /** - * @param joinGameListener - */ - public void registerPreJoinGameListener(PreJoinGameListener joinGameListener) - { - this.preJoinGameListeners.add(joinGameListener); - } - - /** - * @param postLoginListener - */ - public void registerPostLoginListener(PostLoginListener postLoginListener) - { - this.postLoginListeners.add(postLoginListener); - } - - public static void onJoinRealm(long serverId, RealmsServer server) - { - PacketEventsClient.joiningRealm = server; - } - - @Override - protected IThreadListener getPacketContextListener(Packets.Context context) - { - if (context == Packets.Context.SERVER) - { - return MinecraftServer.getServer(); - } - - return Minecraft.getMinecraft(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.PacketEvents#handlePacket( - * com.mumfrey.liteloader.common.transformers.PacketEventInfo, - * net.minecraft.network.INetHandler, - * net.minecraft.network.play.server.S01PacketJoinGame) - */ - @Override - protected void handlePacket(PacketEventInfo e, INetHandler netHandler, S01PacketJoinGame packet) - { - if (this.preJoinGame(e, netHandler, packet)) - { - return; - } - - ((INetHandlerPlayClient)netHandler).handleJoinGame(packet); - super.handlePacket(e, netHandler, packet); - - this.postJoinGame(e, netHandler, packet); - } - - /** - * @param e - * @param netHandler - * @param packet - * @throws EventCancellationException - */ - private boolean preJoinGame(PacketEventInfo e, INetHandler netHandler, S01PacketJoinGame packet) throws EventCancellationException - { - if (!(netHandler instanceof INetHandlerPlayClient)) - { - return true; - } - - e.cancel(); - - return !this.preJoinGameListeners.all().onPreJoinGame(netHandler, packet); - } - - /** - * @param e - * @param netHandler - * @param packet - */ - private void postJoinGame(PacketEventInfo e, INetHandler netHandler, S01PacketJoinGame packet) - { - this.joinGameListeners.all().onJoinGame(netHandler, packet, Minecraft.getMinecraft().getCurrentServerData(), PacketEventsClient.joiningRealm); - PacketEventsClient.joiningRealm = null; - - ClientPluginChannels clientPluginChannels = LiteLoader.getClientPluginChannels(); - if (clientPluginChannels instanceof ClientPluginChannelsClient) - { - ((ClientPluginChannelsClient)clientPluginChannels).onJoinGame(netHandler, packet); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.PacketEvents#handlePacket( - * com.mumfrey.liteloader.common.transformers.PacketEventInfo, - * net.minecraft.network.INetHandler, - * net.minecraft.network.login.server.S02PacketLoginSuccess) - */ - @Override - protected void handlePacket(PacketEventInfo e, INetHandler netHandler, S02PacketLoginSuccess packet) - { - if (netHandler instanceof INetHandlerLoginClient) - { - INetHandlerLoginClient netHandlerLoginClient = (INetHandlerLoginClient)netHandler; - - ClientPluginChannels clientPluginChannels = LiteLoader.getClientPluginChannels(); - if (clientPluginChannels instanceof ClientPluginChannelsClient) - { - ((ClientPluginChannelsClient)clientPluginChannels).onPostLogin(netHandlerLoginClient, packet); - } - - this.postLoginListeners.all().onPostLogin(netHandlerLoginClient, packet); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.PacketEvents#handlePacket( - * com.mumfrey.liteloader.common.transformers.PacketEventInfo, - * net.minecraft.network.INetHandler, - * net.minecraft.network.play.server.S02PacketChat) - */ - @Override - protected void handlePacket(PacketEventInfo e, INetHandler netHandler, S02PacketChat packet) - { - if (packet.getChatComponent() == null) - { - return; - } - - IChatComponent originalChat = packet.getChatComponent(); - IChatComponent chat = originalChat; - String message = chat.getFormattedText(); - - // Chat filters get a stab at the chat first, if any filter returns false the chat is discarded - for (ChatFilter chatFilter : this.chatFilters) - { - ReturnValue ret = new ReturnValue(); - - if (chatFilter.onChat(chat, message, ret)) - { - if (ret.isSet()) - { - chat = ret.get(); - if (chat == null) - { - chat = new ChatComponentText(""); - } - message = chat.getFormattedText(); - } - } - else - { - e.cancel(); - return; - } - } - - if (chat != originalChat) - { - try - { - chat = ChatUtilities.convertLegacyCodes(chat); - ((IChatPacket)packet).setChatComponent(chat); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - // Chat listeners get the chat if no filter removed it - this.chatListeners.all().onChat(chat, message); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/ResourceObserver.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/ResourceObserver.java deleted file mode 100644 index 49949b3e..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/ResourceObserver.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.mumfrey.liteloader.client; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourcePack; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.api.ModLoadObserver; -import com.mumfrey.liteloader.common.Resources; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.core.ModInfo; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.resources.ModResourcePack; -import com.mumfrey.liteloader.resources.ModResourcePackDir; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Observer which handles registering mods on the client as resource packs - * - * @author Adam Mummery-Smith - */ -public class ResourceObserver implements ModLoadObserver -{ - private final Map resourcePacks = new HashMap(); - - public ResourceObserver() - { - } - - @Override - public void onModLoaded(LiteMod mod) - { - } - - @SuppressWarnings("unchecked") - @Override - public void onPostModLoaded(ModInfo> handle) - { - if (!handle.hasContainer()) return; - - LoadableMod container = handle.getContainer(); - String modName = handle.getMod().getName(); - - if (modName == null) return; - - if (container.hasResources()) - { - LiteLoaderLogger.info("Adding \"%s\" to active resource pack set", container.getLocation()); - IResourcePack resourcePack = this.initResourcePack(container, modName); - Resources resources - = (Resources)LiteLoader.getGameEngine().getResources(); - if (resources.registerResourcePack(resourcePack)) - { - LiteLoaderLogger.info("Successfully added \"%s\" to active resource pack set", container.getLocation()); - } - } - } - - public IResourcePack initResourcePack(LoadableMod container, String name) - { - IResourcePack resourcePack = this.getResourcePack(container); - - if (resourcePack == null) - { - if (container.isDirectory()) - { - LiteLoaderLogger.info("Setting up \"%s/%s\" as mod resource pack with identifier \"%s\"", - container.toFile().getParentFile().getName(), container.getName(), name); - resourcePack = new ModResourcePackDir(name, container.toFile()); - } - else - { - LiteLoaderLogger.info("Setting up \"%s\" as mod resource pack with identifier \"%s\"", container.getName(), name); - resourcePack = new ModResourcePack(name, container.toFile()); - } - - this.setResourcePack(container, resourcePack); - } - - return resourcePack; - } - - private IResourcePack getResourcePack(LoadableMod container) - { - String path = container.getLocation(); - return this.resourcePacks.get(path); - } - - private void setResourcePack(LoadableMod container, IResourcePack resourcePack) - { - String path = container.getLocation(); - this.resourcePacks.put(path, resourcePack); - } - - @Override - public void onModLoadFailed(LoadableMod container, String identifier, String reason, Throwable th) - { - } - - @Override - public void onPreInitMod(LiteMod mod) - { - } - - @Override - public void onPostInitMod(LiteMod mod) - { - } - - @Override - public void onMigrateModConfig(LiteMod mod, File newConfigPath, File oldConfigPath) - { - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/ResourcesClient.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/ResourcesClient.java deleted file mode 100644 index 67947d9c..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/ResourcesClient.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.mumfrey.liteloader.client; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.resources.IResourcePack; - -import com.mumfrey.liteloader.client.overlays.IMinecraft; -import com.mumfrey.liteloader.common.LoadingProgress; -import com.mumfrey.liteloader.common.Resources; - -public class ResourcesClient implements Resources -{ - private final Minecraft engine = Minecraft.getMinecraft(); - - /** - * Registered resource packs - */ - private final Map registeredResourcePacks = new HashMap(); - - /** - * True while initialising mods if we need to do a resource manager reload - * once the process is completed. - */ - private boolean pendingResourceReload; - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#refreshResources(boolean) - */ - @Override - public void refreshResources(boolean force) - { - if (this.pendingResourceReload || force) - { - LoadingProgress.setMessage("Reloading Resources..."); - this.pendingResourceReload = false; - this.engine.refreshResources(); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#getResourceManager() - */ - @Override - public IResourceManager getResourceManager() - { - return this.engine.getResourceManager(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#registerResourcePack( - * net.minecraft.client.resources.IResourcePack) - */ - @Override - public boolean registerResourcePack(IResourcePack resourcePack) - { - if (!this.registeredResourcePacks.containsKey(resourcePack.getPackName())) - { - this.pendingResourceReload = true; - - List defaultResourcePacks = ((IMinecraft)this.engine).getDefaultResourcePacks(); - if (!defaultResourcePacks.contains(resourcePack)) - { - defaultResourcePacks.add(resourcePack); - this.registeredResourcePacks.put(resourcePack.getPackName(), resourcePack); - return true; - } - } - - return false; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.common.GameEngine#unRegisterResourcePack( - * net.minecraft.client.resources.IResourcePack) - */ - @Override - public boolean unRegisterResourcePack(IResourcePack resourcePack) - { - if (this.registeredResourcePacks.containsValue(resourcePack)) - { - this.pendingResourceReload = true; - - List defaultResourcePacks = ((IMinecraft)this.engine).getDefaultResourcePacks(); - this.registeredResourcePacks.remove(resourcePack.getPackName()); - defaultResourcePacks.remove(resourcePack); - return true; - } - - return false; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/SoundHandlerReloadInhibitor.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/SoundHandlerReloadInhibitor.java deleted file mode 100644 index 60b1a3ee..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/SoundHandlerReloadInhibitor.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.mumfrey.liteloader.client; - -import java.util.List; - -import com.mumfrey.liteloader.client.ducks.IReloadable; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -import net.minecraft.client.audio.SoundHandler; -import net.minecraft.client.resources.IResourceManagerReloadListener; -import net.minecraft.client.resources.SimpleReloadableResourceManager; - -/** - * Manager object which handles inhibiting the sound handler's reload - * notification at startup. - * - * @author Adam Mummery-Smith - */ -public class SoundHandlerReloadInhibitor -{ - /** - * Resource Manager - */ - private SimpleReloadableResourceManager resourceManager; - - /** - * Sound manager - */ - private SoundHandler soundHandler; - - /** - * True if inhibition is currently active - */ - private boolean inhibited; - - /** - * So that we can re-insert the sound manager at the same index, we store - * the index we remove it from. - */ - private int storedIndex; - - SoundHandlerReloadInhibitor(SimpleReloadableResourceManager resourceManager, SoundHandler soundHandler) - { - this.resourceManager = resourceManager; - this.soundHandler = soundHandler; - } - - /** - * Inhibit the sound manager reload notification - * - * @return true if inhibit was applied - */ - public boolean inhibit() - { - try - { - if (!this.inhibited) - { - List reloadListeners = ((IReloadable)this.resourceManager).getReloadListeners(); - if (reloadListeners != null) - { - this.storedIndex = reloadListeners.indexOf(this.soundHandler); - if (this.storedIndex > -1) - { - LiteLoaderLogger.info("Inhibiting sound handler reload"); - reloadListeners.remove(this.soundHandler); - this.inhibited = true; - return true; - } - } - } - } - catch (Exception ex) - { - LiteLoaderLogger.warning("Error inhibiting sound handler reload"); - } - - return false; - } - - /** - * Remove the sound manager reload inhibit - * - * @param reload True to reload the sound manager now - * @return true if the sound manager was successfully restored - */ - public boolean unInhibit(boolean reload) - { - try - { - if (this.inhibited) - { - List reloadListeners = ((IReloadable)this.resourceManager).getReloadListeners(); - if (reloadListeners != null) - { - if (this.storedIndex > -1) - { - reloadListeners.add(this.storedIndex, this.soundHandler); - } - else - { - reloadListeners.add(this.soundHandler); - } - - LiteLoaderLogger.info("Sound handler reload inhibit removed"); - - if (reload) - { - LiteLoaderLogger.info("Reloading sound handler"); - this.soundHandler.onResourceManagerReload(this.resourceManager); - } - - this.inhibited = false; - return true; - } - } - } - catch (Exception ex) - { - LiteLoaderLogger.warning("Error removing sound handler reload inhibit"); - } - - return false; - } - - public boolean isInhibited() - { - return this.inhibited; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/Translator.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/Translator.java deleted file mode 100644 index 795628bc..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/Translator.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.mumfrey.liteloader.client; - -import net.minecraft.client.resources.I18n; - -import com.mumfrey.liteloader.api.TranslationProvider; - -public class Translator implements TranslationProvider -{ - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.TranslationProvider#translate( - * java.lang.String, java.lang.Object[]) - */ - @Override - public String translate(String key, Object... args) - { - // TODO doesn't currently honour the contract of TranslationProvider::translate, should return null if translation is missing - return I18n.format(key, args); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.TranslationProvider#translate( - * java.lang.String, java.lang.String, java.lang.Object[]) - */ - @Override - public String translate(String locale, String key, Object... args) - { - // TODO doesn't currently honour the contract of TranslationProvider::translate, should return null if translation is missing - return I18n.format(key, args); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/api/LiteLoaderBrandingProvider.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/api/LiteLoaderBrandingProvider.java deleted file mode 100644 index 2d519cdf..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/api/LiteLoaderBrandingProvider.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.mumfrey.liteloader.client.api; - -import java.net.URI; - -import net.minecraft.client.resources.I18n; -import net.minecraft.util.ResourceLocation; - -import com.mumfrey.liteloader.api.BrandingProvider; -import com.mumfrey.liteloader.client.util.render.IconAbsolute; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.util.render.Icon; - -/** - * LiteLoader's branding provider - * - * @author Adam Mummery-Smith - */ -public class LiteLoaderBrandingProvider implements BrandingProvider -{ - public static final int BRANDING_COLOUR = 0xFF4785D1; - - public static final ResourceLocation ABOUT_TEXTURE = new ResourceLocation("liteloader", "textures/gui/about.png"); - - public static final IconAbsolute LOGO_COORDS = new IconAbsolute(LiteLoaderBrandingProvider.ABOUT_TEXTURE, - "logo", 128, 40, 0, 0, 256, 80); - public static final IconAbsolute ICON_COORDS = new IconAbsolute(LiteLoaderBrandingProvider.ABOUT_TEXTURE, - "chicken", 32, 45, 0, 80, 64, 170); - public static final IconAbsolute TWITTER_AVATAR_COORDS = new IconAbsolute(LiteLoaderBrandingProvider.ABOUT_TEXTURE, - "twitter_avatar",32, 32, 192, 80, 256, 144); - - public static final URI LITELOADER_URI = URI.create("http://www.liteloader.com/"); - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.BrandingProvider#getPriority() - */ - @Override - public int getPriority() - { - return -1000; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.BrandingProvider#getDisplayName() - */ - @Override - public String getDisplayName() - { - return "LiteLoader " + I18n.format("gui.about.versiontext", LiteLoader.getVersion()); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.BrandingProvider#getCopyrightText() - */ - @Override - public String getCopyrightText() - { - return "Copyright (c) 2012-2016 Adam Mummery-Smith"; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.BrandingProvider#getHomepage() - */ - @Override - public URI getHomepage() - { - return LiteLoaderBrandingProvider.LITELOADER_URI; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.BrandingProvider#getBrandingColour() - */ - @Override - public int getBrandingColour() - { - return LiteLoaderBrandingProvider.BRANDING_COLOUR; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.BrandingProvider#getLogoResource() - */ - @Override - public ResourceLocation getLogoResource() - { - return LiteLoaderBrandingProvider.ABOUT_TEXTURE; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.BrandingProvider#getLogoCoords() - */ - @Override - public Icon getLogoCoords() - { - return LiteLoaderBrandingProvider.LOGO_COORDS; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.BrandingProvider#getIconResource() - */ - @Override - public ResourceLocation getIconResource() - { - return LiteLoaderBrandingProvider.ABOUT_TEXTURE; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.BrandingProvider#getIconCoords() - */ - @Override - public Icon getIconCoords() - { - return LiteLoaderBrandingProvider.ICON_COORDS; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.BrandingProvider#getTwitterUserName() - */ - @Override - public String getTwitterUserName() - { - return "therealeq2"; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.BrandingProvider - * #getTwitterAvatarResource() - */ - @Override - public ResourceLocation getTwitterAvatarResource() - { - return LiteLoaderBrandingProvider.ABOUT_TEXTURE; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.BrandingProvider#getTwitterAvatarCoords() - */ - @Override - public Icon getTwitterAvatarCoords() - { - return LiteLoaderBrandingProvider.TWITTER_AVATAR_COORDS; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/api/LiteLoaderCoreAPIClient.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/api/LiteLoaderCoreAPIClient.java deleted file mode 100644 index 5c19bbb1..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/api/LiteLoaderCoreAPIClient.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.mumfrey.liteloader.client.api; - -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.server.integrated.IntegratedServer; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ObjectArrays; -import com.mumfrey.liteloader.api.CoreProvider; -import com.mumfrey.liteloader.api.CustomisationProvider; -import com.mumfrey.liteloader.api.InterfaceProvider; -import com.mumfrey.liteloader.api.Observer; -import com.mumfrey.liteloader.client.LiteLoaderCoreProviderClient; -import com.mumfrey.liteloader.client.ResourceObserver; -import com.mumfrey.liteloader.client.Translator; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.core.api.LiteLoaderCoreAPI; -import com.mumfrey.liteloader.interfaces.ObjectFactory; -import com.mumfrey.liteloader.messaging.MessageBus; -import com.mumfrey.liteloader.transformers.event.json.ModEvents; - -/** - * Client side of the core API - * - * @author Adam Mummery-Smith - */ -public class LiteLoaderCoreAPIClient extends LiteLoaderCoreAPI -{ - private static final String PKG_LITELOADER_CLIENT = LiteLoaderCoreAPI.PKG_LITELOADER + ".client"; - - private static final String[] requiredTransformers = { - LiteLoaderCoreAPI.PKG_LITELOADER + ".transformers.event.EventProxyTransformer", - LiteLoaderCoreAPI.PKG_LITELOADER + ".launch.LiteLoaderTransformer", - LiteLoaderCoreAPIClient.PKG_LITELOADER_CLIENT + ".transformers.CrashReportTransformer" - }; - - private static final String[] requiredDownstreamTransformers = { - LiteLoaderCoreAPI.PKG_LITELOADER_COMMON + ".transformers.LiteLoaderPacketTransformer", - LiteLoaderCoreAPIClient.PKG_LITELOADER_CLIENT + ".transformers.MinecraftTransformer", - LiteLoaderCoreAPI.PKG_LITELOADER + ".transformers.event.json.ModEventInjectionTransformer" - }; - - private ObjectFactory objectFactory; - - @Override - public String[] getMixinConfigs() - { - String[] commonConfigs = super.getMixinConfigs(); - return ObjectArrays.concat(commonConfigs, new String[] { - "mixins.liteloader.client.json" - }, String.class); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#getRequiredTransformers() - */ - @Override - public String[] getRequiredTransformers() - { - return LiteLoaderCoreAPIClient.requiredTransformers; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI - * #getRequiredDownstreamTransformers() - */ - @Override - public String[] getRequiredDownstreamTransformers() - { - return LiteLoaderCoreAPIClient.requiredDownstreamTransformers; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#getCustomisationProviders() - */ - @Override - public List getCustomisationProviders() - { - return ImmutableList.of - ( - new LiteLoaderBrandingProvider(), - new LiteLoaderModInfoDecorator(), - new Translator() - ); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#getCoreProviders() - */ - @Override - public List getCoreProviders() - { - return ImmutableList.of - ( - new LiteLoaderCoreProviderClient(this.properties), - LiteLoader.getInput() - ); - } - - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#getInterfaceProviders() - */ - @Override - public List getInterfaceProviders() - { - ObjectFactory objectFactory = this.getObjectFactory(); - - return ImmutableList.of - ( - objectFactory.getEventBroker(), - objectFactory.getPacketEventBroker(), - objectFactory.getClientPluginChannels(), - objectFactory.getServerPluginChannels(), - MessageBus.getInstance() - ); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#getPreInitObservers() - */ - @Override - public List getPreInitObservers() - { - return ImmutableList.of - ( - new ModEvents() - ); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#getObservers() - */ - @Override - public List getObservers() - { - ObjectFactory objectFactory = this.getObjectFactory(); - - return ImmutableList.of - ( - new ResourceObserver(), - objectFactory.getPanelManager(), - objectFactory.getEventBroker() - ); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.api.LiteLoaderCoreAPI#getObjectFactory() - */ - @Override - public ObjectFactory getObjectFactory() - { - if (this.objectFactory == null) - { - this.objectFactory = new ObjectFactoryClient(this.environment, this.properties); - } - - return this.objectFactory; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/api/LiteLoaderModInfoDecorator.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/api/LiteLoaderModInfoDecorator.java deleted file mode 100644 index 92ab4a32..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/api/LiteLoaderModInfoDecorator.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.mumfrey.liteloader.client.api; - -import java.util.List; - -import net.minecraft.client.resources.I18n; - -import com.mumfrey.liteloader.api.ModInfoDecorator; -import com.mumfrey.liteloader.client.gui.GuiLiteLoaderPanel; -import com.mumfrey.liteloader.client.gui.modlist.GuiModListPanel; -import com.mumfrey.liteloader.client.util.render.IconAbsolute; -import com.mumfrey.liteloader.client.util.render.IconAbsoluteClickable; -import com.mumfrey.liteloader.core.ModInfo; -import com.mumfrey.liteloader.util.render.IconTextured; - -/** - * ModInfo decorator - * - * @author Adam Mummery-Smith - */ -public class LiteLoaderModInfoDecorator implements ModInfoDecorator -{ - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ModInfoDecorator - * #addIcons(com.mumfrey.liteloader.core.ModInfo, java.util.List) - */ - @Override - public void addIcons(final ModInfo mod, List icons) - { - if (mod.hasTweakClass()) - { - icons.add(new IconAbsoluteClickable(LiteLoaderBrandingProvider.ABOUT_TEXTURE, - I18n.format("gui.mod.providestweak"), 12, 12, 158, 80, 170, 92) - { - @Override - public void onClicked(Object source, Object container) - { - if (container instanceof GuiModListPanel) - { - ((GuiModListPanel)container).displayModHelpMessage(mod, "gui.mod.providestweak", "gui.mod.help.tweak"); - } - } - }); - } - - if (mod.hasEventTransformers()) - { - icons.add(new IconAbsoluteClickable(LiteLoaderBrandingProvider.ABOUT_TEXTURE, - I18n.format("gui.mod.providesevents"), 12, 12, 170, 92, 182, 104) - { - @Override - public void onClicked(Object source, Object container) - { - if (container instanceof GuiModListPanel) - { - ((GuiModListPanel)container).displayModHelpMessage(mod, "gui.mod.providesevents", "gui.mod.help.events"); - } - } - }); - } - - if (mod.hasClassTransformers()) - { - icons.add(new IconAbsoluteClickable(LiteLoaderBrandingProvider.ABOUT_TEXTURE, - I18n.format("gui.mod.providestransformer"), 12, 12, 170, 80, 182, 92) - { - @Override - public void onClicked(Object source, Object container) - { - if (container instanceof GuiModListPanel) - { - ((GuiModListPanel)container).displayModHelpMessage(mod, "gui.mod.providestransformer", "gui.mod.help.transformer"); - } - } - }); - } - - if (mod.hasMixins()) - { - icons.add(new IconAbsoluteClickable(LiteLoaderBrandingProvider.ABOUT_TEXTURE, - I18n.format("gui.mod.providesmixins"), 12, 12, 122, 104, 134, 116) - { - @Override - public void onClicked(Object source, Object container) - { - if (container instanceof GuiModListPanel) - { - ((GuiModListPanel)container).displayModHelpMessage(mod, "gui.mod.providesmixins", "gui.mod.help.mixins"); - } - } - }); - } - - if (mod.usesAPI()) - { - icons.add(new IconAbsolute(LiteLoaderBrandingProvider.ABOUT_TEXTURE, - I18n.format("gui.mod.usingapi"), 12, 12, 122, 92, 134, 104)); - } - - List startupErrors = mod.getStartupErrors(); - if (startupErrors != null && startupErrors.size() > 0) - { - icons.add(new IconAbsoluteClickable(LiteLoaderBrandingProvider.ABOUT_TEXTURE, - I18n.format("gui.mod.startuperror", startupErrors.size()), 12, 12, 134, 92, 146, 104) - { - @Override - public void onClicked(Object source, Object container) - { - if (source instanceof GuiLiteLoaderPanel) - { - ((GuiLiteLoaderPanel)source).showErrorPanel(mod); - } - } - }); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ModInfoDecorator - * #modifyStatusText(com.mumfrey.liteloader.core.ModInfo, - * java.lang.String) - */ - @Override - public String modifyStatusText(ModInfo mod, String statusText) - { - return null; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ModInfoDecorator - * #onDrawListEntry(int, int, float, int, int, int, int, boolean, - * com.mumfrey.liteloader.core.ModInfo, int, int, int) - */ - @Override - public void onDrawListEntry(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, int height, boolean selected, - ModInfo mod, int gradientColour, int titleColour, int statusColour) - { - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/api/ObjectFactoryClient.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/api/ObjectFactoryClient.java deleted file mode 100644 index 9fbb7342..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/api/ObjectFactoryClient.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.mumfrey.liteloader.client.api; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.launchwrapper.Launch; -import net.minecraft.server.integrated.IntegratedServer; - -import com.mumfrey.liteloader.client.LiteLoaderEventBrokerClient; -import com.mumfrey.liteloader.client.ClientPluginChannelsClient; -import com.mumfrey.liteloader.client.GameEngineClient; -import com.mumfrey.liteloader.client.LiteLoaderPanelManager; -import com.mumfrey.liteloader.client.PacketEventsClient; -import com.mumfrey.liteloader.client.gui.startup.LoadingBar; -import com.mumfrey.liteloader.common.GameEngine; -import com.mumfrey.liteloader.core.ClientPluginChannels; -import com.mumfrey.liteloader.core.LiteLoaderEventBroker; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.core.PacketEvents; -import com.mumfrey.liteloader.core.ServerPluginChannels; -import com.mumfrey.liteloader.interfaces.PanelManager; -import com.mumfrey.liteloader.interfaces.ObjectFactory; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.permissions.PermissionsManagerClient; -import com.mumfrey.liteloader.permissions.PermissionsManagerServer; -import com.mumfrey.liteloader.util.Input; -import com.mumfrey.liteloader.util.InputManager; - -/** - * Factory for lifetime loader objects for the client side - * - * @author Adam Mummery-Smith - */ -class ObjectFactoryClient implements ObjectFactory -{ - private LoaderEnvironment environment; - - private LoaderProperties properties; - - private Input input; - - private LiteLoaderEventBrokerClient clientEvents; - - private PacketEventsClient clientPacketEvents; - - private GameEngineClient engine; - - private PanelManager modPanelManager; - - private ClientPluginChannelsClient clientPluginChannels; - - private ServerPluginChannels serverPluginChannels; - - ObjectFactoryClient(LoaderEnvironment environment, LoaderProperties properties) - { - this.environment = environment; - this.properties = properties; - } - - @Override - public Input getInput() - { - if (this.input == null) - { - this.input = new InputManager(this.environment, this.properties); - } - - return this.input; - } - - @Override - public LiteLoaderEventBroker getEventBroker() - { - if (this.clientEvents == null) - { - this.clientEvents = new LiteLoaderEventBrokerClient(LiteLoader.getInstance(), (GameEngineClient)this.getGameEngine(), this.properties); - } - - return this.clientEvents; - } - - @Override - public PacketEvents getPacketEventBroker() - { - if (this.clientPacketEvents == null) - { - this.clientPacketEvents = new PacketEventsClient(); - } - - return this.clientPacketEvents; - } - - @Override - public GameEngine getGameEngine() - { - if (this.engine == null) - { - this.engine = new GameEngineClient(); - } - - return this.engine; - } - - @Override - public PanelManager getPanelManager() - { - if (this.modPanelManager == null) - { - this.modPanelManager = new LiteLoaderPanelManager(this.getGameEngine(), this.environment, this.properties); - } - - return this.modPanelManager; - } - - @Override - public ClientPluginChannels getClientPluginChannels() - { - if (this.clientPluginChannels == null) - { - this.clientPluginChannels = new ClientPluginChannelsClient(); - } - - return this.clientPluginChannels; - } - - @Override - public ServerPluginChannels getServerPluginChannels() - { - if (this.serverPluginChannels == null) - { - this.serverPluginChannels = new ServerPluginChannels(); - } - - return this.serverPluginChannels; - } - - @Override - public PermissionsManagerClient getClientPermissionManager() - { - return PermissionsManagerClient.getInstance(); - } - - @Override - public PermissionsManagerServer getServerPermissionManager() - { - return null; - } - - @SuppressWarnings("unused") - @Override - public void preBeginGame() - { - try - { - Class progressManagerClass = Class.forName("net.minecraftforge.fml.common.ProgressManager", false, Launch.classLoader); - return; // Disable my loading bar if Forge's is present - } - catch (ClassNotFoundException ex) - { - } - - new LoadingBar(); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IClientNetLoginHandler.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IClientNetLoginHandler.java deleted file mode 100644 index 48ba7442..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IClientNetLoginHandler.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.mumfrey.liteloader.client.ducks; - -import net.minecraft.network.NetworkManager; - -public interface IClientNetLoginHandler -{ - public abstract NetworkManager getNetMgr(); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IFramebuffer.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IFramebuffer.java deleted file mode 100644 index ee7690b7..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IFramebuffer.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.mumfrey.liteloader.client.ducks; - -public interface IFramebuffer -{ - public abstract IFramebuffer setDispatchRenderEvent(boolean dispatchRenderEvent); - - public abstract boolean isDispatchRenderEvent(); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/INamespacedRegistry.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/INamespacedRegistry.java deleted file mode 100644 index c0b24962..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/INamespacedRegistry.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.mumfrey.liteloader.client.ducks; - -public interface INamespacedRegistry -{ - public abstract IObjectIntIdentityMap getUnderlyingMap(); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IObjectIntIdentityMap.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IObjectIntIdentityMap.java deleted file mode 100644 index b468384c..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IObjectIntIdentityMap.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mumfrey.liteloader.client.ducks; - -import java.util.IdentityHashMap; -import java.util.List; - -public interface IObjectIntIdentityMap -{ - public abstract IdentityHashMap getIdentityMap(); - - public abstract List getObjectList(); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IRegistrySimple.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IRegistrySimple.java deleted file mode 100644 index 8567969d..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IRegistrySimple.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.mumfrey.liteloader.client.ducks; - -import java.util.Map; - -public interface IRegistrySimple -{ - public abstract Map getRegistryObjects(); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IReloadable.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IReloadable.java deleted file mode 100644 index 31b8acf0..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IReloadable.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.mumfrey.liteloader.client.ducks; - -import java.util.List; - -import net.minecraft.client.resources.IResourceManagerReloadListener; - -public interface IReloadable -{ - public abstract List getReloadListeners(); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IRenderManager.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IRenderManager.java deleted file mode 100644 index 03138cdb..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/IRenderManager.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mumfrey.liteloader.client.ducks; - -import java.util.Map; - -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.entity.Entity; - -public interface IRenderManager -{ - public abstract Map, Render> getRenderMap(); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/ITileEntityRendererDispatcher.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/ITileEntityRendererDispatcher.java deleted file mode 100644 index fcb1dc07..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/ducks/ITileEntityRendererDispatcher.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mumfrey.liteloader.client.ducks; - -import java.util.Map; - -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; - -public interface ITileEntityRendererDispatcher -{ - public abstract Map, TileEntitySpecialRenderer> getSpecialRenderMap(); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiCheckbox.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiCheckbox.java deleted file mode 100644 index 5ed29f11..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiCheckbox.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import static com.mumfrey.liteloader.gl.GL.*; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; - -import com.mumfrey.liteloader.client.api.LiteLoaderBrandingProvider; - -/** - * Super-simple implementation of a checkbox control - * - * @author Adam Mummery-Smith - */ -public class GuiCheckbox extends GuiButton -{ - public boolean checked; - - public GuiCheckbox(int controlId, int xPosition, int yPosition, String displayString) - { - super(controlId, xPosition, yPosition, Minecraft.getMinecraft().fontRendererObj.getStringWidth(displayString) + 16, 12, displayString); - } - - @Override - public void drawButton(Minecraft minecraft, int mouseX, int mouseY) - { - if (this.visible) - { - minecraft.getTextureManager().bindTexture(LiteLoaderBrandingProvider.ABOUT_TEXTURE); - glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - this.hovered = mouseX >= this.xPosition - && mouseY >= this.yPosition - && mouseX < this.xPosition + this.width - && mouseY < this.yPosition + this.height; - - this.drawTexturedModalRect(this.xPosition, this.yPosition, this.checked ? 134 : 122, 80, 12, 12); - this.mouseDragged(minecraft, mouseX, mouseY); - - int colour = 0xE0E0E0; - if (!this.enabled) - { - colour = 0xA0A0A0; - } - else if (this.hovered) - { - colour = 0xFFFFA0; - } - - this.drawString(minecraft.fontRendererObj, this.displayString, this.xPosition + 16, this.yPosition + 2, colour); - } - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiHoverLabel.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiHoverLabel.java deleted file mode 100644 index efc4da6e..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiHoverLabel.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import com.mumfrey.liteloader.client.api.LiteLoaderBrandingProvider; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; - -public class GuiHoverLabel extends GuiButton -{ - private FontRenderer fontRenderer; - private int colour; - private int hoverColour; - - public GuiHoverLabel(int id, int xPosition, int yPosition, FontRenderer fontRenderer, String displayText) - { - this(id, xPosition, yPosition, fontRenderer, displayText, LiteLoaderBrandingProvider.BRANDING_COLOUR); - } - - public GuiHoverLabel(int id, int xPosition, int yPosition, FontRenderer fontRenderer, String displayText, int colour) - { - this(id, xPosition, yPosition, fontRenderer, displayText, colour, 0xFFFFFFAA); - } - - public GuiHoverLabel(int id, int xPosition, int yPosition, FontRenderer fontRenderer, String displayText, int colour, int hoverColour) - { - super(id, xPosition, yPosition, GuiHoverLabel.getStringWidth(fontRenderer, displayText), 8, displayText); - - this.fontRenderer = fontRenderer; - this.colour = colour; - this.hoverColour = hoverColour; - } - - @Override - public void drawButton(Minecraft minecraft, int mouseX, int mouseY) - { - if (this.visible) - { - this.hovered = mouseX >= this.xPosition - && mouseY >= this.yPosition - && mouseX < this.xPosition + this.width - && mouseY < this.yPosition + this.height; - this.fontRenderer.drawString(this.displayString, this.xPosition, this.yPosition, this.hovered ? this.hoverColour : this.colour); - } - else - { - this.hovered = false; - } - } - - private static int getStringWidth(FontRenderer fontRenderer, String text) - { - return fontRenderer.getStringWidth(text); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiLiteLoaderPanel.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiLiteLoaderPanel.java deleted file mode 100644 index 87051adb..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiLiteLoaderPanel.java +++ /dev/null @@ -1,815 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import static com.mumfrey.liteloader.gl.GL.*; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.GuiMainMenu; -import net.minecraft.client.gui.GuiScreen; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.api.BrandingProvider; -import com.mumfrey.liteloader.api.LiteAPI; -import com.mumfrey.liteloader.api.ModInfoDecorator; -import com.mumfrey.liteloader.client.api.LiteLoaderBrandingProvider; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.core.LiteLoaderMods; -import com.mumfrey.liteloader.core.LiteLoaderVersion; -import com.mumfrey.liteloader.core.ModInfo; -import com.mumfrey.liteloader.core.api.LiteLoaderCoreAPI; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.modconfig.ConfigManager; -import com.mumfrey.liteloader.modconfig.ConfigPanel; -import com.mumfrey.liteloader.util.render.Icon; - -/** - * GUI screen which displays info about loaded mods and also allows them to be - * enabled and disabled. An instance of this class is created every time the - * main menu is displayed and is drawn as an overlay until the tab is clicked, - * at which point it becomes the active GUI screen and draws the parent main - * menu screen as its background to give the appearance of being overlaid on the - * main menu. - * - * @author Adam Mummery-Smith - */ -public class GuiLiteLoaderPanel extends GuiScreen -{ - static final int WHITE = 0xFFFFFFFF; - static final int OPAQUE = 0xFF000000; - static final int NOTIFICATION_TOOLTIP_FOREGROUND = 0xFFFFFF; - static final int NOTIFICATION_TOOLTIP_BACKGROUND = 0xB0000099; - static final int ERROR_TOOLTIP_FOREGROUND = 0xFF5555; - static final int ERROR_TOOLTIP_BACKGROUND = 0xB0330000; - static final int HEADER_HR_COLOUR = 0xFF999999; - static final int HEADER_TEXT_COLOUR = GuiLiteLoaderPanel.WHITE; - static final int HEADER_TEXT_COLOUR_SUB = 0xFFAAAAAA; - static final int TOOLTIP_FOREGROUND = 0xFFFFFF; - static final int TOOLTIP_FOREGROUND_SUB = 0xCCCCCC; - static final int TOOLTIP_BACKGROUND = 0xB0000000; - - static final int LEFT_EDGE = 80; - static final int MARGIN = 12; - static final int TAB_WIDTH = 20; - static final int TAB_HEIGHT = 40; - static final int TAB_TOP = 20; - static final int PANEL_TOP = 83; - static final int PANEL_BOTTOM = 26; - - private static final double TWEEN_RATE = 0.08; - - private static boolean displayErrorToolTip = true; - - /** - * Reference to the main menu which this screen is either overlaying or - * using as its background. - */ - private GuiScreen parentScreen; - - @SuppressWarnings("unused") - private final LoaderEnvironment environment; - - private final LoaderProperties properties; - - /** - * Tick number (update counter) used for tweening - */ - private long tickNumber; - - /** - * Last tick number, for tweening - */ - private double lastTick; - - /** - * Current tween percentage (0.0 -> 1.0) - */ - private double tweenAmount = 0.0; - - /** - * Since we don't get real mouse events we have to simulate them by tracking - * the mouse state. - */ - private boolean mouseDown, toggled, toggleable; - - /** - * Hover opacity for the tab - */ - private float tabOpacity = 0.0F; - - private boolean showTab = true; - - /** - * Text to display under the header - */ - private String activeModText, versionText; - - /** - * Configuration panel - */ - private GuiPanel currentPanel; - - private final GuiPanelMods modsPanel; - private final GuiPanelSettings settingsPanel; - - private int brandColour = LiteLoaderBrandingProvider.BRANDING_COLOUR; - - private ResourceLocation logoResource = LiteLoaderBrandingProvider.ABOUT_TEXTURE; - private Icon logoCoords = LiteLoaderBrandingProvider.LOGO_COORDS; - - private ResourceLocation iconResource = LiteLoaderBrandingProvider.ABOUT_TEXTURE; - private Icon iconCoords = LiteLoaderBrandingProvider.ICON_COORDS; - - private List modInfoDecorators = new ArrayList(); - - private boolean mouseOverLogo = false; - - private int startupErrorCount = 0, criticalErrorCount = 0; - - private String notification; - - private boolean isSnapshot; - - /** - * @param minecraft - * @param parentScreen - * @param mods - */ - public GuiLiteLoaderPanel(Minecraft minecraft, GuiScreen parentScreen, LiteLoaderMods mods, LoaderEnvironment environment, - LoaderProperties properties, ConfigManager configManager, boolean showTab) - { - this.mc = minecraft; - this.fontRendererObj = minecraft.fontRendererObj; - this.parentScreen = parentScreen; - this.showTab = showTab; - - this.environment = environment; - this.properties = properties; - - this.toggleable = true; - - this.versionText = I18n.format("gui.about.versiontext", LiteLoader.getVersion()); - this.activeModText = I18n.format("gui.about.modsloaded", mods.getLoadedMods().size()); - - this.initBranding(); - - this.currentPanel = this.modsPanel = new GuiPanelMods(this, minecraft, mods, environment, configManager, - this.brandColour, this.modInfoDecorators); - this.settingsPanel = new GuiPanelSettings(this, minecraft); - - this.startupErrorCount = mods.getStartupErrorCount(); - this.criticalErrorCount = mods.getCriticalErrorCount(); - - String branding = LiteLoader.getBranding(); - if (branding != null && branding.contains("SNAPSHOT")) - { - this.isSnapshot = true; - this.versionText = "\247c" + branding; - } - } - - /** - * - */ - private void initBranding() - { - LiteAPI logoProvider = null; - - int brandingColourProviderPriority = Integer.MIN_VALUE; - int logoProviderPriority = Integer.MIN_VALUE; - int iconProviderPriority = Integer.MIN_VALUE; - - for (LiteAPI api : LiteLoader.getAPIs()) - { - BrandingProvider brandingProvider = LiteLoader.getCustomisationProvider(api, BrandingProvider.class); - if (brandingProvider != null) - { - if (brandingProvider.getBrandingColour() != 0 && brandingProvider.getPriority() > brandingColourProviderPriority) - { - brandingColourProviderPriority = brandingProvider.getPriority(); - this.brandColour = GuiLiteLoaderPanel.OPAQUE | brandingProvider.getBrandingColour(); - } - - ResourceLocation logoResource = brandingProvider.getLogoResource(); - Icon logoCoords = brandingProvider.getLogoCoords(); - if (logoResource != null && logoCoords != null && brandingProvider.getPriority() > logoProviderPriority) - { - logoProvider = api; - logoProviderPriority = brandingProvider.getPriority(); - this.logoResource = logoResource; - this.logoCoords = logoCoords; - } - - ResourceLocation iconResource = brandingProvider.getIconResource(); - Icon iconCoords = brandingProvider.getIconCoords(); - if (iconResource != null && iconCoords != null && brandingProvider.getPriority() > iconProviderPriority) - { - iconProviderPriority = brandingProvider.getPriority(); - this.iconResource = iconResource; - this.iconCoords = iconCoords; - } - } - - ModInfoDecorator modInfoDecorator = LiteLoader.getCustomisationProvider(api, ModInfoDecorator.class); - if (modInfoDecorator != null) - { - this.modInfoDecorators.add(modInfoDecorator); - } - } - - if (logoProvider != null && !LiteLoaderCoreAPI.class.isAssignableFrom(logoProvider.getClass())) - { - this.versionText = I18n.format("gui.about.poweredbyversion", logoProvider.getVersion(), LiteLoader.getVersion()); - } - } - - /** - * Get the computed branding colour - */ - public int getBrandColour() - { - return this.brandColour; - } - - /** - * Release references prior to being disposed - */ - public void release() - { - this.parentScreen = null; - } - - /** - * Get the parent menu - */ - public GuiScreen getScreen() - { - return this.parentScreen; - } - - /** - * Return true if the panel is not fully closed (tweening or open) - */ - public boolean isOpen() - { - return this.tweenAmount > 0.0; - } - - public void setToggleable(boolean toggleable) - { - this.toggleable = toggleable; - } - - public void setNotification(String notification) - { - this.notification = notification; - } - - /* (non-Javadoc) - * @see net.minecraft.client.gui.GuiScreen#initGui() - */ - @SuppressWarnings("unchecked") - @Override - public void initGui() - { - // Hide the tooltip once the user opens the panel - GuiLiteLoaderPanel.displayErrorToolTip = false; - - this.currentPanel.setSize(this.width - LEFT_EDGE, this.height); - - this.buttonList.add(new GuiHoverLabel(2, LEFT_EDGE + MARGIN, this.height - PANEL_BOTTOM + 9, this.fontRendererObj, - I18n.format("gui.about.taboptions"), this.brandColour)); - - if (LiteLoaderVersion.getUpdateSite().canCheckForUpdate() && this.mc.theWorld == null && !this.isSnapshot) - { - this.buttonList.add(new GuiHoverLabel(3, LEFT_EDGE + MARGIN + 38 + this.fontRendererObj.getStringWidth(this.versionText) + 6, 50, - this.fontRendererObj, I18n.format("gui.about.checkupdates"), this.brandColour)); - } - - Keyboard.enableRepeatEvents(true); - } - - @Override - public void onGuiClosed() - { - Keyboard.enableRepeatEvents(false); - } - - /* (non-Javadoc) - * @see net.minecraft.client.gui.GuiScreen - * #setWorldAndResolution(net.minecraft.client.Minecraft, int, int) - */ - @Override - public void setWorldAndResolution(Minecraft minecraft, int width, int height) - { - if (this.mc.currentScreen == this) - { - // Set res in parent screen if we are the active GUI - this.parentScreen.setWorldAndResolution(minecraft, width, height); - } - - super.setWorldAndResolution(minecraft, width, height); - } - - /* (non-Javadoc) - * @see net.minecraft.client.gui.GuiScreen#updateScreen() - */ - @Override - public void updateScreen() - { - this.currentPanel.onTick(); - - this.tickNumber++; - - if (this.mc.currentScreen == this) - { - this.mc.currentScreen = this.parentScreen; - this.parentScreen.updateScreen(); - this.mc.currentScreen = this; - } - - if (this.toggled && this.toggleable) - { - this.onToggled(); - } - } - - /* (non-Javadoc) - * @see net.minecraft.client.gui.GuiScreen#drawScreen(int, int, float) - */ - @Override - public void drawScreen(int mouseX, int mouseY, float partialTicks) - { - this.drawScreen(mouseX, mouseY, partialTicks, false); - } - - /** - * @param mouseX - * @param mouseY - * @param partialTicks - * @param alwaysExpandTab - */ - public void drawScreen(int mouseX, int mouseY, float partialTicks, boolean alwaysExpandTab) - { - boolean active = this.mc.currentScreen == this; - - if (active) - { - // Draw the parent screen as our background if we are the active screen - glClear(GL_DEPTH_BUFFER_BIT); - this.parentScreen.drawScreen(-10, -10, partialTicks); - glClear(GL_DEPTH_BUFFER_BIT); - } - else - { - // If this is not the active screen, copy the width and height from the parent GUI - this.width = this.parentScreen.width; - this.height = this.parentScreen.height; - } - - // Calculate the current tween position - float xOffset = (this.width - LEFT_EDGE) * this.calcTween(partialTicks, active) + 16.0F + (this.tabOpacity * -32.0F); - int offsetMouseX = mouseX - (int)xOffset; - - // Handle mouse stuff here since we won't get mouse events when not the active GUI - boolean mouseOverTab = this.showTab && (offsetMouseX > LEFT_EDGE - TAB_WIDTH - && offsetMouseX < LEFT_EDGE - && mouseY > TAB_TOP - && mouseY < TAB_TOP + TAB_HEIGHT); - this.handleMouseClick(offsetMouseX, mouseY, partialTicks, active, mouseOverTab); - - // Calculate the tab opacity, not framerate adjusted because we don't really care - this.tabOpacity = mouseOverTab || alwaysExpandTab || this.startupErrorCount > 0 || this.notification != null - || this.isOpen() ? 0.5F : Math.max(0.0F, this.tabOpacity - partialTicks * 0.1F); - - // Draw the panel contents - this.drawPanel(offsetMouseX, mouseY, partialTicks, active, xOffset); - this.drawTooltips(mouseX, mouseY, partialTicks, active, xOffset, mouseOverTab); - } - - /** - * @param mouseX - * @param mouseY - * @param partialTicks - * @param active - * @param xOffset - */ - private void drawPanel(int mouseX, int mouseY, float partialTicks, boolean active, float xOffset) - { - this.mouseOverLogo = false; - - glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO); - - glPushMatrix(); - glTranslatef(xOffset, 0.0F, 0.0F); - - // Draw the background and left edge - drawRect(LEFT_EDGE, 0, this.width, this.height, GuiLiteLoaderPanel.TOOLTIP_BACKGROUND); - - if (this.showTab) - { - drawRect(LEFT_EDGE, 0, LEFT_EDGE + 1, TAB_TOP, GuiLiteLoaderPanel.WHITE); - drawRect(LEFT_EDGE, TAB_TOP + TAB_HEIGHT, LEFT_EDGE + 1, this.height, GuiLiteLoaderPanel.WHITE); - - this.mc.getTextureManager().bindTexture(LiteLoaderBrandingProvider.ABOUT_TEXTURE); - glDrawTexturedRect(LEFT_EDGE - TAB_WIDTH, TAB_TOP, TAB_WIDTH + 1, TAB_HEIGHT, 80, 80, 122, 160, 0.5F + this.tabOpacity); - if (this.startupErrorCount > 0) - { - glDrawTexturedRect(LEFT_EDGE - TAB_WIDTH + 7, TAB_TOP + 2, 12, 12, 134, 92, 134 + 12, 92 + 12, 0.5F + this.tabOpacity); - } - else if (this.notification != null) - { - glDrawTexturedRect(LEFT_EDGE - TAB_WIDTH + 7, TAB_TOP + 2, 12, 12, 134 + 12, 92, 134 + 24, 92 + 12, 0.5F + this.tabOpacity); - } - } - else - { - drawRect(LEFT_EDGE, 0, LEFT_EDGE + 1, this.height, GuiLiteLoaderPanel.WHITE); - } - - // Only draw the panel contents if we are actually open - if (this.isOpen()) - { - if (this.currentPanel.isCloseRequested()) - { - this.closeCurrentPanel(); - } - - this.drawCurrentPanel(mouseX, mouseY, partialTicks); - - if (!this.currentPanel.stealFocus()) - { - // Draw other controls inside the transform so that they slide properly - super.drawScreen(mouseX, mouseY, partialTicks); - } - } - else - { - this.closeCurrentPanel(); - } - - glPopMatrix(); - } - - /** - * @param mouseX - * @param mouseY - * @param partialTicks - */ - private void drawCurrentPanel(int mouseX, int mouseY, float partialTicks) - { - glPushMatrix(); - glTranslatef(LEFT_EDGE, 0, 0); - - this.currentPanel.draw(mouseX - LEFT_EDGE, mouseY, partialTicks); - - glPopMatrix(); - } - - /** - * @param mouseX - * @param mouseY - * @param partialTicks - */ - protected boolean drawInfoPanel(int mouseX, int mouseY, float partialTicks, int left, int bottom) - { - int right = this.width - MARGIN - LEFT_EDGE + left; - left += MARGIN; - - // Draw the header pieces - this.mc.getTextureManager().bindTexture(this.logoResource); - glDrawTexturedRect(left, MARGIN, this.logoCoords, 1.0F); - this.mc.getTextureManager().bindTexture(this.iconResource); - glDrawTexturedRect(right - this.iconCoords.getIconWidth(), MARGIN, this.iconCoords, 1.0F); - - // Draw header text - this.fontRendererObj.drawString(this.versionText, left + 38, 50, GuiLiteLoaderPanel.HEADER_TEXT_COLOUR); - this.fontRendererObj.drawString(this.activeModText, left + 38, 60, GuiLiteLoaderPanel.HEADER_TEXT_COLOUR_SUB); - - // Draw top and bottom horizontal rules - drawRect(left, 80, right, 81, GuiLiteLoaderPanel.HEADER_HR_COLOUR); - drawRect(left, this.height - bottom + 2, right, this.height - bottom + 3, GuiLiteLoaderPanel.HEADER_HR_COLOUR); - - this.mouseOverLogo = (mouseY > MARGIN && mouseY < MARGIN + this.logoCoords.getIconHeight() - && mouseX > left && mouseX < left + this.logoCoords.getIconWidth()); - return this.mouseOverLogo; - } - - private void drawTooltips(int mouseX, int mouseY, float partialTicks, boolean active, float xOffset, boolean mouseOverTab) - { - boolean annoyingTip = this.startupErrorCount > 0 || this.notification != null; - - if (mouseOverTab && this.tweenAmount < 0.01) - { - GuiLiteLoaderPanel.drawTooltip(this.fontRendererObj, LiteLoader.getVersionDisplayString(), mouseX, mouseY, this.width, this.height, - GuiLiteLoaderPanel.TOOLTIP_FOREGROUND, GuiLiteLoaderPanel.TOOLTIP_BACKGROUND); - GuiLiteLoaderPanel.drawTooltip(this.fontRendererObj, this.activeModText, mouseX, mouseY + 13, this.width, this.height, - GuiLiteLoaderPanel.TOOLTIP_FOREGROUND_SUB, GuiLiteLoaderPanel.TOOLTIP_BACKGROUND); - - if (annoyingTip) - { - this.drawNotificationTooltip(mouseX, mouseY - 13); - } - } - else if (GuiLiteLoaderPanel.displayErrorToolTip && annoyingTip && !active && this.parentScreen instanceof GuiMainMenu) - { - this.drawNotificationTooltip((int)xOffset + LEFT_EDGE - 12, TAB_TOP + 2); - } - } - - private void drawNotificationTooltip(int left, int top) - { - if (this.startupErrorCount > 0) - { - GuiLiteLoaderPanel.drawTooltip(this.fontRendererObj, I18n.format("gui.error.tooltip", this.startupErrorCount, this.criticalErrorCount), - left, top, this.width, this.height, GuiLiteLoaderPanel.ERROR_TOOLTIP_FOREGROUND, GuiLiteLoaderPanel.ERROR_TOOLTIP_BACKGROUND); - } - else if (this.notification != null) - { - GuiLiteLoaderPanel.drawTooltip(this.fontRendererObj, this.notification, left, top, this.width, this.height, - GuiLiteLoaderPanel.NOTIFICATION_TOOLTIP_FOREGROUND, GuiLiteLoaderPanel.NOTIFICATION_TOOLTIP_BACKGROUND); - } - } - - /* (non-Javadoc) - * @see net.minecraft.client.gui.GuiScreen - * #actionPerformed(net.minecraft.client.gui.GuiButton) - */ - @Override - protected void actionPerformed(GuiButton button) - { - if (button.id == 2) - { - this.setCurrentPanel(this.settingsPanel); - } - - if (button.id == 3) - { - this.setCurrentPanel(new GuiPanelUpdateCheck(this, this.mc, LiteLoaderVersion.getUpdateSite(), "LiteLoader", this.properties)); - } - } - - /* (non-Javadoc) - * @see net.minecraft.client.gui.GuiScreen#keyTyped(char, int) - */ - @Override - protected void keyTyped(char keyChar, int keyCode) - { - this.currentPanel.keyPressed(keyChar, keyCode); - } - - /** - * - */ - void showLogPanel() - { - this.setCurrentPanel(new GuiPanelLiteLoaderLog(this.mc, this)); - } - - /** - * - */ - void showAboutPanel() - { - this.setCurrentPanel(new GuiPanelAbout(this.mc, this)); - } - - public void showErrorPanel(ModInfo mod) - { - this.setCurrentPanel(new GuiPanelError(this.mc, this, mod)); - } - - /* (non-Javadoc) - * @see net.minecraft.client.gui.GuiScreen#mouseClicked(int, int, int) - */ - @Override - protected void mouseClicked(int mouseX, int mouseY, int button) throws IOException - { - this.currentPanel.mousePressed(mouseX - LEFT_EDGE, mouseY, button); - - if (button == 0 && this.mouseOverLogo && !this.currentPanel.stealFocus()) - { - this.showAboutPanel(); - } - - if (!this.currentPanel.stealFocus()) - { - super.mouseClicked(mouseX, mouseY, button); - } - } - - /* (non-Javadoc) - * @see net.minecraft.client.gui.GuiScreen#mouseReleased(int, int, int) - */ - @Override - protected void mouseReleased(int mouseX, int mouseY, int button) - { - if (button == -1) - { - this.currentPanel.mouseMoved(mouseX - LEFT_EDGE, mouseY); - } - else - { - this.currentPanel.mouseReleased(mouseX - LEFT_EDGE, mouseY, button); - } - - if (!this.currentPanel.stealFocus()) - { - super.mouseReleased(mouseX, mouseY, button); - } - } - - /* (non-Javadoc) - * @see net.minecraft.client.gui.GuiScreen#handleMouseInput() - */ - @Override - public void handleMouseInput() throws IOException - { - int mouseWheelDelta = Mouse.getEventDWheel(); - if (mouseWheelDelta != 0) - { - this.currentPanel.mouseWheelScrolled(mouseWheelDelta); - } - - super.handleMouseInput(); - } - - /** - * @param mouseX - * @param active - * @param mouseOverTab - */ - public void handleMouseClick(int mouseX, int mouseY, float partialTicks, boolean active, boolean mouseOverTab) - { - boolean mouseDown = Mouse.isButtonDown(0); - if (((active && mouseX < LEFT_EDGE && this.tweenAmount > 0.75) || mouseOverTab) && !this.mouseDown && mouseDown) - { - this.mouseDown = true; - this.toggled = true; - } - else if (this.mouseDown && !mouseDown) - { - this.mouseDown = false; - } - } - - /** - * @param partialTicks - * @param active - */ - private float calcTween(float partialTicks, boolean active) - { - double tickValue = this.tickNumber + partialTicks; - - if (active && this.tweenAmount < 1.0) - { - this.tweenAmount = Math.min(1.0, this.tweenAmount + ((tickValue - this.lastTick) * TWEEN_RATE)); - } - else if (!active && this.isOpen()) - { - this.tweenAmount = Math.max(0.0, this.tweenAmount - ((tickValue - this.lastTick) * TWEEN_RATE)); - } - - this.lastTick = tickValue; - return 1.0F - (float)Math.sin(this.tweenAmount * 0.5 * Math.PI); - } - - /** - * Called when the tab is clicked - */ - void onToggled() - { - this.toggled = false; - this.mc.displayGuiScreen(this.mc.currentScreen == this ? this.parentScreen : this); - } - - /** - * Callback for the "config" button, display the config panel for the - * currently selected mod. - */ - void openConfigPanel(ConfigPanel panel, LiteMod mod) - { - if (panel != null) - { - this.setCurrentPanel(new GuiPanelConfigContainer(this.mc, panel, mod)); - } - } - - /** - * @param newPanel - */ - private void setCurrentPanel(GuiPanel newPanel) - { - this.closeCurrentPanel(); - - this.currentPanel = newPanel; - this.currentPanel.setSize(this.width - LEFT_EDGE, this.height); - this.currentPanel.onShown(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.modconfig.ConfigPanelHost#close() - */ - private void closeCurrentPanel() - { - this.currentPanel.onHidden(); - this.currentPanel = this.modsPanel; - this.modsPanel.setSize(this.width - LEFT_EDGE, this.height); - } - - /** - * Draw a tooltip at the specified location and clip to screenWidth and - * screenHeight - * - * @param fontRenderer - * @param tooltipText - * @param mouseX - * @param mouseY - * @param screenWidth - * @param screenHeight - * @param colour - * @param backgroundColour - */ - public static void drawTooltip(FontRenderer fontRenderer, String tooltipText, int mouseX, int mouseY, int screenWidth, int screenHeight, - int colour, int backgroundColour) - { - int textSize = fontRenderer.getStringWidth(tooltipText); - mouseX = Math.max(0, Math.min(screenWidth - 4, mouseX - 4)); - mouseY = Math.max(0, Math.min(screenHeight - 16, mouseY)); - drawRect(mouseX - textSize - 2, mouseY, mouseX + 2, mouseY + 12, backgroundColour); - fontRenderer.drawStringWithShadow(tooltipText, mouseX - textSize, mouseY + 2, colour); - } - - - /** - * @param x - * @param y - * @param width - * @param height - * @param u - * @param v - * @param u2 - * @param v2 - * @param alpha - */ - static void glDrawTexturedRect(int x, int y, int width, int height, int u, int v, int u2, int v2, float alpha) - { - float texMapScale = 0.00390625F; // 256px - glDrawTexturedRect(x, y, width, height, u * texMapScale, v * texMapScale, u2 * texMapScale, v2 * texMapScale, alpha); - } - - /** - * @param x - * @param y - * @param width - * @param height - * @param u - * @param v - * @param u2 - * @param v2 - * @param alpha - */ - static void glDrawTexturedRect(int x, int y, int width, int height, float u, float v, float u2, float v2, float alpha) - { - glDisableLighting(); - glEnableBlend(); - glAlphaFunc(GL_GREATER, 0.0F); - glEnableTexture2D(); - glColor4f(1.0F, 1.0F, 1.0F, alpha); - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldRenderer = tessellator.getWorldRenderer(); - worldRenderer.startDrawingQuads(); - worldRenderer.addVertexWithUV(x + 0, y + height, 0, u , v2); - worldRenderer.addVertexWithUV(x + width, y + height, 0, u2, v2); - worldRenderer.addVertexWithUV(x + width, y + 0, 0, u2, v ); - worldRenderer.addVertexWithUV(x + 0, y + 0, 0, u , v ); - tessellator.draw(); - - glDisableBlend(); - glAlphaFunc(GL_GREATER, 0.01F); - } - - /** - * @param x - * @param y - * @param icon - * @param alpha - */ - static void glDrawTexturedRect(int x, int y, Icon icon, float alpha) - { - glDrawTexturedRect(x, y, icon.getIconWidth(), icon.getIconHeight(), icon.getMinU(), icon.getMinV(), icon.getMaxU(), icon.getMaxV(), alpha); - } -} \ No newline at end of file diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanel.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanel.java deleted file mode 100644 index 219fcd13..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanel.java +++ /dev/null @@ -1,209 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import static com.mumfrey.liteloader.gl.GL.*; - -import java.util.LinkedList; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiButton; - -import com.mumfrey.liteloader.client.api.LiteLoaderBrandingProvider; - -/** - * Base class for panels - * - * @author Adam Mummery-Smith - */ -public abstract class GuiPanel extends Gui -{ - protected static final int TOP = 26; - protected static final int BOTTOM = 40; - protected static final int MARGIN = 12; - - /** - * Minecraft - */ - protected Minecraft mc; - - /** - * Buttons - */ - protected List controls = new LinkedList(); - - /** - * Current available width - */ - protected int width = 0; - - /** - * Current available height - */ - protected int height = 0; - - /** - * Current inner pane width (width - margins) - */ - protected int innerWidth = 0; - - /** - * Current inner pane visible height (height - chrome) - */ - protected int innerHeight = 0; - - /** - * Panel Y position (for scroll) - */ - protected int innerTop = TOP; - - /** - * True if the client wants to close the panel - */ - private boolean closeRequested; - - /** - * @param minecraft - */ - public GuiPanel(Minecraft minecraft) - { - this.mc = minecraft; - } - - boolean stealFocus() - { - return true; - } - - /** - * Called by the containing screen to set the panel size - * - * @param width - * @param height - */ - void setSize(int width, int height) - { - this.controls.clear(); - - this.width = width; - this.height = height; - - this.innerHeight = this.height - TOP - BOTTOM; - this.innerWidth = this.width - (MARGIN * 2) - 6; - } - - /** - * @param mouseX - * @param mouseY - * @param partialTicks - */ - void draw(int mouseX, int mouseY, float partialTicks) - { - for (GuiButton control : this.controls) - control.drawButton(this.mc, mouseX, mouseY); - } - - /** - * - */ - public void close() - { - this.closeRequested = true; - } - - /** - * Get whether the client wants to close the panel - */ - boolean isCloseRequested() - { - return this.closeRequested; - } - - /** - * @param mouseX - * @param mouseY - * @param mouseButton - */ - void mousePressed(int mouseX, int mouseY, int mouseButton) - { - if (mouseButton == 0) - { - for (GuiButton control : this.controls) - { - if (control.mousePressed(this.mc, mouseX, mouseY)) - { - control.playPressSound(this.mc.getSoundHandler()); - this.actionPerformed(control); - } - } - } - } - - /** - * @param mouseX - * @param mouseY - */ - boolean mouseOverPanel(int mouseX, int mouseY) - { - return mouseX > MARGIN && mouseX <= this.width - MARGIN && mouseY > TOP && mouseY <= this.height - BOTTOM; - } - - /** - * Called every tick - */ - abstract void onTick(); - - /** - * Called after the screen is hidden - */ - abstract void onHidden(); - - /** - * Called when the panel is shown - */ - abstract void onShown(); - - /** - * @param keyChar - * @param keyCode - */ - abstract void keyPressed(char keyChar, int keyCode); - - /** - * @param mouseX - * @param mouseY - */ - abstract void mouseMoved(int mouseX, int mouseY); - - /** - * @param mouseX - * @param mouseY - * @param mouseButton - */ - abstract void mouseReleased(int mouseX, int mouseY, int mouseButton); - - /** - * @param mouseWheelDelta - */ - abstract void mouseWheelScrolled(int mouseWheelDelta); - - /** - * @param control - */ - abstract void actionPerformed(GuiButton control); - - /** - * @param x - * @param y - * @param frame - */ - protected void drawThrobber(int x, int y, int frame) - { - glEnableBlend(); - glAlphaFunc(GL_GREATER, 0.0F); - this.mc.getTextureManager().bindTexture(LiteLoaderBrandingProvider.ABOUT_TEXTURE); - this.drawTexturedModalRect(x, y, (frame % 4) * 16, 171 + (((frame / 4) % 3) * 16), 16, 16); - glAlphaFunc(GL_GREATER, 0.1F); - glDisableBlend(); - } -} \ No newline at end of file diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelAbout.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelAbout.java deleted file mode 100644 index 1be79089..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelAbout.java +++ /dev/null @@ -1,251 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.input.Keyboard; - -import com.mumfrey.liteloader.api.BrandingProvider; -import com.mumfrey.liteloader.api.LiteAPI; -import com.mumfrey.liteloader.client.api.LiteLoaderBrandingProvider; -import com.mumfrey.liteloader.client.util.render.IconAbsolute; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.util.SortableValue; -import com.mumfrey.liteloader.util.render.Icon; - -/** - * "About LiteLoader" panel which docks in the mod info screen and lists - * information about the installed APIs. - * - * @author Adam Mummery-Smith - */ -class GuiPanelAbout extends GuiPanel implements ScrollPanelContent -{ - public static final IconAbsolute apiIconCoords = new IconAbsolute(LiteLoaderBrandingProvider.ABOUT_TEXTURE, "api_icon", - 32, 32, 192, 144, 256, 208); - - private static final int ROW_HEIGHT = 40; - - private static final URI MCP_URI = URI.create("http://mcp.ocean-labs.de/"); - - private GuiLiteLoaderPanel parent; - - private GuiScrollPanel scrollPane; - - private List brandings = new ArrayList(); - - private boolean mouseOverLogo; - - public GuiPanelAbout(Minecraft minecraft, GuiLiteLoaderPanel parent) - { - super(minecraft); - this.parent = parent; - this.scrollPane = new GuiScrollPanel(minecraft, this, MARGIN, 90, 100, 100); - - this.sortBrandingProviders(); - - this.scrollPane.addControl(new GuiHoverLabel(-2, 38, 22 + this.brandings.size() * GuiPanelAbout.ROW_HEIGHT, this.mc.fontRendererObj, - "\247n" + MCP_URI.toString(), this.parent.getBrandColour())); - } - - /** - * - */ - private void sortBrandingProviders() - { - Set> sortedBrandingProviders = new TreeSet>(); - - for (LiteAPI api : LiteLoader.getAPIs()) - { - BrandingProvider brandingProvider = LiteLoader.getCustomisationProvider(api, BrandingProvider.class); - if (brandingProvider != null) - { - sortedBrandingProviders.add(new SortableValue(Integer.MAX_VALUE - brandingProvider.getPriority(), 0, - brandingProvider)); - } - } - - int brandingIndex = 0; - - for (SortableValue sortedBrandingProvider : sortedBrandingProviders) - { - BrandingProvider brandingProvider = sortedBrandingProvider.getValue(); - - this.brandings.add(brandingProvider); - URI homepage = brandingProvider.getHomepage(); - if (homepage != null) - { - this.scrollPane.addControl(new GuiHoverLabel(brandingIndex, 38, 22 + brandingIndex * GuiPanelAbout.ROW_HEIGHT, - this.mc.fontRendererObj, "\247n" + homepage, this.parent.getBrandColour())); - } - - brandingIndex++; - } - } - - @Override - void setSize(int width, int height) - { - super.setSize(width, height); - - this.scrollPane.setSizeAndPosition(MARGIN, 86, this.width - MARGIN * 2, this.height - 126); - this.controls.add(new GuiButton(-1, this.width - 99 - MARGIN, this.height - BOTTOM + 9, 100, 20, I18n.format("gui.done"))); - this.controls.add(new GuiButton(-3, MARGIN, this.height - BOTTOM + 9, 100, 20, I18n.format("gui.log.button"))); - } - - @Override - void draw(int mouseX, int mouseY, float partialTicks) - { - this.mouseOverLogo = this.parent.drawInfoPanel(mouseX, mouseY, partialTicks, 0, 38); - - this.scrollPane.draw(mouseX, mouseY, partialTicks); - - super.draw(mouseX, mouseY, partialTicks); - } - - @Override - public int getScrollPanelContentHeight(GuiScrollPanel source) - { - return 64 + this.brandings.size() * GuiPanelAbout.ROW_HEIGHT; - } - - @Override - public void drawScrollPanelContent(GuiScrollPanel source, int mouseX, int mouseY, float partialTicks, int scrollAmount, int visibleHeight) - { - FontRenderer fontRenderer = this.mc.fontRendererObj; - int textColour = 0xFFAAAAAA; - - int yPos = 0; - - for (BrandingProvider branding : this.brandings) - { - ResourceLocation twitterAvatarResource = branding.getTwitterAvatarResource(); - Icon twitterAvatarCoords = branding.getTwitterAvatarCoords(); - - this.mc.getTextureManager().bindTexture(twitterAvatarResource != null ? twitterAvatarResource : LiteLoaderBrandingProvider.ABOUT_TEXTURE); - GuiLiteLoaderPanel.glDrawTexturedRect(0, yPos, twitterAvatarCoords != null ? twitterAvatarCoords : GuiPanelAbout.apiIconCoords, 1.0F); - - fontRenderer.drawString(branding.getDisplayName(), 38, yPos, 0xFFFFFFFF); - fontRenderer.drawString(branding.getCopyrightText(), 38, yPos + 11, textColour); - - yPos += GuiPanelAbout.ROW_HEIGHT; - } - - fontRenderer.drawString("Created using Mod Coder Pack", 38, yPos, 0xFFFFFFFF); - fontRenderer.drawString("MCP is (c) Copyright by the MCP Team", 38, yPos + 11, textColour); - - yPos += GuiPanelAbout.ROW_HEIGHT; - - fontRenderer.drawString("Minecraft is Copyright (c) Mojang AB", 38, yPos, textColour); - fontRenderer.drawString("All rights reserved.", 38, yPos + 11, textColour); - } - - @Override - public void scrollPanelMousePressed(GuiScrollPanel source, int mouseX, int mouseY, int mouseButton) - { - int index = mouseY / GuiPanelAbout.ROW_HEIGHT; - int yOffset = mouseY - (GuiPanelAbout.ROW_HEIGHT * index); - - if (mouseButton == 0 && mouseX < 33 && index >= 0 && index < this.brandings.size() && yOffset < 33) - { - String twitterUserName = this.brandings.get(index).getTwitterUserName(); - if (twitterUserName != null) - { - URI twitterURI = URI.create("https://www.twitter.com/" + twitterUserName); - this.openURI(twitterURI); - } - } - } - - /** - * @param control - */ - @Override - void actionPerformed(GuiButton control) - { - if (control.id == -1) this.close(); - if (control.id == -2) this.openURI(MCP_URI); - if (control.id == -3) this.parent.showLogPanel(); - } - - @Override - public void scrollPanelActionPerformed(GuiScrollPanel source, GuiButton control) - { - if (control.id >= 0 && control.id < this.brandings.size()) - { - URI homepage = this.brandings.get(control.id).getHomepage(); - if (homepage != null) this.openURI(homepage); - } - } - - private void openURI(URI uri) - { - try - { - Class desktop = Class.forName("java.awt.Desktop"); - Object instance = desktop.getMethod("getDesktop").invoke(null); - desktop.getMethod("browse", URI.class).invoke(instance, uri); - } - catch (Throwable th) {} - } - - @Override - void onTick() - { - } - - @Override - void onHidden() - { - } - - @Override - void onShown() - { - } - - @Override - void keyPressed(char keyChar, int keyCode) - { - if (keyCode == Keyboard.KEY_ESCAPE) this.close(); - } - - @Override - void mousePressed(int mouseX, int mouseY, int mouseButton) - { - this.scrollPane.mousePressed(mouseX, mouseY, mouseButton); - - if (mouseButton == 0 && this.mouseOverLogo) - { - this.close(); - } - - super.mousePressed(mouseX, mouseY, mouseButton); - } - - @Override - void mouseMoved(int mouseX, int mouseY) - { - } - - @Override - void mouseReleased(int mouseX, int mouseY, int mouseButton) - { - this.scrollPane.mouseReleased(mouseX, mouseY, mouseButton); - } - - @Override - void mouseWheelScrolled(int mouseWheelDelta) - { - this.scrollPane.mouseWheelScrolled(mouseWheelDelta); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelConfigContainer.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelConfigContainer.java deleted file mode 100644 index dbb3c6ab..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelConfigContainer.java +++ /dev/null @@ -1,274 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import static com.mumfrey.liteloader.gl.GL.*; -import static com.mumfrey.liteloader.gl.GLClippingPlanes.*; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.resources.I18n; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.modconfig.ConfigPanel; -import com.mumfrey.liteloader.modconfig.ConfigPanelHost; - -/** - * Config panel container, this handles drawing the configuration panel chrome - * and also hosts the configuration panels themselves to support scrolling and - * stuff. - * - * @author Adam Mummery-Smith - */ -class GuiPanelConfigContainer extends GuiPanel implements ConfigPanelHost -{ - /** - * Panel we are hosting - */ - private ConfigPanel panel; - - /** - * Mod being configured, the panel may want a reference to it - */ - private LiteMod mod; - - /** - * Scroll bar for the panel - */ - GuiSimpleScrollBar scrollBar = new GuiSimpleScrollBar(); - - /** - * Panel's internal height (for scrolling) - */ - private int totalHeight = -1; - - /** - * @param minecraft - * @param panel - * @param mod - */ - GuiPanelConfigContainer(Minecraft minecraft, ConfigPanel panel, LiteMod mod) - { - super(minecraft); - - this.panel = panel; - this.mod = mod; - } - - /** - * - */ - String getPanelTitle() - { - String panelTitle = this.panel.getPanelTitle(); - return panelTitle != null ? panelTitle : I18n.format("gui.settings.title", this.mod.getName()); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.modconfig.ConfigPanelHost#getMod() - */ - @SuppressWarnings("unchecked") - @Override - public TModClass getMod() - { - return (TModClass)this.mod; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.modconfig.ConfigPanelHost#getWidth() - */ - @Override - public int getWidth() - { - return this.innerWidth; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.modconfig.ConfigPanelHost#getHeight() - */ - @Override - public int getHeight() - { - return this.innerHeight; - } - - /** - * Callback from parent screen when window is resized - * - * @param width - * @param height - */ - @Override - void setSize(int width, int height) - { - super.setSize(width, height); - - this.panel.onPanelResize(this); - this.controls.add(new GuiButton(0, this.width - 99 - MARGIN, this.height - BOTTOM + 9, 100, 20, I18n.format("gui.saveandclose"))); - } - - /** - * Callback from parent screen when panel is displayed - */ - @Override - void onShown() - { - try - { - this.panel.onPanelShown(this); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - /** - * Callback from parent screen when panel is hidden - */ - @Override - void onHidden() - { - try - { - this.panel.onPanelHidden(); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - /** - * Callback from parent screen every tick - */ - @Override - void onTick() - { - this.panel.onTick(this); - } - - /** - * Draw the panel and chrome - * - * @param mouseX - * @param mouseY - * @param partialTicks - */ - @Override - void draw(int mouseX, int mouseY, float partialTicks) - { - // Scroll position - this.innerTop = TOP - this.scrollBar.getValue(); - - // Draw panel title - this.mc.fontRendererObj.drawString(this.getPanelTitle(), MARGIN, TOP - 14, 0xFFFFFFFF); - - // Draw top and bottom horizontal bars - drawRect(MARGIN, TOP - 4, this.width - MARGIN, TOP - 3, 0xFF999999); - drawRect(MARGIN, this.height - BOTTOM + 2, this.width - MARGIN, this.height - BOTTOM + 3, 0xFF999999); - - // Clip rect - glEnableClipping(MARGIN, this.width - MARGIN - 6, TOP, this.height - BOTTOM); - - // Offset by scroll - glPushMatrix(); - glTranslatef(MARGIN, this.innerTop, 0.0F); - - // Draw panel contents - this.panel.drawPanel(this, mouseX - MARGIN - (this.mouseOverPanel(mouseX, mouseY) ? 0 : 99999), mouseY - this.innerTop, partialTicks); - glClear(GL_DEPTH_BUFFER_BIT); - - // Disable clip rect - glDisableClipping(); - - // Restore transform - glPopMatrix(); - - // Get total scroll height from panel - this.totalHeight = Math.max(-1, this.panel.getContentHeight()); - - // Update and draw scroll bar - this.scrollBar.setMaxValue(this.totalHeight - this.innerHeight); - this.scrollBar.drawScrollBar(mouseX, mouseY, partialTicks, this.width - MARGIN - 5, TOP, 5, this.innerHeight, - Math.max(this.innerHeight, this.totalHeight)); - - // Draw other buttons - super.draw(mouseX, mouseY, partialTicks); - } - - /** - * @param control - */ - @Override - void actionPerformed(GuiButton control) - { - if (control.id == 0) this.close(); - } - - /** - * @param mouseWheelDelta - */ - @Override - void mouseWheelScrolled(int mouseWheelDelta) - { - this.scrollBar.offsetValue(-mouseWheelDelta / 8); - } - - /** - * @param mouseX - * @param mouseY - * @param mouseButton - */ - @Override - void mousePressed(int mouseX, int mouseY, int mouseButton) - { - if (mouseButton == 0) - { - if (this.scrollBar.wasMouseOver()) - { - this.scrollBar.setDragging(true); - } - } - - super.mousePressed(mouseX, mouseY, mouseButton); - - if (this.mouseOverPanel(mouseX, mouseY)) - { - this.panel.mousePressed(this, mouseX - MARGIN, mouseY - this.innerTop, mouseButton); - } - } - - /** - * @param mouseX - * @param mouseY - * @param mouseButton - */ - @Override - void mouseReleased(int mouseX, int mouseY, int mouseButton) - { - if (mouseButton == 0) - { - this.scrollBar.setDragging(false); - } - - this.panel.mouseReleased(this, mouseX - MARGIN, mouseY - this.innerTop, mouseButton); - } - - /** - * @param mouseX - * @param mouseY - */ - @Override - void mouseMoved(int mouseX, int mouseY) - { - this.panel.mouseMoved(this, mouseX - MARGIN, mouseY - this.innerTop); - } - - /** - * @param keyChar - * @param keyCode - */ - @Override - void keyPressed(char keyChar, int keyCode) - { - this.panel.keyPressed(this, keyChar, keyCode); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelError.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelError.java deleted file mode 100644 index d465e556..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelError.java +++ /dev/null @@ -1,161 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.List; - -import org.lwjgl.input.Keyboard; - -import com.mumfrey.liteloader.core.ModInfo; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.resources.I18n; - -public class GuiPanelError extends GuiPanel implements ScrollPanelContent -{ - private final ModInfo mod; - - private GuiScrollPanel scrollPane; - - private List scrollPaneContent = new ArrayList(); - - public GuiPanelError(Minecraft minecraft, GuiLiteLoaderPanel parent, ModInfo mod) - { - super(minecraft); - - this.mod = mod; - this.scrollPane = new GuiScrollPanel(minecraft, this, MARGIN, TOP, this.width - (MARGIN * 2), this.height - TOP - BOTTOM); - - this.populateScrollPaneContent(); - } - - private void populateScrollPaneContent() - { - for (Throwable th : this.mod.getStartupErrors()) - { - StringWriter sw = new StringWriter(); - th.printStackTrace(new PrintWriter(sw, true)); - for (String line : sw.toString().split("\\r?\\n")) - { - this.scrollPaneContent.add(line.replace("\t", " ")); - } - - this.scrollPaneContent.add("!"); - } - - this.scrollPaneContent.remove(this.scrollPaneContent.size() - 1); - } - - @Override - public int getScrollPanelContentHeight(GuiScrollPanel source) - { - return this.scrollPaneContent.size() * 10; - } - - @Override - public void drawScrollPanelContent(GuiScrollPanel source, int mouseX, int mouseY, float partialTicks, int scrollAmount, int visibleHeight) - { - int yPos = -10; - - for (String line : this.scrollPaneContent) - { - if ("!".equals(line)) - { - yPos += 10; - drawRect(0, yPos + 4, this.width, yPos + 5, 0xFF555555); - } - else - { - boolean indented = line.startsWith(" "); - line = line.replaceAll("\\((.+?\\.java:[0-9]+)\\)", "(\247f$1\247r)"); - line = line.replaceAll("at ([^\\(]+)\\(", "at \2476$1\247r("); - this.mc.fontRendererObj.drawString(line, 2, yPos += 10, indented ? 0xFF999999 : 0xFFFF5555); - } - } - } - - @Override - public void scrollPanelActionPerformed(GuiScrollPanel source, GuiButton control) - { - } - - @Override - public void scrollPanelMousePressed(GuiScrollPanel source, int mouseX, int mouseY, int mouseButton) - { - } - - @Override - void setSize(int width, int height) - { - super.setSize(width, height); - - this.scrollPane.setSizeAndPosition(MARGIN, TOP, this.width - (MARGIN * 2), this.height - TOP - BOTTOM); - this.controls.add(new GuiButton(0, this.width - 59 - MARGIN, this.height - BOTTOM + 9, 60, 20, I18n.format("gui.done"))); - } - - @Override - void draw(int mouseX, int mouseY, float partialTicks) - { - this.mc.fontRendererObj.drawString(I18n.format("gui.error.title", this.mod.getDisplayName()), MARGIN, TOP - 14, 0xFFFFFFFF); - - drawRect(MARGIN, TOP - 4, this.width - MARGIN, TOP - 3, 0xFF999999); - drawRect(MARGIN, this.height - BOTTOM + 2, this.width - MARGIN, this.height - BOTTOM + 3, 0xFF999999); - - this.scrollPane.draw(mouseX, mouseY, partialTicks); - - super.draw(mouseX, mouseY, partialTicks); - } - - @Override - void onTick() - { - } - - @Override - void onHidden() - { - } - - @Override - void onShown() - { - } - - @Override - void keyPressed(char keyChar, int keyCode) - { - if (keyCode == Keyboard.KEY_ESCAPE) this.close(); - } - - @Override - void mousePressed(int mouseX, int mouseY, int mouseButton) - { - this.scrollPane.mousePressed(mouseX, mouseY, mouseButton); - super.mousePressed(mouseX, mouseY, mouseButton); - } - - @Override - void mouseMoved(int mouseX, int mouseY) - { - } - - @Override - void mouseReleased(int mouseX, int mouseY, int mouseButton) - { - this.scrollPane.mouseReleased(mouseX, mouseY, mouseButton); - } - - @Override - void mouseWheelScrolled(int mouseWheelDelta) - { - this.scrollPane.mouseWheelScrolled(mouseWheelDelta); - } - - @Override - void actionPerformed(GuiButton control) - { - if (control.id == 0) this.close(); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelLiteLoaderLog.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelLiteLoaderLog.java deleted file mode 100644 index 0204ca96..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelLiteLoaderLog.java +++ /dev/null @@ -1,406 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import static com.mumfrey.liteloader.gl.GL.*; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.resources.I18n; -import net.minecraft.util.Session; - -import org.lwjgl.input.Keyboard; - -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.net.LiteLoaderLogUpload; - -/** - * - * @author Adam Mummery-Smith - */ -class GuiPanelLiteLoaderLog extends GuiPanel implements ScrollPanelContent -{ - private static boolean useNativeRes = true; - - /** - * Scroll pane - */ - private GuiScrollPanel scrollPane; - - private List logEntries = new ArrayList(); - - private long logIndex = -1; - - private GuiCheckbox chkScale; - - private float guiScale; - - private GuiButton btnUpload; - - private LiteLoaderLogUpload logUpload; - - private String logURL; - - private int throb; - - private boolean closeDialog; - - private GuiLiteLoaderPanel parent; - - private int debugInfoTimer = 0; - - /** - * @param minecraft - * @param parent - */ - GuiPanelLiteLoaderLog(Minecraft minecraft, GuiLiteLoaderPanel parent) - { - super(minecraft); - this.parent = parent; - this.scrollPane = new GuiScrollPanel(minecraft, this, MARGIN, TOP, this.width - (MARGIN * 2), this.height - TOP - BOTTOM); - } - - private void updateLog() - { - this.logEntries = LiteLoaderLogger.getLogTail(); - this.logIndex = LiteLoaderLogger.getLogIndex(); - this.scrollPane.updateHeight(); - this.scrollPane.scrollToBottom(); - } - - @Override - public int getScrollPanelContentHeight(GuiScrollPanel source) - { - return (int)(this.logEntries.size() * 10 / (this.chkScale.checked ? this.guiScale : 1.0F)); - } - - /** - * Callback from parent screen when window is resized - * - * @param width - * @param height - */ - @Override - void setSize(int width, int height) - { - super.setSize(width, height); - - this.controls.add(new GuiButton(0, this.width - 59 - MARGIN, this.height - BOTTOM + 9, 60, 20, - I18n.format("gui.done"))); - this.controls.add(this.btnUpload = new GuiButton(1, this.width - 145 - MARGIN, this.height - BOTTOM + 9, 80, 20, - I18n.format("gui.log.postlog"))); - this.controls.add(this.chkScale = new GuiCheckbox(2, MARGIN, this.height - BOTTOM + 15, - I18n.format("gui.log.scalecheckbox"))); - - this.chkScale.checked = GuiPanelLiteLoaderLog.useNativeRes; - - ScaledResolution res = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); - this.guiScale = res.getScaleFactor(); - - this.scrollPane.setSizeAndPosition(MARGIN, TOP, this.width - (MARGIN * 2), this.height - TOP - BOTTOM); - - this.updateLog(); - } - - /** - * Callback from parent screen when panel is displayed - */ - @Override - void onShown() - { - } - - /** - * Callback from parent screen when panel is hidden - */ - @Override - void onHidden() - { - } - - /** - * Callback from parent screen every tick - */ - @Override - void onTick() - { - this.throb++; - - if (LiteLoaderLogger.getLogIndex() > this.logIndex) - { - this.updateLog(); - } - - if (this.logUpload != null && this.logUpload.isCompleted()) - { - this.logURL = this.logUpload.getLogUrl().trim(); - this.logUpload = null; - - int xMid = this.width / 2; - if (this.logURL.startsWith("http:")) - { - LiteLoaderLogger.info("Log file upload succeeded, url is %s", this.logURL); - int urlWidth = this.mc.fontRendererObj.getStringWidth(this.logURL); - this.controls.add(new GuiHoverLabel(3, xMid - (urlWidth / 2), this.height / 2, this.mc.fontRendererObj, "\247n" + this.logURL, - this.parent.getBrandColour())); - } - else - { - LiteLoaderLogger.info("Log file upload failed, reason is %s", this.logURL); - } - - this.controls.add(new GuiButton(4, xMid - 40, this.height - BOTTOM - MARGIN - 24, 80, 20, I18n.format("gui.log.closedialog"))); - } - - if (this.closeDialog) - { - this.closeDialog = false; - this.logURL = null; - this.setSize(this.width, this.height); - } - - if (Keyboard.isKeyDown(Keyboard.KEY_F3)) - { - this.debugInfoTimer++; - if (this.debugInfoTimer == 60) - { - LiteLoader.dumpDebugInfo(); - } - } - else - { - this.debugInfoTimer = 0; - } - } - - /** - * Draw the panel and chrome - * - * @param mouseX - * @param mouseY - * @param partialTicks - */ - @Override - void draw(int mouseX, int mouseY, float partialTicks) - { - // Draw panel title - this.mc.fontRendererObj.drawString(I18n.format("gui.log.title"), MARGIN, TOP - 14, 0xFFFFFFFF); - - // Draw top and bottom horizontal bars - drawRect(MARGIN, TOP - 4, this.width - MARGIN, TOP - 3, 0xFF999999); - drawRect(MARGIN, this.height - BOTTOM + 2, this.width - MARGIN, this.height - BOTTOM + 3, 0xFF999999); - - this.scrollPane.draw(mouseX, mouseY, partialTicks); - - int xMid = this.width / 2; - int yMid = this.height / 2; - - if (this.logUpload != null || this.logURL != null) - { - drawRect(MARGIN + MARGIN, TOP + MARGIN, this.width - MARGIN - MARGIN, this.height - BOTTOM - MARGIN, 0xC0000000); - - if (this.logUpload != null) - { - this.drawCenteredString(this.mc.fontRendererObj, I18n.format("gui.log.uploading"), xMid, yMid - 10, 0xFFFFFFFF); - this.drawThrobber(xMid - 90, yMid - 14, this.throb); - } - else - { - if (this.logURL.startsWith("http:")) - { - this.drawCenteredString(this.mc.fontRendererObj, I18n.format("gui.log.uploadsuccess"), xMid, yMid - 14, 0xFF55FF55); - } - else - { - this.drawCenteredString(this.mc.fontRendererObj, I18n.format("gui.log.uploadfailed"), xMid, yMid - 10, 0xFFFF5555); - } - } - } - - // Draw other buttons - super.draw(mouseX, mouseY, partialTicks); - } - - @Override - public void drawScrollPanelContent(GuiScrollPanel source, int mouseX, int mouseY, float partialTicks, int scrollAmount, int visibleHeight) - { - int yPos = 0; - int height = this.innerHeight; - - if (this.chkScale.checked) - { - float scale = 1.0F / this.guiScale; - glScalef(scale, scale, scale); - - height = (int)(height * this.guiScale); - scrollAmount = (int)(scrollAmount * this.guiScale); - } - - for (String logLine : this.logEntries) - { - if (yPos > scrollAmount - 10 && yPos <= scrollAmount + height) - { - this.mc.fontRendererObj.drawString(logLine, 0, yPos, this.getMessageColour(logLine.toLowerCase().substring(11))); - } - yPos += 10; - } - } - - @Override - public void scrollPanelMousePressed(GuiScrollPanel source, int mouseX, int mouseY, int mouseButton) - { - } - - private int getMessageColour(String logLine) - { - if (logLine.startsWith("liteloader")) return 0xFFFFFF; - if (logLine.startsWith("active pack:")) return 0xFFFF55; - if (logLine.startsWith("success")) return 0x55FF55; - if (logLine.startsWith("discovering")) return 0xFFFF55; - if (logLine.startsWith("searching")) return 0x00AA00; - if (logLine.startsWith("considering")) return 0xFFAA00; - if (logLine.startsWith("not adding")) return 0xFF5555; - if (logLine.startsWith("mod in")) return 0xAA0000; - if (logLine.startsWith("error")) return 0xAA0000; - if (logLine.startsWith("adding newest")) return 0x5555FF; - if (logLine.startsWith("found")) return 0xFFFF55; - if (logLine.startsWith("discovered")) return 0xFFFF55; - if (logLine.startsWith("setting up")) return 0xAA00AA; - if (logLine.startsWith("adding \"")) return 0xAA00AA; - if (logLine.startsWith("injecting")) return 0xFF55FF; - if (logLine.startsWith("loading")) return 0x5555FF; - if (logLine.startsWith("initialising")) return 0x55FFFF; - if (logLine.startsWith("calling late")) return 0x00AAAA; - if (logLine.startsWith("dependency check")) return 0xFFAA00; - if (logLine.startsWith("dependency")) return 0xFF5500; - if (logLine.startsWith("mod name collision")) return 0xAA0000; - if (logLine.startsWith("registering discovery module")) return 0x55FF55; - if (logLine.startsWith("registering interface provider")) return 0xFFAA00; - if (logLine.startsWith("mod file '")) return 0xFFAA00; - if (logLine.startsWith("classtransformer '")) return 0x5555FF; - if (logLine.startsWith("tweakClass '")) return 0x5555FF; - if (logLine.startsWith("baking listener list")) return 0x00AAAA; - if (logLine.startsWith("generating new event handler")) return 0xFFFF55; - - return 0xCCCCCC; - } - - /** - * @param control - */ - @Override - public void actionPerformed(GuiButton control) - { - if (control.id == 0) this.close(); - if (control.id == 1) this.postLog(); - - if (control.id == 2 && this.chkScale != null) - { - this.chkScale.checked = !this.chkScale.checked; - GuiPanelLiteLoaderLog.useNativeRes = this.chkScale.checked; - this.updateLog(); - } - - if (control.id == 3 && this.logURL != null) - { - this.openURI(URI.create(this.logURL)); - } - - if (control.id == 4) - { - this.closeDialog = true; - } - } - - @Override - public void scrollPanelActionPerformed(GuiScrollPanel source, GuiButton control) - { - } - - /** - * @param mouseWheelDelta - */ - @Override - void mouseWheelScrolled(int mouseWheelDelta) - { - this.scrollPane.mouseWheelScrolled(mouseWheelDelta); - } - - /** - * @param mouseX - * @param mouseY - * @param mouseButton - */ - @Override - void mousePressed(int mouseX, int mouseY, int mouseButton) - { - this.scrollPane.mousePressed(mouseX, mouseY, mouseButton); - - super.mousePressed(mouseX, mouseY, mouseButton); - } - - /** - * @param mouseX - * @param mouseY - * @param mouseButton - */ - @Override - void mouseReleased(int mouseX, int mouseY, int mouseButton) - { - this.scrollPane.mouseReleased(mouseX, mouseY, mouseButton); - } - - /** - * @param mouseX - * @param mouseY - */ - @Override - void mouseMoved(int mouseX, int mouseY) - { - } - - /** - * @param keyChar - * @param keyCode - */ - @Override - void keyPressed(char keyChar, int keyCode) - { - if (keyCode == Keyboard.KEY_ESCAPE) this.close(); - if (keyCode == Keyboard.KEY_SPACE) this.actionPerformed(this.chkScale); - - this.scrollPane.keyPressed(keyChar, keyCode); - } - - private void postLog() - { - this.btnUpload.enabled = false; - - StringBuilder completeLog = new StringBuilder(); - - for (String logLine : this.logEntries) - { - completeLog.append(logLine).append("\r\n"); - } - - LiteLoaderLogger.info("Uploading log file to liteloader..."); - Session session = this.mc.getSession(); - this.logUpload = new LiteLoaderLogUpload(session.getUsername(), session.getPlayerID(), completeLog.toString()); - this.logUpload.start(); - } - - private void openURI(URI uri) - { - try - { - Class desktop = Class.forName("java.awt.Desktop"); - Object instance = desktop.getMethod("getDesktop").invoke(null); - desktop.getMethod("browse", URI.class).invoke(instance, uri); - } - catch (Throwable th) {} - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelMods.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelMods.java deleted file mode 100644 index 29b6de81..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelMods.java +++ /dev/null @@ -1,295 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import static com.mumfrey.liteloader.gl.GL.*; -import static com.mumfrey.liteloader.gl.GLClippingPlanes.*; - -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.resources.I18n; - -import org.lwjgl.input.Keyboard; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.api.ModInfoDecorator; -import com.mumfrey.liteloader.client.gui.modlist.ModList; -import com.mumfrey.liteloader.client.gui.modlist.ModListContainer; -import com.mumfrey.liteloader.core.LiteLoaderMods; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.modconfig.ConfigManager; -import com.mumfrey.liteloader.modconfig.ConfigPanel; - -/** - * Mods panel - * - * @author Adam Mummery-Smith - */ -public class GuiPanelMods extends GuiPanel implements ModListContainer -{ - private static final int SCROLLBAR_WIDTH = 5; - - private final GuiLiteLoaderPanel parentScreen; - - private final ConfigManager configManager; - - /** - * List of enumerated mods - */ - private ModList modList; - - /** - * Enable / disable button - */ - private GuiButton btnToggle; - - /** - * Config button - */ - private GuiButton btnConfig; - - /** - * Height of all the items in the list - */ - private int listHeight = 100; - - /** - * Scroll bar control for the mods list - */ - private GuiSimpleScrollBar scrollBar = new GuiSimpleScrollBar(); - - public GuiPanelMods(GuiLiteLoaderPanel parentScreen, Minecraft minecraft, LiteLoaderMods mods, LoaderEnvironment environment, - ConfigManager configManager, int brandColour, List decorators) - { - super(minecraft); - - this.parentScreen = parentScreen; - this.configManager = configManager; - - this.modList = new ModList(this, minecraft, mods, environment, configManager, brandColour, decorators); - } - - @Override - public GuiLiteLoaderPanel getParentScreen() - { - return this.parentScreen; - } - - @Override - public void setConfigButtonVisible(boolean visible) - { - this.btnConfig.visible = visible; - } - - @Override - public void setEnableButtonVisible(boolean visible) - { - this.btnToggle.visible = visible; - } - - @Override - public void setEnableButtonText(String displayString) - { - this.btnToggle.displayString = displayString; - } - - @Override - boolean stealFocus() - { - return false; - } - - @Override - void setSize(int width, int height) - { - super.setSize(width, height); - - int rightPanelLeftEdge = MARGIN + 4 + (this.width - MARGIN - MARGIN - 4) / 2; - - this.controls.clear(); - this.controls.add(this.btnToggle = new GuiButton(0, rightPanelLeftEdge, this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - 24, 90, 20, - I18n.format("gui.enablemod"))); - this.controls.add(this.btnConfig = new GuiButton(1, rightPanelLeftEdge + 92, this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - 24, 69, 20, - I18n.format("gui.modsettings"))); - - this.modList.setSize(width, height); - } - - @Override - void onTick() - { - this.modList.onTick(); - } - - @Override - void onHidden() - { - } - - @Override - void onShown() - { - } - - @Override - void mousePressed(int mouseX, int mouseY, int mouseButton) - { - if (mouseButton == 0) - { - if (this.scrollBar.wasMouseOver()) - { - this.scrollBar.setDragging(true); - } - - if (mouseY > GuiLiteLoaderPanel.PANEL_TOP && mouseY < this.height - GuiLiteLoaderPanel.PANEL_BOTTOM) - { - this.modList.mousePressed(mouseX, mouseY, mouseButton); - } - } - - super.mousePressed(mouseX, mouseY, mouseButton); - } - - @Override - void keyPressed(char keyChar, int keyCode) - { - if (keyCode == Keyboard.KEY_ESCAPE) - { - this.parentScreen.onToggled(); - return; - } - else if (this.modList.keyPressed(keyChar, keyCode)) - { - // Suppress further handling - } - else if (keyCode == Keyboard.KEY_F3) - { - this.parentScreen.showLogPanel(); - } - else if (keyCode == Keyboard.KEY_F1) - { - this.parentScreen.showAboutPanel(); - } - } - - @Override - void mouseMoved(int mouseX, int mouseY) - { - } - - @Override - void mouseReleased(int mouseX, int mouseY, int mouseButton) - { - if (mouseButton == 0) - { - this.scrollBar.setDragging(false); - this.modList.mouseReleased(mouseX, mouseY, mouseButton); - } - } - - @Override - void mouseWheelScrolled(int mouseWheelDelta) - { - if (!this.modList.mouseWheelScrolled(mouseWheelDelta)) - { - this.scrollBar.offsetValue(-mouseWheelDelta / 8); - } - } - - @Override - public void showConfig() - { - this.actionPerformed(this.btnConfig); - } - - @Override - void actionPerformed(GuiButton control) - { - if (control.id == 0) - { - this.modList.toggleSelectedMod(); - } - - if (control.id == 1) - { - Class modClass = this.modList.getSelectedModClass(); - - if (modClass != null) - { - ConfigPanel panel = this.configManager.getPanel(modClass); - LiteMod mod = this.modList.getSelectedModInstance(); - this.parentScreen.openConfigPanel(panel, mod); - } - } - } - - @Override - void draw(int mouseX, int mouseY, float partialTicks) - { - this.parentScreen.drawInfoPanel(mouseX, mouseY, partialTicks, 0, GuiLiteLoaderPanel.PANEL_BOTTOM); - - int innerWidth = this.width - MARGIN - MARGIN - 4; - int panelWidth = innerWidth / 2; - int panelHeight = this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - GuiLiteLoaderPanel.PANEL_TOP; - - this.drawModsList(mouseX, mouseY, partialTicks, panelWidth, panelHeight); - - int left = MARGIN + panelWidth; - int top = GuiLiteLoaderPanel.PANEL_TOP; - int spaceForButtons = (this.btnConfig.visible || this.btnToggle.visible ? 28 : 0); - int bottom = this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - spaceForButtons; - - glEnableClipping(left, this.width - MARGIN, top, bottom); - this.modList.drawModPanel(mouseX, mouseY, partialTicks, left, top, this.width - MARGIN - left, panelHeight - spaceForButtons); - glDisableClipping(); - - super.draw(mouseX, mouseY, partialTicks); - } - - /** - * @param mouseX - * @param mouseY - * @param partialTicks - * @param width - * @param height - */ - private void drawModsList(int mouseX, int mouseY, float partialTicks, int width, int height) - { - this.scrollBar.drawScrollBar(mouseX, mouseY, partialTicks, MARGIN + width - SCROLLBAR_WIDTH, GuiLiteLoaderPanel.PANEL_TOP, SCROLLBAR_WIDTH, - height, this.listHeight); - - // clip outside of scroll area - glEnableClipping(MARGIN, MARGIN + width - SCROLLBAR_WIDTH - 1, GuiLiteLoaderPanel.PANEL_TOP, this.height - GuiLiteLoaderPanel.PANEL_BOTTOM); - - // handle scrolling - glPushMatrix(); - glTranslatef(0.0F, GuiLiteLoaderPanel.PANEL_TOP - this.scrollBar.getValue(), 0.0F); - - mouseY -= (GuiLiteLoaderPanel.PANEL_TOP - this.scrollBar.getValue()); - - this.listHeight = this.modList.drawModList(mouseX, mouseY, partialTicks, MARGIN, 0, width - SCROLLBAR_WIDTH - 1, height); - this.scrollBar.setMaxValue(this.listHeight - height); - - glPopMatrix(); - glDisableClipping(); - } - - @Override - public void scrollTo(int yPosTop, int yPosBottom) - { - // Mod is above the top of the visible window - if (yPosTop < this.scrollBar.getValue()) - { - this.scrollBar.setValue(yPosTop); - return; - } - - int panelHeight = this.height - GuiLiteLoaderPanel.PANEL_BOTTOM - GuiLiteLoaderPanel.PANEL_TOP; - - // Mod is below the bottom of the visible window - if (yPosBottom - this.scrollBar.getValue() > panelHeight) - { - this.scrollBar.setValue(yPosBottom - panelHeight); - } - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelSettings.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelSettings.java deleted file mode 100644 index 05c68b75..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelSettings.java +++ /dev/null @@ -1,152 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import org.lwjgl.input.Keyboard; - -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.interfaces.PanelManager; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.resources.I18n; - -class GuiPanelSettings extends GuiPanel -{ - private GuiLiteLoaderPanel parentScreen; - - private GuiCheckbox chkShowTab, chkNoHide, chkForceUpdate; - - private boolean hide; - - private String[] helpText = new String[5]; - - GuiPanelSettings(GuiLiteLoaderPanel parentScreen, Minecraft minecraft) - { - super(minecraft); - - this.parentScreen = parentScreen; - - this.helpText[0] = I18n.format("gui.settings.showtab.help1"); - this.helpText[1] = I18n.format("gui.settings.showtab.help2"); - this.helpText[2] = I18n.format("gui.settings.notabhide.help1"); - this.helpText[3] = I18n.format("gui.settings.forceupdate.help1"); - this.helpText[4] = I18n.format("gui.settings.forceupdate.help2"); - } - - @Override - public void close() - { - this.hide = true; - } - - @Override - boolean isCloseRequested() - { - boolean hide = this.hide; - this.hide = false; - return hide; - } - - @Override - void setSize(int width, int height) - { - super.setSize(width, height); - - this.controls.add(new GuiButton(-1, this.width - 99 - MARGIN, this.height - BOTTOM + 9, 100, 20, I18n.format("gui.done"))); - this.controls.add(this.chkShowTab = new GuiCheckbox(0, 34, 90, I18n.format("gui.settings.showtab.label"))); - this.controls.add(this.chkNoHide = new GuiCheckbox(1, 34, 128, I18n.format("gui.settings.notabhide.label"))); - this.controls.add(this.chkForceUpdate = new GuiCheckbox(2, 34, 158, I18n.format("gui.settings.forceupdate.label"))); - - this.updateCheckBoxes(); - } - - private void updateCheckBoxes() - { - PanelManager panelManager = LiteLoader.getModPanelManager(); - - this.chkShowTab.checked = panelManager.isTabVisible(); - this.chkNoHide.checked = panelManager.isTabAlwaysExpanded(); - this.chkForceUpdate.checked = panelManager.isForceUpdateEnabled(); - } - - private void updateSettings() - { - PanelManager panelManager = LiteLoader.getModPanelManager(); - - panelManager.setTabVisible(this.chkShowTab.checked); - panelManager.setTabAlwaysExpanded(this.chkNoHide.checked); - panelManager.setForceUpdateEnabled(this.chkForceUpdate.checked); - } - - @Override - void draw(int mouseX, int mouseY, float partialTicks) - { - this.parentScreen.drawInfoPanel(mouseX, mouseY, partialTicks, 0, 38); - - FontRenderer fontRenderer = this.mc.fontRendererObj; - int brandColour = this.parentScreen.getBrandColour(); - - fontRenderer.drawString(this.helpText[0], 50, 104, brandColour); - fontRenderer.drawString(this.helpText[1], 50, 114, brandColour); - fontRenderer.drawString(this.helpText[2], 50, 142, brandColour); - fontRenderer.drawString(this.helpText[3], 50, 172, brandColour); - fontRenderer.drawString(this.helpText[4], 50, 182, brandColour); - - super.draw(mouseX, mouseY, partialTicks); - } - - @Override - void actionPerformed(GuiButton control) - { - if (control.id == -1) - { - this.close(); - return; - } - - if (control instanceof GuiCheckbox) - { - ((GuiCheckbox)control).checked = !((GuiCheckbox)control).checked; - this.updateSettings(); - } - } - - @Override - void keyPressed(char keyChar, int keyCode) - { - if (keyCode == Keyboard.KEY_ESCAPE) - { - this.close(); - } - } - - @Override - void onTick() - { - } - - @Override - void onHidden() - { - } - - @Override - void onShown() - { - } - - @Override - void mouseMoved(int mouseX, int mouseY) - { - } - - @Override - void mouseReleased(int mouseX, int mouseY, int mouseButton) - { - } - - @Override - void mouseWheelScrolled(int mouseWheelDelta) - { - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelUpdateCheck.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelUpdateCheck.java deleted file mode 100644 index 908abf6a..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiPanelUpdateCheck.java +++ /dev/null @@ -1,232 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import java.net.URI; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.GuiButton; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.resources.I18n; - -import org.lwjgl.input.Keyboard; - -import com.mumfrey.liteloader.core.LiteLoaderUpdateSite; -import com.mumfrey.liteloader.launch.ClassPathUtilities; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.update.UpdateSite; - -/** - * "Check for updates" panel which docks in the mod info screen - * - * @author Adam Mummery-Smith - */ -class GuiPanelUpdateCheck extends GuiPanel -{ - private static final int WHITE = 0xFFFFFFFF; - - /** - * URI to open if a new version is available - */ - private static final URI DOWNLOAD_URI = URI.create("http://dl.liteloader.com"); - - private final GuiLiteLoaderPanel parentScreen; - - /** - * Update site to contact - */ - private final UpdateSite updateSite; - - /** - * Panel title - */ - private final String panelTitle; - - /** - * Buttons - */ - private GuiButton btnCheck, btnDownload; - - /** - * Throbber frame - */ - private int throb; - - private boolean canForceUpdate, updateForced; - - public GuiPanelUpdateCheck(GuiLiteLoaderPanel parentScreen, Minecraft minecraft, UpdateSite updateSite, String updateName, - LoaderProperties properties) - { - super(minecraft); - - this.parentScreen = parentScreen; - this.updateSite = updateSite; - this.panelTitle = I18n.format("gui.updates.title", updateName); - - this.canForceUpdate = (updateSite instanceof LiteLoaderUpdateSite && ((LiteLoaderUpdateSite)updateSite).canForceUpdate(properties)); - } - - @Override - void setSize(int width, int height) - { - super.setSize(width, height); - - this.controls.add(new GuiButton(0, this.width - 99 - MARGIN, this.height - BOTTOM + 9, 100, 20, - this.updateForced ? I18n.format("gui.exitgame") : I18n.format("gui.done"))); - this.controls.add(this.btnCheck = new GuiButton(1, MARGIN + 16, TOP + 16, 100, 20, - I18n.format("gui.checknow"))); - this.controls.add(this.btnDownload = new GuiButton(2, MARGIN + 16, TOP + 118, 100, 20, - this.canForceUpdate ? I18n.format("gui.forceupdate") : I18n.format("gui.downloadupdate"))); - } - - @Override - void draw(int mouseX, int mouseY, float partialTicks) - { - FontRenderer fontRenderer = this.mc.fontRendererObj; - - // Draw panel title - fontRenderer.drawString(this.panelTitle, MARGIN, TOP - 14, GuiPanelUpdateCheck.WHITE); - - // Draw top and bottom horizontal bars - drawRect(MARGIN, TOP - 4, this.width - MARGIN, TOP - 3, 0xFF999999); - drawRect(MARGIN, this.height - BOTTOM + 2, this.width - MARGIN, this.height - BOTTOM + 3, 0xFF999999); - - this.btnCheck.enabled = !this.updateForced && !this.updateSite.isCheckInProgress(); - this.btnDownload.visible = false; - - if (this.updateSite.isCheckInProgress()) - { - this.drawThrobber(MARGIN, TOP + 40, this.throb); - fontRenderer.drawString(I18n.format("gui.updates.status.checking", ""), MARGIN + 18, TOP + 44, GuiPanelUpdateCheck.WHITE); - } - else if (this.updateSite.isCheckComplete()) - { - boolean success = this.updateSite.isCheckSucceess(); - String status = success ? I18n.format("gui.updates.status.success") : I18n.format("gui.updates.status.failed"); - fontRenderer.drawString(I18n.format("gui.updates.status.checking", status), MARGIN + 18, TOP + 44, GuiPanelUpdateCheck.WHITE); - - if (success) - { - fontRenderer.drawString(I18n.format("gui.updates.available.title"), MARGIN + 18, TOP + 70, GuiPanelUpdateCheck.WHITE); - if (this.updateSite.isUpdateAvailable()) - { - this.btnDownload.visible = !this.updateForced; - fontRenderer.drawString(I18n.format("gui.updates.available.newversion"), MARGIN + 18, TOP + 84, GuiPanelUpdateCheck.WHITE); - fontRenderer.drawString(I18n.format("gui.updates.available.version", this.updateSite.getAvailableVersion()), - MARGIN + 18, TOP + 94, GuiPanelUpdateCheck.WHITE); - fontRenderer.drawString(I18n.format("gui.updates.available.date", this.updateSite.getAvailableVersionDate()), - MARGIN + 18, TOP + 104, GuiPanelUpdateCheck.WHITE); - - if (this.updateForced) - { - fontRenderer.drawString(I18n.format("gui.updates.forced"), MARGIN + 18, TOP + 144, 0xFFFFAA00); - } - } - else - { - fontRenderer.drawString(I18n.format("gui.updates.available.nonewversion"), MARGIN + 18, TOP + 84, GuiPanelUpdateCheck.WHITE); - } - } - } - else - { - fontRenderer.drawString(I18n.format("gui.updates.status.idle"), MARGIN + 18, TOP + 44, GuiPanelUpdateCheck.WHITE); - } - - super.draw(mouseX, mouseY, partialTicks); - } - - @Override - public void close() - { - if (this.updateForced) - { - return; - } - - super.close(); - } - - /** - * @param control - */ - @Override - void actionPerformed(GuiButton control) - { - if (control.id == 0) - { - if (this.updateForced) - { - ClassPathUtilities.terminateRuntime(0); - return; - } - - this.close(); - } - if (control.id == 1) this.updateSite.beginUpdateCheck(); - if (control.id == 2) - { - if (this.canForceUpdate && ((LiteLoaderUpdateSite)this.updateSite).forceUpdate()) - { - this.updateForced = true; - this.parentScreen.setToggleable(false); - ScaledResolution sr = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); - this.parentScreen.setWorldAndResolution(this.mc, sr.getScaledWidth(), sr.getScaledHeight()); - } - else - { - this.openURI(GuiPanelUpdateCheck.DOWNLOAD_URI); - } - - this.btnDownload.enabled = false; - } - } - - private void openURI(URI uri) - { - try - { - Class desktop = Class.forName("java.awt.Desktop"); - Object instance = desktop.getMethod("getDesktop").invoke(null); - desktop.getMethod("browse", URI.class).invoke(instance, uri); - } - catch (Throwable th) {} - } - - @Override - void onTick() - { - this.throb++; - } - - @Override - void onHidden() - { - } - - @Override - void onShown() - { - } - - @Override - void keyPressed(char keyChar, int keyCode) - { - if (keyCode == Keyboard.KEY_ESCAPE) this.close(); - } - - @Override - void mouseMoved(int mouseX, int mouseY) - { - } - - @Override - void mouseReleased(int mouseX, int mouseY, int mouseButton) - { - } - - @Override - void mouseWheelScrolled(int mouseWheelDelta) - { - } - -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiScrollPanel.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiScrollPanel.java deleted file mode 100644 index 8853e9c1..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiScrollPanel.java +++ /dev/null @@ -1,208 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import static com.mumfrey.liteloader.gl.GL.*; -import static com.mumfrey.liteloader.gl.GLClippingPlanes.*; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.GuiButton; - -import org.lwjgl.input.Keyboard; - -/** - * Basic non-interactive scrollable panel using OpenGL clipping planes - * - * TODO handle interaction - * - * @author Adam Mummery-Smith - */ -class GuiScrollPanel extends GuiPanel -{ - private ScrollPanelContent content; - - /** - * Scroll bar for the panel - */ - private GuiSimpleScrollBar scrollBar = new GuiSimpleScrollBar(); - - /** - * Left edge coord - specified - */ - private int left; - - /** - * Top edge coord - specified - */ - private int top; - - /** - * - */ - private int contentHeight; - - public GuiScrollPanel(Minecraft minecraft, ScrollPanelContent content, int left, int top, int width, int height) - { - super(minecraft); - - this.setContent(content); - } - - public void setContent(ScrollPanelContent content) - { - if (content == null) - { - throw new IllegalArgumentException("Scroll pane content can not be null"); - } - - this.content = content; - } - - @Override - void setSize(int width, int height) - { - this.width = width; - this.height = height; - - this.updateHeight(); - } - - public void setSizeAndPosition(int left, int top, int width, int height) - { - this.left = left; - this.top = top; - - this.setSize(width, height); - } - - public void updateHeight() - { - this.contentHeight = this.content.getScrollPanelContentHeight(this); - this.scrollBar.setMaxValue(this.contentHeight - this.height); - } - - public void scrollToBottom() - { - this.scrollBar.setValue(this.contentHeight); - } - - public void scrollToTop() - { - this.scrollBar.setValue(0); - } - - public void scrollBy(int amount) - { - this.scrollBar.offsetValue(amount); - } - - public GuiButton addControl(GuiButton control) - { - this.controls.add(control); - return control; - } - - /** - * Draw the panel and chrome - * - * @param mouseX - * @param mouseY - * @param partialTicks - */ - @Override - public void draw(int mouseX, int mouseY, float partialTicks) - { - int scrollPosition = this.scrollBar.getValue(); - - // Clip rect - glEnableClipping(this.left, this.left + this.width - 6, this.top, this.top + this.height); - - // Offset by scroll - glPushMatrix(); - glTranslatef(this.left, this.top - scrollPosition, 0.0F); - - this.content.drawScrollPanelContent(this, mouseX, mouseY, partialTicks, scrollPosition, this.height); - - super.draw(mouseX - this.left, mouseY + scrollPosition - this.top, partialTicks); - - // Disable clip rect - glDisableClipping(); - - // Restore transform - glPopMatrix(); - - // Update and draw scroll bar - this.scrollBar.drawScrollBar(mouseX, mouseY, partialTicks, this.left + this.width - 5, this.top, 5, this.height, - Math.max(this.height, this.contentHeight)); - } - - @Override - public void mouseWheelScrolled(int mouseWheelDelta) - { - this.scrollBy(-mouseWheelDelta / 8); - } - - @Override - public void mousePressed(int mouseX, int mouseY, int mouseButton) - { - mouseY += this.scrollBar.getValue() - this.top; - mouseX -= this.left; - super.mousePressed(mouseX, mouseY, mouseButton); - - if (mouseX > 0 && mouseX < this.width && mouseY > 0 && mouseY < this.contentHeight) - { - this.content.scrollPanelMousePressed(this, mouseX, mouseY, mouseButton); - } - - if (mouseButton == 0) - { - if (this.scrollBar.wasMouseOver()) - { - this.scrollBar.setDragging(true); - } - } - } - - @Override - public void mouseReleased(int mouseX, int mouseY, int mouseButton) - { - if (mouseButton == 0) - { - this.scrollBar.setDragging(false); - } - } - - @Override - public void keyPressed(char keyChar, int keyCode) - { - if (keyCode == Keyboard.KEY_UP) this.scrollBar.offsetValue(-10); - if (keyCode == Keyboard.KEY_DOWN) this.scrollBar.offsetValue(10); - if (keyCode == Keyboard.KEY_PRIOR) this.scrollBar.offsetValue(-this.height + 10); - if (keyCode == Keyboard.KEY_NEXT) this.scrollBar.offsetValue(this.height - 10); - if (keyCode == Keyboard.KEY_HOME) this.scrollBar.setValue(0); - if (keyCode == Keyboard.KEY_END) this.scrollBar.setValue(this.contentHeight); - } - - @Override - void onTick() - { - } - - @Override - void onHidden() - { - } - - @Override - void onShown() - { - } - - @Override - void mouseMoved(int mouseX, int mouseY) - { - } - - @Override - void actionPerformed(GuiButton control) - { - this.content.scrollPanelActionPerformed(this, control); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiSimpleScrollBar.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiSimpleScrollBar.java deleted file mode 100644 index 51cc7f37..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/GuiSimpleScrollBar.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import net.minecraft.client.gui.Gui; - -/** - * Extremely simple scrollbar implementation - * - * @author Adam Mummery-Smith - */ -public class GuiSimpleScrollBar extends Gui -{ - /** - * Current value - */ - private int value = 0; - - /** - * Current maximum value - */ - private int maxValue = 100; - - private int backColour = 0x44FFFFFF; - private int foreColour = 0xFFFFFFFF; - - /** - * True if mouse was over the drag bar when last drawn - */ - private boolean mouseOver = false; - - /** - * True if currently dragging the scroll bar - */ - private boolean dragging = false; - - /** - * Value prior to starting to drag - */ - private int mouseDownValue = 0; - - /** - * mouse Y coordinate prior to starting to drag - */ - private int mouseDownY = 0; - - /** - * Get the current scroll value - */ - public int getValue() - { - return this.value; - } - - /** - * Set the scroll value, the value is clamped between 0 and the current max - * value. - */ - public void setValue(int value) - { - this.value = Math.min(Math.max(value, 0), this.maxValue); - } - - /** - * Offset the scroll value by the specified amount, the value is clamped - * between 0 and the current max value. - */ - public void offsetValue(int offset) - { - this.setValue(this.value + offset); - } - - /** - * Get the current max value - */ - public int getMaxValue() - { - return this.maxValue; - } - - /** - * Sets the current max value - */ - public void setMaxValue(int maxValue) - { - this.maxValue = Math.max(0, maxValue); - this.value = Math.min(this.value, this.maxValue); - } - - /** - * Returns true if the mouse was over the drag bar on the last render - */ - public boolean wasMouseOver() - { - return this.mouseOver; - } - - /** - * Set the current dragging state - */ - public void setDragging(boolean dragging) - { - this.dragging = dragging; - } - - /** - * Draw the scroll bar - * - * @param mouseX - * @param mouseY - * @param partialTicks - * @param xPosition - * @param yPosition - * @param width - * @param height - * @param totalHeight - */ - public void drawScrollBar(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, int height, int totalHeight) - { - drawRect(xPosition, yPosition, xPosition + width, yPosition + height, this.backColour); - - if (totalHeight > 0) - { - int slideHeight = height - 2; - float pct = Math.min(1.0F, (float)slideHeight / (float)totalHeight); - int barHeight = (int)(pct * slideHeight); - int barTravel = slideHeight - barHeight; - int barPosition = yPosition + 1 + (this.maxValue > 0 ? (int)((this.value / (float)this.maxValue) * barTravel) : 0); - - drawRect(xPosition + 1, barPosition, xPosition + width - 1, barPosition + barHeight, this.foreColour); - - this.mouseOver = mouseX > xPosition && mouseX < xPosition + width && mouseY > barPosition && mouseY < barPosition + barHeight; - this.handleDrag(mouseY, barTravel); - } - } - - /** - * @param mouseY - * @param barTravel - */ - public void handleDrag(int mouseY, int barTravel) - { - if (this.dragging) - { - // Convert pixel delta to value delta - float valuePerPixel = (float)this.maxValue / barTravel; - this.setValue((int)(this.mouseDownValue + ((mouseY - this.mouseDownY) * valuePerPixel))); - } - else - { - this.mouseDownY = mouseY; - this.mouseDownValue = this.value; - } - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/ScrollPanelContent.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/ScrollPanelContent.java deleted file mode 100644 index a2436103..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/ScrollPanelContent.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.mumfrey.liteloader.client.gui; - -import net.minecraft.client.gui.GuiButton; - -public interface ScrollPanelContent -{ - public abstract int getScrollPanelContentHeight(GuiScrollPanel source); - - public abstract void drawScrollPanelContent(GuiScrollPanel source, int mouseX, int mouseY, float partialTicks, int scrollAmt, int visibleHeight); - - public abstract void scrollPanelActionPerformed(GuiScrollPanel source, GuiButton control); - - public abstract void scrollPanelMousePressed(GuiScrollPanel source, int mouseX, int mouseY, int mouseButton); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/GuiModInfoPanel.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/GuiModInfoPanel.java deleted file mode 100644 index 87b1d83a..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/GuiModInfoPanel.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.mumfrey.liteloader.client.gui.modlist; - -import static com.mumfrey.liteloader.gl.GL.*; -import static com.mumfrey.liteloader.gl.GLClippingPlanes.*; -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; -import net.minecraft.client.resources.I18n; - -import com.google.common.base.Strings; -import com.mumfrey.liteloader.client.api.LiteLoaderBrandingProvider; -import com.mumfrey.liteloader.client.gui.GuiSimpleScrollBar; -import com.mumfrey.liteloader.client.util.render.IconAbsolute; -import com.mumfrey.liteloader.core.ModInfo; -import com.mumfrey.liteloader.util.render.IconTextured; - -public class GuiModInfoPanel extends Gui -{ - private static final int TITLE_COLOUR = GuiModListPanel.WHITE; - private static final int AUTHORS_COLOUR = GuiModListPanel.WHITE; - private static final int DIVIDER_COLOUR = GuiModListPanel.GREY; - private static final int DESCRIPTION_COLOUR = GuiModListPanel.WHITE; - - private static final IconAbsolute infoIcon = new IconAbsolute(LiteLoaderBrandingProvider.ABOUT_TEXTURE, "Info", 12, 12, 146, 92, 158, 104); - - private final ModListEntry owner; - - private final FontRenderer fontRenderer; - - private final int brandColour; - - private final ModInfo modInfo; - - private GuiSimpleScrollBar scrollBar = new GuiSimpleScrollBar(); - - private boolean mouseOverPanel, mouseOverScrollBar; - - private boolean showHelp; - - private String helpTitle, helpText; - - public GuiModInfoPanel(ModListEntry owner, FontRenderer fontRenderer, int brandColour, ModInfo modInfo) - { - this.owner = owner; - this.fontRenderer = fontRenderer; - this.brandColour = brandColour; - this.modInfo = modInfo; - } - - public void draw(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, int height) - { - int bottom = height + yPosition; - int yPos = yPosition + 2; - - this.mouseOverPanel = this.isMouseOver(mouseX, mouseY, xPosition, yPos, width, height); - - this.fontRenderer.drawString(this.owner.getTitleText(), xPosition + 5, yPos, GuiModInfoPanel.TITLE_COLOUR); yPos += 10; - this.fontRenderer.drawString(this.owner.getVersionText(), xPosition + 5, yPos, GuiModListPanel.VERSION_TEXT_COLOUR); yPos += 10; - - drawRect(xPosition + 5, yPos, xPosition + width, yPos + 1, GuiModInfoPanel.DIVIDER_COLOUR); yPos += 4; // divider - - this.fontRenderer.drawString(I18n.format("gui.about.authors") + ": \2477" + this.modInfo.getAuthor(), xPosition + 5, yPos, - GuiModInfoPanel.AUTHORS_COLOUR); yPos += 10; - if (!Strings.isNullOrEmpty(this.modInfo.getURL())) - { - this.fontRenderer.drawString(this.modInfo.getURL(), xPosition + 5, yPos, GuiModListPanel.BLEND_2THRDS & this.brandColour); yPos += 10; - } - - drawRect(xPosition + 5, yPos, xPosition + width, yPos + 1, GuiModInfoPanel.DIVIDER_COLOUR); yPos += 4; // divider - drawRect(xPosition + 5, bottom - 1, xPosition + width, bottom, GuiModInfoPanel.DIVIDER_COLOUR); // divider - - glEnableClipping(-1, -1, yPos, bottom - 3); - - int scrollHeight = bottom - yPos - 3; - int contentHeight = this.drawContent(xPosition, width, yPos); - - this.scrollBar.setMaxValue(contentHeight - scrollHeight); - this.scrollBar.drawScrollBar(mouseX, mouseY, partialTicks, xPosition + width - 5, yPos, 5, scrollHeight, contentHeight); - - this.mouseOverScrollBar = this.isMouseOver(mouseX, mouseY, xPosition + width - 5, yPos, 5, scrollHeight); - } - - private int drawContent(int xPosition, int width, int yPos) - { - yPos -= this.scrollBar.getValue(); - - if (this.showHelp) - { - this.drawIcon(xPosition + 3, yPos, GuiModInfoPanel.infoIcon); yPos += 2; - this.fontRenderer.drawString(this.helpTitle, xPosition + 17, yPos, this.brandColour); yPos += 12; - return this.drawText(xPosition + 17, width - 24, yPos, this.helpText, GuiModInfoPanel.DESCRIPTION_COLOUR) + 15; - } - - return this.drawText(xPosition + 5, width - 11, yPos, this.modInfo.getDescription(), GuiModInfoPanel.DESCRIPTION_COLOUR); - } - - protected void drawIcon(int xPosition, int yPosition, IconTextured icon) - { - glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - Minecraft.getMinecraft().getTextureManager().bindTexture(icon.getTextureResource()); - - glEnableBlend(); - this.drawTexturedModalRect(xPosition, yPosition, icon.getUPos(), icon.getVPos(), icon.getIconWidth(), icon.getIconHeight()); - glDisableBlend(); - } - - private int drawText(int xPosition, int width, int yPos, String text, int colour) - { - int totalHeight = this.fontRenderer.splitStringWidth(text, width); - this.fontRenderer.drawSplitString(text, xPosition, yPos, width, colour); - return totalHeight; - } - - private boolean isMouseOver(int mouseX, int mouseY, int x, int y, int width, int height) - { - return mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + height; - } - - public void mousePressed() - { - if (this.mouseOverScrollBar) - { - this.scrollBar.setDragging(true); - } - } - - public void mouseReleased() - { - this.scrollBar.setDragging(false); - } - - public boolean mouseWheelScrolled(int mouseWheelDelta) - { - if (this.mouseOverPanel) - { - this.scrollBar.offsetValue(-mouseWheelDelta / 8); - return true; - } - - return false; - } - - public void displayHelpMessage(String title, String text) - { - this.showHelp = true; - this.helpTitle = I18n.format(title); - this.helpText = I18n.format(text); - this.scrollBar.setValue(0); - } - - public void clearHelpMessage() - { - this.showHelp = false; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/GuiModListPanel.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/GuiModListPanel.java deleted file mode 100644 index cced9b66..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/GuiModListPanel.java +++ /dev/null @@ -1,271 +0,0 @@ -package com.mumfrey.liteloader.client.gui.modlist; - -import static com.mumfrey.liteloader.gl.GL.*; -import static com.mumfrey.liteloader.gl.GLClippingPlanes.*; - -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.Gui; - -import com.mumfrey.liteloader.api.ModInfoDecorator; -import com.mumfrey.liteloader.client.gui.GuiLiteLoaderPanel; -import com.mumfrey.liteloader.core.ModInfo; -import com.mumfrey.liteloader.util.render.IconClickable; -import com.mumfrey.liteloader.util.render.IconTextured; - -public class GuiModListPanel extends Gui -{ - static final int BLACK = 0xFF000000; - static final int DARK_GREY = 0xB0333333; - static final int GREY = 0xFF999999; - static final int WHITE = 0xFFFFFFFF; - - static final int BLEND_2THRDS = 0xB0FFFFFF; - static final int BLEND_HALF = 0x80FFFFFF; - - static final int API_COLOUR = 0xFFAA00AA; - static final int EXTERNAL_ENTRY_COLOUR = 0xFF47D1AA; - static final int MISSING_DEPENDENCY_COLOUR = 0xFFFFAA00; - static final int ERROR_COLOUR = 0xFFFF5555; - static final int ERROR_GRADIENT_COLOUR = 0xFFAA0000; - static final int ERROR_GRADIENT_COLOUR2 = 0xFF550000; - - static final int VERSION_TEXT_COLOUR = GuiModListPanel.GREY; - static final int GRADIENT_COLOUR2 = GuiModListPanel.BLEND_2THRDS & GuiModListPanel.DARK_GREY; - static final int HANGER_COLOUR = GuiModListPanel.GREY; - static final int HANGER_COLOUR_MOUSEOVER = GuiModListPanel.WHITE; - - static final int PANEL_HEIGHT = 32; - static final int PANEL_SPACING = 3; - - protected ModListEntry owner; - - /** - * For text display - */ - protected final FontRenderer fontRenderer; - - protected final int brandColour; - - protected final List decorators; - - protected final ModInfo modInfo; - - /** - * True if the mouse was over this mod on the last render - */ - private boolean mouseOver; - - private IconClickable mouseOverIcon = null; - - private List modIcons = new ArrayList(); - - public GuiModListPanel(ModListEntry owner, FontRenderer fontRenderer, int brandColour, ModInfo modInfo, List decorators) - { - this.owner = owner; - this.fontRenderer = fontRenderer; - this.brandColour = brandColour; - this.modInfo = modInfo; - this.decorators = decorators; - - for (ModInfoDecorator decorator : this.decorators) - { - decorator.addIcons(modInfo, this.modIcons); - } - } - - public void draw(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected, int pass) - { - if (pass == 0) - { - this.render(mouseX, mouseY, partialTicks, xPosition, yPosition, width, selected); - } - else if (pass == 1) - { - this.postRender(mouseX, mouseY, partialTicks, xPosition, yPosition, width, selected); - } - } - - /** - * Draw this list entry as a list item - * - * @param mouseX - * @param mouseY - * @param partialTicks - * @param xPosition - * @param yPosition - * @param width - * @param selected - */ - protected void render(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected) - { - int gradientColour = this.getGradientColour(selected); - int titleColour = this.getTitleColour(selected); - int statusColour = this.getStatusColour(selected); - - this.drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + GuiModListPanel.PANEL_HEIGHT, gradientColour, - GuiModListPanel.GRADIENT_COLOUR2); - - String titleText = this.owner.getTitleText(); - String versionText = this.owner.getVersionText(); - String statusText = this.owner.getStatusText(); - - for (ModInfoDecorator decorator : this.decorators) - { - String newStatusText = decorator.modifyStatusText(this.modInfo, statusText); - if (newStatusText != null) statusText = newStatusText; - } - - this.fontRenderer.drawString(titleText, xPosition + 5, yPosition + 2, titleColour); - this.fontRenderer.drawString(versionText, xPosition + 5, yPosition + 12, GuiModListPanel.VERSION_TEXT_COLOUR); - this.fontRenderer.drawString(statusText, xPosition + 5, yPosition + 22, statusColour); - - this.updateMouseOver(mouseX, mouseY, xPosition, yPosition, width); - int hangerColour = this.mouseOver ? GuiModListPanel.HANGER_COLOUR_MOUSEOVER : GuiModListPanel.HANGER_COLOUR; - drawRect(xPosition, yPosition, xPosition + 1, yPosition + PANEL_HEIGHT, hangerColour); - - for (ModInfoDecorator decorator : this.decorators) - { - decorator.onDrawListEntry(mouseX, mouseY, partialTicks, xPosition, yPosition, width, GuiModListPanel.PANEL_HEIGHT, selected, - this.modInfo, gradientColour, titleColour, statusColour); - } - } - - /** - * @param mouseX - * @param mouseY - * @param xPosition - * @param yPosition - * @param width - */ - protected void updateMouseOver(int mouseX, int mouseY, int xPosition, int yPosition, int width) - { - this.mouseOver = this.isMouseOver(mouseX, mouseY, xPosition, yPosition, width, PANEL_HEIGHT); - } - - protected void postRender(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected) - { - xPosition += (width - 14); - yPosition += (GuiModListPanel.PANEL_HEIGHT - 14); - - this.mouseOverIcon = null; - - for (IconTextured icon : this.modIcons) - { - xPosition = this.drawPropertyIcon(xPosition, yPosition, icon, mouseX, mouseY); - } - } - - protected int drawPropertyIcon(int xPosition, int yPosition, IconTextured icon, int mouseX, int mouseY) - { - glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - Minecraft.getMinecraft().getTextureManager().bindTexture(icon.getTextureResource()); - - glEnableBlend(); - this.drawTexturedModalRect(xPosition, yPosition, icon.getUPos(), icon.getVPos(), icon.getIconWidth(), icon.getIconHeight()); - glDisableBlend(); - - if (mouseX >= xPosition && mouseX <= xPosition + 12 && mouseY >= yPosition && mouseY <= yPosition + 12) - { - String tooltipText = icon.getDisplayText(); - if (tooltipText != null) - { - glDisableClipping(); - GuiLiteLoaderPanel.drawTooltip(this.fontRenderer, tooltipText, mouseX, mouseY, 4096, 4096, GuiModListPanel.WHITE, - GuiModListPanel.BLEND_HALF & GuiModListPanel.BLACK); - glEnableClipping(); - } - - if (icon instanceof IconClickable) this.mouseOverIcon = (IconClickable)icon; - } - - return xPosition - 14; - } - - /** - * @param selected - */ - protected int getGradientColour(boolean selected) - { - return GuiModListPanel.BLEND_2THRDS - & (this.owner.isErrored() - ? (selected ? GuiModListPanel.ERROR_GRADIENT_COLOUR : GuiModListPanel.ERROR_GRADIENT_COLOUR2) - : (selected ? (this.owner.isExternal() ? GuiModListPanel.EXTERNAL_ENTRY_COLOUR : this.brandColour) : GuiModListPanel.BLACK)); - } - - /** - * @param selected - */ - protected int getTitleColour(boolean selected) - { - if (this.owner.isMissingDependencies()) return GuiModListPanel.MISSING_DEPENDENCY_COLOUR; - if (this.owner.isMissingAPIs()) return GuiModListPanel.API_COLOUR; - if (this.owner.isErrored()) return GuiModListPanel.ERROR_COLOUR; - if (!this.owner.isActive()) return GuiModListPanel.GREY; - return this.owner.isExternal() ? GuiModListPanel.EXTERNAL_ENTRY_COLOUR : GuiModListPanel.WHITE; - } - - /** - * @param selected - */ - protected int getStatusColour(boolean selected) - { - return this.owner.isExternal() ? GuiModListPanel.EXTERNAL_ENTRY_COLOUR : this.brandColour; - } - - public boolean isVisible() - { - return true; - } - - public int getSpacing() - { - return GuiModListPanel.PANEL_SPACING; - } - - public int getHeight() - { - return GuiModListPanel.PANEL_HEIGHT; - } - - public int getTotalHeight() - { - return GuiModListPanel.PANEL_HEIGHT + GuiModListPanel.PANEL_SPACING; - } - - protected boolean isMouseOver(int mouseX, int mouseY, int x, int y, int width, int height) - { - return mouseX > x && mouseX < x + width && mouseY > y && mouseY < y + height; - } - - public boolean isMouseOverIcon() - { - return this.mouseOver && this.mouseOverIcon != null; - } - - public boolean isMouseOver() - { - return this.mouseOver; - } - - public void iconClick(Object source) - { - if (this.mouseOverIcon != null) - { - this.mouseOverIcon.onClicked(source, this); - } - } - - public void mousePressed(int mouseX, int mouseY, int mouseButton) - { - this.owner.clearHelpMessage(); - } - - public void displayModHelpMessage(ModInfo mod, String title, String text) - { - this.owner.displayHelpMessage(title, text); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/GuiModListPanelInvalid.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/GuiModListPanelInvalid.java deleted file mode 100644 index 82bee8a6..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/GuiModListPanelInvalid.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.mumfrey.liteloader.client.gui.modlist; - -import java.util.List; - -import net.minecraft.client.gui.FontRenderer; - -import com.mumfrey.liteloader.api.ModInfoDecorator; -import com.mumfrey.liteloader.core.ModInfo; - -public class GuiModListPanelInvalid extends GuiModListPanel -{ - private static final int BAD_PANEL_HEIGHT = 22; - - public GuiModListPanelInvalid(ModListEntry owner, FontRenderer fontRenderer, int brandColour, ModInfo modInfo, - List decorators) - { - super(owner, fontRenderer, brandColour, modInfo, decorators); - } - - @Override - protected void render(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected) - { - int gradientColour = selected ? ERROR_GRADIENT_COLOUR : ERROR_GRADIENT_COLOUR2; - - this.drawGradientRect(xPosition, yPosition, xPosition + width, yPosition + 22, gradientColour, GuiModListPanel.GRADIENT_COLOUR2); - - String titleText = this.owner.getTitleText(); - String reasonText = this.modInfo.getDescription(); - - this.fontRenderer.drawString(titleText, xPosition + 5, yPosition + 2, 0xFF8888); - this.fontRenderer.drawString(reasonText, xPosition + 5, yPosition + 12, GuiModListPanel.ERROR_GRADIENT_COLOUR); - - this.updateMouseOver(mouseX, mouseY, xPosition, yPosition, width); - drawRect(xPosition, yPosition, xPosition + 1, yPosition + 22, ERROR_COLOUR); - } - - @Override - protected void postRender(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, boolean selected) - { - } - - @Override - public int getHeight() - { - return GuiModListPanelInvalid.BAD_PANEL_HEIGHT; - } - - @Override - public int getTotalHeight() - { - return GuiModListPanelInvalid.BAD_PANEL_HEIGHT + GuiModListPanel.PANEL_SPACING; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/ModList.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/ModList.java deleted file mode 100644 index 073ae4a8..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/ModList.java +++ /dev/null @@ -1,273 +0,0 @@ -package com.mumfrey.liteloader.client.gui.modlist; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.resources.I18n; - -import org.lwjgl.input.Keyboard; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.api.ModInfoDecorator; -import com.mumfrey.liteloader.client.gui.GuiLiteLoaderPanel; -import com.mumfrey.liteloader.core.LiteLoaderMods; -import com.mumfrey.liteloader.core.ModInfo; -import com.mumfrey.liteloader.interfaces.Loadable; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.modconfig.ConfigManager; - -public class ModList -{ - private final ModListContainer container; - - private final ConfigManager configManager; - - /** - * List of enumerated mods - */ - private final List mods = new ArrayList(); - - /** - * Currently selected mod - */ - private ModListEntry selectedMod = null; - - private boolean hasConfig = false; - - public ModList(ModListContainer container, Minecraft minecraft, LiteLoaderMods mods, LoaderEnvironment environment, ConfigManager configManager, - int brandColour, List decorators) - { - this.container = container; - this.configManager = configManager; - - this.populate(minecraft, mods, environment, brandColour, decorators); - } - - /** - * @param minecraft - * @param mods - * @param environment - * @param brandColour - * @param decorators - */ - protected void populate(Minecraft minecraft, LiteLoaderMods mods, LoaderEnvironment environment, int brandColour, - List decorators) - { - // Add mods to this treeset first, in order to sort them - Map sortedMods = new TreeMap(); - - // Active mods - for (ModInfo> mod : mods.getLoadedMods()) - { - ModListEntry modListEntry = new ModListEntry(this, mods, environment, minecraft.fontRendererObj, brandColour, decorators, mod); - sortedMods.put(modListEntry.getKey(), modListEntry); - } - - // Disabled mods - for (ModInfo disabledMod : mods.getDisabledMods()) - { - ModListEntry modListEntry = new ModListEntry(this, mods, environment, minecraft.fontRendererObj, brandColour, decorators, disabledMod); - sortedMods.put(modListEntry.getKey(), modListEntry); - } - - // Show bad containers if no other containers are found, should help users realise they have the wrong mod version! - if (sortedMods.size() == 0) - { - for (ModInfo badMod : mods.getBadContainers()) - { - ModListEntry modListEntry = new ModListEntry(this, mods, environment, minecraft.fontRendererObj, brandColour, decorators, badMod); - sortedMods.put(modListEntry.getKey(), modListEntry); - } - } - - // Injected tweaks - for (ModInfo> injectedTweak : mods.getInjectedTweaks()) - { - ModListEntry modListEntry = new ModListEntry(this, mods, environment, minecraft.fontRendererObj, brandColour, decorators, injectedTweak); - sortedMods.put(modListEntry.getKey(), modListEntry); - } - - // Add the sorted mods to the mods list - this.mods.addAll(sortedMods.values()); - - // Select the first mod in the list - if (this.mods.size() > 0) - { - this.selectedMod = this.mods.get(0); - } - } - - public GuiLiteLoaderPanel getParentScreen() - { - return this.container.getParentScreen(); - } - - public LiteMod getSelectedModInstance() - { - return this.selectedMod != null ? this.selectedMod.getModInstance() : null; - } - - public Class getSelectedModClass() - { - return this.selectedMod != null ? this.selectedMod.getModClass() : null; - } - - public void setSize(int width, int height) - { - this.selectMod(this.selectedMod); - } - - public void onTick() - { - for (ModListEntry mod : this.mods) - { - mod.onTick(); - } - } - - public void mousePressed(int mouseX, int mouseY, int mouseButton) - { - ModListEntry lastSelectedMod = this.selectedMod; - - for (ModListEntry mod : this.mods) - { - mod.mousePressed(mouseX, mouseY, mouseButton); - } - - if (this.selectedMod != null && this.selectedMod == lastSelectedMod) - { - this.selectedMod.getInfoPanel().mousePressed(); - } - } - - public boolean keyPressed(char keyChar, int keyCode) - { - if (keyCode == Keyboard.KEY_UP) - { - int selectedIndex = this.mods.indexOf(this.selectedMod) - 1; - if (selectedIndex > -1) this.selectMod(this.mods.get(selectedIndex)); - this.scrollSelectedModIntoView(); - return true; - } - else if (keyCode == Keyboard.KEY_DOWN) - { - int selectedIndex = this.mods.indexOf(this.selectedMod); - if (selectedIndex > -1 && selectedIndex < this.mods.size() - 1) this.selectMod(this.mods.get(selectedIndex + 1)); - this.scrollSelectedModIntoView(); - return true; - } - else if (keyCode == Keyboard.KEY_SPACE - || keyCode == Keyboard.KEY_RETURN - || keyCode == Keyboard.KEY_NUMPADENTER - || keyCode == Keyboard.KEY_RIGHT) - { - this.toggleSelectedMod(); - return true; - } - - return false; - } - - public void mouseReleased(int mouseX, int mouseY, int mouseButton) - { - if (this.selectedMod != null) - { - this.selectedMod.getInfoPanel().mouseReleased(); - } - } - - public boolean mouseWheelScrolled(int mouseWheelDelta) - { - return this.selectedMod != null && this.selectedMod.getInfoPanel().mouseWheelScrolled(mouseWheelDelta); - } - - public int drawModList(int mouseX, int mouseY, float partialTicks, int left, int top, int width, int height) - { - this.drawModListPass(mouseX, mouseY, partialTicks, left, top, width, 0); - return this.drawModListPass(mouseX, mouseY, partialTicks, left, top, width, 1); - } - - protected int drawModListPass(int mouseX, int mouseY, float partialTicks, int left, int top, int width, int pass) - { - int yPos = top; - for (ModListEntry mod : this.mods) - { - GuiModListPanel panel = mod.getListPanel(); - if (panel.isVisible()) - { - if (yPos > 0) yPos += panel.getSpacing(); - panel.draw(mouseX, mouseY, partialTicks, left, yPos, width, mod == this.selectedMod, pass); - yPos += panel.getHeight(); - } - } - return yPos; - } - - public void drawModPanel(int mouseX, int mouseY, float partialTicks, int left, int top, int width, int height) - { - if (this.selectedMod != null) - { - this.selectedMod.getInfoPanel().draw(mouseX, mouseY, partialTicks, left, top, width, height); - } - } - - /** - * @param mod Mod list entry to select - */ - void selectMod(ModListEntry mod) - { - if (this.selectedMod != null) - { - this.selectedMod.getInfoPanel().mouseReleased(); - } - - this.selectedMod = mod; - this.hasConfig = false; - this.container.setEnableButtonVisible(false); - this.container.setConfigButtonVisible(false); - - if (this.selectedMod != null && this.selectedMod.canBeToggled()) - { - this.container.setEnableButtonVisible(true); - this.container.setEnableButtonText(this.selectedMod.willBeEnabled() ? I18n.format("gui.disablemod") : I18n.format("gui.enablemod")); - this.hasConfig = this.configManager.hasPanel(this.selectedMod.getModClass()); - this.container.setConfigButtonVisible(this.hasConfig); - } - } - - /** - * Toggle the selected mod's enabled status - */ - public void toggleSelectedMod() - { - if (this.selectedMod != null) - { - this.selectedMod.toggleEnabled(); - this.selectMod(this.selectedMod); - } - } - - private void scrollSelectedModIntoView() - { - if (this.selectedMod == null) return; - - int yPos = 0; - for (ModListEntry mod : this.mods) - { - if (mod == this.selectedMod) break; - yPos += mod.getListPanel().getTotalHeight(); - } - - int modHeight = this.selectedMod.getListPanel().getTotalHeight(); - this.container.scrollTo(yPos, yPos + modHeight); - } - - public void showConfig(ModListEntry modListEntry) - { - this.container.showConfig(); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/ModListContainer.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/ModListContainer.java deleted file mode 100644 index 4e0011b5..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/ModListContainer.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.mumfrey.liteloader.client.gui.modlist; - -import com.mumfrey.liteloader.client.gui.GuiLiteLoaderPanel; - -public interface ModListContainer -{ - public abstract GuiLiteLoaderPanel getParentScreen(); - - public abstract void setEnableButtonVisible(boolean visible); - - public abstract void setConfigButtonVisible(boolean visible); - - public abstract void setEnableButtonText(String displayString); - - public abstract void showConfig(); - - public abstract void scrollTo(int yPos, int modHeight); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/ModListEntry.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/ModListEntry.java deleted file mode 100644 index 13a28170..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/modlist/ModListEntry.java +++ /dev/null @@ -1,334 +0,0 @@ -package com.mumfrey.liteloader.client.gui.modlist; - -import java.util.List; -import java.util.Set; - -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.resources.I18n; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.api.ModInfoDecorator; -import com.mumfrey.liteloader.core.LiteLoaderMods; -import com.mumfrey.liteloader.core.ModInfo; -import com.mumfrey.liteloader.interfaces.Loadable; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.launch.LoaderEnvironment; - -/** - * Represents a mod in the mod info screen, keeps track of mod information and - * provides methods for displaying the mod in the mod list and drawing the - * selected mod info. - * - * @author Adam Mummery-Smith - */ -public class ModListEntry -{ - private final ModList modList; - - private final LiteLoaderMods mods; - - private final ModInfo modInfo; - - private GuiModListPanel listPanel; - - private GuiModInfoPanel infoPanel; - - /** - * Whether the mod is currently active - */ - private boolean isActive; - - private boolean isValid; - - private boolean isMissingDependencies; - - private boolean isMissingAPIs; - - private boolean isErrored; - - /** - * True if the mod is missing a dependency which has caused it not to load - */ - private Set missingDependencies; - - /** - * True if the mod is missing an API which has caused it not to load - */ - private Set missingAPIs; - - /** - * Whether the mod can be toggled, not all mods support this, eg. internal - * mods - */ - private boolean canBeToggled; - - /** - * Whether the mod WILL be enabled on the next startup, if the mod is active - * and has been disabled this will be false, and if it's currently disabled - * by has been toggled then it will be true. - */ - private boolean willBeEnabled; - - /** - * True if this is not a mod but an external jar - */ - private boolean isExternal; - - /** - * Timer used to handle double-clicking on a mod - */ - private int doubleClickTime = 0; - - /** - * @param modList - * @param mods - * @param environment - * @param fontRenderer - * @param brandColour - * @param decorators - * @param modInfo - */ - ModListEntry(ModList modList, LiteLoaderMods mods, LoaderEnvironment environment, FontRenderer fontRenderer, int brandColour, - List decorators, ModInfo modInfo) - { - this.modList = modList; - this.mods = mods; - this.modInfo = modInfo; - - this.isActive = modInfo.isActive(); - this.isValid = modInfo.isValid(); - this.canBeToggled = modInfo.isToggleable() && mods.getEnabledModsList().saveAllowed(); - this.willBeEnabled = mods.isModEnabled(this.modInfo.getIdentifier()); - this.isExternal = modInfo.getContainer().isExternalJar(); - this.isErrored = modInfo.getStartupErrors() != null && modInfo.getStartupErrors().size() > 0; - - if (!modInfo.isActive() && this.isValid) - { - this.isActive = modInfo.getContainer().isEnabled(environment); - - Loadable modContainer = modInfo.getContainer(); - if (modContainer instanceof LoadableMod) - { - LoadableMod loadableMod = (LoadableMod)modContainer; - - this.missingDependencies = loadableMod.getMissingDependencies(); - this.missingAPIs = loadableMod.getMissingAPIs(); - this.isMissingDependencies = this.missingDependencies.size() > 0; - this.isMissingAPIs = this.missingAPIs.size() > 0; - } - } - - this.initPanels(fontRenderer, brandColour, decorators, modInfo); - } - - /** - * @param fontRenderer - * @param brandColour - * @param decorators - * @param modInfo - */ - protected void initPanels(FontRenderer fontRenderer, int brandColour, List decorators, ModInfo modInfo) - { - this.infoPanel = new GuiModInfoPanel(this, fontRenderer, brandColour, modInfo); - - if (this.isValid) - { - this.listPanel = new GuiModListPanel(this, fontRenderer, brandColour, modInfo, decorators); - } - else - { - this.listPanel = new GuiModListPanelInvalid(this, fontRenderer, brandColour, modInfo, decorators); - } - } - - public void onTick() - { - if (this.doubleClickTime > 0) - { - this.doubleClickTime--; - } - } - - public void mousePressed(int mouseX, int mouseY, int mouseButton) - { - if (this.getListPanel().isMouseOver()) - { - this.modList.selectMod(this); - - if (this.getListPanel().isMouseOver()) - { - this.getListPanel().mousePressed(mouseX, mouseY, mouseButton); - } - - if (this.getListPanel().isMouseOverIcon()) - { - this.getListPanel().iconClick(this.modList.getParentScreen()); - } - else - { - // handle double-click - if (this.doubleClickTime > 0) - { - this.onDoubleClicked(); - } - } - - this.doubleClickTime = 5; - } - } - - protected void onDoubleClicked() - { - this.modList.showConfig(this); - } - - protected String getTitleText() - { - return this.modInfo.getDisplayName(); - } - - protected String getVersionText() - { - return I18n.format("gui.about.versiontext", this.modInfo.getVersion()); - } - - protected String getStatusText() - { - String statusText = this.isExternal ? I18n.format("gui.status.loaded") : I18n.format("gui.status.active"); - - if (this.isMissingAPIs) - { - statusText = "\2475" + I18n.format("gui.status.missingapis"); - if (this.canBeToggled && !this.willBeEnabled) statusText = "\247c" + I18n.format("gui.status.pending.disabled"); - } - else if (this.isMissingDependencies) - { - statusText = "\247e" + I18n.format("gui.status.missingdeps"); - if (this.canBeToggled && !this.willBeEnabled) statusText = "\247c" + I18n.format("gui.status.pending.disabled"); - } - else if (this.isErrored) - { - statusText = "\247c" + I18n.format("gui.status.startuperror"); - } - else if (this.canBeToggled) - { - if (!this.isActive && !this.willBeEnabled) statusText = "\2477" + I18n.format("gui.status.disabled"); - if (!this.isActive && this.willBeEnabled) statusText = "\247a" + I18n.format("gui.status.pending.enabled"); - if ( this.isActive && !this.willBeEnabled) statusText = "\247c" + I18n.format("gui.status.pending.disabled"); - } - - return statusText; - } - - /** - * Toggle the enablement status of this mod, if supported - */ - public void toggleEnabled() - { - if (this.canBeToggled) - { - this.willBeEnabled = !this.willBeEnabled; - this.mods.setModEnabled(this.modInfo.getIdentifier(), this.willBeEnabled); - } - } - - protected void displayHelpMessage(String title, String text) - { - this.infoPanel.displayHelpMessage(title, text); - } - - public void clearHelpMessage() - { - this.infoPanel.clearHelpMessage(); - } - - public String getKey() - { - return (this.isErrored ? "0000" : "") + this.modInfo.getIdentifier() + Integer.toHexString(this.hashCode()); - } - - public ModInfo getModInfo() - { - return this.modInfo; - } - - public LiteMod getModInstance() - { - return this.modInfo.getMod(); - } - - public Class getModClass() - { - return this.modInfo.getModClass(); - } - - public String getName() - { - return this.modInfo.getDisplayName(); - } - - public String getVersion() - { - return this.modInfo.getVersion(); - } - - public String getAuthor() - { - return this.modInfo.getAuthor(); - } - - public String getDescription() - { - return this.modInfo.getDescription(); - } - - public boolean isEnabled() - { - return this.isActive; - } - - public boolean canBeToggled() - { - return this.canBeToggled; - } - - public boolean willBeEnabled() - { - return this.willBeEnabled; - } - - public boolean isActive() - { - return this.isActive; - } - - public boolean isErrored() - { - return this.isErrored; - } - - public boolean isExternal() - { - return this.isExternal; - } - - public boolean isMissingAPIs() - { - return this.isMissingAPIs; - } - - public boolean isMissingDependencies() - { - return this.isMissingDependencies; - } - - public GuiModListPanel getListPanel() - { - return this.listPanel; - } - - public GuiModInfoPanel getInfoPanel() - { - return this.infoPanel; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/startup/LoadingBar.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/startup/LoadingBar.java deleted file mode 100644 index 155414f1..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/gui/startup/LoadingBar.java +++ /dev/null @@ -1,440 +0,0 @@ -package com.mumfrey.liteloader.client.gui.startup; - -import static com.mumfrey.liteloader.gl.GL.*; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; - -import javax.imageio.ImageIO; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.texture.DynamicTexture; -import net.minecraft.client.renderer.texture.ITextureObject; -import net.minecraft.client.renderer.texture.TextureManager; -import net.minecraft.client.resources.IResource; -import net.minecraft.client.resources.IResourceManager; -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.util.ResourceLocation; - -import org.lwjgl.opengl.Display; - -import com.mumfrey.liteloader.common.LoadingProgress; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Crappy implementation of a "Mojang Screen" loading bar - * - * @author Adam Mummery-Smith - */ -public class LoadingBar extends LoadingProgress -{ - private static LoadingBar instance; - - private static final String LOADING_MESSAGE_1 = "Starting Game..."; - private static final String LOADING_MESSAGE_2 = "Initialising..."; - - private int minecraftProgress = 0; - private int totalMinecraftProgress = 606; - - private int liteLoaderProgressScale = 3; - - private int liteLoaderProgress = 0; - private int totalLiteLoaderProgress = 0; - - private ResourceLocation textureLocation = new ResourceLocation("textures/gui/title/mojang.png"); - - private String minecraftMessage = LoadingBar.LOADING_MESSAGE_1; - private String message = ""; - - private Minecraft minecraft; - private TextureManager textureManager; - private FontRenderer fontRenderer; - - private Framebuffer fbo; - - private boolean enabled = true; - private boolean errored; - - private boolean calculatedColour = false; - private int barLuma = 0, r2 = 246, g2 = 136, b2 = 62; - - private int logIndex = 0; - private List logTail = new ArrayList(); - - public LoadingBar() - { - LoadingBar.instance = this; - } - - @Override - protected void _setEnabled(boolean enabled) - { - this.enabled = enabled; - } - - @Override - protected void _dispose() - { - this.minecraft = null; - this.textureManager = null; - this.fontRenderer = null; - - this.disposeFbo(); - } - - private void disposeFbo() - { - if (this.fbo != null) - { - this.fbo.deleteFramebuffer(); - this.fbo = null; - } - } - - public static void incrementProgress() - { - if (LoadingBar.instance != null) LoadingBar.instance._incrementProgress(); - } - - protected void _incrementProgress() - { - this.message = this.minecraftMessage; - - this.minecraftProgress++; - this.render(); - } - - public static void initTextures() - { - if (LoadingBar.instance != null) LoadingBar.instance._initTextures(); - } - - protected void _initTextures() - { - this.minecraftMessage = LoadingBar.LOADING_MESSAGE_2; - } - - @Override - protected void _incLiteLoaderProgress() - { - this.liteLoaderProgress += this.liteLoaderProgressScale; - this.render(); - } - - @Override - protected void _setMessage(String message) - { - this.message = message; - this.render(); - } - - @Override - protected void _incLiteLoaderProgress(String message) - { - this.message = message; - this.liteLoaderProgress += this.liteLoaderProgressScale ; - this.render(); - } - - @Override - protected void _incTotalLiteLoaderProgress(int by) - { - this.totalLiteLoaderProgress += (by * this.liteLoaderProgressScale); - this.render(); - } - - /** - * - */ - private void render() - { - if (!this.enabled || this.errored) return; - - try - { - if (this.minecraft == null) this.minecraft = Minecraft.getMinecraft(); - if (this.textureManager == null) this.textureManager = this.minecraft.getTextureManager(); - - if (Display.isCreated() && this.textureManager != null) - { - if (this.fontRenderer == null) - { - this.fontRenderer = new FontRenderer(this.minecraft.gameSettings, new ResourceLocation("textures/font/ascii.png"), - this.textureManager, false); - this.fontRenderer.onResourceManagerReload(this.minecraft.getResourceManager()); - } - - double totalProgress = this.totalMinecraftProgress + this.totalLiteLoaderProgress; - double progress = (this.minecraftProgress + this.liteLoaderProgress) / totalProgress; - -// if (progress >= 1.0) LoadingBar.message = "Preparing..."; - - this.render(progress); - } - } - catch (Exception ex) - { - // Disable the loading bar if ANY errors occur - this.errored = true; - } - } - - /** - * @param progress - */ - private void render(double progress) - { - if (this.totalMinecraftProgress == -1) - { - this.totalMinecraftProgress = 606 - this.minecraftProgress; - this.minecraftProgress = 0; - } - - // Calculate the bar colour if we haven't already done that - if (!this.calculatedColour) - { - this.calculatedColour = true; - ITextureObject texture = this.textureManager.getTexture(this.textureLocation); - if (texture == null) - { - try - { - DynamicTexture textureData = this.loadTexture(this.minecraft.getResourceManager(), this.textureLocation); - this.textureLocation = this.minecraft.getTextureManager().getDynamicTextureLocation("loadingScreen", textureData); - this.findMostCommonColour(textureData.getTextureData()); - textureData.updateDynamicTexture(); - } - catch (IOException ex) - { - ex.printStackTrace(); - } - } - } - - ScaledResolution scaledResolution = new ScaledResolution(this.minecraft, this.minecraft.displayWidth, this.minecraft.displayHeight); - int scaleFactor = scaledResolution.getScaleFactor(); - int scaledWidth = scaledResolution.getScaledWidth(); - int scaledHeight = scaledResolution.getScaledHeight(); - - int fboWidth = scaledWidth * scaleFactor; - int fboHeight = scaledHeight * scaleFactor; - - if (this.fbo == null) - { - this.fbo = new Framebuffer(fboWidth, fboHeight, true); - } - else if (this.fbo.framebufferWidth != fboWidth || this.fbo.framebufferHeight != fboHeight) - { - this.fbo.createBindFramebuffer(fboWidth, fboHeight); - } - - this.fbo.bindFramebuffer(false); - - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0.0D, scaledWidth, scaledHeight, 0.0D, 1000.0D, 3000.0D); - - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - glTranslatef(0.0F, 0.0F, -2000.0F); - - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - - glDisableLighting(); - glDisableFog(); - glDisableDepthTest(); - glEnableTexture2D(); - - this.textureManager.bindTexture(this.textureLocation); - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldRenderer = tessellator.getWorldRenderer(); - worldRenderer.startDrawingQuads(); - worldRenderer.setColorOpaque_I(0xFFFFFFFF); // TODO OBF MCPTEST func_178991_c - setColorOpaque_I - worldRenderer.addVertexWithUV(0.0D, scaledHeight, 0.0D, 0.0D, 0.0D); - worldRenderer.addVertexWithUV(scaledWidth, scaledHeight, 0.0D, 0.0D, 0.0D); - worldRenderer.addVertexWithUV(scaledWidth, 0.0D, 0.0D, 0.0D, 0.0D); - worldRenderer.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D); - tessellator.draw(); - - glColor4f(1.0F, 1.0F, 1.0F, 1.0F); - - int left = (scaledWidth - 256) / 2; - int top = (scaledHeight - 256) / 2; - int u1 = 0; - int v1 = 0; - int u2 = 256; - int v2 = 256; - - float texMapScale = 0.00390625F; - worldRenderer.startDrawingQuads(); - worldRenderer.setColorOpaque_I(0xFFFFFFFF); // TODO OBF MCPTEST func_178991_c - setColorOpaque_I - worldRenderer.addVertexWithUV(left + 0, top + v2, 0.0D, (u1 + 0) * texMapScale, (v1 + v2) * texMapScale); - worldRenderer.addVertexWithUV(left + u2, top + v2, 0.0D, (u1 + u2) * texMapScale, (v1 + v2) * texMapScale); - worldRenderer.addVertexWithUV(left + u2, top + 0, 0.0D, (u1 + u2) * texMapScale, (v1 + 0) * texMapScale); - worldRenderer.addVertexWithUV(left + 0, top + 0, 0.0D, (u1 + 0) * texMapScale, (v1 + 0) * texMapScale); - tessellator.draw(); - - glEnableTexture2D(); - glEnableColorLogic(); - glLogicOp(GL_OR_REVERSE); - this.fontRenderer.drawString(this.message, 1, scaledHeight - 19, 0xFF000000); - - if (LiteLoaderLogger.DEBUG) - { - int logBottom = this.minecraft.displayHeight - (20 * scaleFactor) - 2; - - glPushMatrix(); - glScalef(1.0F / scaleFactor, 1.0F / scaleFactor, 1.0F); - this.renderLogTail(logBottom); - glPopMatrix(); - } - - glDisableColorLogic(); - glEnableTexture2D(); - - double barHeight = 10.0D; - - double barWidth = scaledResolution.getScaledWidth_double() - 2.0D; - - glDisableTexture2D(); - glEnableBlend(); - glEnableAlphaTest(); - glAlphaFunc(GL_GREATER, 0.0F); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - -// tessellator.startDrawingQuads(); -// tessellator.setColorRGBA(0, 0, 0, 32); -// tessellator.addVertex(0.0D, scaledHeight, 0.0D); -// tessellator.setColorRGBA(0, 0, 0, 180); -// tessellator.addVertex(0.0D + scaledWidth, scaledHeight, 0.0D); -// tessellator.setColorRGBA(0, 0, 0, 0); -// tessellator.addVertex(0.0D + scaledWidth, (scaledHeight / 10), 0.0D); -// tessellator.addVertex(0.0D, scaledHeight - (scaledHeight / 3), 0.0D); -// tessellator.draw(); - - worldRenderer.startDrawingQuads(); - worldRenderer.setColorRGBA(this.barLuma, this.barLuma, this.barLuma, 128); // TODO OBF MCPTEST func_178961_b - setColorRGBA - worldRenderer.addVertex(0.0D, scaledHeight, 0.0D); - worldRenderer.addVertex(0.0D + scaledWidth, scaledHeight, 0.0D); - worldRenderer.addVertex(0.0D + scaledWidth, scaledHeight - barHeight, 0.0D); - worldRenderer.addVertex(0.0D, scaledHeight - barHeight, 0.0D); - tessellator.draw(); - - barHeight -= 1; - - worldRenderer.startDrawingQuads(); - worldRenderer.setColorRGBA(this.r2, this.g2, this.b2, 255); // TODO OBF MCPTEST func_178961_b - setColorRGBA - worldRenderer.addVertex(1.0D + barWidth * progress, scaledHeight - 1, 1.0D); - worldRenderer.addVertex(1.0D + barWidth * progress, scaledHeight - barHeight, 1.0D); - worldRenderer.setColorRGBA(0, 0, 0, 255); // TODO OBF MCPTEST func_178961_b - setColorRGBA - worldRenderer.addVertex(1.0D, scaledHeight - barHeight, 1.0D); - worldRenderer.addVertex(1.0D, scaledHeight - 1, 1.0D); - tessellator.draw(); - - glAlphaFunc(GL_GREATER, 0.1F); - glDisableLighting(); - glDisableFog(); - this.fbo.unbindFramebuffer(); - - this.fbo.framebufferRender(fboWidth, fboHeight); - - glEnableAlphaTest(); - glAlphaFunc(GL_GREATER, 0.1F); -// glFlush(); - - this.minecraft.updateDisplay(); // TODO OBF MCPTEST updateDisplay - func_175601_h - } - - private void renderLogTail(int yPos) - { - if (this.logIndex != LiteLoaderLogger.getLogIndex()) - { - this.logTail = LiteLoaderLogger.getLogTail(); - } - - for (int logIndex = this.logTail.size() - 1; yPos > 10 && logIndex >= 0; logIndex--) - { - this.fontRenderer.drawString(this.logTail.get(logIndex), 10, yPos -= 10, 0xFF000000); - } - } - - /** - * Find the most common (approx) colour in the image and assign it to the - * bar, reduces the palette to 9-bit by stripping the the 5 LSB from each - * byte to create a 9-bit palette index in the form RRRGGGBBB - * - * @param textureData - */ - private void findMostCommonColour(int[] textureData) - { - // Array of frequency values, indexed by palette index - int[] freq = new int[512]; - - for (int pos = 0; pos < textureData.length; pos++) - { - int paletteIndex = ((textureData[pos] >> 21 & 0x7) << 6) + ((textureData[pos] >> 13 & 0x7) << 3) + (textureData[pos] >> 5 & 0x7); - freq[paletteIndex]++; - } - - int peak = 0; - - // Black, white and 0x200000 excluded on purpose - for (int paletteIndex = 2; paletteIndex < 511; paletteIndex++) - { - if (freq[paletteIndex] > peak) - { - peak = freq[paletteIndex]; - this.setBarColour(paletteIndex); - } - } - } - - /** - * @param paletteIndex - */ - private void setBarColour(int paletteIndex) - { - this.r2 = this.padComponent((paletteIndex & 0x1C0) >> 1); - this.g2 = this.padComponent((paletteIndex & 0x38) << 2); - this.b2 = this.padComponent((paletteIndex & 0x7) << 5); - - this.barLuma = (Math.max(this.r2, Math.max(this.g2, this.b2)) < 64) ? 255 : 0; - } - - /** - * Pad LSB with 1's if any MSB are 1 (effectively a bitwise ceil() function) - * - * @param component - */ - private int padComponent(int component) - { - return (component > 0x1F) ? component | 0x1F : component; - } - - private DynamicTexture loadTexture(IResourceManager resourceManager, ResourceLocation textureLocation) throws IOException - { - InputStream inputStream = null; - - try - { - IResource resource = resourceManager.getResource(textureLocation); - inputStream = resource.getInputStream(); - BufferedImage image = ImageIO.read(inputStream); - return new DynamicTexture(image); - } - finally - { - if (inputStream != null) - { - inputStream.close(); - } - } - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinEntityPlayerSP.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinEntityPlayerSP.java deleted file mode 100644 index 5522cf0c..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinEntityPlayerSP.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.mumfrey.liteloader.client.ClientProxy; - -import net.minecraft.client.entity.AbstractClientPlayer; -import net.minecraft.client.entity.EntityPlayerSP; - -@Mixin(EntityPlayerSP.class) -public abstract class MixinEntityPlayerSP extends AbstractClientPlayer -{ - public MixinEntityPlayerSP() - { - super(null, null); - } - - @Inject(method = "sendChatMessage(Ljava/lang/String;)V", at = { @At("HEAD") }, cancellable = true) - public void onSendChatMessage(String message, CallbackInfo ci) - { - ClientProxy.onOutboundChat(ci, message); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinEntityRenderer.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinEntityRenderer.java deleted file mode 100644 index 94fea707..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinEntityRenderer.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.At.Shift; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.mumfrey.liteloader.client.ClientProxy; - -import net.minecraft.client.renderer.EntityRenderer; -import net.minecraft.client.renderer.RenderGlobal; - -@Mixin(EntityRenderer.class) -public abstract class MixinEntityRenderer -{ - @Inject(method = "updateCameraAndRender(F)V", at = @At( - value = "INVOKE", - shift = Shift.AFTER, - target = "Lnet/minecraft/client/renderer/GlStateManager;clear(I)V" - )) - private void onPreRenderGUI(float partialTicks, CallbackInfo ci) - { - ClientProxy.preRenderGUI(partialTicks); - } - - @Inject(method = "updateCameraAndRender(F)V", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/gui/GuiIngame;renderGameOverlay(F)V" - )) - private void onRenderHUD(float partialTicks, CallbackInfo ci) - { - ClientProxy.onRenderHUD(partialTicks); - } - - @Inject(method = "updateCameraAndRender(F)V", at = @At( - value = "INVOKE", - shift = Shift.AFTER, - target = "Lnet/minecraft/client/gui/GuiIngame;renderGameOverlay(F)V" - )) - private void onPostRenderHUD(float partialTicks, CallbackInfo ci) - { - ClientProxy.postRenderHUD(partialTicks); - } - - @Inject(method = "renderWorld(FJ)V", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/profiler/Profiler;startSection(Ljava/lang/String;)V", - ordinal = 0 - )) - private void onRenderWorld(float partialTicks, long timeSlice, CallbackInfo ci) - { - ClientProxy.onRenderWorld(partialTicks, timeSlice); - } - - @Inject(method = "renderWorld(FJ)V", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/profiler/Profiler;endSection()V", - ordinal = 0 - )) - private void onPostRender(float partialTicks, long timeSlice, CallbackInfo ci) - { - ClientProxy.postRender(partialTicks, timeSlice); - } - - @Inject(method = "renderWorldPass(IFJ)V", at = @At( - value = "INVOKE_STRING", - target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V", - args = "ldc=frustum" - )) - private void onSetupCameraTransform(int pass, float partialTicks, long timeSlice, CallbackInfo ci) - { - ClientProxy.onSetupCameraTransform(pass, partialTicks, timeSlice); - } - - @Inject(method = "renderWorldPass(IFJ)V", at = @At( - value = "INVOKE_STRING", - target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V", - args = "ldc=sky" - )) - private void onRenderSky(int pass, float partialTicks, long timeSlice, CallbackInfo ci) - { - ClientProxy.onRenderSky(pass, partialTicks, timeSlice); - } - - @Inject(method = "renderWorldPass(IFJ)V", at = @At( - value = "INVOKE_STRING", - target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V", - args = "ldc=terrain" - )) - private void onRenderTerrain(int pass, float partialTicks, long timeSlice, CallbackInfo ci) - { - ClientProxy.onRenderTerrain(pass, partialTicks, timeSlice); - - } - - @Inject(method = "renderWorldPass(IFJ)V", at = @At( - value = "INVOKE_STRING", - target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V", - args = "ldc=litParticles" - )) - private void onPostRenderEntities(int pass, float partialTicks, long timeSlice, CallbackInfo ci) - { - ClientProxy.postRenderEntities(pass, partialTicks, timeSlice); - } - - @Inject(method = "renderCloudsCheck(Lnet/minecraft/client/renderer/RenderGlobal;FI)V", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V" - )) - private void onRenderClouds(RenderGlobal renderGlobalIn, float partialTicks, int pass, CallbackInfo ci) - { - ClientProxy.onRenderClouds(renderGlobalIn, partialTicks, pass); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinFramebuffer.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinFramebuffer.java deleted file mode 100644 index 96fd89b6..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinFramebuffer.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.mumfrey.liteloader.client.ClientProxy; -import com.mumfrey.liteloader.client.ducks.IFramebuffer; - -import net.minecraft.client.shader.Framebuffer; - -@Mixin(Framebuffer.class) -public abstract class MixinFramebuffer implements IFramebuffer -{ - private boolean dispatchRenderEvent; - - @Override - public IFramebuffer setDispatchRenderEvent(boolean dispatchRenderEvent) - { - this.dispatchRenderEvent = dispatchRenderEvent; - return this; - } - - @Override - public boolean isDispatchRenderEvent() - { - return this.dispatchRenderEvent; - } - - @Inject(method = "framebufferRenderExt(IIZ)V", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/shader/Framebuffer;bindFramebufferTexture()V" - )) - private void onRenderFBO(int width, int height, boolean flag, CallbackInfo ci) - { - if (this.dispatchRenderEvent) - { - ClientProxy.renderFBO((Framebuffer)(Object)this, width, height, flag); - this.dispatchRenderEvent = false; - } - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinGuiIngame.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinGuiIngame.java deleted file mode 100644 index 0f2cedb4..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinGuiIngame.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.At.Shift; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.mumfrey.liteloader.client.ClientProxy; - -import net.minecraft.client.gui.Gui; -import net.minecraft.client.gui.GuiIngame; -import net.minecraft.client.gui.GuiNewChat; - -@Mixin(GuiIngame.class) -public abstract class MixinGuiIngame extends Gui -{ - @Shadow private GuiNewChat persistantChatGUI; - - @Inject(method = "renderGameOverlay(F)V", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/gui/GuiNewChat;drawChat(I)V" - )) - private void onRenderChat(float partialTicks, CallbackInfo ci) - { - ClientProxy.onRenderChat(this.persistantChatGUI, partialTicks); - } - - @Inject(method = "renderGameOverlay(F)V", at = @At( - value = "INVOKE", - shift = Shift.AFTER, - target = "Lnet/minecraft/client/gui/GuiNewChat;drawChat(I)V" - )) - private void postRenderChat(float partialTicks, CallbackInfo ci) - { - ClientProxy.postRenderChat(this.persistantChatGUI, partialTicks); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinIntegratedServer.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinIntegratedServer.java deleted file mode 100644 index 486719fb..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinIntegratedServer.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Surrogate; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.mumfrey.liteloader.client.ClientProxy; - -import net.minecraft.client.Minecraft; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.integrated.IntegratedServer; -import net.minecraft.world.WorldSettings; - -@Mixin(IntegratedServer.class) -public abstract class MixinIntegratedServer extends MinecraftServer -{ - public MixinIntegratedServer() - { - super(null, null); - } - - @Inject( - method = "*", //(Lnet/minecraft/client/Minecraft;Ljava/lang/String;Ljava/lang/String;Lnet/minecraft/world/WorldSettings;)V", - at = @At("RETURN"), - remap = false - ) - private void onConstructed(Minecraft mcIn, String folderName, String worldName, WorldSettings settings, CallbackInfo ci) - { - ClientProxy.onCreateIntegratedServer((IntegratedServer)(Object)this, folderName, worldName, settings); - } - - @Surrogate - private void onConstructed(Minecraft mcIn, CallbackInfo ci) - { -// ClientProxy.onCreateIntegratedServer((IntegratedServer)(Object)this, folderName, worldName, settings); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinMinecraft.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinMinecraft.java deleted file mode 100644 index f7ab0d86..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinMinecraft.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.At.Shift; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.mumfrey.liteloader.client.ClientProxy; - -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.OpenGlHelper; -import net.minecraft.client.shader.Framebuffer; - -@Mixin(Minecraft.class) -public abstract class MixinMinecraft -{ - @Inject(method = "startGame()V", at = @At("RETURN")) - private void onStartupComplete(CallbackInfo ci) - { - ClientProxy.onStartupComplete(); - } - - @Inject(method = "updateFramebufferSize()V", at = @At("HEAD")) - private void onResize(CallbackInfo ci) - { - ClientProxy.onResize((Minecraft)(Object)this); - } - - @Inject(method = "runTick()V", at = @At("HEAD")) - private void newTick(CallbackInfo ci) - { - ClientProxy.newTick(); - } - - @Inject(method = "runGameLoop()V", at = @At( - value = "INVOKE", - shift = Shift.AFTER, - target = "Lnet/minecraft/client/renderer/EntityRenderer;updateCameraAndRender(F)V" - )) - private void onTick(CallbackInfo ci) - { - ClientProxy.onTick(); - } - - @Redirect(method = "runGameLoop()V", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/shader/Framebuffer;framebufferRender(II)V" - )) - private void renderFBO(Framebuffer framebufferMc, int width, int height) - { - boolean fboEnabled = OpenGlHelper.isFramebufferEnabled(); - if (fboEnabled) - { - ClientProxy.preRenderFBO(framebufferMc); - framebufferMc.framebufferRender(width, height); - ClientProxy.preRenderFBO(framebufferMc); - } - else - { - framebufferMc.framebufferRender(width, height); - } - } - - @Inject(method = "runGameLoop()V", at = @At( - value = "INVOKE_STRING", - target = "Lnet/minecraft/profiler/Profiler;startSection(Ljava/lang/String;)V", - args = "ldc=tick" - )) - private void onTimerUpdate(CallbackInfo ci) - { - ClientProxy.onTimerUpdate(); - } - - @Inject (method = "runGameLoop()V", at = @At( - value = "INVOKE_STRING", - target = "Lnet/minecraft/profiler/Profiler;endStartSection(Ljava/lang/String;)V", - args = "ldc=gameRenderer" - )) - private void onRender(CallbackInfo ci) - { - ClientProxy.onRender(); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinNetHandlerLoginClient.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinNetHandlerLoginClient.java deleted file mode 100644 index 4de0048f..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinNetHandlerLoginClient.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import com.mumfrey.liteloader.client.ducks.IClientNetLoginHandler; - -import net.minecraft.client.network.NetHandlerLoginClient; -import net.minecraft.network.NetworkManager; - -@Mixin(NetHandlerLoginClient.class) -public abstract class MixinNetHandlerLoginClient implements IClientNetLoginHandler -{ - @Shadow private NetworkManager networkManager; - - @Override - public NetworkManager getNetMgr() - { - return this.networkManager; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinObjectIntIdentityMap.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinObjectIntIdentityMap.java deleted file mode 100644 index 53c20bc4..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinObjectIntIdentityMap.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import java.util.IdentityHashMap; -import java.util.List; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import com.mumfrey.liteloader.client.ducks.IObjectIntIdentityMap; - -import net.minecraft.util.ObjectIntIdentityMap; - -@Mixin(ObjectIntIdentityMap.class) -public abstract class MixinObjectIntIdentityMap implements IObjectIntIdentityMap -{ - @Shadow private IdentityHashMap identityMap; - @Shadow private List objectList; - - @SuppressWarnings("unchecked") - @Override - public IdentityHashMap getIdentityMap() - { - return (IdentityHashMap)this.identityMap; - } - - @SuppressWarnings("unchecked") - @Override - public List getObjectList() - { - return (List)this.objectList; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRealmsMainScreen.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRealmsMainScreen.java deleted file mode 100644 index 8c8ce8e4..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRealmsMainScreen.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; - -import com.mojang.realmsclient.RealmsMainScreen; -import com.mojang.realmsclient.dto.RealmsServer; -import com.mumfrey.liteloader.client.PacketEventsClient; - -import net.minecraft.realms.RealmsScreen; - -@Mixin(value = RealmsMainScreen.class, remap = false) -public abstract class MixinRealmsMainScreen extends RealmsScreen -{ - @Inject(method = "play(J)V", locals = LocalCapture.CAPTURE_FAILSOFT, at = @At( - value = "INVOKE", - target = "Lcom/mojang/realmsclient/RealmsMainScreen;stopRealmsFetcherAndPinger()V" - )) - private void onJoinRealm(long serverId, CallbackInfo ci, RealmsServer server) - { - PacketEventsClient.onJoinRealm(serverId, server); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRegistryNamespaced.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRegistryNamespaced.java deleted file mode 100644 index 71f41b53..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRegistryNamespaced.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import com.mumfrey.liteloader.client.ducks.INamespacedRegistry; -import com.mumfrey.liteloader.client.ducks.IObjectIntIdentityMap; - -import net.minecraft.util.ObjectIntIdentityMap; -import net.minecraft.util.RegistryNamespaced; -import net.minecraft.util.RegistrySimple; - -@Mixin(RegistryNamespaced.class) -public abstract class MixinRegistryNamespaced extends RegistrySimple implements INamespacedRegistry -{ - @Shadow protected ObjectIntIdentityMap underlyingIntegerMap; - - @Override - public IObjectIntIdentityMap getUnderlyingMap() - { - return (IObjectIntIdentityMap)this.underlyingIntegerMap; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRegistrySimple.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRegistrySimple.java deleted file mode 100644 index 313d909d..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRegistrySimple.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import java.util.Map; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import com.mumfrey.liteloader.client.ducks.IRegistrySimple; - -import net.minecraft.util.RegistrySimple; - -@Mixin(RegistrySimple.class) -public abstract class MixinRegistrySimple implements IRegistrySimple -{ - @Shadow protected Map registryObjects; - - @SuppressWarnings("unchecked") - @Override - public Map getRegistryObjects() - { - return (Map)this.registryObjects; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRenderManager.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRenderManager.java deleted file mode 100644 index 6a1fe6de..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinRenderManager.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import java.util.Map; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; - -import com.mumfrey.liteloader.client.ClientProxy; -import com.mumfrey.liteloader.client.ducks.IRenderManager; - -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.entity.Entity; - -@Mixin(RenderManager.class) -public abstract class MixinRenderManager implements IRenderManager -{ - @Shadow private Map, Render> entityRenderMap; - - @Override - public Map, Render> getRenderMap() - { - return this.entityRenderMap; - } - - @Redirect(method = "doRenderEntity(Lnet/minecraft/entity/Entity;DDDFFZ)Z", at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/entity/Render;doRender(Lnet/minecraft/entity/Entity;DDDFF)V" - )) - private void onRenderEntity(Render render, Entity entity, double x, double y, double z, float entityYaw, float partialTicks) - { - RenderManager source = (RenderManager)(Object)this; - ClientProxy.onRenderEntity(source, render, entity, x, y, z, entityYaw, partialTicks); - render.doRender(entity, x, y, z, entityYaw, partialTicks); - ClientProxy.onPostRenderEntity(source, render, entity, x, y, z, entityYaw, partialTicks); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinScreenShotHelper.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinScreenShotHelper.java deleted file mode 100644 index e809a497..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinScreenShotHelper.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import java.io.File; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import com.mumfrey.liteloader.client.ClientProxy; - -import net.minecraft.client.shader.Framebuffer; -import net.minecraft.util.IChatComponent; -import net.minecraft.util.ScreenShotHelper; - -@Mixin(ScreenShotHelper.class) -public abstract class MixinScreenShotHelper -{ - @Inject( - method = "saveScreenshot(Ljava/io/File;Ljava/lang/String;IILnet/minecraft/client/shader/Framebuffer;)Lnet/minecraft/util/IChatComponent;", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/renderer/OpenGlHelper;isFramebufferEnabled()Z", - ordinal = 0 - ), - cancellable = true - ) - private static void onSaveScreenshot(File gameDir, String name, int width, int height, Framebuffer fbo, CallbackInfoReturnable ci) - { - ClientProxy.onSaveScreenshot(ci, gameDir, name, width, height, fbo); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinSession.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinSession.java deleted file mode 100644 index 78615edf..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinSession.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import java.util.UUID; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import com.mojang.authlib.GameProfile; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.util.Session; - -@Mixin(Session.class) -public abstract class MixinSession -{ - @Shadow public abstract String getUsername(); - - @Inject(method = "getProfile()Lcom/mojang/authlib/GameProfile;", cancellable = true, at = @At( - value = "NEW", - args = "class=com/mojang/authlib/GameProfile", - ordinal = 1 - )) - private void generateGameProfile(CallbackInfoReturnable ci) - { - UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, this.getUsername())); - ci.setReturnValue(new GameProfile(uuid, this.getUsername())); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinSimpleReloadableResourceManager.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinSimpleReloadableResourceManager.java deleted file mode 100644 index 686c7884..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinSimpleReloadableResourceManager.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import java.util.List; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import com.mumfrey.liteloader.client.ducks.IReloadable; - -import net.minecraft.client.resources.IResourceManagerReloadListener; -import net.minecraft.client.resources.SimpleReloadableResourceManager; - -@Mixin(SimpleReloadableResourceManager.class) -public abstract class MixinSimpleReloadableResourceManager implements IReloadable -{ - @Shadow private List reloadListeners; - - @Override - public List getReloadListeners() - { - return this.reloadListeners; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinTileEntityRendererDispatcher.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinTileEntityRendererDispatcher.java deleted file mode 100644 index 4c56eeca..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/mixin/MixinTileEntityRendererDispatcher.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.mumfrey.liteloader.client.mixin; - -import java.util.Map; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import com.mumfrey.liteloader.client.ducks.ITileEntityRendererDispatcher; - -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.tileentity.TileEntity; - -@Mixin(TileEntityRendererDispatcher.class) -public abstract class MixinTileEntityRendererDispatcher implements ITileEntityRendererDispatcher -{ - @Shadow private Map, TileEntitySpecialRenderer> mapSpecialRenderers; - - @Override - public Map, TileEntitySpecialRenderer> getSpecialRenderMap() - { - return this.mapSpecialRenderers; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/IEntityRenderer.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/IEntityRenderer.java deleted file mode 100644 index 1729548f..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/IEntityRenderer.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.mumfrey.liteloader.client.overlays; - -import net.minecraft.util.ResourceLocation; - -import com.mumfrey.liteloader.transformers.access.Accessor; -import com.mumfrey.liteloader.transformers.access.Invoker; - -/** - * Adapter for EntityRenderer to expose some private functionality - * - * @author Adam Mummery-Smith - */ -@Accessor("EntityRenderer") -public interface IEntityRenderer -{ - @Accessor("useShader") public abstract boolean getUseShader(); - @Accessor("useShader") public abstract void setUseShader(boolean useShader); - - @Accessor("shaderResourceLocations") public abstract ResourceLocation[] getShaders(); - - @Accessor("shaderIndex") public abstract int getShaderIndex(); - @Accessor("shaderIndex") public abstract void setShaderIndex(int shaderIndex); - - @Invoker("loadShader") public abstract void selectShader(ResourceLocation shader); - - @Invoker("getFOVModifier") public abstract float getFOV(float partialTicks, boolean armFOV); - - @Invoker("setupCameraTransform") public abstract void setupCamera(float partialTicks, int pass); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/IGuiTextField.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/IGuiTextField.java deleted file mode 100644 index 411792e4..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/IGuiTextField.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.mumfrey.liteloader.client.overlays; - -import com.mumfrey.liteloader.transformers.access.Accessor; - -/** - * Adapter for GuiTextField to expose internal properties, mainly to allow - * sensible subclassing. - * - * @author Adam Mummery-Smith - */ -@Accessor("GuiTextField") -public interface IGuiTextField -{ - @Accessor("#2") public abstract int getXPosition(); - @Accessor("#2") public abstract void setXPosition(int xPosition); - - @Accessor("#3") public abstract int getYPosition(); - @Accessor("#3") public abstract void setYPosition(int yPosition); - - @Accessor("#4") public abstract int getInternalWidth(); - @Accessor("#4") public abstract void setInternalWidth(int width); - - @Accessor("#5") public abstract int getHeight(); - @Accessor("#5") public abstract void setHeight(int height); - - @Accessor("#12") public abstract boolean isEnabled(); -// @Accessor("#12") public abstract void setEnabled(boolean enabled); // built in - - @Accessor("#13") public abstract int getLineScrollOffset(); - - @Accessor("#16") public abstract int getTextColor(); -// @Accessor("#16") public abstract void setTextColor(int color); // built in - - @Accessor("#17") public abstract int getDisabledTextColour(); -// @Accessor("#17") public abstract void setDisabledTextColour(int color); // built in -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/IMinecraft.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/IMinecraft.java deleted file mode 100644 index 6ce18247..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/IMinecraft.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.mumfrey.liteloader.client.overlays; - -import java.util.List; - -import net.minecraft.client.resources.IResourcePack; -import net.minecraft.util.Timer; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.access.Accessor; -import com.mumfrey.liteloader.transformers.access.Invoker; -import com.mumfrey.liteloader.transformers.access.ObfTableClass; - -/** - * Interface containing injected accessors for Minecraft - * - * @author Adam Mummery-Smith - */ -@ObfTableClass(Obf.class) -@Accessor("Minecraft") -public interface IMinecraft -{ - /** - * Get the timer instance - */ - @Accessor("timer") - public abstract Timer getTimer(); - - /** - * Get the "running" flag - */ - @Accessor("running") - public abstract boolean isRunning(); - - /** - * Get the default resource packs set - */ - @Accessor("defaultResourcePacks") - public abstract List getDefaultResourcePacks(); - - /** - * Get the current server address (from connection) - */ - @Accessor("serverName") - public abstract String getServerName(); - - /** - * Get the current server port (from connection) - */ - @Accessor("serverPort") - public abstract int getServerPort(); - - /** - * Notify the client that the window was resized - * - * @param width - * @param height - */ - @Invoker("resize") - public abstract void onResizeWindow(int width, int height); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/ISoundHandler.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/ISoundHandler.java deleted file mode 100644 index 930f6d13..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/overlays/ISoundHandler.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.mumfrey.liteloader.client.overlays; - -import net.minecraft.client.audio.SoundList; -import net.minecraft.util.ResourceLocation; - -import com.mumfrey.liteloader.transformers.access.Accessor; -import com.mumfrey.liteloader.transformers.access.Invoker; - -@Accessor("SoundHandler") -public interface ISoundHandler -{ - @Invoker("loadSoundResource") - public abstract void addSound(ResourceLocation sound, SoundList soundList); -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/transformers/CrashReportTransformer.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/transformers/CrashReportTransformer.java deleted file mode 100644 index f82d795b..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/transformers/CrashReportTransformer.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.mumfrey.liteloader.client.transformers; - -import java.util.ListIterator; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.InsnList; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.MethodNode; -import org.objectweb.asm.tree.VarInsnNode; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.ClassTransformer; - -public class CrashReportTransformer extends ClassTransformer -{ - @Override - public byte[] transform(String name, String transformedName, byte[] basicClass) - { - if (basicClass != null && (Obf.CrashReport$6.name.equals(name) || Obf.CrashReport$6.obf.equals(name))) - { - try - { - return this.transformCallableJVMFlags(basicClass); - } - catch (Exception ex) {} - } - - return basicClass; - } - - /** - * Inject the additional callback for populating the crash report into the - * CallableJVMFlags class. - * - * @param basicClass basic class - * @return transformed class - */ - private byte[] transformCallableJVMFlags(byte[] basicClass) - { - ClassNode classNode = this.readClass(basicClass, true); - - for (MethodNode method : classNode.methods) - { - if ("".equals(method.name)) - { - this.transformCallableJVMFlagsConstructor(method); - } - } - - return this.writeClass(classNode); - } - - /** - * @param ctor - */ - public void transformCallableJVMFlagsConstructor(MethodNode ctor) - { - InsnList code = new InsnList(); - code.add(new VarInsnNode(Opcodes.ALOAD, 1)); - code.add(new MethodInsnNode(Opcodes.INVOKESTATIC, "com/mumfrey/liteloader/core/LiteLoader", "populateCrashReport", - "(Ljava/lang/Object;)V", false)); - - ListIterator insns = ctor.instructions.iterator(); - while (insns.hasNext()) - { - AbstractInsnNode insnNode = insns.next(); - if (insnNode.getOpcode() == Opcodes.RETURN) - { - ctor.instructions.insertBefore(insnNode, code); - } - } - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/transformers/MinecraftTransformer.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/transformers/MinecraftTransformer.java deleted file mode 100644 index 643ee18c..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/transformers/MinecraftTransformer.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.mumfrey.liteloader.client.transformers; - -import java.util.Iterator; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.InsnList; -import org.objectweb.asm.tree.LdcInsnNode; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.MethodNode; -import org.objectweb.asm.tree.TypeInsnNode; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.launch.LiteLoaderTweaker; -import com.mumfrey.liteloader.transformers.access.AccessorTransformer; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -public class MinecraftTransformer extends AccessorTransformer -{ - private static final String TWEAKCLASS = LiteLoaderTweaker.class.getName().replace('.', '/'); - - @Override - protected void addAccessors() - { - this.addAccessor(Obf.IMinecraft.name); - this.addAccessor(Obf.IGuiTextField.name); - this.addAccessor(Obf.IEntityRenderer.name); - this.addAccessor(Obf.ISoundHandler.name); - } - - @Override - protected void postTransform(String name, String transformedName, ClassNode classNode) - { - if ((Obf.Minecraft.name.equals(transformedName) || Obf.Minecraft.obf.equals(transformedName))) - { - for (MethodNode method : classNode.methods) - { - if (Obf.startGame.obf.equals(method.name) || Obf.startGame.srg.equals(method.name) || Obf.startGame.name.equals(method.name)) - { - this.transformStartGame(method); - } - } - } - } - - private void transformStartGame(MethodNode method) - { - InsnList insns = new InsnList(); - - boolean found = false; - - Iterator iter = method.instructions.iterator(); - while (iter.hasNext()) - { - AbstractInsnNode insn = iter.next(); - insns.add(insn); - - if (insn instanceof TypeInsnNode && insn.getOpcode() == Opcodes.NEW && insns.getLast() != null) - { - TypeInsnNode typeNode = (TypeInsnNode)insn; - if (!found && (Obf.EntityRenderer.obf.equals(typeNode.desc) || Obf.EntityRenderer.ref.equals(typeNode.desc))) - { - LiteLoaderLogger.info("MinecraftTransformer found INIT injection point, this is good."); - found = true; - - insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, MinecraftTransformer.TWEAKCLASS, Obf.init.name, "()V", false)); - insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, MinecraftTransformer.TWEAKCLASS, Obf.postInit.name, "()V", false)); - } - } - - if (LiteLoaderTweaker.loadingBarEnabled()) - { - if (insn instanceof LdcInsnNode) - { - LdcInsnNode ldcInsn = (LdcInsnNode)insn; - if ("textures/blocks".equals(ldcInsn.cst)) - { - insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Obf.LoadingBar.ref, "initTextures", "()V", false)); - } - } - - insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Obf.LoadingBar.ref, "incrementProgress", "()V", false)); - } - } - - method.instructions = insns; - - if (!found) LiteLoaderLogger.severe("MinecraftTransformer failed to find INIT injection point, the game will probably crash pretty soon."); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/util/PrivateFieldsClient.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/util/PrivateFieldsClient.java deleted file mode 100644 index d8529eee..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/util/PrivateFieldsClient.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.mumfrey.liteloader.client.util; - -import java.util.Map; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.util.PrivateFields; - -import net.minecraft.tileentity.TileEntity; - -@SuppressWarnings("rawtypes") -public final class PrivateFieldsClient extends PrivateFields -{ - private PrivateFieldsClient(Class

owner, Obf obf) - { - super(owner, obf); - } - - // CHECKSTYLE:OFF - - public static final PrivateFieldsClient tileEntityNameToClassMap = new PrivateFieldsClient(TileEntity.class, Obf.tileEntityNameToClassMap); - public static final PrivateFieldsClient tileEntityClassToNameMap = new PrivateFieldsClient(TileEntity.class, Obf.tileEntityClassToNameMap); -} \ No newline at end of file diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/util/render/IconAbsolute.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/util/render/IconAbsolute.java deleted file mode 100644 index 1f01788c..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/util/render/IconAbsolute.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.mumfrey.liteloader.client.util.render; - -import com.mumfrey.liteloader.util.render.IconTextured; - -import net.minecraft.util.ResourceLocation; - -public class IconAbsolute implements IconTextured -{ - private ResourceLocation textureResource; - - private String displayText; - - private int texMapSize = 256; - - private int width; - private int height; - - private int uPos, vPos; - - private float uCoord; - private float uCoord2; - private float vCoord; - private float vCoord2; - - public IconAbsolute(ResourceLocation textureResource, String displayText, int width, int height, float uCoord, float vCoord, float uCoord2, - float vCoord2) - { - this(textureResource, displayText, width, height, uCoord, vCoord, uCoord2, vCoord2, 256); - } - - public IconAbsolute(ResourceLocation textureResource, String displayText, int width, int height, float uCoord, float vCoord, float uCoord2, - float vCoord2, int texMapSize) - { - this.textureResource = textureResource; - this.displayText = displayText; - this.width = width; - this.height = height; - - this.uPos = (int)uCoord; - this.vPos = (int)vCoord; - - this.texMapSize = texMapSize; - this.uCoord = uCoord / this.texMapSize; - this.uCoord2 = uCoord2 / this.texMapSize; - this.vCoord = vCoord / this.texMapSize; - this.vCoord2 = vCoord2 / this.texMapSize; - } - - @Override - public String getDisplayText() - { - return this.displayText; - } - - @Override - public ResourceLocation getTextureResource() - { - return this.textureResource; - } - - @Override - public int getIconWidth() - { - return this.width; - } - - @Override - public int getIconHeight() - { - return this.height; - } - - @Override - public int getUPos() - { - return this.uPos; - } - - @Override - public int getVPos() - { - return this.vPos; - } - - @Override - public float getMinU() - { - return this.uCoord; - } - - @Override - public float getMaxU() - { - return this.uCoord2 - Float.MIN_VALUE; - } - - @Override - public float getInterpolatedU(double slice) - { - float uSize = this.uCoord2 - this.uCoord; - return this.uCoord + uSize * ((float)slice / 16.0F) - Float.MIN_VALUE; - } - - @Override - public float getMinV() - { - return this.vCoord; - } - - @Override - public float getMaxV() - { - return this.vCoord2 - Float.MIN_VALUE; - } - - @Override - public float getInterpolatedV(double slice) - { - float vSize = this.vCoord2 - this.vCoord; - return this.vCoord + vSize * ((float)slice / 16.0F) - Float.MIN_VALUE; - } - - @Override - public String getIconName() - { - return this.displayText; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/util/render/IconAbsoluteClickable.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/util/render/IconAbsoluteClickable.java deleted file mode 100644 index 26fbb032..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/util/render/IconAbsoluteClickable.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.mumfrey.liteloader.client.util.render; - -import net.minecraft.util.ResourceLocation; - -import com.mumfrey.liteloader.util.render.IconClickable; - -public abstract class IconAbsoluteClickable extends IconAbsolute implements IconClickable -{ - public IconAbsoluteClickable(ResourceLocation textureResource, String displayText, int width, int height, float uCoord, float vCoord, - float uCoord2, float vCoord2) - { - super(textureResource, displayText, width, height, uCoord, vCoord, uCoord2, vCoord2); - } - - public IconAbsoluteClickable(ResourceLocation textureResource, String displayText, int width, int height, float uCoord, float vCoord, - float uCoord2, float vCoord2, int texMapSize) - { - super(textureResource, displayText, width, height, uCoord, vCoord, uCoord2, vCoord2, texMapSize); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/client/util/render/IconTiled.java b/liteloader/src/client/java/com/mumfrey/liteloader/client/util/render/IconTiled.java deleted file mode 100644 index 83cf2a13..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/client/util/render/IconTiled.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.mumfrey.liteloader.client.util.render; - -import com.mumfrey.liteloader.util.render.Icon; - -import net.minecraft.util.ResourceLocation; - -public class IconTiled implements Icon -{ - private ResourceLocation textureResource; - - protected int iconID; - - protected int iconU; - protected int iconV; - private int width; - private int height; - private float uCoord; - private float uCoord2; - private float vCoord; - private float vCoord2; - - private int textureWidth, textureHeight; - - public IconTiled(ResourceLocation textureResource, int id) - { - this(textureResource, id, 16); - } - - public IconTiled(ResourceLocation textureResource, int id, int iconSize) - { - this(textureResource, id, iconSize, 0); - } - - public IconTiled(ResourceLocation textureResource, int id, int iconSize, int yOffset) - { - this(textureResource, id, iconSize, (id % (256 / iconSize)) * iconSize, (id / (256 / iconSize)) * iconSize + yOffset); - } - - public IconTiled(ResourceLocation textureResource, int id, int iconSize, int iconU, int iconV) - { - this(textureResource, id, iconU, iconV, iconSize, iconSize, 256, 256); - } - - public IconTiled(ResourceLocation textureResource, int id, int iconU, int iconV, int width, int height, int textureWidth, int textureHeight) - { - this.iconID = id; - this.textureResource = textureResource; - - this.textureWidth = textureWidth; - this.textureHeight = textureHeight; - - this.width = width; - this.height = height; - - this.init(iconU, iconV); - } - - protected void init(int iconU, int iconV) - { - this.iconU = iconU; - this.iconV = iconV; - - this.uCoord = (float)iconU / (float)this.textureWidth; - this.uCoord2 = (float)(iconU + this.width) / (float)this.textureWidth; - this.vCoord = (float)iconV / (float)this.textureHeight; - this.vCoord2 = (float)(iconV + this.height) / (float)this.textureHeight; - } - - public ResourceLocation getTextureResource() - { - return this.textureResource; - } - - public int getIconID() - { - return this.iconID; - } - - public void setIconID(int id) - { - this.iconID = id; - this.init((id % 16) * 16, (id / 16) * 16); - } - - @Override - public int getIconWidth() - { - return this.width; - } - - @Override - public int getIconHeight() - { - return this.height; - } - - @Override - public float getMinU() - { - return this.uCoord; - } - - @Override - public float getMaxU() - { - return this.uCoord2 - Float.MIN_VALUE; - } - - @Override - public float getInterpolatedU(double slice) - { - float uSize = this.uCoord2 - this.uCoord; - return this.uCoord + uSize * ((float)slice / 16.0F) - Float.MIN_VALUE; - } - - @Override - public float getMinV() - { - return this.vCoord; - } - - @Override - public float getMaxV() - { - return this.vCoord2 - Float.MIN_VALUE; - } - - @Override - public float getInterpolatedV(double slice) - { - float vSize = this.vCoord2 - this.vCoord; - return this.vCoord + vSize * ((float)slice / 16.0F) - Float.MIN_VALUE; - } - - @Override - public String getIconName() - { - return this.textureResource + "_" + this.iconID; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/gl/GL.java b/liteloader/src/client/java/com/mumfrey/liteloader/gl/GL.java deleted file mode 100644 index 33d83415..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/gl/GL.java +++ /dev/null @@ -1,1296 +0,0 @@ -package com.mumfrey.liteloader.gl; - -import java.nio.ByteBuffer; -import java.nio.DoubleBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; - -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.GlStateManager.TexGen; - -import org.lwjgl.opengl.GL11; -import org.lwjgl.util.glu.GLU; - -/** - * Convenience class for working with Mojang's GLStateManager: - * - *

It would be pretty tolerable to work with GLStateManager as a static - * import were it not for the fact that you still need to import the GL - * namespaces themselves from LWJGL in order to get the constants, and also have - * to deal with the fact that GLStateManager's methods don't have "gl-style" - * names, making it annoying to work with. This class is designed to function as - * an adapter to allow changeover to be more painless. Using this class means - * that the following code:

- * - *
glEnable(GL_BLEND);
- * glAlphaFunc(GL_GREATER, 0.0F);
- * - *

becomes:

- * - *
glEnableBlend();
- * glAlphaFunc(GL_GREATER, 0.0F);
- * - *

Notice that the glAlphaFunc invocation remains unchanged, and the - * glEnable call simply gets replaced with a logical equivalent which - * invokes the GLStateManager method behind the scenes.

- * - *

To use this class, simply replace existing static imports in your classes - * with this single static import, then change glEnable and - * glDisable calls accordingly. - * - * @author Adam Mummery-Smith - */ -public class GL -{ - // GL11 - public static final int GL_ACCUM = 0x100; - public static final int GL_LOAD = 0x101; - public static final int GL_RETURN = 0x102; - public static final int GL_MULT = 0x103; - public static final int GL_ADD = 0x104; - public static final int GL_NEVER = 0x200; - public static final int GL_LESS = 0x201; - public static final int GL_EQUAL = 0x202; - public static final int GL_LEQUAL = 0x203; - public static final int GL_GREATER = 0x204; - public static final int GL_NOTEQUAL = 0x205; - public static final int GL_GEQUAL = 0x206; - public static final int GL_ALWAYS = 0x207; - public static final int GL_CURRENT_BIT = 0x1; - public static final int GL_POINT_BIT = 0x2; - public static final int GL_LINE_BIT = 0x4; - public static final int GL_POLYGON_BIT = 0x8; - public static final int GL_POLYGON_STIPPLE_BIT = 0x10; - public static final int GL_PIXEL_MODE_BIT = 0x20; - public static final int GL_LIGHTING_BIT = 0x40; - public static final int GL_FOG_BIT = 0x80; - public static final int GL_DEPTH_BUFFER_BIT = 0x100; - public static final int GL_ACCUM_BUFFER_BIT = 0x200; - public static final int GL_STENCIL_BUFFER_BIT = 0x400; - public static final int GL_VIEWPORT_BIT = 0x800; - public static final int GL_TRANSFORM_BIT = 0x1000; - public static final int GL_ENABLE_BIT = 0x2000; - public static final int GL_COLOR_BUFFER_BIT = 0x4000; - public static final int GL_HINT_BIT = 0x8000; - public static final int GL_EVAL_BIT = 0x10000; - public static final int GL_LIST_BIT = 0x20000; - public static final int GL_TEXTURE_BIT = 0x40000; - public static final int GL_SCISSOR_BIT = 0x80000; - public static final int GL_ALL_ATTRIB_BITS = 0xfffff; - public static final int GL_POINTS = 0x0; - public static final int GL_LINES = 0x1; - public static final int GL_LINE_LOOP = 0x2; - public static final int GL_LINE_STRIP = 0x3; - public static final int GL_TRIANGLES = 0x4; - public static final int GL_TRIANGLE_STRIP = 0x5; - public static final int GL_TRIANGLE_FAN = 0x6; - public static final int GL_QUADS = 0x7; - public static final int GL_QUAD_STRIP = 0x8; - public static final int GL_POLYGON = 0x9; - public static final int GL_ZERO = 0x0; - public static final int GL_ONE = 0x1; - public static final int GL_SRC_COLOR = 0x300; - public static final int GL_ONE_MINUS_SRC_COLOR = 0x301; - public static final int GL_SRC_ALPHA = 0x302; - public static final int GL_ONE_MINUS_SRC_ALPHA = 0x303; - public static final int GL_DST_ALPHA = 0x304; - public static final int GL_ONE_MINUS_DST_ALPHA = 0x305; - public static final int GL_DST_COLOR = 0x306; - public static final int GL_ONE_MINUS_DST_COLOR = 0x307; - public static final int GL_SRC_ALPHA_SATURATE = 0x308; - public static final int GL_CONSTANT_COLOR = 0x8001; - public static final int GL_ONE_MINUS_CONSTANT_COLOR = 0x8002; - public static final int GL_CONSTANT_ALPHA = 0x8003; - public static final int GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004; - public static final int GL_TRUE = 0x1; - public static final int GL_FALSE = 0x0; - public static final int GL_CLIP_PLANE0 = 0x3000; - public static final int GL_CLIP_PLANE1 = 0x3001; - public static final int GL_CLIP_PLANE2 = 0x3002; - public static final int GL_CLIP_PLANE3 = 0x3003; - public static final int GL_CLIP_PLANE4 = 0x3004; - public static final int GL_CLIP_PLANE5 = 0x3005; - public static final int GL_BYTE = 0x1400; - public static final int GL_UNSIGNED_BYTE = 0x1401; - public static final int GL_SHORT = 0x1402; - public static final int GL_UNSIGNED_SHORT = 0x1403; - public static final int GL_INT = 0x1404; - public static final int GL_UNSIGNED_INT = 0x1405; - public static final int GL_FLOAT = 0x1406; - public static final int GL_2_BYTES = 0x1407; - public static final int GL_3_BYTES = 0x1408; - public static final int GL_4_BYTES = 0x1409; - public static final int GL_DOUBLE = 0x140a; - public static final int GL_NONE = 0x0; - public static final int GL_FRONT_LEFT = 0x400; - public static final int GL_FRONT_RIGHT = 0x401; - public static final int GL_BACK_LEFT = 0x402; - public static final int GL_BACK_RIGHT = 0x403; - public static final int GL_FRONT = 0x404; - public static final int GL_BACK = 0x405; - public static final int GL_LEFT = 0x406; - public static final int GL_RIGHT = 0x407; - public static final int GL_FRONT_AND_BACK = 0x408; - public static final int GL_AUX0 = 0x409; - public static final int GL_AUX1 = 0x40a; - public static final int GL_AUX2 = 0x40b; - public static final int GL_AUX3 = 0x40c; - public static final int GL_NO_ERROR = 0x0; - public static final int GL_INVALID_ENUM = 0x500; - public static final int GL_INVALID_VALUE = 0x501; - public static final int GL_INVALID_OPERATION = 0x502; - public static final int GL_STACK_OVERFLOW = 0x503; - public static final int GL_STACK_UNDERFLOW = 0x504; - public static final int GL_OUT_OF_MEMORY = 0x505; - public static final int GL_2D = 0x600; - public static final int GL_3D = 0x601; - public static final int GL_3D_COLOR = 0x602; - public static final int GL_3D_COLOR_TEXTURE = 0x603; - public static final int GL_4D_COLOR_TEXTURE = 0x604; - public static final int GL_PASS_THROUGH_TOKEN = 0x700; - public static final int GL_POINT_TOKEN = 0x701; - public static final int GL_LINE_TOKEN = 0x702; - public static final int GL_POLYGON_TOKEN = 0x703; - public static final int GL_BITMAP_TOKEN = 0x704; - public static final int GL_DRAW_PIXEL_TOKEN = 0x705; - public static final int GL_COPY_PIXEL_TOKEN = 0x706; - public static final int GL_LINE_RESET_TOKEN = 0x707; - public static final int GL_EXP = 0x800; - public static final int GL_EXP2 = 0x801; - public static final int GL_CW = 0x900; - public static final int GL_CCW = 0x901; - public static final int GL_COEFF = 0xa00; - public static final int GL_ORDER = 0xa01; - public static final int GL_DOMAIN = 0xa02; - public static final int GL_CURRENT_COLOR = 0xb00; - public static final int GL_CURRENT_INDEX = 0xb01; - public static final int GL_CURRENT_NORMAL = 0xb02; - public static final int GL_CURRENT_TEXTURE_COORDS = 0xb03; - public static final int GL_CURRENT_RASTER_COLOR = 0xb04; - public static final int GL_CURRENT_RASTER_INDEX = 0xb05; - public static final int GL_CURRENT_RASTER_TEXTURE_COORDS = 0xb06; - public static final int GL_CURRENT_RASTER_POSITION = 0xb07; - public static final int GL_CURRENT_RASTER_POSITION_VALID = 0xb08; - public static final int GL_CURRENT_RASTER_DISTANCE = 0xb09; - public static final int GL_POINT_SMOOTH = 0xb10; - public static final int GL_POINT_SIZE = 0xb11; - public static final int GL_POINT_SIZE_RANGE = 0xb12; - public static final int GL_POINT_SIZE_GRANULARITY = 0xb13; - public static final int GL_LINE_SMOOTH = 0xb20; - public static final int GL_LINE_WIDTH = 0xb21; - public static final int GL_LINE_WIDTH_RANGE = 0xb22; - public static final int GL_LINE_WIDTH_GRANULARITY = 0xb23; - public static final int GL_LINE_STIPPLE = 0xb24; - public static final int GL_LINE_STIPPLE_PATTERN = 0xb25; - public static final int GL_LINE_STIPPLE_REPEAT = 0xb26; - public static final int GL_LIST_MODE = 0xb30; - public static final int GL_MAX_LIST_NESTING = 0xb31; - public static final int GL_LIST_BASE = 0xb32; - public static final int GL_LIST_INDEX = 0xb33; - public static final int GL_POLYGON_MODE = 0xb40; - public static final int GL_POLYGON_SMOOTH = 0xb41; - public static final int GL_POLYGON_STIPPLE = 0xb42; - public static final int GL_EDGE_FLAG = 0xb43; - public static final int GL_CULL_FACE = 0xb44; - public static final int GL_CULL_FACE_MODE = 0xb45; - public static final int GL_FRONT_FACE = 0xb46; - public static final int GL_LIGHTING = 0xb50; - public static final int GL_LIGHT_MODEL_LOCAL_VIEWER = 0xb51; - public static final int GL_LIGHT_MODEL_TWO_SIDE = 0xb52; - public static final int GL_LIGHT_MODEL_AMBIENT = 0xb53; - public static final int GL_SHADE_MODEL = 0xb54; - public static final int GL_COLOR_MATERIAL_FACE = 0xb55; - public static final int GL_COLOR_MATERIAL_PARAMETER = 0xb56; - public static final int GL_COLOR_MATERIAL = 0xb57; - public static final int GL_FOG = 0xb60; - public static final int GL_FOG_INDEX = 0xb61; - public static final int GL_FOG_DENSITY = 0xb62; - public static final int GL_FOG_START = 0xb63; - public static final int GL_FOG_END = 0xb64; - public static final int GL_FOG_MODE = 0xb65; - public static final int GL_FOG_COLOR = 0xb66; - public static final int GL_DEPTH_RANGE = 0xb70; - public static final int GL_DEPTH_TEST = 0xb71; - public static final int GL_DEPTH_WRITEMASK = 0xb72; - public static final int GL_DEPTH_CLEAR_VALUE = 0xb73; - public static final int GL_DEPTH_FUNC = 0xb74; - public static final int GL_ACCUM_CLEAR_VALUE = 0xb80; - public static final int GL_STENCIL_TEST = 0xb90; - public static final int GL_STENCIL_CLEAR_VALUE = 0xb91; - public static final int GL_STENCIL_FUNC = 0xb92; - public static final int GL_STENCIL_VALUE_MASK = 0xb93; - public static final int GL_STENCIL_FAIL = 0xb94; - public static final int GL_STENCIL_PASS_DEPTH_FAIL = 0xb95; - public static final int GL_STENCIL_PASS_DEPTH_PASS = 0xb96; - public static final int GL_STENCIL_REF = 0xb97; - public static final int GL_STENCIL_WRITEMASK = 0xb98; - public static final int GL_MATRIX_MODE = 0xba0; - public static final int GL_NORMALIZE = 0xba1; - public static final int GL_VIEWPORT = 0xba2; - public static final int GL_MODELVIEW_STACK_DEPTH = 0xba3; - public static final int GL_PROJECTION_STACK_DEPTH = 0xba4; - public static final int GL_TEXTURE_STACK_DEPTH = 0xba5; - public static final int GL_MODELVIEW_MATRIX = 0xba6; - public static final int GL_PROJECTION_MATRIX = 0xba7; - public static final int GL_TEXTURE_MATRIX = 0xba8; - public static final int GL_ATTRIB_STACK_DEPTH = 0xbb0; - public static final int GL_CLIENT_ATTRIB_STACK_DEPTH = 0xbb1; - public static final int GL_ALPHA_TEST = 0xbc0; - public static final int GL_ALPHA_TEST_FUNC = 0xbc1; - public static final int GL_ALPHA_TEST_REF = 0xbc2; - public static final int GL_DITHER = 0xbd0; - public static final int GL_BLEND_DST = 0xbe0; - public static final int GL_BLEND_SRC = 0xbe1; - public static final int GL_BLEND = 0xbe2; - public static final int GL_LOGIC_OP_MODE = 0xbf0; - public static final int GL_INDEX_LOGIC_OP = 0xbf1; - public static final int GL_COLOR_LOGIC_OP = 0xbf2; - public static final int GL_AUX_BUFFERS = 0xc00; - public static final int GL_DRAW_BUFFER = 0xc01; - public static final int GL_READ_BUFFER = 0xc02; - public static final int GL_SCISSOR_BOX = 0xc10; - public static final int GL_SCISSOR_TEST = 0xc11; - public static final int GL_INDEX_CLEAR_VALUE = 0xc20; - public static final int GL_INDEX_WRITEMASK = 0xc21; - public static final int GL_COLOR_CLEAR_VALUE = 0xc22; - public static final int GL_COLOR_WRITEMASK = 0xc23; - public static final int GL_INDEX_MODE = 0xc30; - public static final int GL_RGBA_MODE = 0xc31; - public static final int GL_DOUBLEBUFFER = 0xc32; - public static final int GL_STEREO = 0xc33; - public static final int GL_RENDER_MODE = 0xc40; - public static final int GL_PERSPECTIVE_CORRECTION_HINT = 0xc50; - public static final int GL_POINT_SMOOTH_HINT = 0xc51; - public static final int GL_LINE_SMOOTH_HINT = 0xc52; - public static final int GL_POLYGON_SMOOTH_HINT = 0xc53; - public static final int GL_FOG_HINT = 0xc54; - public static final int GL_TEXTURE_GEN_S = 0xc60; - public static final int GL_TEXTURE_GEN_T = 0xc61; - public static final int GL_TEXTURE_GEN_R = 0xc62; - public static final int GL_TEXTURE_GEN_Q = 0xc63; - public static final int GL_PIXEL_MAP_I_TO_I = 0xc70; - public static final int GL_PIXEL_MAP_S_TO_S = 0xc71; - public static final int GL_PIXEL_MAP_I_TO_R = 0xc72; - public static final int GL_PIXEL_MAP_I_TO_G = 0xc73; - public static final int GL_PIXEL_MAP_I_TO_B = 0xc74; - public static final int GL_PIXEL_MAP_I_TO_A = 0xc75; - public static final int GL_PIXEL_MAP_R_TO_R = 0xc76; - public static final int GL_PIXEL_MAP_G_TO_G = 0xc77; - public static final int GL_PIXEL_MAP_B_TO_B = 0xc78; - public static final int GL_PIXEL_MAP_A_TO_A = 0xc79; - public static final int GL_PIXEL_MAP_I_TO_I_SIZE = 0xcb0; - public static final int GL_PIXEL_MAP_S_TO_S_SIZE = 0xcb1; - public static final int GL_PIXEL_MAP_I_TO_R_SIZE = 0xcb2; - public static final int GL_PIXEL_MAP_I_TO_G_SIZE = 0xcb3; - public static final int GL_PIXEL_MAP_I_TO_B_SIZE = 0xcb4; - public static final int GL_PIXEL_MAP_I_TO_A_SIZE = 0xcb5; - public static final int GL_PIXEL_MAP_R_TO_R_SIZE = 0xcb6; - public static final int GL_PIXEL_MAP_G_TO_G_SIZE = 0xcb7; - public static final int GL_PIXEL_MAP_B_TO_B_SIZE = 0xcb8; - public static final int GL_PIXEL_MAP_A_TO_A_SIZE = 0xcb9; - public static final int GL_UNPACK_SWAP_BYTES = 0xcf0; - public static final int GL_UNPACK_LSB_FIRST = 0xcf1; - public static final int GL_UNPACK_ROW_LENGTH = 0xcf2; - public static final int GL_UNPACK_SKIP_ROWS = 0xcf3; - public static final int GL_UNPACK_SKIP_PIXELS = 0xcf4; - public static final int GL_UNPACK_ALIGNMENT = 0xcf5; - public static final int GL_PACK_SWAP_BYTES = 0xd00; - public static final int GL_PACK_LSB_FIRST = 0xd01; - public static final int GL_PACK_ROW_LENGTH = 0xd02; - public static final int GL_PACK_SKIP_ROWS = 0xd03; - public static final int GL_PACK_SKIP_PIXELS = 0xd04; - public static final int GL_PACK_ALIGNMENT = 0xd05; - public static final int GL_MAP_COLOR = 0xd10; - public static final int GL_MAP_STENCIL = 0xd11; - public static final int GL_INDEX_SHIFT = 0xd12; - public static final int GL_INDEX_OFFSET = 0xd13; - public static final int GL_RED_SCALE = 0xd14; - public static final int GL_RED_BIAS = 0xd15; - public static final int GL_ZOOM_X = 0xd16; - public static final int GL_ZOOM_Y = 0xd17; - public static final int GL_GREEN_SCALE = 0xd18; - public static final int GL_GREEN_BIAS = 0xd19; - public static final int GL_BLUE_SCALE = 0xd1a; - public static final int GL_BLUE_BIAS = 0xd1b; - public static final int GL_ALPHA_SCALE = 0xd1c; - public static final int GL_ALPHA_BIAS = 0xd1d; - public static final int GL_DEPTH_SCALE = 0xd1e; - public static final int GL_DEPTH_BIAS = 0xd1f; - public static final int GL_MAX_EVAL_ORDER = 0xd30; - public static final int GL_MAX_LIGHTS = 0xd31; - public static final int GL_MAX_CLIP_PLANES = 0xd32; - public static final int GL_MAX_TEXTURE_SIZE = 0xd33; - public static final int GL_MAX_PIXEL_MAP_TABLE = 0xd34; - public static final int GL_MAX_ATTRIB_STACK_DEPTH = 0xd35; - public static final int GL_MAX_MODELVIEW_STACK_DEPTH = 0xd36; - public static final int GL_MAX_NAME_STACK_DEPTH = 0xd37; - public static final int GL_MAX_PROJECTION_STACK_DEPTH = 0xd38; - public static final int GL_MAX_TEXTURE_STACK_DEPTH = 0xd39; - public static final int GL_MAX_VIEWPORT_DIMS = 0xd3a; - public static final int GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = 0xd3b; - public static final int GL_SUBPIXEL_BITS = 0xd50; - public static final int GL_INDEX_BITS = 0xd51; - public static final int GL_RED_BITS = 0xd52; - public static final int GL_GREEN_BITS = 0xd53; - public static final int GL_BLUE_BITS = 0xd54; - public static final int GL_ALPHA_BITS = 0xd55; - public static final int GL_DEPTH_BITS = 0xd56; - public static final int GL_STENCIL_BITS = 0xd57; - public static final int GL_ACCUM_RED_BITS = 0xd58; - public static final int GL_ACCUM_GREEN_BITS = 0xd59; - public static final int GL_ACCUM_BLUE_BITS = 0xd5a; - public static final int GL_ACCUM_ALPHA_BITS = 0xd5b; - public static final int GL_NAME_STACK_DEPTH = 0xd70; - public static final int GL_AUTO_NORMAL = 0xd80; - public static final int GL_MAP1_COLOR_4 = 0xd90; - public static final int GL_MAP1_INDEX = 0xd91; - public static final int GL_MAP1_NORMAL = 0xd92; - public static final int GL_MAP1_TEXTURE_COORD_1 = 0xd93; - public static final int GL_MAP1_TEXTURE_COORD_2 = 0xd94; - public static final int GL_MAP1_TEXTURE_COORD_3 = 0xd95; - public static final int GL_MAP1_TEXTURE_COORD_4 = 0xd96; - public static final int GL_MAP1_VERTEX_3 = 0xd97; - public static final int GL_MAP1_VERTEX_4 = 0xd98; - public static final int GL_MAP2_COLOR_4 = 0xdb0; - public static final int GL_MAP2_INDEX = 0xdb1; - public static final int GL_MAP2_NORMAL = 0xdb2; - public static final int GL_MAP2_TEXTURE_COORD_1 = 0xdb3; - public static final int GL_MAP2_TEXTURE_COORD_2 = 0xdb4; - public static final int GL_MAP2_TEXTURE_COORD_3 = 0xdb5; - public static final int GL_MAP2_TEXTURE_COORD_4 = 0xdb6; - public static final int GL_MAP2_VERTEX_3 = 0xdb7; - public static final int GL_MAP2_VERTEX_4 = 0xdb8; - public static final int GL_MAP1_GRID_DOMAIN = 0xdd0; - public static final int GL_MAP1_GRID_SEGMENTS = 0xdd1; - public static final int GL_MAP2_GRID_DOMAIN = 0xdd2; - public static final int GL_MAP2_GRID_SEGMENTS = 0xdd3; - public static final int GL_TEXTURE_1D = 0xde0; - public static final int GL_TEXTURE_2D = 0xde1; - public static final int GL_FEEDBACK_BUFFER_POINTER = 0xdf0; - public static final int GL_FEEDBACK_BUFFER_SIZE = 0xdf1; - public static final int GL_FEEDBACK_BUFFER_TYPE = 0xdf2; - public static final int GL_SELECTION_BUFFER_POINTER = 0xdf3; - public static final int GL_SELECTION_BUFFER_SIZE = 0xdf4; - public static final int GL_TEXTURE_WIDTH = 0x1000; - public static final int GL_TEXTURE_HEIGHT = 0x1001; - public static final int GL_TEXTURE_INTERNAL_FORMAT = 0x1003; - public static final int GL_TEXTURE_BORDER_COLOR = 0x1004; - public static final int GL_TEXTURE_BORDER = 0x1005; - public static final int GL_DONT_CARE = 0x1100; - public static final int GL_FASTEST = 0x1101; - public static final int GL_NICEST = 0x1102; - public static final int GL_LIGHT0 = 0x4000; - public static final int GL_LIGHT1 = 0x4001; - public static final int GL_LIGHT2 = 0x4002; - public static final int GL_LIGHT3 = 0x4003; - public static final int GL_LIGHT4 = 0x4004; - public static final int GL_LIGHT5 = 0x4005; - public static final int GL_LIGHT6 = 0x4006; - public static final int GL_LIGHT7 = 0x4007; - public static final int GL_AMBIENT = 0x1200; - public static final int GL_DIFFUSE = 0x1201; - public static final int GL_SPECULAR = 0x1202; - public static final int GL_POSITION = 0x1203; - public static final int GL_SPOT_DIRECTION = 0x1204; - public static final int GL_SPOT_EXPONENT = 0x1205; - public static final int GL_SPOT_CUTOFF = 0x1206; - public static final int GL_CONSTANT_ATTENUATION = 0x1207; - public static final int GL_LINEAR_ATTENUATION = 0x1208; - public static final int GL_QUADRATIC_ATTENUATION = 0x1209; - public static final int GL_COMPILE = 0x1300; - public static final int GL_COMPILE_AND_EXECUTE = 0x1301; - public static final int GL_CLEAR = 0x1500; - public static final int GL_AND = 0x1501; - public static final int GL_AND_REVERSE = 0x1502; - public static final int GL_COPY = 0x1503; - public static final int GL_AND_INVERTED = 0x1504; - public static final int GL_NOOP = 0x1505; - public static final int GL_XOR = 0x1506; - public static final int GL_OR = 0x1507; - public static final int GL_NOR = 0x1508; - public static final int GL_EQUIV = 0x1509; - public static final int GL_INVERT = 0x150a; - public static final int GL_OR_REVERSE = 0x150b; - public static final int GL_COPY_INVERTED = 0x150c; - public static final int GL_OR_INVERTED = 0x150d; - public static final int GL_NAND = 0x150e; - public static final int GL_SET = 0x150f; - public static final int GL_EMISSION = 0x1600; - public static final int GL_SHININESS = 0x1601; - public static final int GL_AMBIENT_AND_DIFFUSE = 0x1602; - public static final int GL_COLOR_INDEXES = 0x1603; - public static final int GL_MODELVIEW = 0x1700; - public static final int GL_PROJECTION = 0x1701; - public static final int GL_TEXTURE = 0x1702; - public static final int GL_COLOR = 0x1800; - public static final int GL_DEPTH = 0x1801; - public static final int GL_STENCIL = 0x1802; - public static final int GL_COLOR_INDEX = 0x1900; - public static final int GL_STENCIL_INDEX = 0x1901; - public static final int GL_DEPTH_COMPONENT = 0x1902; - public static final int GL_RED = 0x1903; - public static final int GL_GREEN = 0x1904; - public static final int GL_BLUE = 0x1905; - public static final int GL_ALPHA = 0x1906; - public static final int GL_RGB = 0x1907; - public static final int GL_RGBA = 0x1908; - public static final int GL_LUMINANCE = 0x1909; - public static final int GL_LUMINANCE_ALPHA = 0x190a; - public static final int GL_BITMAP = 0x1a00; - public static final int GL_POINT = 0x1b00; - public static final int GL_LINE = 0x1b01; - public static final int GL_FILL = 0x1b02; - public static final int GL_RENDER = 0x1c00; - public static final int GL_FEEDBACK = 0x1c01; - public static final int GL_SELECT = 0x1c02; - public static final int GL_FLAT = 0x1d00; - public static final int GL_SMOOTH = 0x1d01; - public static final int GL_KEEP = 0x1e00; - public static final int GL_REPLACE = 0x1e01; - public static final int GL_INCR = 0x1e02; - public static final int GL_DECR = 0x1e03; - public static final int GL_VENDOR = 0x1f00; - public static final int GL_RENDERER = 0x1f01; - public static final int GL_VERSION = 0x1f02; - public static final int GL_EXTENSIONS = 0x1f03; - public static final int GL_S = 0x2000; - public static final int GL_T = 0x2001; - public static final int GL_R = 0x2002; - public static final int GL_Q = 0x2003; - public static final int GL_MODULATE = 0x2100; - public static final int GL_DECAL = 0x2101; - public static final int GL_TEXTURE_ENV_MODE = 0x2200; - public static final int GL_TEXTURE_ENV_COLOR = 0x2201; - public static final int GL_TEXTURE_ENV = 0x2300; - public static final int GL_EYE_LINEAR = 0x2400; - public static final int GL_OBJECT_LINEAR = 0x2401; - public static final int GL_SPHERE_MAP = 0x2402; - public static final int GL_TEXTURE_GEN_MODE = 0x2500; - public static final int GL_OBJECT_PLANE = 0x2501; - public static final int GL_EYE_PLANE = 0x2502; - public static final int GL_NEAREST = 0x2600; - public static final int GL_LINEAR = 0x2601; - public static final int GL_NEAREST_MIPMAP_NEAREST = 0x2700; - public static final int GL_LINEAR_MIPMAP_NEAREST = 0x2701; - public static final int GL_NEAREST_MIPMAP_LINEAR = 0x2702; - public static final int GL_LINEAR_MIPMAP_LINEAR = 0x2703; - public static final int GL_TEXTURE_MAG_FILTER = 0x2800; - public static final int GL_TEXTURE_MIN_FILTER = 0x2801; - public static final int GL_TEXTURE_WRAP_S = 0x2802; - public static final int GL_TEXTURE_WRAP_T = 0x2803; - public static final int GL_CLAMP = 0x2900; - public static final int GL_REPEAT = 0x2901; - public static final int GL_CLIENT_PIXEL_STORE_BIT = 0x1; - public static final int GL_CLIENT_VERTEX_ARRAY_BIT = 0x2; - public static final int GL_ALL_CLIENT_ATTRIB_BITS = 0xffffffff; - public static final int GL_POLYGON_OFFSET_FACTOR = 0x8038; - public static final int GL_POLYGON_OFFSET_UNITS = 0x2a00; - public static final int GL_POLYGON_OFFSET_POINT = 0x2a01; - public static final int GL_POLYGON_OFFSET_LINE = 0x2a02; - public static final int GL_POLYGON_OFFSET_FILL = 0x8037; - public static final int GL_ALPHA4 = 0x803b; - public static final int GL_ALPHA8 = 0x803c; - public static final int GL_ALPHA12 = 0x803d; - public static final int GL_ALPHA16 = 0x803e; - public static final int GL_LUMINANCE4 = 0x803f; - public static final int GL_LUMINANCE8 = 0x8040; - public static final int GL_LUMINANCE12 = 0x8041; - public static final int GL_LUMINANCE16 = 0x8042; - public static final int GL_LUMINANCE4_ALPHA4 = 0x8043; - public static final int GL_LUMINANCE6_ALPHA2 = 0x8044; - public static final int GL_LUMINANCE8_ALPHA8 = 0x8045; - public static final int GL_LUMINANCE12_ALPHA4 = 0x8046; - public static final int GL_LUMINANCE12_ALPHA12 = 0x8047; - public static final int GL_LUMINANCE16_ALPHA16 = 0x8048; - public static final int GL_INTENSITY = 0x8049; - public static final int GL_INTENSITY4 = 0x804a; - public static final int GL_INTENSITY8 = 0x804b; - public static final int GL_INTENSITY12 = 0x804c; - public static final int GL_INTENSITY16 = 0x804d; - public static final int GL_R3_G3_B2 = 0x2a10; - public static final int GL_RGB4 = 0x804f; - public static final int GL_RGB5 = 0x8050; - public static final int GL_RGB8 = 0x8051; - public static final int GL_RGB10 = 0x8052; - public static final int GL_RGB12 = 0x8053; - public static final int GL_RGB16 = 0x8054; - public static final int GL_RGBA2 = 0x8055; - public static final int GL_RGBA4 = 0x8056; - public static final int GL_RGB5_A1 = 0x8057; - public static final int GL_RGBA8 = 0x8058; - public static final int GL_RGB10_A2 = 0x8059; - public static final int GL_RGBA12 = 0x805a; - public static final int GL_RGBA16 = 0x805b; - public static final int GL_TEXTURE_RED_SIZE = 0x805c; - public static final int GL_TEXTURE_GREEN_SIZE = 0x805d; - public static final int GL_TEXTURE_BLUE_SIZE = 0x805e; - public static final int GL_TEXTURE_ALPHA_SIZE = 0x805f; - public static final int GL_TEXTURE_LUMINANCE_SIZE = 0x8060; - public static final int GL_TEXTURE_INTENSITY_SIZE = 0x8061; - public static final int GL_PROXY_TEXTURE_1D = 0x8063; - public static final int GL_PROXY_TEXTURE_2D = 0x8064; - public static final int GL_TEXTURE_PRIORITY = 0x8066; - public static final int GL_TEXTURE_RESIDENT = 0x8067; - public static final int GL_TEXTURE_BINDING_1D = 0x8068; - public static final int GL_TEXTURE_BINDING_2D = 0x8069; - public static final int GL_VERTEX_ARRAY = 0x8074; - public static final int GL_NORMAL_ARRAY = 0x8075; - public static final int GL_COLOR_ARRAY = 0x8076; - public static final int GL_INDEX_ARRAY = 0x8077; - public static final int GL_TEXTURE_COORD_ARRAY = 0x8078; - public static final int GL_EDGE_FLAG_ARRAY = 0x8079; - public static final int GL_VERTEX_ARRAY_SIZE = 0x807a; - public static final int GL_VERTEX_ARRAY_TYPE = 0x807b; - public static final int GL_VERTEX_ARRAY_STRIDE = 0x807c; - public static final int GL_NORMAL_ARRAY_TYPE = 0x807e; - public static final int GL_NORMAL_ARRAY_STRIDE = 0x807f; - public static final int GL_COLOR_ARRAY_SIZE = 0x8081; - public static final int GL_COLOR_ARRAY_TYPE = 0x8082; - public static final int GL_COLOR_ARRAY_STRIDE = 0x8083; - public static final int GL_INDEX_ARRAY_TYPE = 0x8085; - public static final int GL_INDEX_ARRAY_STRIDE = 0x8086; - public static final int GL_TEXTURE_COORD_ARRAY_SIZE = 0x8088; - public static final int GL_TEXTURE_COORD_ARRAY_TYPE = 0x8089; - public static final int GL_TEXTURE_COORD_ARRAY_STRIDE = 0x808a; - public static final int GL_EDGE_FLAG_ARRAY_STRIDE = 0x808c; - public static final int GL_VERTEX_ARRAY_POINTER = 0x808e; - public static final int GL_NORMAL_ARRAY_POINTER = 0x808f; - public static final int GL_COLOR_ARRAY_POINTER = 0x8090; - public static final int GL_INDEX_ARRAY_POINTER = 0x8091; - public static final int GL_TEXTURE_COORD_ARRAY_POINTER = 0x8092; - public static final int GL_EDGE_FLAG_ARRAY_POINTER = 0x8093; - public static final int GL_V2F = 0x2a20; - public static final int GL_V3F = 0x2a21; - public static final int GL_C4UB_V2F = 0x2a22; - public static final int GL_C4UB_V3F = 0x2a23; - public static final int GL_C3F_V3F = 0x2a24; - public static final int GL_N3F_V3F = 0x2a25; - public static final int GL_C4F_N3F_V3F = 0x2a26; - public static final int GL_T2F_V3F = 0x2a27; - public static final int GL_T4F_V4F = 0x2a28; - public static final int GL_T2F_C4UB_V3F = 0x2a29; - public static final int GL_T2F_C3F_V3F = 0x2a2a; - public static final int GL_T2F_N3F_V3F = 0x2a2b; - public static final int GL_T2F_C4F_N3F_V3F = 0x2a2c; - public static final int GL_T4F_C4F_N3F_V4F = 0x2a2d; - public static final int GL_LOGIC_OP = 0xbf1; - public static final int GL_TEXTURE_COMPONENTS = 0x1003; - - // GL12 - public static final int GL_TEXTURE_BINDING_3D = 0x806a; - public static final int GL_PACK_SKIP_IMAGES = 0x806b; - public static final int GL_PACK_IMAGE_HEIGHT = 0x806c; - public static final int GL_UNPACK_SKIP_IMAGES = 0x806d; - public static final int GL_UNPACK_IMAGE_HEIGHT = 0x806e; - public static final int GL_TEXTURE_3D = 0x806f; - public static final int GL_PROXY_TEXTURE_3D = 0x8070; - public static final int GL_TEXTURE_DEPTH = 0x8071; - public static final int GL_TEXTURE_WRAP_R = 0x8072; - public static final int GL_MAX_3D_TEXTURE_SIZE = 0x8073; - public static final int GL_BGR = 0x80e0; - public static final int GL_BGRA = 0x80e1; - public static final int GL_UNSIGNED_BYTE_3_3_2 = 0x8032; - public static final int GL_UNSIGNED_BYTE_2_3_3_REV = 0x8362; - public static final int GL_UNSIGNED_SHORT_5_6_5 = 0x8363; - public static final int GL_UNSIGNED_SHORT_5_6_5_REV = 0x8364; - public static final int GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033; - public static final int GL_UNSIGNED_SHORT_4_4_4_4_REV = 0x8365; - public static final int GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034; - public static final int GL_UNSIGNED_SHORT_1_5_5_5_REV = 0x8366; - public static final int GL_UNSIGNED_INT_8_8_8_8 = 0x8035; - public static final int GL_UNSIGNED_INT_8_8_8_8_REV = 0x8367; - public static final int GL_UNSIGNED_INT_10_10_10_2 = 0x8036; - public static final int GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368; - public static final int GL_RESCALE_NORMAL = 0x803a; - public static final int GL_LIGHT_MODEL_COLOR_CONTROL = 0x81f8; - public static final int GL_SINGLE_COLOR = 0x81f9; - public static final int GL_SEPARATE_SPECULAR_COLOR = 0x81fa; - public static final int GL_CLAMP_TO_EDGE = 0x812f; - public static final int GL_TEXTURE_MIN_LOD = 0x813a; - public static final int GL_TEXTURE_MAX_LOD = 0x813b; - public static final int GL_TEXTURE_BASE_LEVEL = 0x813c; - public static final int GL_TEXTURE_MAX_LEVEL = 0x813d; - public static final int GL_MAX_ELEMENTS_VERTICES = 0x80e8; - public static final int GL_MAX_ELEMENTS_INDICES = 0x80e9; - public static final int GL_ALIASED_POINT_SIZE_RANGE = 0x846d; - public static final int GL_ALIASED_LINE_WIDTH_RANGE = 0x846e; - public static final int GL_SMOOTH_POINT_SIZE_RANGE = 0xb12; - public static final int GL_SMOOTH_POINT_SIZE_GRANULARITY = 0xb13; - public static final int GL_SMOOTH_LINE_WIDTH_RANGE = 0xb22; - public static final int GL_SMOOTH_LINE_WIDTH_GRANULARITY = 0xb23; - - // GL13 - public static final int GL_TEXTURE0 = 0x84c0; - public static final int GL_TEXTURE1 = 0x84c1; - public static final int GL_TEXTURE2 = 0x84c2; - public static final int GL_TEXTURE3 = 0x84c3; - public static final int GL_TEXTURE4 = 0x84c4; - public static final int GL_TEXTURE5 = 0x84c5; - public static final int GL_TEXTURE6 = 0x84c6; - public static final int GL_TEXTURE7 = 0x84c7; - public static final int GL_TEXTURE8 = 0x84c8; - public static final int GL_TEXTURE9 = 0x84c9; - public static final int GL_TEXTURE10 = 0x84ca; - public static final int GL_TEXTURE11 = 0x84cb; - public static final int GL_TEXTURE12 = 0x84cc; - public static final int GL_TEXTURE13 = 0x84cd; - public static final int GL_TEXTURE14 = 0x84ce; - public static final int GL_TEXTURE15 = 0x84cf; - public static final int GL_TEXTURE16 = 0x84d0; - public static final int GL_TEXTURE17 = 0x84d1; - public static final int GL_TEXTURE18 = 0x84d2; - public static final int GL_TEXTURE19 = 0x84d3; - public static final int GL_TEXTURE20 = 0x84d4; - public static final int GL_TEXTURE21 = 0x84d5; - public static final int GL_TEXTURE22 = 0x84d6; - public static final int GL_TEXTURE23 = 0x84d7; - public static final int GL_TEXTURE24 = 0x84d8; - public static final int GL_TEXTURE25 = 0x84d9; - public static final int GL_TEXTURE26 = 0x84da; - public static final int GL_TEXTURE27 = 0x84db; - public static final int GL_TEXTURE28 = 0x84dc; - public static final int GL_TEXTURE29 = 0x84dd; - public static final int GL_TEXTURE30 = 0x84de; - public static final int GL_TEXTURE31 = 0x84df; - public static final int GL_ACTIVE_TEXTURE = 0x84e0; - public static final int GL_CLIENT_ACTIVE_TEXTURE = 0x84e1; - public static final int GL_MAX_TEXTURE_UNITS = 0x84e2; - public static final int GL_NORMAL_MAP = 0x8511; - public static final int GL_REFLECTION_MAP = 0x8512; - public static final int GL_TEXTURE_CUBE_MAP = 0x8513; - public static final int GL_TEXTURE_BINDING_CUBE_MAP = 0x8514; - public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515; - public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516; - public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517; - public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518; - public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519; - public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851a; - public static final int GL_PROXY_TEXTURE_CUBE_MAP = 0x851b; - public static final int GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851c; - public static final int GL_COMPRESSED_ALPHA = 0x84e9; - public static final int GL_COMPRESSED_LUMINANCE = 0x84ea; - public static final int GL_COMPRESSED_LUMINANCE_ALPHA = 0x84eb; - public static final int GL_COMPRESSED_INTENSITY = 0x84ec; - public static final int GL_COMPRESSED_RGB = 0x84ed; - public static final int GL_COMPRESSED_RGBA = 0x84ee; - public static final int GL_TEXTURE_COMPRESSION_HINT = 0x84ef; - public static final int GL_TEXTURE_COMPRESSED_IMAGE_SIZE = 0x86a0; - public static final int GL_TEXTURE_COMPRESSED = 0x86a1; - public static final int GL_NUM_COMPRESSED_TEXTURE_FORMATS = 0x86a2; - public static final int GL_COMPRESSED_TEXTURE_FORMATS = 0x86a3; - public static final int GL_MULTISAMPLE = 0x809d; - public static final int GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809e; - public static final int GL_SAMPLE_ALPHA_TO_ONE = 0x809f; - public static final int GL_SAMPLE_COVERAGE = 0x80a0; - public static final int GL_SAMPLE_BUFFERS = 0x80a8; - public static final int GL_SAMPLES = 0x80a9; - public static final int GL_SAMPLE_COVERAGE_VALUE = 0x80aa; - public static final int GL_SAMPLE_COVERAGE_INVERT = 0x80ab; - public static final int GL_MULTISAMPLE_BIT = 0x20000000; - public static final int GL_TRANSPOSE_MODELVIEW_MATRIX = 0x84e3; - public static final int GL_TRANSPOSE_PROJECTION_MATRIX = 0x84e4; - public static final int GL_TRANSPOSE_TEXTURE_MATRIX = 0x84e5; - public static final int GL_TRANSPOSE_COLOR_MATRIX = 0x84e6; - public static final int GL_COMBINE = 0x8570; - public static final int GL_COMBINE_RGB = 0x8571; - public static final int GL_COMBINE_ALPHA = 0x8572; - public static final int GL_SOURCE0_RGB = 0x8580; - public static final int GL_SOURCE1_RGB = 0x8581; - public static final int GL_SOURCE2_RGB = 0x8582; - public static final int GL_SOURCE0_ALPHA = 0x8588; - public static final int GL_SOURCE1_ALPHA = 0x8589; - public static final int GL_SOURCE2_ALPHA = 0x858a; - public static final int GL_OPERAND0_RGB = 0x8590; - public static final int GL_OPERAND1_RGB = 0x8591; - public static final int GL_OPERAND2_RGB = 0x8592; - public static final int GL_OPERAND0_ALPHA = 0x8598; - public static final int GL_OPERAND1_ALPHA = 0x8599; - public static final int GL_OPERAND2_ALPHA = 0x859a; - public static final int GL_RGB_SCALE = 0x8573; - public static final int GL_ADD_SIGNED = 0x8574; - public static final int GL_INTERPOLATE = 0x8575; - public static final int GL_SUBTRACT = 0x84e7; - public static final int GL_CONSTANT = 0x8576; - public static final int GL_PRIMARY_COLOR = 0x8577; - public static final int GL_PREVIOUS = 0x8578; - public static final int GL_DOT3_RGB = 0x86ae; - public static final int GL_DOT3_RGBA = 0x86af; - public static final int GL_CLAMP_TO_BORDER = 0x812d; - - // GL14 - public static final int GL_GENERATE_MIPMAP = 0x8191; - public static final int GL_GENERATE_MIPMAP_HINT = 0x8192; - public static final int GL_DEPTH_COMPONENT16 = 0x81a5; - public static final int GL_DEPTH_COMPONENT24 = 0x81a6; - public static final int GL_DEPTH_COMPONENT32 = 0x81a7; - public static final int GL_TEXTURE_DEPTH_SIZE = 0x884a; - public static final int GL_DEPTH_TEXTURE_MODE = 0x884b; - public static final int GL_TEXTURE_COMPARE_MODE = 0x884c; - public static final int GL_TEXTURE_COMPARE_FUNC = 0x884d; - public static final int GL_COMPARE_R_TO_TEXTURE = 0x884e; - public static final int GL_FOG_COORDINATE_SOURCE = 0x8450; - public static final int GL_FOG_COORDINATE = 0x8451; - public static final int GL_FRAGMENT_DEPTH = 0x8452; - public static final int GL_CURRENT_FOG_COORDINATE = 0x8453; - public static final int GL_FOG_COORDINATE_ARRAY_TYPE = 0x8454; - public static final int GL_FOG_COORDINATE_ARRAY_STRIDE = 0x8455; - public static final int GL_FOG_COORDINATE_ARRAY_POINTER = 0x8456; - public static final int GL_FOG_COORDINATE_ARRAY = 0x8457; - public static final int GL_POINT_SIZE_MIN = 0x8126; - public static final int GL_POINT_SIZE_MAX = 0x8127; - public static final int GL_POINT_FADE_THRESHOLD_SIZE = 0x8128; - public static final int GL_POINT_DISTANCE_ATTENUATION = 0x8129; - public static final int GL_COLOR_SUM = 0x8458; - public static final int GL_CURRENT_SECONDARY_COLOR = 0x8459; - public static final int GL_SECONDARY_COLOR_ARRAY_SIZE = 0x845a; - public static final int GL_SECONDARY_COLOR_ARRAY_TYPE = 0x845b; - public static final int GL_SECONDARY_COLOR_ARRAY_STRIDE = 0x845c; - public static final int GL_SECONDARY_COLOR_ARRAY_POINTER = 0x845d; - public static final int GL_SECONDARY_COLOR_ARRAY = 0x845e; - public static final int GL_BLEND_DST_RGB = 0x80c8; - public static final int GL_BLEND_SRC_RGB = 0x80c9; - public static final int GL_BLEND_DST_ALPHA = 0x80ca; - public static final int GL_BLEND_SRC_ALPHA = 0x80cb; - public static final int GL_INCR_WRAP = 0x8507; - public static final int GL_DECR_WRAP = 0x8508; - public static final int GL_TEXTURE_FILTER_CONTROL = 0x8500; - public static final int GL_TEXTURE_LOD_BIAS = 0x8501; - public static final int GL_MAX_TEXTURE_LOD_BIAS = 0x84fd; - public static final int GL_MIRRORED_REPEAT = 0x8370; - public static final int GL_BLEND_COLOR = 0x8005; - public static final int GL_BLEND_EQUATION = 0x8009; - public static final int GL_FUNC_ADD = 0x8006; - public static final int GL_FUNC_SUBTRACT = 0x800a; - public static final int GL_FUNC_REVERSE_SUBTRACT = 0x800b; - public static final int GL_MIN = 0x8007; - public static final int GL_MAX = 0x8008; - - // GL15 - public static final int GL_ARRAY_BUFFER = 0x8892; - public static final int GL_ELEMENT_ARRAY_BUFFER = 0x8893; - public static final int GL_ARRAY_BUFFER_BINDING = 0x8894; - public static final int GL_ELEMENT_ARRAY_BUFFER_BINDING = 0x8895; - public static final int GL_VERTEX_ARRAY_BUFFER_BINDING = 0x8896; - public static final int GL_NORMAL_ARRAY_BUFFER_BINDING = 0x8897; - public static final int GL_COLOR_ARRAY_BUFFER_BINDING = 0x8898; - public static final int GL_INDEX_ARRAY_BUFFER_BINDING = 0x8899; - public static final int GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING = 0x889a; - public static final int GL_EDGE_FLAG_ARRAY_BUFFER_BINDING = 0x889b; - public static final int GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING = 0x889c; - public static final int GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING = 0x889d; - public static final int GL_WEIGHT_ARRAY_BUFFER_BINDING = 0x889e; - public static final int GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889f; - public static final int GL_STREAM_DRAW = 0x88e0; - public static final int GL_STREAM_READ = 0x88e1; - public static final int GL_STREAM_COPY = 0x88e2; - public static final int GL_STATIC_DRAW = 0x88e4; - public static final int GL_STATIC_READ = 0x88e5; - public static final int GL_STATIC_COPY = 0x88e6; - public static final int GL_DYNAMIC_DRAW = 0x88e8; - public static final int GL_DYNAMIC_READ = 0x88e9; - public static final int GL_DYNAMIC_COPY = 0x88ea; - public static final int GL_READ_ONLY = 0x88b8; - public static final int GL_WRITE_ONLY = 0x88b9; - public static final int GL_READ_WRITE = 0x88ba; - public static final int GL_BUFFER_SIZE = 0x8764; - public static final int GL_BUFFER_USAGE = 0x8765; - public static final int GL_BUFFER_ACCESS = 0x88bb; - public static final int GL_BUFFER_MAPPED = 0x88bc; - public static final int GL_BUFFER_MAP_POINTER = 0x88bd; - public static final int FOG_COORD_SRC = 0x8450; - public static final int GL_FOG_COORD = 0x8451; - public static final int GL_CURRENT_FOG_COORD = 0x8453; - public static final int GL_FOG_COORD_ARRAY_TYPE = 0x8454; - public static final int GL_FOG_COORD_ARRAY_STRIDE = 0x8455; - public static final int GL_FOG_COORD_ARRAY_POINTER = 0x8456; - public static final int GL_FOG_COORD_ARRAY = 0x8457; - public static final int GL_FOG_COORD_ARRAY_BUFFER_BINDING = 0x889d; - public static final int GL_SRC0_RGB = 0x8580; - public static final int GL_SRC1_RGB = 0x8581; - public static final int GL_SRC2_RGB = 0x8582; - public static final int GL_SRC0_ALPHA = 0x8588; - public static final int GL_SRC1_ALPHA = 0x8589; - public static final int GL_SRC2_ALPHA = 0x858a; - - public static void glPushAttrib() - { - // GL_ENABLE_BIT | GL_LIGHTING_BIT - GlStateManager.pushAttrib(); - } - - public static void glPushAttrib(int mask) - { - GL11.glPushAttrib(mask); - } - - public static void glPopAttrib() - { - GlStateManager.popAttrib(); - } - - public static void glDisableAlphaTest() - { - GlStateManager.disableAlpha(); - } - - public static void glEnableAlphaTest() - { - GlStateManager.enableAlpha(); - } - - public static void glAlphaFunc(int func, float ref) - { - GlStateManager.alphaFunc(func, ref); - } - - public static void glEnableLighting() - { - GlStateManager.enableLighting(); - } - - public static void glDisableLighting() - { - GlStateManager.disableLighting(); - } - - public static void glEnableLight(int light) - { - GlStateManager.enableLight(light); // TODO OBF MCPTEST enableBooleanStateAt - enableLight - } - - public static void glDisableLight(int light) - { - GlStateManager.disableLight(light); // TODO OBF MCPTEST disableBooleanStateAt - disableLight - } - - public static void glLight(int light, int pname, FloatBuffer params) - { - GL11.glLight(light, pname, params); - } - - public static void glLightModel(int pname, FloatBuffer params) - { - GL11.glLightModel(pname, params); - } - - public static void glLightModeli(int pname, int param) - { - GL11.glLightModeli(pname, param); - } - - public static void glEnableColorMaterial() - { - GlStateManager.enableColorMaterial(); - } - - public static void glDisableColorMaterial() - { - GlStateManager.disableColorMaterial(); - } - - public static void glColorMaterial(int face, int mode) - { - GlStateManager.colorMaterial(face, mode); - } - - public static void glDisableDepthTest() - { - GlStateManager.disableDepth(); - } - - public static void glEnableDepthTest() - { - GlStateManager.enableDepth(); - } - - public static void glDepthFunc(int func) - { - GlStateManager.depthFunc(func); - } - - public static void glDepthMask(boolean flag) - { - GlStateManager.depthMask(flag); - } - - public static void glDisableBlend() - { - GlStateManager.disableBlend(); - } - - public static void glEnableBlend() - { - GlStateManager.enableBlend(); - } - - public static void glBlendFunc(int sfactor, int dfactor) - { - GlStateManager.blendFunc(sfactor, dfactor); - } - - public static void glBlendFuncSeparate(int sfactorRGB, int dfactorRGB, int sfactorAlpha, int dfactorAlpha) - { - GlStateManager.tryBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha); - } - - public static void glEnableFog() - { - GlStateManager.enableFog(); - } - - public static void glDisableFog() - { - GlStateManager.disableFog(); - } - - public static void glSetFogMode(int mode) - { - GlStateManager.setFog(mode); - } - - public static void glSetFogDensity(float density) - { - GlStateManager.setFogDensity(density); - } - - public static void glSetFogStart(float start) - { - GlStateManager.setFogStart(start); - } - - public static void glSetFogEnd(float end) - { - GlStateManager.setFogEnd(end); - } - - public static void glSetFogColour(FloatBuffer colour) - { - GL11.glFog(GL_FOG_COLOR, colour); - } - - public static void glFogi(int pname, int param) - { - GL11.glFogi(pname, param); - } - - public static void glFogf(int pname, float param) - { - GL11.glFogf(pname, param); - } - - public static void glEnableCulling() - { - GlStateManager.enableCull(); - } - - public static void glDisableCulling() - { - GlStateManager.disableCull(); - } - - public static void glCullFace(int mode) - { - GlStateManager.cullFace(mode); - } - - public static void glEnablePolygonOffset() - { - GlStateManager.enablePolygonOffset(); - } - - public static void glDisablePolygonOffset() - { - GlStateManager.disablePolygonOffset(); - } - - public static void glPolygonOffset(float factor, float units) - { - GlStateManager.doPolygonOffset(factor, units); - } - - public static void glEnableColorLogic() - { - GlStateManager.enableColorLogic(); - } - - public static void glDisableColorLogic() - { - GlStateManager.disableColorLogic(); - } - - public static void glLogicOp(int opcode) - { - GlStateManager.colorLogicOp(opcode); - } - - public static void glEnableTexGenCoord(TexGen tex) - { - GlStateManager.enableTexGenCoord(tex); - } - - public static void glDisableTexGenCoord(TexGen tex) - { - GlStateManager.disableTexGenCoord(tex); - } - - public static void glTexGeni(TexGen tex, int mode) - { - GlStateManager.texGen(tex, mode); - } - - public static void glTexGen(TexGen tex, int pname, FloatBuffer params) - { - GlStateManager.func_179105_a(tex, pname, params); - } - - public static void glSetActiveTextureUnit(int texture) - { - GlStateManager.setActiveTexture(texture); - } - - public static void glEnableTexture2D() - { - GlStateManager.enableTexture2D(); // TODO OBF MCPTEST func_179098_w - enableTexture2D - } - - public static void glDisableTexture2D() - { - GlStateManager.disableTexture2D(); // TODO OBF MCPTEST func_179090_x - disableTexture2D - } - - public static int glGenTextures() - { - return GlStateManager.generateTexture(); // TODO OBF MCPTEST func_179146_y - generateTexture - } - - public static void glDeleteTextures(int textureName) - { - GlStateManager.deleteTexture(textureName); // TODO OBF MCPTEST func_179150_h - deleteTexture - } - - public static void glBindTexture2D(int textureName) - { - GlStateManager.bindTexture(textureName); // TODO OBF MCPTEST func_179144_i - bindTexture - } - - public static void glEnableNormalize() - { - GlStateManager.enableNormalize(); - } - - public static void glDisableNormalize() - { - GlStateManager.disableNormalize(); - } - - public static void glShadeModel(int mode) - { - GlStateManager.shadeModel(mode); - } - - public static void glEnableRescaleNormal() - { - GlStateManager.enableRescaleNormal(); - } - - public static void glDisableRescaleNormal() - { - GlStateManager.disableRescaleNormal(); - } - - public static void glViewport(int x, int y, int width, int height) - { - GlStateManager.viewport(x, y, width, height); - } - - public static void glColorMask(boolean red, boolean green, boolean blue, boolean alpha) - { - GlStateManager.colorMask(red, green, blue, alpha); - } - - public static void glClearDepth(double depth) - { - GlStateManager.clearDepth(depth); - } - - public static void glClearColor(float red, float green, float blue, float alpha) - { - GlStateManager.clearColor(red, green, blue, alpha); - } - - public static void glClear(int mask) - { - GlStateManager.clear(mask); - } - - public static void glMatrixMode(int mode) - { - GlStateManager.matrixMode(mode); - } - - public static void glLoadIdentity() - { - GlStateManager.loadIdentity(); - } - - public static void glPushMatrix() - { - GlStateManager.pushMatrix(); - } - - public static void glPopMatrix() - { - GlStateManager.popMatrix(); - } - - public static void glGetFloat(int pname, FloatBuffer params) - { - GlStateManager.getFloat(pname, params); - } - - public static float glGetFloat(int pname) - { - return GL11.glGetFloat(pname); - } - - public static void glGetDouble(int pname, DoubleBuffer params) - { - GL11.glGetDouble(pname, params); - } - - public static double glGetDouble(int pname) - { - return GL11.glGetDouble(pname); - } - - public static void glGetInteger(int pname, IntBuffer params) - { - GL11.glGetInteger(pname, params); - } - - public static int glGetInteger(int pname) - { - return GL11.glGetInteger(pname); - } - - public static void glGetBoolean(int pname, ByteBuffer params) - { - GL11.glGetBoolean(pname, params); - } - - public static boolean glGetBoolean(int pname) - { - return GL11.glGetBoolean(pname); - } - - public static void gluProject(float objx, float objy, float objz, FloatBuffer modelMatrix, FloatBuffer projMatrix, IntBuffer viewport, - FloatBuffer winPos) - { - GLU.gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, winPos); - } - - public static void gluPerspective(float fovy, float aspect, float zNear, float zFar) - { - GLU.gluPerspective(fovy, aspect, zNear, zFar); - } - - public static void glOrtho(double left, double right, double bottom, double top, double zNear, double zFar) - { - GlStateManager.ortho(left, right, bottom, top, zNear, zFar); - } - - public static void glRotatef(float angle, float x, float y, float z) - { - GlStateManager.rotate(angle, x, y, z); - } - - public static void glRotated(double angle, double x, double y, double z) - { - GL11.glRotated(angle, x, y, z); - } - - public static void glScalef(float x, float y, float z) - { - GlStateManager.scale(x, y, z); - } - - public static void glScaled(double x, double y, double z) - { - GlStateManager.scale(x, y, z); - } - - public static void glTranslatef(float x, float y, float z) - { - GlStateManager.translate(x, y, z); - } - - public static void glTranslated(double x, double y, double z) - { - GlStateManager.translate(x, y, z); - } - - public static void glMultMatrix(FloatBuffer m) - { - GlStateManager.multMatrix(m); - } - - public static void glColor4f(float red, float green, float blue, float alpha) - { - GlStateManager.color(red, green, blue, alpha); - } - - public static void glColor3f(float red, float green, float blue) - { - GlStateManager.color(red, green, blue, 1.0F); - } - - public static void glResetColor() - { - GlStateManager.resetColor(); - } - - public static void glCallList(int list) - { - GlStateManager.callList(list); - } - - public static void glCallLists(IntBuffer lists) - { - GL11.glCallLists(lists); - } - - public static void glNewList(int list, int mode) - { - GL11.glNewList(list, mode); - } - - public static void glEndList() - { - GL11.glEndList(); - } - - public static void glLineWidth(float width) - { - GL11.glLineWidth(width); - } - - public static void glPolygonMode(int face, int mode) - { - GL11.glPolygonMode(face, mode); - } - - public static void glPixelStorei(int pname, int param) - { - GL11.glPixelStorei(pname, param); - } - - public static void glReadPixels(int x, int y, int width, int height, int format, int type, ByteBuffer pixels) - { - GL11.glReadPixels(x, y, width, height, format, type, pixels); - } - - public static void glGetTexImage(int target, int level, int format, int type, ByteBuffer pixels) - { - GL11.glGetTexImage(target, level, format, type, pixels); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/gl/GLClippingPlanes.java b/liteloader/src/client/java/com/mumfrey/liteloader/gl/GLClippingPlanes.java deleted file mode 100644 index a7d4c76b..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/gl/GLClippingPlanes.java +++ /dev/null @@ -1,193 +0,0 @@ -package com.mumfrey.liteloader.gl; - -import static org.lwjgl.opengl.GL11.*; - -import java.nio.DoubleBuffer; - -import org.lwjgl.BufferUtils; -import org.lwjgl.util.Rectangle; - -/** - * OpenGL clipping plane convenience functions. We prefer to clip rectangular - * GUI regions in Minecraft using clipping rather than scissor because scissor - * is a nuisance to work with, primarily because it works in "window" (OpenGL - * window) coordinates and doesn't respect the current transformation matrix. - * Using clipping planes we can specify clipping edges in "Minecraft screen - * coordinates", can optionally clip on only one or two axes, and also don't - * need to worry about the current transform. - * - * @author Adam Mummery-Smith - */ -public final class GLClippingPlanes -{ - public enum Plane - { - LEFT(GL_CLIP_PLANE0), - RIGHT(GL_CLIP_PLANE1), - TOP(GL_CLIP_PLANE2), - BOTTOM(GL_CLIP_PLANE3); - - final int plane; - final int sign; - - private Plane(int plane) - { - this.plane = plane; - this.sign = (plane % 2 == 0) ? -1 : 1; - } - } - - private static final int STACK_DEPTH = 1; - private static final int STACK_FRAME_SIZE = 128; - - private static DoubleBuffer doubleBuffer = BufferUtils.createByteBuffer(STACK_FRAME_SIZE * STACK_DEPTH).asDoubleBuffer(); - - private static int clippingPlaneFlags = 0; - - private static int totalClippingPlanes = glGetInteger(GL_MAX_CLIP_PLANES); - -// private static int frame = 0; - - static - { - for (int f = 0; f < STACK_DEPTH; f++) - { - // Clipping normals - GLClippingPlanes.doubleBuffer.put(1).put(0).put(0).put(0); - GLClippingPlanes.doubleBuffer.put(-1).put(0).put(0).put(0); - GLClippingPlanes.doubleBuffer.put(0).put(1).put(0).put(0); - GLClippingPlanes.doubleBuffer.put(0).put(-1).put(0).put(0); - } - } - - private GLClippingPlanes() {} - - /** - * Get the total number of available clipping planes on the platform - */ - public static int glGetTotalClippingPlanes() - { - return GLClippingPlanes.totalClippingPlanes; - } - - /** - * Enable OpenGL clipping planes (uses planes 0, 1, 2 and 3) - * - * @param left Left edge clip or -1 to not use this plane - * @param right Right edge clip or -1 to not use this plane - * @param top Top edge clip or -1 to not use this plane - * @param bottom Bottom edge clip or -1 to not use this plane - */ - public static void glEnableClipping(int left, int right, int top, int bottom) - { - GLClippingPlanes.clippingPlaneFlags = 0; - - glEnableClipping(GL_CLIP_PLANE0, left, -1); - glEnableClipping(GL_CLIP_PLANE1, right, 1); - glEnableClipping(GL_CLIP_PLANE2, top, -1); - glEnableClipping(GL_CLIP_PLANE3, bottom, 1); - } - - /** - * Enable OpenGL clipping planes (uses planes 0, 1, 2 and 3) - * - * @param rect Clipping rectangle - */ - public static void glEnableClipping(Rectangle rect) - { - GLClippingPlanes.clippingPlaneFlags = 0; - - glEnableClipping(GL_CLIP_PLANE0, rect.getX(), -1); - glEnableClipping(GL_CLIP_PLANE1, rect.getX() + rect.getWidth(), 1); - glEnableClipping(GL_CLIP_PLANE2, rect.getY(), -1); - glEnableClipping(GL_CLIP_PLANE3, rect.getY() + rect.getHeight(), 1); - } - - /** - * Enable horizontal clipping planes (left and right) (uses planes 0, 1) - * - * @param left Left edge clip or -1 to not use this plane - * @param right Right edge clip or -1 to not use this plane - */ - public static void glEnableHorizontalClipping(int left, int right) - { - glEnableClipping(GL_CLIP_PLANE0, left, -1); - glEnableClipping(GL_CLIP_PLANE1, right, 1); - } - - /** - * Enable vertical clipping planes (top and bottom) (uses planes 2, 3) - * - * @param top Top edge clip or -1 to not use this plane - * @param bottom Bottom edge clip or -1 to not use this plane - */ - public static void glEnableVerticalClipping(int top, int bottom) - { - glEnableClipping(GL_CLIP_PLANE2, top, -1); - glEnableClipping(GL_CLIP_PLANE3, bottom, 1); - } - - /** - * @param plane - * @param value - */ - public static void glEnableClipping(int plane, int value) - { - if (plane < GL_CLIP_PLANE0 || plane >= (GL_CLIP_PLANE0 + GLClippingPlanes.totalClippingPlanes)) - { - throw new IllegalArgumentException("Invalid clipping plane enum specified GL_CLIP_PLANE" + (plane - GL_CLIP_PLANE0)); - } - - glEnableClipping(plane, value, (plane % 2 == 0) ? -1 : 1); - } - - /** - * @param plane - * @param value - */ - public static void glEnableClipping(Plane plane, int value) - { - glEnableClipping(plane.plane, value, plane.sign); - } - - /** - * Enable clipping on a particular axis - * - * @param plane Clipping plane to enable - * @param value Clipping plane position - * @param sign Sign of the position - */ - private static void glEnableClipping(int plane, int value, int sign) - { - if (value == -1) return; - - int offset = (plane - GL_CLIP_PLANE0) << 2; - GLClippingPlanes.doubleBuffer.put(offset + 3, value * sign).position(offset); - GLClippingPlanes.clippingPlaneFlags |= plane; - - glClipPlane(plane, GLClippingPlanes.doubleBuffer); - glEnable(plane); - } - - /** - * Enable clipping planes which were previously enabled - */ - public static void glEnableClipping() - { - if ((GLClippingPlanes.clippingPlaneFlags & GL_CLIP_PLANE0) == GL_CLIP_PLANE0) glEnable(GL_CLIP_PLANE0); - if ((GLClippingPlanes.clippingPlaneFlags & GL_CLIP_PLANE1) == GL_CLIP_PLANE1) glEnable(GL_CLIP_PLANE1); - if ((GLClippingPlanes.clippingPlaneFlags & GL_CLIP_PLANE2) == GL_CLIP_PLANE2) glEnable(GL_CLIP_PLANE2); - if ((GLClippingPlanes.clippingPlaneFlags & GL_CLIP_PLANE3) == GL_CLIP_PLANE3) glEnable(GL_CLIP_PLANE3); - } - - /** - * Disable OpenGL clipping planes (uses planes 2, 3, 4 and 5) - */ - public static void glDisableClipping() - { - glDisable(GL_CLIP_PLANE3); - glDisable(GL_CLIP_PLANE2); - glDisable(GL_CLIP_PLANE1); - glDisable(GL_CLIP_PLANE0); - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/resources/InternalResourcePack.java b/liteloader/src/client/java/com/mumfrey/liteloader/resources/InternalResourcePack.java deleted file mode 100644 index 331221e7..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/resources/InternalResourcePack.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.mumfrey.liteloader.resources; - -import java.awt.image.BufferedImage; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashSet; -import java.util.Set; - -import net.minecraft.client.resources.IResourcePack; -import net.minecraft.client.resources.data.IMetadataSection; -import net.minecraft.client.resources.data.IMetadataSerializer; -import net.minecraft.util.ResourceLocation; - -/** - * Resource pack which returns resources using Class::getResourceAsStream() on - * the specified class. - * - * @author Adam Mummery-Smith - */ -public class InternalResourcePack implements IResourcePack -{ - /** - * Domains supported by this resource pack - */ - private final Set resourceDomains = new HashSet(); - - /** - * Name of this resource pack - */ - private final String packName; - - /** - * Class to execute getResourceAsStream() upon - */ - private final Class resourceClass; - - /** - * @param name - * @param resourceClass - * @param domains - */ - public InternalResourcePack(String name, Class resourceClass, String... domains) - { - if (domains.length < 1) throw new IllegalArgumentException("No domains specified for internal resource pack"); - - this.packName = name; - this.resourceClass = resourceClass; - - for (String domain : domains) - this.resourceDomains.add(domain); - } - - /* (non-Javadoc) - * @see net.minecraft.client.resources.IResourcePack - * #getInputStream(net.minecraft.util.ResourceLocation) - */ - @Override - public InputStream getInputStream(ResourceLocation resourceLocation) throws IOException - { - return this.getResourceStream(resourceLocation); - } - - /** - * @param resourceLocation - */ - private InputStream getResourceStream(ResourceLocation resourceLocation) - { - return this.resourceClass.getResourceAsStream(String.format("/assets/%s/%s", - resourceLocation.getResourceDomain(), resourceLocation.getResourcePath())); - } - - /* (non-Javadoc) - * @see net.minecraft.client.resources.IResourcePack#resourceExists( - * net.minecraft.util.ResourceLocation) - */ - @Override - public boolean resourceExists(ResourceLocation resourceLocation) - { - return this.getResourceStream(resourceLocation) != null; - } - - /* (non-Javadoc) - * @see net.minecraft.client.resources.IResourcePack#getResourceDomains() - */ - @Override - public Set getResourceDomains() - { - return this.resourceDomains; - } - - /* (non-Javadoc) - * @see net.minecraft.client.resources.IResourcePack#getPackMetadata( - * net.minecraft.client.resources.data.IMetadataSerializer, - * java.lang.String) - */ - @Override - public IMetadataSection getPackMetadata(IMetadataSerializer par1MetadataSerializer, String par2Str) throws IOException - { - return null; - } - - /* (non-Javadoc) - * @see net.minecraft.client.resources.IResourcePack#getPackImage() - */ - @Override - public BufferedImage getPackImage() throws IOException - { - return null; - } - - /* (non-Javadoc) - * @see net.minecraft.client.resources.IResourcePack#getPackName() - */ - @Override - public String getPackName() - { - return this.packName; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/resources/ModResourcePack.java b/liteloader/src/client/java/com/mumfrey/liteloader/resources/ModResourcePack.java deleted file mode 100644 index f8fa5acc..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/resources/ModResourcePack.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.mumfrey.liteloader.resources; - -import java.io.File; -import java.io.IOException; - -import net.minecraft.client.resources.FileResourcePack; -import net.minecraft.client.resources.data.IMetadataSection; -import net.minecraft.client.resources.data.IMetadataSerializer; - -/** - * Resource pack which wraps a mod file - * - * @author Adam Mummery-Smith - */ -public class ModResourcePack extends FileResourcePack -{ - /** - * Display name, only shows up in debug output - */ - private final String name; - - /** - * @param name Friendly name - * @param modFile - */ - public ModResourcePack(String name, File modFile) - { - super(modFile); - this.name = name; - } - - /* (non-Javadoc) - * @see net.minecraft.client.resources.AbstractResourcePack#getPackMetadata( - * net.minecraft.client.resources.data.IMetadataSerializer, - * java.lang.String) - */ - @Override - public IMetadataSection getPackMetadata(IMetadataSerializer metadataSerializer, String metadataSectionName) throws IOException - { - try - { - // This will fail when fetching pack.mcmeta if there isn't one in the mod file, since we don't care we - // just catch the exception and return null instead - return super.getPackMetadata(metadataSerializer, metadataSectionName); - } - catch (Exception ex) {} - - return null; - } - - /* (non-Javadoc) - * @see net.minecraft.client.resources.AbstractResourcePack#getPackName() - */ - @Override - public String getPackName() - { - return this.name; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/resources/ModResourcePackDir.java b/liteloader/src/client/java/com/mumfrey/liteloader/resources/ModResourcePackDir.java deleted file mode 100644 index 5efba35f..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/resources/ModResourcePackDir.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.mumfrey.liteloader.resources; - -import java.io.File; -import java.io.IOException; - -import net.minecraft.client.resources.FolderResourcePack; -import net.minecraft.client.resources.data.IMetadataSection; -import net.minecraft.client.resources.data.IMetadataSerializer; - -/** - * Resource pack which wraps a mod directory on the classpath - * - * @author Adam Mummery-Smith - */ -public class ModResourcePackDir extends FolderResourcePack -{ - /** - * Display name, only shows up in debug output - */ - private final String name; - - /** - * @param name Friendly name - * @param modFile - */ - public ModResourcePackDir(String name, File modFile) - { - super(modFile); - this.name = name; - } - - /* (non-Javadoc) - * @see net.minecraft.client.resources.AbstractResourcePack#getPackMetadata( - * net.minecraft.client.resources.data.IMetadataSerializer, - * java.lang.String) - */ - @Override - public IMetadataSection getPackMetadata(IMetadataSerializer metadataSerializer, String metadataSectionName) throws IOException - { - try - { - // This will fail when fetching pack.mcmeta if there isn't one in the mod file, since we don't care we - // just catch the exception and return null instead - return super.getPackMetadata(metadataSerializer, metadataSectionName); - } - catch (Exception ex) {} - - return null; - } - - /* (non-Javadoc) - * @see net.minecraft.client.resources.AbstractResourcePack#getPackName() - */ - @Override - public String getPackName() - { - return this.name; - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/util/InputManager.java b/liteloader/src/client/java/com/mumfrey/liteloader/util/InputManager.java deleted file mode 100644 index 76be35bd..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/util/InputManager.java +++ /dev/null @@ -1,361 +0,0 @@ -package com.mumfrey.liteloader.util; - -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import net.java.games.input.Component; -import net.java.games.input.Controller; -import net.java.games.input.Event; -import net.java.games.input.EventQueue; -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.profiler.Profiler; - -import com.mumfrey.liteloader.common.GameEngine; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.util.jinput.ComponentRegistry; - -/** - * Mod input class, aggregates functionality from LiteLoader's mod key - * registration functions and JInputLib. - * - * @author Adam Mummery-Smith - */ -public final class InputManager extends Input -{ - private GameEngine engine; - - /** - * - */ - private Profiler profiler; - - /** - * File in which we will store mod key mappings - */ - private final File keyMapSettingsFile; - - /** - * Properties object which stores mod key mappings - */ - private final Properties keyMapSettings = new Properties(); - - /** - * List of all registered mod keys - */ - private final List modKeyBindings = new ArrayList(); - - /** - * Map of mod key bindings to their key codes, stored so that we don't need - * to cast from string in the properties file every tick. - */ - private final Map storedModKeyBindings = new HashMap(); - - /** - * JInput component registry - */ - private final ComponentRegistry jInputComponentRegistry; - - /** - * List of handlers for JInput components - */ - private final Map componentEvents = new HashMap(); - - /** - * JInput Controllers to poll - */ - private Controller[] pollControllers = new Controller[0]; - - /** - * - */ - public InputManager(LoaderEnvironment environment, LoaderProperties properties) - { - if (LiteLoader.getInstance() != null && LiteLoader.getInput() != null) - { - throw new IllegalStateException("Only one instance of Input is allowed, use LiteLoader.getInput() to get the active instance"); - } - - this.keyMapSettingsFile = new File(environment.getCommonConfigFolder(), "liteloader.keys.properties"); - this.jInputComponentRegistry = new ComponentRegistry(); - - if (!properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_JINPUT_DISABLE, false)) - { - this.jInputComponentRegistry.enumerate(); - } - } - - @Override - public void onInit() - { - if (this.keyMapSettingsFile.exists()) - { - try - { - this.keyMapSettings.load(new FileReader(this.keyMapSettingsFile)); - } - catch (Exception ex) {} - } - } - - @Override - public void onPostInit(GameEngine engine) - { - this.engine = engine; - this.profiler = engine.getProfiler(); - } - - /** - * Register a key for a mod - * - * @param binding - */ - @Override - public void registerKeyBinding(KeyBinding binding) - { - List keyBindings = this.engine.getKeyBindings(); - - if (!keyBindings.contains(binding)) - { - if (this.keyMapSettings.containsKey(binding.getKeyDescription())) - { - try - { - int code = Integer.parseInt(this.keyMapSettings.getProperty(binding.getKeyDescription(), String.valueOf(binding.getKeyCode()))); - binding.setKeyCode(code); - } - catch (NumberFormatException ex) {} - } - - keyBindings.add(binding); - - this.engine.setKeyBindings(keyBindings); - this.modKeyBindings.add(binding); - - this.updateBinding(binding); - this.storeBindings(); - - KeyBinding.resetKeyBindingArrayAndHash(); - } - } - - /** - * Unregisters a registered keybind with the game settings class, thus - * removing it from the "controls" screen. - * - * @param binding - */ - @Override - public void unRegisterKeyBinding(KeyBinding binding) - { - List keyBindings = this.engine.getKeyBindings(); - - if (keyBindings.contains(binding)) - { - keyBindings.remove(binding); - this.engine.setKeyBindings(keyBindings); - - this.modKeyBindings.remove(binding); - - KeyBinding.resetKeyBindingArrayAndHash(); - } - } - - /** - * Checks for changed mod keybindings and stores any that have changed - */ - @Override - public void onTick(boolean clock, float partialTicks, boolean inGame) - { - this.profiler.startSection("keybindings"); - if (clock) - { - boolean updated = false; - - for (KeyBinding binding : this.modKeyBindings) - { - if (binding.getKeyCode() != this.storedModKeyBindings.get(binding)) - { - this.updateBinding(binding); - updated = true; - } - } - - if (updated) this.storeBindings(); - } - - this.pollControllers(); - this.profiler.endSection(); - } - - /** - * @param binding - */ - private void updateBinding(KeyBinding binding) - { - this.keyMapSettings.setProperty(binding.getKeyDescription(), String.valueOf(binding.getKeyCode())); - this.storedModKeyBindings.put(binding, Integer.valueOf(binding.getKeyCode())); - } - - @Override - public void onShutDown() - { - this.storeBindings(); - } - - /** - * Writes mod bindings to disk - */ - @Override - public void storeBindings() - { - try - { - this.keyMapSettings.store(new FileWriter(this.keyMapSettingsFile), - "Mod key mappings for LiteLoader mods, stored here to avoid losing settings stored in options.txt"); - } - catch (IOException ex) {} - } - - /** - * Gets the underlying JInput component registry - */ - @Override - public ComponentRegistry getComponentRegistry() - { - return this.jInputComponentRegistry; - } - - /** - * Returns a handle to the event described by descriptor (or null if no - * component is found matching the descriptor. Retrieving an event via this - * method adds the controller (if found) to the polling list and causes it - * to raise events against the specified handler. - * - *

This method returns an {@link InputEvent} which is passed as an - * argument to the relevant callback on the supplied handler in order to - * identify the event. For example:

- * - * this.joystickButton = input.getEvent(descriptor, this); - * - *

then in onAxisEvent

- * - * if (source == this.joystickButton) // do something with button - * - * - * @param descriptor - * @param handler - */ - @Override - public InputEvent getEvent(String descriptor, InputHandler handler) - { - if (handler == null) return null; - Component component = this.jInputComponentRegistry.getComponent(descriptor); - Controller controller = this.jInputComponentRegistry.getController(descriptor); - return this.addEventHandler(controller, component, handler); - } - - /** - * Get events for all components which match the supplied descriptor - * - * @param descriptor - * @param handler - */ - @Override - public InputEvent[] getEvents(String descriptor, InputHandler handler) - { - List events = new ArrayList(); - Controller controller = this.jInputComponentRegistry.getController(descriptor); - if (controller != null) - { - for (Component component : controller.getComponents()) - { - events.add(this.addEventHandler(controller, component, handler)); - } - } - - return events.toArray(new InputEvent[0]); - } - - /** - * @param controller - * @param component - * @param handler - */ - private InputEvent addEventHandler(Controller controller, Component component, InputHandler handler) - { - if (controller != null && component != null && handler != null) - { - this.addController(controller); - - InputEvent event = new InputEvent(controller, component, handler); - this.componentEvents.put(component, event.link(this.componentEvents.get(component))); - - return event; - } - - return null; - } - - /** - * @param controller - */ - private void addController(Controller controller) - { - Set controllers = this.getActiveControllers(); - controllers.add(controller); - this.setActiveControllers(controllers); - } - - /** - * - */ - private Set getActiveControllers() - { - Set allControllers = new HashSet(); - for (Controller controller : this.pollControllers) - allControllers.add(controller); - return allControllers; - } - - /** - * @param controllers - */ - private void setActiveControllers(Set controllers) - { - this.pollControllers = controllers.toArray(new Controller[controllers.size()]); - } - - /** - * - */ - private void pollControllers() - { - for (Controller controller : this.pollControllers) - { - controller.poll(); - EventQueue controllerQueue = controller.getEventQueue(); - - for (Event event = new Event(); controllerQueue.getNextEvent(event); ) - { - Component cmp = event.getComponent(); - - InputEvent inputEvent = this.componentEvents.get(cmp); - if (inputEvent != null) - { - inputEvent.onEvent(event); - } - } - } - } -} diff --git a/liteloader/src/client/java/com/mumfrey/liteloader/util/ModUtilities.java b/liteloader/src/client/java/com/mumfrey/liteloader/util/ModUtilities.java deleted file mode 100644 index e28fb761..00000000 --- a/liteloader/src/client/java/com/mumfrey/liteloader/util/ModUtilities.java +++ /dev/null @@ -1,253 +0,0 @@ -package com.mumfrey.liteloader.util; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.IdentityHashMap; -import java.util.List; -import java.util.Map; - -import org.lwjgl.LWJGLException; -import org.lwjgl.opengl.Display; -import org.lwjgl.opengl.DisplayMode; - -import com.mumfrey.liteloader.client.ducks.*; -import com.mumfrey.liteloader.client.overlays.IMinecraft; -import com.mumfrey.liteloader.client.util.PrivateFieldsClient; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -import net.minecraft.block.Block; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.entity.Render; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; -import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; -import net.minecraft.entity.Entity; -import net.minecraft.init.Blocks; -import net.minecraft.init.Items; -import net.minecraft.item.Item; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.RegistrySimple; -import net.minecraft.util.ResourceLocation; - -/** - * A small collection of useful functions for mods - * - * @author Adam Mummery-Smith - */ -public abstract class ModUtilities -{ - /** - * @return true if FML is present in the current environment - */ - public static boolean fmlIsPresent() - { - return ObfuscationUtilities.fmlIsPresent(); - } - - public static void setWindowSize(int width, int height) - { - try - { - Minecraft mc = Minecraft.getMinecraft(); - Display.setDisplayMode(new DisplayMode(width, height)); - ((IMinecraft)mc).onResizeWindow(width, height); - Display.setVSyncEnabled(mc.gameSettings.enableVsync); - } - catch (LWJGLException ex) - { - ex.printStackTrace(); - } - } - - /** - * Add a renderer map entry for the specified entity class - * - * @param entityClass - * @param renderer - */ - public static void addRenderer(Class entityClass, Render renderer) - { - RenderManager renderManager = Minecraft.getMinecraft().getRenderManager(); - - Map, Render> entityRenderMap = ((IRenderManager)renderManager).getRenderMap(); - if (entityRenderMap != null) - { - entityRenderMap.put(entityClass, renderer); - } - else - { - LiteLoaderLogger.warning("Attempted to set renderer %s for entity class %s but the operation failed", - renderer.getClass().getSimpleName(), entityClass.getSimpleName()); - } - } - - public static void addRenderer(Class tileEntityClass, TileEntitySpecialRenderer renderer) - { - TileEntityRendererDispatcher tileEntityRenderer = TileEntityRendererDispatcher.instance; - - try - { - Map, TileEntitySpecialRenderer> specialRendererMap - = ((ITileEntityRendererDispatcher)tileEntityRenderer).getSpecialRenderMap(); - specialRendererMap.put(tileEntityClass, renderer); - renderer.setRendererDispatcher(tileEntityRenderer); - } - catch (Exception ex) - { - LiteLoaderLogger.warning("Attempted to set renderer %s for tile entity class %s but the operation failed", - renderer.getClass().getSimpleName(), tileEntityClass.getSimpleName()); - } - } - - /** - * Add a block to the blocks registry - * - * @param blockId Block ID to insert - * @param blockName Block identifier - * @param block Block to register - * @param force Force insertion even if the operation is blocked by FMl - */ - public static void addBlock(int blockId, ResourceLocation blockName, Block block, boolean force) - { - Block existingBlock = (Block)Block.blockRegistry.getObject(blockName); - - try - { - Block.blockRegistry.register(blockId, blockName, block); - } - catch (IllegalArgumentException ex) - { - if (!force) throw new IllegalArgumentException("Could not register block '" + blockName + "', the operation was blocked by FML.", ex); - - ModUtilities.removeObjectFromRegistry(Block.blockRegistry, blockName); - Block.blockRegistry.register(blockId, blockName, block); - } - - if (existingBlock != null) - { - try - { - for (Field field : Blocks.class.getDeclaredFields()) - { - field.setAccessible(true); - if (field.isAccessible() && Block.class.isAssignableFrom(field.getType())) - { - Block fieldValue = (Block)field.get(null); - if (fieldValue == existingBlock) - { - ModUtilities.setFinalStaticField(field, block); - } - } - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - } - - /** - * Add an item to the items registry - * - * @param itemId Item ID to insert - * @param itemName Item identifier - * @param item Item to register - * @param force Force insertion even if the operation is blocked by FMl - */ - public static void addItem(int itemId, ResourceLocation itemName, Item item, boolean force) - { - Item existingItem = (Item)Item.itemRegistry.getObject(itemName); - - try - { - Item.itemRegistry.register(itemId, itemName, item); - } - catch (IllegalArgumentException ex) - { - if (!force) throw new IllegalArgumentException("Could not register item '" + itemName + "', the operation was blocked by FML.", ex); - - ModUtilities.removeObjectFromRegistry(Block.blockRegistry, itemName); - Item.itemRegistry.register(itemId, itemName, item); - } - - if (existingItem != null) - { - try - { - for (Field field : Items.class.getDeclaredFields()) - { - field.setAccessible(true); - if (field.isAccessible() && Item.class.isAssignableFrom(field.getType())) - { - Item fieldValue = (Item)field.get(null); - if (fieldValue == existingItem) - { - ModUtilities.setFinalStaticField(field, item); - } - } - } - } - catch (Exception ex) {} - } - } - - @SuppressWarnings("unchecked") - public static void addTileEntity(String entityName, Class tileEntityClass) - { - try - { - Map> nameToClassMap = PrivateFieldsClient.tileEntityNameToClassMap.get(null); - Map, String> classToNameMap = PrivateFieldsClient.tileEntityClassToNameMap.get(null); - nameToClassMap.put(entityName, tileEntityClass); - classToNameMap.put(tileEntityClass, entityName); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - private static V removeObjectFromRegistry(RegistrySimple registry, K key) - { - if (registry == null) return null; - - IObjectIntIdentityMap underlyingIntegerMap = null; - - if (registry instanceof INamespacedRegistry) - { - underlyingIntegerMap = ((INamespacedRegistry)registry).getUnderlyingMap(); - } - - Map registryObjects = ((IRegistrySimple)registry).getRegistryObjects(); - if (registryObjects != null) - { - V existingValue = registryObjects.get(key); - if (existingValue != null) - { - registryObjects.remove(key); - - if (underlyingIntegerMap != null) - { - IdentityHashMap identityMap = underlyingIntegerMap.getIdentityMap(); - List objectList = underlyingIntegerMap.getObjectList(); - if (identityMap != null) identityMap.remove(existingValue); - if (objectList != null) objectList.remove(existingValue); - } - - return existingValue; - } - } - - return null; - } - - private static void setFinalStaticField(Field field, Object value) - throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException - { - Field modifiers = Field.class.getDeclaredField("modifiers"); - modifiers.setAccessible(true); - modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL); - field.set(null, value); - } -} diff --git a/liteloader/src/client/resources/mixins.liteloader.client.json b/liteloader/src/client/resources/mixins.liteloader.client.json deleted file mode 100644 index bed9cc0b..00000000 --- a/liteloader/src/client/resources/mixins.liteloader.client.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "required": true, - "minVersion": "0.4.10", - "package": "com.mumfrey.liteloader.client.mixin", - "refmap": "mixins.liteloader.client.refmap.json", - "mixins": [ - "MixinMinecraft", - "MixinSession", - "MixinEntityRenderer", - "MixinRenderManager", - "MixinGuiIngame", - "MixinEntityPlayerSP", - "MixinFramebuffer", - "MixinIntegratedServer", - "MixinScreenShotHelper", - "MixinRealmsMainScreen", - "MixinNetHandlerLoginClient", - "MixinRegistrySimple", - "MixinRegistryNamespaced", - "MixinTileEntityRendererDispatcher", - "MixinSimpleReloadableResourceManager" - ] -} \ No newline at end of file diff --git a/liteloader/src/debug/java/com/mumfrey/liteloader/debug/LoginManager.java b/liteloader/src/debug/java/com/mumfrey/liteloader/debug/LoginManager.java deleted file mode 100644 index 7c56e93a..00000000 --- a/liteloader/src/debug/java/com/mumfrey/liteloader/debug/LoginManager.java +++ /dev/null @@ -1,458 +0,0 @@ -package com.mumfrey.liteloader.debug; - -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.lang.reflect.Type; -import java.net.Proxy; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import javax.swing.JOptionPane; - -import com.google.common.base.Strings; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonPrimitive; -import com.google.gson.JsonSerializationContext; -import com.google.gson.JsonSerializer; -import com.google.gson.annotations.SerializedName; -import com.mojang.authlib.Agent; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.UserType; -import com.mojang.authlib.exceptions.AuthenticationException; -import com.mojang.authlib.exceptions.InvalidCredentialsException; -import com.mojang.authlib.properties.Property; -import com.mojang.authlib.properties.PropertyMap; -import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService; -import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Manages login requests against Yggdrasil for use in MCP - * - * @author Adam Mummery-Smith - */ -public class LoginManager -{ - /** - * Gson instance for serialising and deserialising the authentication data - */ - private static Gson gson = new GsonBuilder().setPrettyPrinting().create(); - - /** - * Authentication service - */ - private YggdrasilAuthenticationService authService; - - /** - * Authentication agent - */ - private YggdrasilUserAuthentication authentication; - - /** - * JSON file to load/save auth data from - */ - private File jsonFile; - - /** - * Username read from the auth JSON file, we use this as the default in the - * login dialog in case login fails. This is stored in the JSON even if - * authentication is not successful so that we can display the same username - * next time. - */ - private String defaultUsername; - - /** - * Minecraft screen name read from the auth JSON file. Use this as default - * in case the login fails or is skipped (when offline) so that at least the - * Minecraft client has a sensible display name. - * - *

Defaults to user.name when not specified

- */ - private String defaultDisplayName = System.getProperty("user.name"); - - /** - * True if login should not be attempted, skips the authentication attempt - * and the login dialog. - */ - private boolean offline = false; - - /** - * If authentication fails with token then the first attempt will be to use - * the user/pass specified on the command line (if any). This flag is set - * after that first attempt so that we know to display the login - * dialog anyway (eg. the login on the command line was bad). - */ - private boolean forceShowLoginDialog = false; - - /** - * ctor - * - * @param jsonFile - */ - public LoginManager(File jsonFile) - { - this.jsonFile = jsonFile; - - this.resetAuth(); - this.load(); - } - - /** - * When authenticaion fails, we regenerate the auth service and agent - * because trying again with the same client data will fail. - */ - public void resetAuth() - { - this.authService = new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID.randomUUID().toString()); - this.authentication = new YggdrasilUserAuthentication(this.authService, Agent.MINECRAFT); - } - - /** - * Load auth data from the json file - */ - private void load() - { - if (this.jsonFile != null && this.jsonFile.exists()) - { - FileReader fileReader = null; - - try - { - fileReader = new FileReader(this.jsonFile); - AuthData authData = LoginManager.gson.fromJson(fileReader, AuthData.class); - - if (authData != null && authData.validate()) - { - LiteLoaderLogger.info("Initialising Yggdrasil authentication service with client token: %s", authData.getClientToken()); - this.authService = new YggdrasilAuthenticationService(Proxy.NO_PROXY, authData.getClientToken()); - this.authentication = new YggdrasilUserAuthentication(this.authService, Agent.MINECRAFT); - authData.loadFromStorage(this.authentication); - this.offline = authData.workOffline(); - this.defaultUsername = authData.getUsername(); - this.defaultDisplayName = authData.getDisplayName(); - } - } - catch (IOException ex) {} - finally - { - try - { - if (fileReader != null) fileReader.close(); - } - catch (IOException ex) {} - } - } - } - - /** - * Save auth data to the JSON file - */ - private void save() - { - if (this.jsonFile != null) - { - FileWriter fileWriter = null; - - try - { - fileWriter = new FileWriter(this.jsonFile); - - AuthData authData = new AuthData(this.authService, this.authentication, this.offline, this.defaultUsername, this.defaultDisplayName); - LoginManager.gson.toJson(authData, fileWriter); - } - catch (IOException ex) - { - ex.printStackTrace(); - } - finally - { - try - { - if (fileWriter != null) fileWriter.close(); - } - catch (IOException ex) - { - ex.printStackTrace(); - } - } - } - } - - /** - * Attempt to login. If authentication data are found on disk then tries - * first to log in with the stored token. If the token login fails then - * attempts to log in with the username and password specified. If no user - * or pass are specified or if they fail then displays a login dialog to - * allow the user to login. If login succeeds then the token is stored on - * disk and the method returns. - * - *

If the user presses cancel in the login dialog then the method returns - * false.

- * - * @param username User name to log in with if token login fails, if null - * displays the login dialog immediately - * @param password Password to log in with if token login fails, if null - * displays the login dialog immediately - * @param remainingTries Number of loops to go through before giving up, - * decremented for each try, specify -1 for unlimited - * @return false if the user presses cancel in the login dialog, otherwise - * returns true - */ - public boolean login(String username, String password, int remainingTries) - { - if (this.offline || remainingTries == 0) - { - LiteLoaderLogger.info("LoginManager is set to work offline, skipping login"); - return false; - } - - LiteLoaderLogger.info("Remaining login tries: %s", remainingTries > 0 ? remainingTries : "unlimited"); - - try - { - LiteLoaderLogger.info("Attempting login, contacting Mojang auth servers..."); - - this.authentication.logIn(); - - if (this.authentication.isLoggedIn()) - { - LiteLoaderLogger.info("LoginManager logged in successfully. Can play online = %s", this.authentication.canPlayOnline()); - this.save(); - return true; - } - - LiteLoaderLogger.info("LoginManager failed to log in, unspecified status."); - } - catch (InvalidCredentialsException ex) - { - LiteLoaderLogger.info("Authentication agent reported invalid credentials: %s", ex.getMessage()); - this.resetAuth(); - - if (remainingTries > 1) - { - if (username == null) - { - username = this.defaultUsername; - } - - if (this.forceShowLoginDialog || username == null || password == null) - { - LoginPanel loginPanel = LoginPanel.getLoginPanel(username, password, this.forceShowLoginDialog ? ex.getMessage() : null); - boolean dialogResult = loginPanel.showModalDialog(); - this.offline = loginPanel.workOffline(); - this.defaultUsername = loginPanel.getUsername(); - - if (!dialogResult) - { - LiteLoaderLogger.info("User cancelled login dialog"); - return false; - } - - if (this.offline) - { - if (JOptionPane.showConfirmDialog(null, "You have chosen to work offline. " - + "You will never be prompted to log in again.

" - + "If you would like to re-enable login please delete the file .auth.json " - + "from the working dir
" - + "or press Cancel to return to the login dialog.", - "Confirm work offline", - JOptionPane.OK_CANCEL_OPTION, - JOptionPane.INFORMATION_MESSAGE) == JOptionPane.CANCEL_OPTION) - { - this.offline = false; - remainingTries = Math.max(remainingTries, 3); - } - } - - username = loginPanel.getUsername(); - password = loginPanel.getPassword(); - this.save(); - } - - if (!Strings.isNullOrEmpty(username) && !Strings.isNullOrEmpty(password)) - { - this.authentication.setUsername(username); - this.authentication.setPassword(password); - } - - this.forceShowLoginDialog = true; - this.login(username, password, --remainingTries); - } - } - catch (AuthenticationException ex) - { - ex.printStackTrace(); - } - - this.save(); - return false; - } - - /** - * Get whether user logged in - */ - public boolean isLoggedIn() - { - return this.authentication.isLoggedIn(); - } - - /** - * Get whether we are able to play online or not - */ - public boolean canPlayOnline() - { - return this.authentication.canPlayOnline(); - } - - /** - * Get the profile name (minecraft player name) from login - */ - public String getProfileName() - { - GameProfile selectedProfile = this.authentication.getSelectedProfile(); - return selectedProfile != null ? selectedProfile.getName() : this.defaultDisplayName; - } - - /** - * Get the profile name (minecraft player name) from login - */ - public String getUUID() - { - GameProfile selectedProfile = this.authentication.getSelectedProfile(); - return selectedProfile != null ? selectedProfile.getId().toString().replace("-", "") : this.defaultDisplayName; - } - - /** - * Get the session token - */ - public String getAuthenticatedToken() - { - String accessToken = this.authentication.getAuthenticatedToken(); - return accessToken != null ? accessToken : "-"; - } - - public String getUserType() - { - UserType userType = this.authentication.getUserType(); - return (userType != null ? userType : UserType.LEGACY).toString().toLowerCase(); - } - - public String getUserProperties() - { - PropertyMap userProperties = this.authentication.getUserProperties(); - return userProperties != null ? (new GsonBuilder()).registerTypeAdapter(PropertyMap.class, - new UserPropertiesSerializer()).create().toJson(userProperties) : "{}"; - } - - class UserPropertiesSerializer implements JsonSerializer - { - @Override - public JsonElement serialize(PropertyMap propertyMap, Type argType, JsonSerializationContext context) - { - JsonObject result = new JsonObject(); - - for (String key : propertyMap.keySet()) - { - JsonArray values = new JsonArray(); - for (Property property : propertyMap.get(key)) - { - values.add(new JsonPrimitive(property.getValue())); - } - - result.add(key, values); - } - - return result; - } - } - - - /** - * Struct for Gson serialisation of authenticaion settings - * - * @author Adam Mummery-Smith - */ - class AuthData - { - @SerializedName("clientToken") - private String clientToken; - - @SerializedName("workOffline") - private boolean workOffline; - - @SerializedName("authData") - private Map credentials; - - public AuthData() - { - // default ctor for Gson - } - - public AuthData(YggdrasilAuthenticationService authService, YggdrasilUserAuthentication authentication, boolean workOffline, - String defaultUserName, String defaultDisplayName) - { - this.clientToken = authService.getClientToken(); - this.credentials = authentication.saveForStorage(); - this.workOffline = workOffline; - - if (defaultUserName != null && !this.credentials.containsKey("username")) - { - this.credentials.put("username", defaultUserName); - } - - if (defaultDisplayName != null && !this.credentials.containsKey("displayName")) - { - this.credentials.put("displayName", defaultDisplayName); - } - } - - /** - * Called after Gson deserialisation to check that deserialisation was - * successful. - */ - public boolean validate() - { - if (this.clientToken == null) this.clientToken = UUID.randomUUID().toString(); - if (this.credentials == null) this.credentials = new HashMap(); - return true; - } - - public String getClientToken() - { - return this.clientToken; - } - - public void setClientToken(String clientToken) - { - this.clientToken = clientToken; - } - - public void loadFromStorage(YggdrasilUserAuthentication authentication) - { - authentication.loadFromStorage(this.credentials); - } - - public boolean workOffline() - { - return this.workOffline; - } - - public String getUsername() - { - return this.credentials != null ? this.credentials.get("username").toString() : null; - } - - public String getDisplayName() - { - return this.credentials != null && this.credentials.containsKey("displayName") - ? this.credentials.get("displayName").toString() : System.getProperty("user.name"); - } - } -} diff --git a/liteloader/src/debug/java/com/mumfrey/liteloader/debug/LoginPanel.java b/liteloader/src/debug/java/com/mumfrey/liteloader/debug/LoginPanel.java deleted file mode 100644 index 5614e8ba..00000000 --- a/liteloader/src/debug/java/com/mumfrey/liteloader/debug/LoginPanel.java +++ /dev/null @@ -1,366 +0,0 @@ -package com.mumfrey.liteloader.debug; - -import static javax.swing.WindowConstants.*; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JDialog; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.UIManager; -import javax.swing.border.EmptyBorder; -import javax.swing.border.TitledBorder; - -/** - * JPanel displayed in a JDialog to prompt the user for login credentials for - * minecraft. - * - * @author Adam Mummery-Smith - */ -public class LoginPanel extends JPanel -{ - private static final long serialVersionUID = 1L; - - private GridBagLayout panelLoginLayout; - - private JPanel panelTitle; - private JPanel panelCentre; - private JPanel panelPadding; - private JPanel panelBottom; - private JLabel lblTitle; - private JLabel lblSubTitle; - private JLabel lblMessage; - private JLabel lblUserName; - private JLabel lblPassword; - private TextField txtUsername; - private TextField txtPassword; - private JButton btnLogin; - private JButton btnCancel; - private JCheckBox chkOffline; - - private JDialog dialog; - - private ListFocusTraversal tabOrder = new ListFocusTraversal(); - - private boolean dialogResult = false; - - public LoginPanel(String username, String password, String error) - { - Color backColour = new Color(102, 118, 144); - - this.setFocusable(false); - this.setPreferredSize(new Dimension(400, 260)); - this.setBackground(new Color(105, 105, 105)); - this.setLayout(new BorderLayout(0, 0)); - - this.panelTitle = new JPanel(); - this.panelTitle.setBackground(backColour); - this.panelTitle.setPreferredSize(new Dimension(400, 64)); - this.panelTitle.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); - - this.panelBottom = new JPanel(); - this.panelBottom.setBackground(backColour); - this.panelBottom.setPreferredSize(new Dimension(400, 32)); - this.panelBottom.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); - - this.panelPadding = new JPanel(); - this.panelPadding.setBorder(new EmptyBorder(4, 8, 8, 8)); - this.panelPadding.setOpaque(false); - this.panelPadding.setLayout(new BorderLayout(0, 0)); - - this.panelCentre = new JPanel(); - this.panelCentre.setOpaque(false); - this.panelCentre.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Yggdrasil Login", - TitledBorder.LEADING, TitledBorder.TOP, null, Color.WHITE)); - this.panelLoginLayout = new GridBagLayout(); - this.panelLoginLayout.columnWidths = new int[] {30, 80, 120, 120, 30}; - this.panelLoginLayout.rowHeights = new int[] {24, 32, 32, 32}; - this.panelLoginLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE}; - this.panelLoginLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0}; - this.panelCentre.setLayout(this.panelLoginLayout); - - this.lblTitle = new JLabel("Log in to minecraft.net"); - this.lblTitle.setBorder(new EmptyBorder(4, 16, 0, 16)); - this.lblTitle.setFont(new Font("Tahoma", Font.BOLD, 18)); - this.lblTitle.setForeground(Color.WHITE); - this.lblTitle.setPreferredSize(new Dimension(400, 26)); - - this.lblSubTitle = new JLabel("Your password will not be stored, logging in with Yggdrasil"); - this.lblSubTitle.setBorder(new EmptyBorder(0, 16, 0, 16)); - this.lblSubTitle.setForeground(Color.WHITE); - this.lblSubTitle.setPreferredSize(new Dimension(400, 16)); - - this.lblMessage = new JLabel("Enter your login details for minecraft.net"); - this.lblMessage.setForeground(Color.WHITE); - - this.lblUserName = new JLabel("User name"); - this.lblUserName.setForeground(Color.WHITE); - - this.lblPassword = new JLabel("Password"); - this.lblPassword.setForeground(Color.WHITE); - - this.txtUsername = new TextField(); - this.txtUsername.setPreferredSize(new Dimension(200, 22)); - this.txtUsername.setText(username); - - this.txtPassword = new TextField(); - this.txtPassword.setEchoChar('*'); - this.txtPassword.setPreferredSize(new Dimension(200, 22)); - this.txtPassword.setText(password); - - this.btnLogin = new JButton("Log in"); - this.btnLogin.addActionListener(new ActionListener() - { - @Override public void actionPerformed(ActionEvent e) - { - LoginPanel.this.onLoginClick(); - } - }); - - this.btnCancel = new JButton("Cancel"); - this.btnCancel.addActionListener(new ActionListener() - { - @Override public void actionPerformed(ActionEvent e) - { - LoginPanel.this.onCancelClick(); - } - }); - - this.chkOffline = new JCheckBox("Never ask me to log in (always run offline)"); - this.chkOffline.setPreferredSize(new Dimension(380, 23)); - this.chkOffline.setForeground(Color.WHITE); - this.chkOffline.setOpaque(false); - this.chkOffline.addActionListener(new ActionListener() - { - @Override public void actionPerformed(ActionEvent e) - { - LoginPanel.this.onOfflineCheckedChanged(); - } - }); - - GridBagConstraints lblMessageConstraints = new GridBagConstraints(); - lblMessageConstraints.anchor = GridBagConstraints.WEST; - lblMessageConstraints.gridwidth = 2; - lblMessageConstraints.insets = new Insets(0, 0, 5, 5); - lblMessageConstraints.gridx = 2; - lblMessageConstraints.gridy = 0; - - GridBagConstraints lblUserNameConstraints = new GridBagConstraints(); - lblUserNameConstraints.anchor = GridBagConstraints.WEST; - lblUserNameConstraints.fill = GridBagConstraints.VERTICAL; - lblUserNameConstraints.insets = new Insets(0, 0, 5, 5); - lblUserNameConstraints.gridx = 1; - lblUserNameConstraints.gridy = 1; - - GridBagConstraints lblPasswordConstraints = new GridBagConstraints(); - lblPasswordConstraints.anchor = GridBagConstraints.WEST; - lblPasswordConstraints.fill = GridBagConstraints.VERTICAL; - lblPasswordConstraints.insets = new Insets(0, 0, 5, 5); - lblPasswordConstraints.gridx = 1; - lblPasswordConstraints.gridy = 2; - - GridBagConstraints txtUsernameConstraints = new GridBagConstraints(); - txtUsernameConstraints.gridwidth = 2; - txtUsernameConstraints.fill = GridBagConstraints.HORIZONTAL; - txtUsernameConstraints.insets = new Insets(0, 0, 5, 0); - txtUsernameConstraints.gridx = 2; - txtUsernameConstraints.gridy = 1; - - GridBagConstraints txtPasswordConstraints = new GridBagConstraints(); - txtPasswordConstraints.gridwidth = 2; - txtPasswordConstraints.insets = new Insets(0, 0, 5, 0); - txtPasswordConstraints.fill = GridBagConstraints.HORIZONTAL; - txtPasswordConstraints.gridx = 2; - txtPasswordConstraints.gridy = 2; - - GridBagConstraints btnLoginConstraints = new GridBagConstraints(); - btnLoginConstraints.fill = GridBagConstraints.HORIZONTAL; - btnLoginConstraints.gridx = 3; - btnLoginConstraints.gridy = 3; - - GridBagConstraints btnCancelConstraints = new GridBagConstraints(); - btnCancelConstraints.anchor = GridBagConstraints.EAST; - btnCancelConstraints.insets = new Insets(0, 0, 0, 5); - btnCancelConstraints.gridx = 2; - btnCancelConstraints.gridy = 3; - - this.add(this.panelTitle, BorderLayout.NORTH); - this.add(this.panelPadding, BorderLayout.CENTER); - this.add(this.panelBottom, BorderLayout.SOUTH); - - this.panelPadding.add(this.panelCentre); - - this.panelTitle.add(this.lblTitle); - this.panelTitle.add(this.lblSubTitle); - - this.panelCentre.add(this.lblMessage, lblMessageConstraints); - this.panelCentre.add(this.lblUserName, lblUserNameConstraints); - this.panelCentre.add(this.lblPassword, lblPasswordConstraints); - this.panelCentre.add(this.txtUsername, txtUsernameConstraints); - this.panelCentre.add(this.txtPassword, txtPasswordConstraints); - this.panelCentre.add(this.btnLogin, btnLoginConstraints); - this.panelCentre.add(this.btnCancel, btnCancelConstraints); - - this.panelBottom.add(this.chkOffline); - - this.tabOrder.add(this.txtUsername); - this.tabOrder.add(this.txtPassword); - this.tabOrder.add(this.btnLogin); - this.tabOrder.add(this.btnCancel); - this.tabOrder.add(this.chkOffline); - - if (error != null) - { - this.lblMessage.setText(error); - this.lblMessage.setForeground(new Color(255, 180, 180)); - } - } - - protected void onShowDialog() - { - if (this.txtUsername.getText().length() > 0) - { - if (this.txtPassword.getText().length() > 0) - { - this.txtUsername.select(0, this.txtUsername.getText().length()); - } - else - { - this.txtPassword.requestFocusInWindow(); - } - } - } - - protected void onLoginClick() - { - this.dialogResult = true; - this.dialog.setVisible(false); - } - - protected void onCancelClick() - { - this.dialog.setVisible(false); - } - - protected void onOfflineCheckedChanged() - { - boolean selected = this.chkOffline.isSelected(); - this.btnLogin.setText(selected ? "Work Offline" : "Log In"); - this.txtUsername.setEnabled(!selected); - this.txtPassword.setEnabled(!selected); - } - - /** - * @param dialog - */ - public void setDialog(JDialog dialog) - { - this.dialog = dialog; - - this.dialog.addWindowListener(new WindowAdapter() - { - @Override - public void windowOpened(WindowEvent e) - { - LoginPanel.this.onShowDialog(); - } - }); - - this.dialog.getRootPane().setDefaultButton(this.btnLogin); - this.dialog.setFocusTraversalPolicy(this.tabOrder); - } - - public boolean showModalDialog() - { - this.dialog.setVisible(true); - this.dialog.dispose(); - return this.dialogResult; - } - - public String getUsername() - { - return this.txtUsername.getText(); - } - - public String getPassword() - { - return this.txtPassword.getText(); - } - - public boolean workOffline() - { - return this.chkOffline.isSelected(); - } - - public static LoginPanel getLoginPanel(String username, String password, String error) - { - if (username == null) username = ""; - if (password == null) password = ""; - - final JDialog dialog = new JDialog(); - final LoginPanel panel = new LoginPanel(username, password, error); - panel.setDialog(dialog); - - dialog.setContentPane(panel); - dialog.setTitle("Yggdrasil Login"); - dialog.setResizable(false); - dialog.pack(); - dialog.setDefaultCloseOperation(DISPOSE_ON_CLOSE); - dialog.setLocationRelativeTo(null); - dialog.setModal(true); - - return panel; - } - - class ListFocusTraversal extends FocusTraversalPolicy - { - private final List components = new ArrayList(); - - void add(Component component) - { - this.components.add(component); - } - - @Override - public Component getComponentAfter(Container container, Component component) - { - int index = this.components.indexOf(component) + 1; - if (index >= this.components.size()) return this.components.get(0); - return this.components.get(index); - } - - @Override - public Component getComponentBefore(Container container, Component component) - { - int index = this.components.indexOf(component) - 1; - if (index < 0) return this.getLastComponent(container); - return this.components.get(index); - } - - @Override - public Component getFirstComponent(Container container) - { - return this.components.get(0); - } - - @Override - public Component getLastComponent(Container container) - { - return this.components.get(this.components.size() - 1); - } - - @Override - public Component getDefaultComponent(Container container) - { - return this.getFirstComponent(container); - } - } -} diff --git a/liteloader/src/debug/resources/obfuscation.properties b/liteloader/src/debug/resources/obfuscation.properties deleted file mode 100644 index e5d91592..00000000 --- a/liteloader/src/debug/resources/obfuscation.properties +++ /dev/null @@ -1,69 +0,0 @@ -field_71424_I=mcProfiler -field_78729_o=entityRenderMap -field_110546_b=reloadListeners -field_147393_d=networkManager -field_82596_a=registryObjects -field_148759_a=underlyingIntegerMap -field_148749_a=identityMap -field_148748_b=objectList -field_147559_m=mapSpecialRenderers -field_145855_i=nameToClassMap -field_145853_j=classToNameMap -field_71428_T=timer -field_71424_I=mcProfiler -field_71425_J=running -field_110449_ao=defaultResourcePacks -field_71475_ae=serverName -field_71477_af=serverPort -field_147712_ad=shaderResourceLocations -field_147713_ae=shaderIndex -field_175083_ad=useShader -field_149528_b=view -field_70163_u=posY -field_148919_a=chatComponent -func_148833_a=processPacket -func_71411_J=runGameLoop -func_71407_l=runTick -func_78480_b=updateCameraAndRender -func_78471_a=renderWorld -func_175180_a=renderGameOverlay -func_76320_a=startSection -func_76319_b=endSection -func_76318_c=endStartSection -func_148545_a=createPlayerForUser -func_72368_a=recreatePlayerEntity -func_72355_a=initializeConnectionToPlayer -func_72377_c=playerLoggedIn -func_72367_e=playerLoggedOut -func_71384_a=startGame -func_71197_b=startServer -func_71256_s=startServerThread -func_71165_d=sendChatMessage -func_147119_ah=updateFramebufferSize -func_147615_c=framebufferRender -func_178038_a=framebufferRenderExt -func_147612_c=bindFramebufferTexture -func_146230_a=drawChat -func_179086_m=clear -func_175068_a=renderWorldPass -func_148256_e=getProfile -func_148260_a=saveScreenshot -func_148822_b=isFramebufferEnabled -func_147939_a=doRenderEntity -func_76986_a=doRender -func_71370_a=resize -func_175069_a=loadShader -func_78481_a=getFOVModifier -func_78479_a=setupCameraTransform -func_147693_a=loadSoundResource -func_180784_a=onBlockClicked -func_180236_a=activateBlockOrUseItem -func_147346_a=processPlayerBlockPlacement -func_175087_a=handleAnimation -func_147345_a=processPlayerDigging -func_71190_q=updateTimeLightAndEntities -func_180031_a=checkThreadAndEnqueue -func_147347_a=processPlayer -func_174976_a=renderSky -func_180437_a=renderCloudsCheck -func_78468_a=setupFog \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/Configurable.java b/liteloader/src/main/java/com/mumfrey/liteloader/Configurable.java deleted file mode 100644 index f73ac2de..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/Configurable.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.mumfrey.liteloader; - -import com.mumfrey.liteloader.modconfig.ConfigPanel; - -/** - * Interface for mods which want to provide a configuration panel inside the - * "mod info" screen. - * - * @author Adam Mummery-Smith - */ -public interface Configurable -{ - /** - * Get the class of the configuration panel to use, the returned class must - * have a default (no-arg) constructor - * - * @return configuration panel class - */ - public abstract Class getConfigPanelClass(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/LiteMod.java b/liteloader/src/main/java/com/mumfrey/liteloader/LiteMod.java deleted file mode 100644 index 4df09ec4..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/LiteMod.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.mumfrey.liteloader; - -import java.io.File; - -import com.mumfrey.liteloader.api.Listener; -import com.mumfrey.liteloader.modconfig.Exposable; - -/** - * Base interface for mods - * - * @author Adam Mummery-Smith - */ -public interface LiteMod extends Exposable, Listener -{ - /** - * Get the mod version string - * - * @return the mod version as a string - */ - public abstract String getVersion(); - - /** - * Do startup stuff here, minecraft is not fully initialised when this - * function is called so mods must not interact with minecraft in any - * way here. - * - * @param configPath Configuration path to use - */ - public abstract void init(File configPath); - - /** - * Called when the loader detects that a version change has happened since - * this mod was last loaded. - * - * @param version new version - * @param configPath Path for the new version-specific config - * @param oldConfigPath Path for the old version-specific config - */ - public abstract void upgradeSettings(String version, File configPath, File oldConfigPath); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/PacketHandler.java b/liteloader/src/main/java/com/mumfrey/liteloader/PacketHandler.java deleted file mode 100644 index 6c4ada21..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/PacketHandler.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.mumfrey.liteloader; - -import java.util.List; - -import net.minecraft.network.INetHandler; -import net.minecraft.network.Packet; - -/** - * Interface for mods which want to handle raw packets - * - * @author Adam Mummery-Smith - */ -public interface PacketHandler extends LiteMod -{ - /** - * Get list of packets to handle - */ - public List> getHandledPackets(); - - /** - * @param netHandler The vanilla nethandler which will handle this packet if - * not cancelled - * @param packet Incoming packet - * @return True to allow further processing of this packet, including other - * PacketHandlers and eventually the vanilla netHandler, to inhibit - * further processing return false. You may choose to return false and - * then invoke the vanilla handler method on the supplied INetHandler - * if you wish to inhibit later PacketHandlers but preserve vanilla - * behaviour. - */ - public abstract boolean handlePacket(INetHandler netHandler, Packet packet); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/Permissible.java b/liteloader/src/main/java/com/mumfrey/liteloader/Permissible.java deleted file mode 100644 index 5b8a7cad..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/Permissible.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.mumfrey.liteloader; - -import com.mumfrey.liteloader.permissions.PermissionsManager; -import com.mumfrey.liteloader.permissions.PermissionsManagerClient; - -/** - * Interface for mods which use the ClientPermissions system - * - * @author Adam Mummery-Smith - */ -public interface Permissible extends LiteMod -{ - /** - * Returns the node name of the mod, replicated permissions will be of the - * form mod..permission.node so this method must return a valid name - * for use in permission nodes. This method must also return the same value - * every time it is called since permissible names are not necessarily - * cached. - * - * @return Permissible name - */ - public abstract String getPermissibleModName(); - - /** - * The mod version to replicate to the server - * - * @return Mod version as a float - */ - public abstract float getPermissibleModVersion(); - - /** - * Called by the permissions manager at initialisation to instruct the mod - * to populate the list of permissions it supports. This method should call - * back against the supplied permissions manager to register the permissions - * to be sent to the server when connecting. - * - * @param permissionsManager Client permissions manager - */ - public abstract void registerPermissions(PermissionsManagerClient permissionsManager); - - /** - * Called when the permissions set is cleared - * - * @param manager - */ - public abstract void onPermissionsCleared(PermissionsManager manager); - - /** - * Called when the permissions are changed (eg. when new permissions are - * received from the server) - * - * @param manager - */ - public abstract void onPermissionsChanged(PermissionsManager manager); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/PlayerInteractionListener.java b/liteloader/src/main/java/com/mumfrey/liteloader/PlayerInteractionListener.java deleted file mode 100644 index a63a1b4a..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/PlayerInteractionListener.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.MovingObjectPosition.MovingObjectType; - -/** - * Interface for mods which want to observe the player's "interaction" status - * (player mouse clicks), allows block interaction events to be cancelled. - * - * @author Adam Mummery-Smith - */ -public interface PlayerInteractionListener extends LiteMod -{ - /** - * Mouse buttons - */ - public static enum MouseButton - { - LEFT, - RIGHT - } - - /** - * Called when the player clicks but does not "hit" a block, the trace - * position is raytraced to the player's current view distance and - * represents the block which the player is "looking at". This method is - * not called when the player right clicks with an empty hand. - * - * @param player Player - * @param button Mouse button the user clicked - * @param tracePos Raytraced location of the block which was hit - * @param traceSideHit Raytraced side hit - * @param traceHitType Type of hit, will be MISS if the trace expired - * without hitting anything (eg. the player clicked the sky) - */ - public abstract void onPlayerClickedAir(EntityPlayerMP player, MouseButton button, BlockPos tracePos, EnumFacing traceSideHit, - MovingObjectType traceHitType); - - /** - * Calls when the player clicks and hits a block, usually indicates that the - * player is digging or placing a block, although a block placement does not - * necessarily succeed. Return true from this callback to allow the action - * to proceed, or false to cancel the action. Cancelling the action does not - * prevent further handlers from receiving the event. - * - * @param player Player - * @param button Mouse button that was pressed, left = dig, right = interact - * @param hitPos Block which was *hit*. Note that block placement will - * normally be at hitPos.offset(sideHit) - * @param sideHit Side of the block which was hit - * @return true to allow the action to be processed (another listener may - * still inhibit the action), return false to cancel the action (other - * listeners will still be notified) - */ - public abstract boolean onPlayerClickedBlock(EntityPlayerMP player, MouseButton button, BlockPos hitPos, EnumFacing sideHit); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/PlayerMoveListener.java b/liteloader/src/main/java/com/mumfrey/liteloader/PlayerMoveListener.java deleted file mode 100644 index 2ca8447e..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/PlayerMoveListener.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.entity.player.EntityPlayerMP; - -import com.mumfrey.liteloader.core.LiteLoaderEventBroker.ReturnValue; -import com.mumfrey.liteloader.util.Position; - -/** - * Interface for mods which want to monitor or control player movements - * - * @author Adam Mummery-Smith - */ -public interface PlayerMoveListener extends LiteMod -{ - /** - * Called when a movement/look packet is received from the client. - * - * @param playerMP Player moving - * @param from Player's previous recorded position - * @param to Position the player is attempting to move to - * @param newPos Set this position to teleport the player to newPos instead - * of processing the original move - * @return false to cancel the event or true to allow the movement to be - * processed as normal or newPos to be applied - */ - public abstract boolean onPlayerMove(EntityPlayerMP playerMP, Position from, Position to, ReturnValue newPos); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/PluginChannelListener.java b/liteloader/src/main/java/com/mumfrey/liteloader/PluginChannelListener.java deleted file mode 100644 index 1ddda3ba..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/PluginChannelListener.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.network.PacketBuffer; - -import com.mumfrey.liteloader.core.CommonPluginChannelListener; - -/** - * Interface for mods which want to use plugin channels - * - * @author Adam Mummery-Smith - */ -public interface PluginChannelListener extends LiteMod, CommonPluginChannelListener -{ - /** - * Called when a custom payload packet arrives on a channel this mod has - * registered. - * - * @param channel Channel on which the custom payload was received - * @param data Custom payload data - */ - public abstract void onCustomPayload(String channel, PacketBuffer data); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/PreJoinGameListener.java b/liteloader/src/main/java/com/mumfrey/liteloader/PreJoinGameListener.java deleted file mode 100644 index 54dec8cb..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/PreJoinGameListener.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.network.INetHandler; -import net.minecraft.network.play.server.S01PacketJoinGame; - - -/** - * Interface for mods which wish to be notified when the player connects to a - * server (or local game). - * - * @author Adam Mummery-Smith - */ -public interface PreJoinGameListener extends LiteMod -{ - /** - * Called before login. NOTICE: as of 1.8 the return value of this method - * has a different meaning! - * - * @param netHandler Net handler - * @param joinGamePacket Join game packet - * @return true to allow login to continue, false to cancel login - */ - public abstract boolean onPreJoinGame(INetHandler netHandler, S01PacketJoinGame joinGamePacket); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/Priority.java b/liteloader/src/main/java/com/mumfrey/liteloader/Priority.java deleted file mode 100644 index 5a0b24ac..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/Priority.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.mumfrey.liteloader; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Priority declaration for LiteMods, used when sorting listener lists. Default - * value if no Priority annotation is specified is 1000. - * - * @author Adam Mummery-Smith - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface Priority -{ - /** - * Priority value, default priority is 1000 - */ - public int value(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/ServerChatFilter.java b/liteloader/src/main/java/com/mumfrey/liteloader/ServerChatFilter.java deleted file mode 100644 index 15ea6676..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/ServerChatFilter.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.play.client.C01PacketChatMessage; - -/** - * Interface for mods which can filter inbound chat - * - * @author Adam Mummery-Smith - */ -public interface ServerChatFilter extends LiteMod -{ - /** - * Chat filter function, return false to filter this packet, true to pass - * the packet. - * - * @param chatPacket Chat packet to examine - * @param message Chat message - * @return True to keep the packet, false to discard - */ - public abstract boolean onChat(EntityPlayerMP player, C01PacketChatMessage chatPacket, String message); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/ServerCommandProvider.java b/liteloader/src/main/java/com/mumfrey/liteloader/ServerCommandProvider.java deleted file mode 100644 index 36a3c24e..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/ServerCommandProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.command.ServerCommandManager; - - -/** - * Interface for mods which provide commands to the local integrated server - * - * @author Adam Mummery-Smith - */ -public interface ServerCommandProvider extends LiteMod -{ - /** - * Allows the mod to provide commands to the server command manager by - * invoking commandManager.registerCommand() to provide new commands for - * single player and lan worlds - * - * @param commandManager - */ - public abstract void provideCommands(ServerCommandManager commandManager); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/ServerPlayerListener.java b/liteloader/src/main/java/com/mumfrey/liteloader/ServerPlayerListener.java deleted file mode 100644 index 3ff7df24..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/ServerPlayerListener.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.entity.player.EntityPlayerMP; - -import com.mojang.authlib.GameProfile; - -/** - * Interface for mods which want to handle players joining and leaving a LAN - * game (or single player game) - * - * @author Adam Mummery-Smith - */ -public interface ServerPlayerListener extends LiteMod -{ - /** - * Called when a player connects to the server and the EntityPlayerMP - * instance is created, the player has not logged in at this point and may - * be disconnected if login fails. - * - * @param player Player attempting to connect - * @param profile Player's GameProfile from the authentication service - */ - public abstract void onPlayerConnect(EntityPlayerMP player, GameProfile profile); - - /** - * Called once the player has successfully logged in and all player - * variables are initialised and replicated. - * - * @param player Player connected - */ - public abstract void onPlayerLoggedIn(EntityPlayerMP player); - - /** - * Called when a player respawns. This event is raised when a player - * respawns after dying or conquers the end. - * - * @param player New player instance - * @param oldPlayer Old player instance being discarded - * @param newDimension Dimension the player is respawning in - * @param playerWonTheGame True if the player conquered the end (this - * respawn is NOT as the result of a death) - */ - public abstract void onPlayerRespawn(EntityPlayerMP player, EntityPlayerMP oldPlayer, int newDimension, boolean playerWonTheGame); - - /** - * Called when a player disconnects from the game - * - * @param player Player disconnecting - */ - public abstract void onPlayerLogout(EntityPlayerMP player); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/ServerPluginChannelListener.java b/liteloader/src/main/java/com/mumfrey/liteloader/ServerPluginChannelListener.java deleted file mode 100644 index 9ca14d47..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/ServerPluginChannelListener.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.PacketBuffer; - -import com.mumfrey.liteloader.core.CommonPluginChannelListener; - -/** - * Interface for mods which want to use plugin channels on the (integrated) - * server side. - * - * @author Adam Mummery-Smith - */ -public interface ServerPluginChannelListener extends CommonPluginChannelListener -{ - /** - * Called when a custom payload packet arrives on a channel this mod has - * registered. - * - * @param sender Player object which is the source of this message - * @param channel Channel on which the custom payload was received - * @param data Custom payload data - */ - public abstract void onCustomPayload(EntityPlayerMP sender, String channel, PacketBuffer data); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/ServerTickable.java b/liteloader/src/main/java/com/mumfrey/liteloader/ServerTickable.java deleted file mode 100644 index 61b1eee3..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/ServerTickable.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.mumfrey.liteloader; - -import net.minecraft.server.MinecraftServer; - -/** - * Interface for mods which want to be ticked on the server thread - * - * @author Adam Mummery-Smith - */ -public interface ServerTickable extends LiteMod -{ - /** - * Called at the start of every server update tick - * - * @param server - */ - public abstract void onTick(MinecraftServer server); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/ShutdownListener.java b/liteloader/src/main/java/com/mumfrey/liteloader/ShutdownListener.java deleted file mode 100644 index 12c3efb4..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/ShutdownListener.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.mumfrey.liteloader; - -/** - * Interface for mods that want to receive an event when the game is shutting - * down due to a user request. They do not receive the callback when the VM is - * terminating for other reasons, use a regular VM shutdownhook for that. - * - * @author Adam Mummery-Smith - */ -public interface ShutdownListener extends LiteMod -{ - public abstract void onShutDown(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/BrandingProvider.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/BrandingProvider.java deleted file mode 100644 index 5f129c64..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/BrandingProvider.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.mumfrey.liteloader.api; - -import java.net.URI; - -import net.minecraft.util.ResourceLocation; - -import com.mumfrey.liteloader.util.render.Icon; - -/** - * LiteLoader Extensible API - Branding Provider - * - *

The Branding Provider manages loader branding alterations for a particular - * API. This is an optional API component which allows an API to specify - * customisations and additions to the loader environment in order to provide a - * more comfortable integration for the API.

- * - *

Since some branding options simply stack (like the API copyright notices - * for example) all APIs will be allowed to supply this information, however - * other options (like the main logo image) can only be set by one API. To - * determine which API should be used to set this information, the getPriority() - * method will be called and used to sort branding providers by priority, with - * highest priority winning.

- * - *

All branding options may return a null/not set value, allowing a branding - * provider to only override the branding features it wishes. Some options - * require a non-null value to be returned from a set of methods in order to - * take effect. eg. the logo option requires non-null return values from BOTH - * the getLogoResource() and getLogoCoords() methods.

- * - * @author Adam Mummery-Smith - */ -public interface BrandingProvider extends CustomisationProvider -{ - /** - * Get the priority of this provider, higher numbers take precedence. Some - * brandings can only be set by one provider (eg. the main "about" logo) so - * the branding provider with the highest priority will be the one which - * gets control of that feature. - */ - public abstract int getPriority(); - - /** - * Get the primary branding colour for this API, the branding provider - * should return 0 if it does not wish to override the branding colour. The - * branding colour is used for the mod list entries and hyper-links within - * the about GUI panels, the colour returned should be fully opaque. - */ - public abstract int getBrandingColour(); - - /** - * Get the resource to use for the main logo, the API with the highest - * priority gets to define the logo, this method can return null if this API - * does not want to override the logo. - */ - public abstract ResourceLocation getLogoResource(); - - /** - * Gets the coordinates of the logo as an IIcon instance, only called if - * getLogoResource() returns a non-null value and the logo will only be used - * if BOTH methods return a valid object. - */ - public abstract Icon getLogoCoords(); - - /** - * Get the resource to use for the icon logo (the chicken in the default - * setup), the API with the highest priority gets to define the icon logo, - * this method can return null if this API does not want to override the - * icon. - */ - public abstract ResourceLocation getIconResource(); - - /** - * Gets the coordinates of the icon logo as an IIcon instance, only called - * if getIconResource() returns a non-null value and the icon will only be - * used if BOTH methods return a valid object. - */ - public abstract Icon getIconCoords(); - - /** - * Get the display name for this API, used on the "about" screen, must not - * return null. - */ - public abstract String getDisplayName(); - - /** - * Get the copyright text for this API, used on the "about" screen, must not - * return null. - */ - public abstract String getCopyrightText(); - - /** - * Get the main home page URL for this API, used on the "about" screen, must - * not return null. - */ - public abstract URI getHomepage(); - - /** - * If you wish to display a clickable twitter icon next to the API - * information in the "about" panel then you must return values from this - * method as well as getTwitterAvatarResource() and - * getTwitterAvatarCoords(). Return the twitter user name here. - */ - public abstract String getTwitterUserName(); - - /** - * If you wish to display a clickable twitter icon next to the API - * information, return the icon resource here. - */ - public abstract ResourceLocation getTwitterAvatarResource(); - - /** - * If you wish to display a clickable twitter icon next to the API - * information, return the icon coordinates here. - */ - public abstract Icon getTwitterAvatarCoords(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/ContainerRegistry.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/ContainerRegistry.java deleted file mode 100644 index fcd66eec..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/ContainerRegistry.java +++ /dev/null @@ -1,98 +0,0 @@ -package com.mumfrey.liteloader.api; - -import java.io.File; -import java.util.Collection; - -import com.mumfrey.liteloader.core.ModInfo; -import com.mumfrey.liteloader.interfaces.Loadable; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.interfaces.TweakContainer; - -/** - * Registry for enabled, disabled, injected and bad containers - * - * @author Adam Mummery-Smith - */ -public interface ContainerRegistry -{ - public enum DisabledReason - { - UNKNOWN("Container %s is could not be loaded for UNKNOWN reason"), - USER_DISABLED("Container %s is disabled"), - MISSING_DEPENDENCY("Container %s is missing one or more dependencies"), - MISSING_API("Container %s is missing one or more required APIs"); - - private final String message; - - private DisabledReason(String message) - { - this.message = message; - } - - public String getMessage(LoadableMod container) - { - return String.format(this.message, container); - } - } - - /** - * Register an enabled container, removes the container from the disabled - * containers list if present. - */ - public abstract void registerEnabledContainer(LoadableMod container); - - /** - * Get all enabled containers - */ - public abstract Collection> getEnabledContainers(); - - /** - * Get a specific enabled container by id - */ - public abstract LoadableMod getEnabledContainer(String identifier); - - /** - * Register a disabled container - */ - public abstract void registerDisabledContainer(LoadableMod container, DisabledReason reason); - - /** - * Get all disabled containers - */ - public abstract Collection>> getDisabledContainers(); - - /** - * Check whether a specific container is registered as disabled - */ - public abstract boolean isDisabledContainer(LoadableMod container); - - /** - * Register a bad container - */ - public abstract void registerBadContainer(Loadable container, String reason); - - /** - * Get all bad containers - */ - public abstract Collection>> getBadContainers(); - - /** - * Register a candidate tweak container - */ - public abstract void registerTweakContainer(TweakContainer container); - - /** - * Get all registered tweak containers - */ - public abstract Collection> getTweakContainers(); - - /** - * Register an injected tweak container - */ - public abstract void registerInjectedTweak(TweakContainer container); - - /** - * Get all injected tweak containers - */ - public abstract Collection>> getInjectedTweaks(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/CoreProvider.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/CoreProvider.java deleted file mode 100644 index f9feefb6..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/CoreProvider.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.mumfrey.liteloader.api; - -import net.minecraft.network.INetHandler; -import net.minecraft.network.play.server.S01PacketJoinGame; - -import com.mumfrey.liteloader.common.GameEngine; -import com.mumfrey.liteloader.core.LiteLoaderMods; - -/** - * LiteLoader Extensible API - API Core Provider - * - * Core Providers are objects whose lifecycle is equivalent to the run time of - * game and thus the entire lifecycle of your API, they are instanced early in - * the loader startup process. CoreProviders can implement any Observer - * interface as appropriate and are automatically considered when allocating - * Observers to callback lists. - * - * @author Adam Mummery-Smith - */ -public interface CoreProvider extends TickObserver, WorldObserver, ShutdownObserver, PostRenderObserver -{ - public abstract void onInit(); - - /** - * During the postInit phase, the mods which were discovered during preInit - * phase are initialised and the interfaces are allocated. This callback is - * invoked at the very start of the postInit phase, before mods are - * initialised but after the point at which it is safe to assume it's ok to - * access game classes. This is the first point at which the Minecraft game - * instance should be referenced. Be aware that certain game classes (such - * as the EntityRenderer) are NOT initialised at this point. - * - * @param engine - */ - public abstract void onPostInit(GameEngine engine); - - /** - * Once the mods are initialised and the interfaces have been allocated, - * this callback is invoked to allow the CoreProvider to perform any tasks - * which should be performed in the postInit phase but after mods have been - * initialised. - * - * @param mods - */ - public abstract void onPostInitComplete(LiteLoaderMods mods); - - /** - * Called once startup is complete and the game loop begins running. This - * callback is invoked immediately prior to the first "tick" event and - * immediately after the the "late init" phase for mods - * (InitCompleteListener). - */ - public abstract void onStartupComplete(); - - /** - * Called immediately on joining a single or multi-player world when the - * JoinGame packet is received. Only called on the client. - * - * @param netHandler - * @param loginPacket - */ - public abstract void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/CustomisationProvider.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/CustomisationProvider.java deleted file mode 100644 index 23ab0437..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/CustomisationProvider.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mumfrey.liteloader.api; - -/** - * Base interface for loader customisation providers, has to be here so that we - * don't load branding provider classes too soon. - * - * @author Adam Mummery-Smith - */ -public interface CustomisationProvider -{ -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/EnumerationObserver.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/EnumerationObserver.java deleted file mode 100644 index ebd8b9fa..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/EnumerationObserver.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mumfrey.liteloader.api; - -import java.io.File; - -import com.mumfrey.liteloader.api.ContainerRegistry.DisabledReason; -import com.mumfrey.liteloader.core.ModInfo; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.interfaces.LoaderEnumerator; -import com.mumfrey.liteloader.interfaces.TweakContainer; - -/** - * LiteLoader Extensible API - Enumeration observer - * - * EnumerationObserver receive callbacks when mod containers are enumerated. - * Instances of this class must be returned from getPreInitObservers in - * order to work. - * - * @author Adam Mummery-Smith - */ -public interface EnumerationObserver extends Observer -{ - /** - * Called upon registration for every discovered container which is enabled - * - * @param enumerator - * @param container - */ - public abstract void onRegisterEnabledContainer(LoaderEnumerator enumerator, LoadableMod container); - - /** - * Called upon registration for every discovered container which is - * currently disabled, either because - * - * @param enumerator - * @param container - * @param reason - */ - public abstract void onRegisterDisabledContainer(LoaderEnumerator enumerator, LoadableMod container, DisabledReason reason); - - /** - * Called AFTER registration of an ENABLED container (eg. - * onRegisterEnabledContainer will be called first) if that container also - * contains tweaks. - * - * @param enumerator - * @param container - */ - public abstract void onRegisterTweakContainer(LoaderEnumerator enumerator, TweakContainer container); - - /** - * Called when a mod container is added to the pending mods list. This does - * not mean that the specific mod will actually be instanced since the mod - * can still be disabled via the exclusion list (this is to allow entire - * containers to be disabled or just individual mods) and so if you wish to - * observe actual mod instantiation you should still provide a - * {@link com.mumfrey.liteloader.client.ResourceObserver}. However this - * event expresses a declaration by the enumerator of an intention to load - * the specified mod. - * - * @param enumerator - * @param mod - */ - public abstract void onModAdded(LoaderEnumerator enumerator, ModInfo> mod); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/EnumeratorModule.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/EnumeratorModule.java deleted file mode 100644 index 2fc1cdea..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/EnumeratorModule.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.mumfrey.liteloader.api; - -import com.mumfrey.liteloader.interfaces.ModularEnumerator; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; - -import net.minecraft.launchwrapper.LaunchClassLoader; - -/** - * LiteLoader Extensible API - Interface for objects which can enumerate mods in - * places. - * - *

EnumeratorModules plug into the LoaderEnumerator and are used to discover - * mod containers in various locations, for example searching in a specific - * folder for particular files.

- * - * @author Adam Mummery-Smith - */ -public interface EnumeratorModule -{ - /** - * @param environment Loader environment - * @param properties Loader properties - */ - public abstract void init(LoaderEnvironment environment, LoaderProperties properties); - - /** - * @param environment Loader environment - * @param properties Loader properties - */ - public abstract void writeSettings(LoaderEnvironment environment, LoaderProperties properties); - - /** - * Find loadable mods in this enumerator's domain, the enumerator module - * should call back against the enumerator itself to register containers it - * discovers using the registerModContainer() and registerTweakContainer() - * callbacks. - * - *

This method is called during loader PREINIT phase so do not use any - * game classes here!

- * - * @param enumerator - * @param profile - */ - public abstract void enumerate(ModularEnumerator enumerator, String profile); - - /** - * The enumerator module should inject (as required) any discovered - * containers into the classpath. - * - *

This method is called during the loader INIT phase.

- * - * @param enumerator - * @param classLoader - */ - public abstract void injectIntoClassLoader(ModularEnumerator enumerator, LaunchClassLoader classLoader); - - /** - * The enumerator module should callback against the enumerator using the - * registerModsFrom() callback to register mods from discovered containers. - * - *

This method is called during the loader INIT phase

- * - * @param enumerator - * @param classLoader - */ - public abstract void registerMods(ModularEnumerator enumerator, LaunchClassLoader classLoader); -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/EnumeratorPlugin.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/EnumeratorPlugin.java deleted file mode 100644 index e7b113ba..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/EnumeratorPlugin.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.mumfrey.liteloader.api; - -import java.util.List; - -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; - -/** - * LiteLoader Extensible API - Interface for objects which can interact with the - * enumeration process, not yet available to APIs. - * - * @author Adam Mummery-Smith - */ -public interface EnumeratorPlugin -{ - /** - * Initialise this plugin - */ - public abstract void init(LoaderEnvironment environment, LoaderProperties properties); - - /** - * Get classes in the supplied container - * - * @param container Container to inspect - * @param classloader ClassLoader for this container - * @param validator Mod class validator - * @return list of classes in the container - */ - public abstract List> getClasses(LoadableMod container, ClassLoader classloader, ModClassValidator validator); - - public abstract boolean checkEnabled(ContainerRegistry containers, LoadableMod container); - - public abstract boolean checkDependencies(ContainerRegistry containers, LoadableMod base); - - public abstract boolean checkAPIRequirements(ContainerRegistry containers, LoadableMod container); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/GenericObserver.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/GenericObserver.java deleted file mode 100644 index 98389292..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/GenericObserver.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.mumfrey.liteloader.api; - -/** - * Generic Observer class, for Intra-API Observer inking - * - * @author Adam Mummery-Smith - * - * @param Argument type for observable events - */ -public interface GenericObserver extends Observer -{ - public abstract void onObservableEvent(String eventName, T... eventArgs) throws ClassCastException; -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/InterfaceObserver.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/InterfaceObserver.java deleted file mode 100644 index 58137627..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/InterfaceObserver.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mumfrey.liteloader.api; - -/** - * Observer for interface binding events - * - * @author Adam Mummery-Smith - */ -public interface InterfaceObserver extends Observer -{ - public void onRegisterListener(InterfaceProvider provider, Class interfaceType, Listener listener); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/InterfaceProvider.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/InterfaceProvider.java deleted file mode 100644 index a6432eea..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/InterfaceProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.mumfrey.liteloader.api; - -import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate; - -/** - * LiteLoader Extensible API - Interface Provider - * - * InterfaceProviders are able to advertise and provide Listener interfaces - * which can be implemented by mods or other Listener-derived classes. - * - * @author Adam Mummery-Smith - */ -public interface InterfaceProvider -{ - /** - * Base type of Listeners which can consume events provided by this provider - */ - public abstract Class getListenerBaseType(); - - /** - * The provider should call back against the supplied delegate in order to - * advertise the interfaces it provides. - * - * @param delegate - */ - public abstract void registerInterfaces(InterfaceRegistrationDelegate delegate); - - /** - * Initialise this provider, called AFTER enumeration but before binding - */ - public abstract void initProvider(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/Listener.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/Listener.java deleted file mode 100644 index 65044ae8..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/Listener.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.mumfrey.liteloader.api; - -/** - * LiteLoader Extensible API - Listener is the base interface for - * (counter-intuitively) consumable Listener interfaces, in that derived - * interfaces are consumable (from the point of view of the providers) but - * actual implementors consume the events thus advertised by implementing those - * interfaces, making them themselves the consumers. Okay so that's probably - * pretty confusing but I can't think of any better terminology so it's - * staying :) - * - * @author Adam Mummery-Smith - */ -public interface Listener -{ - /** - * Get the display name - * - * @return display name - */ - public abstract String getName(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/LiteAPI.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/LiteAPI.java deleted file mode 100644 index ef5c5d59..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/LiteAPI.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.mumfrey.liteloader.api; - -import java.util.List; - -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; - -/** - * LiteLoader Extensible API - main Mod API - * - *

Implementors of this class don't really do anything except provide - * instances of other classes which make up the API proper. Where possible, - * instance things as late as possible (eg. do not instance your - * CoreProviders in the constructor or init()) because it's possible to screw up - * the game startup if things get loaded out of order, in general it's best to - * instance things only at the earliest point in time at which they are needed. - *

- * - * @author Adam Mummery-Smith - */ -public interface LiteAPI -{ - /** - * Initialise this API, the API should do as little processing as possible - * here, but should also cache the supplied environment and properties - * instances for later use. - * - * @param environment - * @param properties - */ - public abstract void init(LoaderEnvironment environment, LoaderProperties properties); - - /** - * Get the identifier for this API, the identifier is used to retrieve the - * API and match it against specified mod API dependencies. - */ - public abstract String getIdentifier(); - - /** - * Get the friendly name of this API - */ - public abstract String getName(); - - /** - * Get the human-readable version of the API, can be any value - */ - public abstract String getVersion(); - - /** - * Get the revision number of this API. Unlike the version number, the - * revision number should only change when an incompatible change is made to - * the APIs interfaces, it is also used when a mod specifies an API - * dependency using the api@revision syntax. - */ - public abstract int getRevision(); - - /** - * Get mixin environment configuration provider for this API, can return - * null. - */ - public abstract MixinConfigProvider getMixins(); - - /** - * Should return an array of required transformer names, these transformers - * will be injected UPSTREAM. Can return null. - */ - public abstract String[] getRequiredTransformers(); - - /** - * Should return an array of required transformer names, these transformers - * will be injected DOWNSTREAM. Can return null. - */ - public abstract String[] getRequiredDownstreamTransformers(); - - /** - * Return a mod class prefix supported by this API, can return null if an - * API just wants to use "LiteMod" as a standard class name prefix - */ - public abstract String getModClassPrefix(); - - /** - * Should return a list of Enumerator modules to be injected, can return - * null if the API doesn't want to inject any additonal modules - */ - public abstract List getEnumeratorModules(); - - /** - * Should return a list of CoreProviders for this API, can return null if - * the API doesn't have any CoreProviders, (almost) guaranteed to only be - * called once. - */ - public abstract List getCoreProviders(); - - /** - * Should return a list of InterfaceProviders for this API, can return null - * if the API doesn't have any InterfaceProviders, (almost) guaranteed to - * only be called once - */ - public abstract List getInterfaceProviders(); - - /** - * Should return a list of Observers which are safe to instantiate during - * pre-init, for example EnumerationObservers. Can return null if the API - * doesn't have any Observers. - */ - public abstract List getPreInitObservers(); - - /** - * Should return a list of Observers for this API, can return null if the - * API doesn't have any Observers, (almost) guaranteed to only be called - * once. This list may include Observers returned by getPreInitObservers if - * the observers are still required. - */ - public abstract List getObservers(); - - /** - * Get the customisation providers for this API, can return null - */ - public abstract List getCustomisationProviders(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/MixinConfigProvider.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/MixinConfigProvider.java deleted file mode 100644 index 097f34f2..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/MixinConfigProvider.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.mumfrey.liteloader.api; - -import org.spongepowered.asm.mixin.MixinEnvironment.CompatibilityLevel; - -/** - * Container for all of an API's mixin environment configuration - */ -public interface MixinConfigProvider -{ - /** - * Get the minimum required mixin operating compatibility level for this - * API, can return null. - */ - public abstract CompatibilityLevel getCompatibilityLevel(); - - /** - * Get mixin configuration files for this API, all returned configs will be - * added to the DEFAULT environment. Can return null. - */ - public abstract String[] getMixinConfigs(); - - /** - * Get mixin error handler classes to register for this API. Can return - * null. - */ - public abstract String[] getErrorHandlers(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/ModClassValidator.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/ModClassValidator.java deleted file mode 100644 index 3c3c85eb..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/ModClassValidator.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.mumfrey.liteloader.api; - -/** - * Interface for object which validates whether a supplied mod class can be - * loaded. - * - * @author Adam Mummery-Smith - */ -public interface ModClassValidator -{ - public abstract boolean validateName(String className); - - public abstract boolean validateClass(ClassLoader classLoader, Class candidateClass); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/ModInfoDecorator.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/ModInfoDecorator.java deleted file mode 100644 index d176c491..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/ModInfoDecorator.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.mumfrey.liteloader.api; - -import java.util.List; - -import com.mumfrey.liteloader.core.ModInfo; -import com.mumfrey.liteloader.util.render.IconTextured; - -/** - * LiteLoader Extensible API - Branding Provider - * - * Decorator for ModInfo classes, to alter the appearance of ModInfo entries in - * the mod list. - * - * @author Adam Mummery-Smith - */ -public interface ModInfoDecorator extends CustomisationProvider -{ - /** - * Add icons to the mod list entry for this mod - * - * @param mod - * @param icons - */ - public abstract void addIcons(ModInfo mod, List icons); - - /** - * Allows this decorator to modify the status text for the specified mod, - * return null if no modification required. - * - * @param statusText - * @return new status text or NULL to indicate the text should remain - * default - */ - public abstract String modifyStatusText(ModInfo mod, String statusText); - - /** - * Allow decorators to draw custom content on the mod list entries - * - * @param mouseX Mouse X position - * @param mouseY Mouse Y position - * @param partialTicks - * @param xPosition Panel X position - * @param yPosition Panel Y position - * @param width Panel width - * @param selected Panel height - * @param mod ModInfo - * @param gradientColour - * @param titleColour - * @param statusColour - */ - public abstract void onDrawListEntry(int mouseX, int mouseY, float partialTicks, int xPosition, int yPosition, int width, int height, - boolean selected, ModInfo mod, int gradientColour, int titleColour, int statusColour); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/ModLoadObserver.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/ModLoadObserver.java deleted file mode 100644 index 82b9804e..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/ModLoadObserver.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.mumfrey.liteloader.api; - -import java.io.File; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.core.ModInfo; -import com.mumfrey.liteloader.interfaces.LoadableMod; - -/** - * LiteLoader Extensible API - Mod Load Observer - * - * ModLoadObservers receive callbacks when mod loading events are occurring, - * prior to init and other loader-managed processes. - * - * @author Adam Mummery-Smith - */ -public interface ModLoadObserver extends Observer -{ - /** - * Called immediately after a mod instance is created, throw an exception - * from this method in order to prevent further initialisation. - */ - public abstract void onModLoaded(LiteMod mod); - - /** - * Called after a mod is instanced and has been successfully added to the - * active mods list. - * - * @param handle Mod handle - */ - public abstract void onPostModLoaded(ModInfo> handle); - - /** - * Called if mod loading fails - * - * @param container - * @param identifier - * @param reason - * @param th - */ - public abstract void onModLoadFailed(LoadableMod container, String identifier, String reason, Throwable th); - - /** - * Called before a mod's init() method is called - * - * @param mod - */ - public abstract void onPreInitMod(LiteMod mod); - - /** - * Called after a mod's init() method is called - * - * @param mod - */ - public abstract void onPostInitMod(LiteMod mod); - - /** - * Called when migrating mod config from version to version - * - * @param mod - * @param newConfigPath - * @param oldConfigPath - */ - public abstract void onMigrateModConfig(LiteMod mod, File newConfigPath, File oldConfigPath); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/Observer.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/Observer.java deleted file mode 100644 index ffbbe86c..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/Observer.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mumfrey.liteloader.api; - -/** - * LiteLoader Extensible API - Observer base interface - * - *

Observers are essentially "core listeners" which are objects which make up - * the core a of a particular API implementation and sink events generated by - * the Loader or by other observable components. See the derived interfaces for - * more detail.

- * - * @author Adam Mummery-Smith - */ -public interface Observer -{ -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/PostRenderObserver.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/PostRenderObserver.java deleted file mode 100644 index 2d733b2b..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/PostRenderObserver.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.mumfrey.liteloader.api; - -/** - * LiteLoader Extensible API - Post-render Observers - * - *

PostRenderObservers receive the onPostRender event every frame, allowing - * "draw-on-top" behaviour for API components.

- * - * @author Adam Mummery-Smith - */ -public interface PostRenderObserver extends Observer -{ - public abstract void onPostRender(int mouseX, int mouseY, float partialTicks); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/ShutdownObserver.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/ShutdownObserver.java deleted file mode 100644 index dced2a89..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/ShutdownObserver.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.mumfrey.liteloader.api; - -/** - * LiteLoader Extensible API - ShutDownObserver - * - * ShutDownObservers receive an event when the game is shutting down due to a - * user request. They do NOT receive the callback when the VM is terminating, - * use a regular VM shutdownhook for that. - * - * @author Adam Mummery-Smith - */ -public interface ShutdownObserver extends Observer -{ - public abstract void onShutDown(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/TickObserver.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/TickObserver.java deleted file mode 100644 index a2fc4e9d..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/TickObserver.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.mumfrey.liteloader.api; - -/** - * LiteLoader Extensible API - TickObserver - * - * Received a callback every tick (duh) PRIOR to the mod tick event - * - * @author Adam Mummery-Smith - */ -public interface TickObserver extends Observer -{ - public abstract void onTick(boolean clock, float partialTicks, boolean inGame); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/TranslationProvider.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/TranslationProvider.java deleted file mode 100644 index 6f945f79..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/TranslationProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mumfrey.liteloader.api; - -/** - * Interface for providers which can handle translation requests - * - * @author Adam Mummery-Smith - */ -public interface TranslationProvider extends CustomisationProvider -{ - /** - * Translate the supplied key or return NULL if the provider has no - * translation for the specified key - */ - public abstract String translate(String key, Object... args); - - /** - * Translate the supplied key to the specified locale, or return NULL if the - * provider has no translation for this key - */ - public abstract String translate(String locale, String key, Object... args); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/WorldObserver.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/WorldObserver.java deleted file mode 100644 index 4b662b9f..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/WorldObserver.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mumfrey.liteloader.api; - -import net.minecraft.world.World; - -/** - * LiteLoader Extensible API - WorldObserver - * - *

WorldObservers receive a callback when the Minecraft.theWorld reference - * changes, beware the value is allowed to be null.

- * - * @author Adam Mummery-Smith - */ -public interface WorldObserver extends Observer -{ - public abstract void onWorldChanged(World world); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/APIException.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/APIException.java deleted file mode 100644 index f2e9d1d7..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/APIException.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.mumfrey.liteloader.api.exceptions; - -public abstract class APIException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public APIException() - { - super(); - } - - public APIException(String message) - { - super(message); - } - - public APIException(Throwable cause) - { - super(cause); - } - - public APIException(String message, Throwable cause) - { - super(message, cause); - } - -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/InvalidAPIException.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/InvalidAPIException.java deleted file mode 100644 index 8615f121..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/InvalidAPIException.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mumfrey.liteloader.api.exceptions; - -public class InvalidAPIException extends APIException -{ - private static final long serialVersionUID = 1L; - - public InvalidAPIException(String message, Throwable cause) - { - super(message, cause); - } - - public InvalidAPIException(String message) - { - super(message); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/InvalidAPIStateException.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/InvalidAPIStateException.java deleted file mode 100644 index 57de5e7f..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/InvalidAPIStateException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mumfrey.liteloader.api.exceptions; - -public class InvalidAPIStateException extends APIException -{ - private static final long serialVersionUID = 1L; - - public InvalidAPIStateException(String message) - { - super(message); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/InvalidProviderException.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/InvalidProviderException.java deleted file mode 100644 index a361b9df..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/exceptions/InvalidProviderException.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mumfrey.liteloader.api.exceptions; - -public class InvalidProviderException extends APIException -{ - private static final long serialVersionUID = 1L; - - public InvalidProviderException(String message, Throwable cause) - { - super(message, cause); - } - - public InvalidProviderException(String message) - { - super(message); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIAdapter.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIAdapter.java deleted file mode 100644 index 53583fc1..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIAdapter.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.mumfrey.liteloader.api.manager; - -import java.util.List; - -import com.mumfrey.liteloader.api.CoreProvider; -import com.mumfrey.liteloader.api.LiteAPI; -import com.mumfrey.liteloader.api.Observer; -import com.mumfrey.liteloader.interfaces.InterfaceRegistry; - -/** - * API Adapter provides convenience methods for invoking actions on ALL - * registered APIs - * - * @author Adam Mummery-Smith - */ -public interface APIAdapter -{ - /** - * APIs should register their mixin configs and set up the mixin environment - * here. - */ - public abstract void initMixins(); - - /** - * Aggregate and return required transformers from all registered APIs - */ - public abstract List getRequiredTransformers(); - - /** - * Aggregate and return required downstream transformers from all registered - * APIs - */ - public abstract List getRequiredDownstreamTransformers(); - - /** - * Register interfaces from all registered APIs with the specified registry - */ - public abstract void registerInterfaces(InterfaceRegistry interfaceManager); - - /** - * Get the CoreProviders for the specified API. Consuming classes should - * call this method instead of calling API::getCoreProviders() directly - * since getCoreProviders() should only be invoked once and the resulting - * collection is cached by the API Adapter - */ - public abstract List getCoreProviders(); - - /** - * Get the observers for the specified API. Consuming classes should call - * this method instead of calling API::getObservers() directly since - * getObservers() should only be invoked once and the resulting list is - * cached by the API Adapter - * - * @param api API to get observers for - */ - public abstract List getObservers(LiteAPI api); - - /** - * Get the observers for the specified API which implement the specified - * Observer interface. Always returns a valid list (even if empty) and - * doesn't return null. - * - * @param api API to get observers for - * @param observerType type of observer to search for - */ - public abstract List getObservers(LiteAPI api, Class observerType); - - /** - * Get the observers for all registered APIs which implement the specified - * Observer interface. Always returns a valid list (even if empty) and - * doesn't return null. Also includes core providers - * - * @param observerType type of observer to search for - */ - public abstract List getAllObservers(Class observerType); - - /** - * @param api - */ - public abstract List getPreInitObservers(LiteAPI api); - - /** - * @param observerType - */ - public abstract List getPreInitObservers(Class observerType); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIProvider.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIProvider.java deleted file mode 100644 index 8669b192..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIProvider.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.mumfrey.liteloader.api.manager; - -import java.util.regex.Pattern; - -import com.mumfrey.liteloader.api.LiteAPI; - -/** - * Interface for the API Provider, which manages API instances and lifecycle - * - * @author Adam Mummery-Smith - */ -public interface APIProvider -{ - public static final Pattern idAndRevisionPattern = Pattern.compile("^([^@]+)@([0-9]{1,5})$"); - - /** - * Get all available API instances in an array - */ - public abstract LiteAPI[] getAPIs(); - - /** - * Returns true if the specified API is available - * - * @param identifier API identifier (case sensitive) or API - * identifier-plus-minrevision in the form "identifier@minver" - */ - public abstract boolean isAPIAvailable(String identifier); - - /** - * Returns true if the specified API is available - * - * @param identifier API identifier (case sensitive) - * @param minRevision minimum required revision - */ - public abstract boolean isAPIAvailable(String identifier, int minRevision); - - /** - * Gets a specific API by identifier - * - * @param identifier API identifier (case sensitive) - */ - public abstract LiteAPI getAPI(String identifier); - - /** - * Gets a specific API by class - * - * @param apiClass - */ - public abstract T getAPI(Class apiClass); -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIProviderBasic.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIProviderBasic.java deleted file mode 100644 index fc7466f3..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIProviderBasic.java +++ /dev/null @@ -1,340 +0,0 @@ -package com.mumfrey.liteloader.api.manager; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; - -import org.spongepowered.asm.mixin.MixinEnvironment; -import org.spongepowered.asm.mixin.MixinEnvironment.CompatibilityLevel; - -import com.mumfrey.liteloader.api.CoreProvider; -import com.mumfrey.liteloader.api.LiteAPI; -import com.mumfrey.liteloader.api.MixinConfigProvider; -import com.mumfrey.liteloader.api.Observer; -import com.mumfrey.liteloader.interfaces.InterfaceRegistry; - -/** - * Basic implementation of APIProvider and APIAdapter - * - * @author Adam Mummery-Smith - */ -class APIProviderBasic implements APIProvider, APIAdapter -{ - /** - * API instances - */ - private final LiteAPI[] apis; - - /** - * Map of API identifiers to API instances - */ - private final Map apiMap = new HashMap(); - - /** - * Cached observer set - */ - private final Map> observers = new HashMap>(); - - /** - * Cached preinit observers - */ - private final Map> preInitiObservers = new HashMap>(); - - /** - * Cached CoreProvider set - */ - private List coreProviders; - - APIProviderBasic(LiteAPI[] apis) - { - this.apis = apis; - - for (LiteAPI api : this.apis) - { - this.apiMap.put(api.getIdentifier(), api); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.manager.APIAdapter#initMixins() - */ - @Override - public void initMixins() - { - for (LiteAPI api : this.apis) - { - MixinConfigProvider mixins = api.getMixins(); - if (mixins != null) - { - CompatibilityLevel level = mixins.getCompatibilityLevel(); - if (level != null) - { - MixinEnvironment.setCompatibilityLevel(level); - } - - String[] configs = mixins.getMixinConfigs(); - if (configs != null) - { - for (String config : configs) - { - MixinEnvironment.getDefaultEnvironment().addConfiguration(config); - } - } - - String[] errorHandlers = mixins.getErrorHandlers(); - if (errorHandlers != null) - { - for (String handlerName : errorHandlers) - { - MixinEnvironment.getDefaultEnvironment().registerErrorHandlerClass(handlerName); - } - } - } - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.manager.APIProvider - * #getRequiredTransformers() - */ - @Override - public List getRequiredTransformers() - { - List requiredTransformers = new ArrayList(); - - for (LiteAPI api : this.apis) - { - String[] apiTransformers = api.getRequiredTransformers(); - if (apiTransformers != null) - { - requiredTransformers.addAll(Arrays.asList(apiTransformers)); - } - } - - return requiredTransformers; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.manager.APIProvider - * #getRequiredDownstreamTransformers() - */ - @Override - public List getRequiredDownstreamTransformers() - { - List requiredDownstreamTransformers = new ArrayList(); - - for (LiteAPI api : this.apis) - { - String[] apiTransformers = api.getRequiredDownstreamTransformers(); - if (apiTransformers != null) - { - requiredDownstreamTransformers.addAll(Arrays.asList(apiTransformers)); - } - } - - return requiredDownstreamTransformers; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.manager.APIProvider - * #getObservers(com.mumfrey.liteloader.api.LiteAPI) - */ - @Override - public List getObservers(LiteAPI api) - { - if (!this.observers.containsKey(api)) - { - List apiObservers = api.getObservers(); - this.observers.put(api, Collections.unmodifiableList(apiObservers != null ? apiObservers : new ArrayList())); - } - - return this.observers.get(api); - } - - @Override - public List getPreInitObservers(LiteAPI api) - { - if (!this.preInitiObservers.containsKey(api)) - { - List apiObservers = api.getPreInitObservers(); - this.preInitiObservers.put(api, Collections.unmodifiableList(apiObservers != null ? apiObservers : new ArrayList())); - } - - return this.preInitiObservers.get(api); - } - - @SuppressWarnings("unchecked") - @Override - public List getObservers(LiteAPI api, Class observerType) - { - List matchingObservers = new ArrayList(); - - for (Observer observer : this.getObservers(api)) - { - if (observerType.isAssignableFrom(observer.getClass()) && !matchingObservers.contains(observer)) - { - matchingObservers.add((T)observer); - } - } - - return matchingObservers; - } - - @SuppressWarnings("unchecked") - @Override - public List getAllObservers(Class observerType) - { - List matchingObservers = new ArrayList(); - for (LiteAPI api : this.apis) - { - matchingObservers.addAll(this.getObservers(api, observerType)); - } - - for (CoreProvider coreProvider : this.getCoreProviders()) - { - if (observerType.isAssignableFrom(coreProvider.getClass()) && !matchingObservers.contains(coreProvider)) - { - matchingObservers.add((T)coreProvider); - } - } - - return matchingObservers; - } - - @SuppressWarnings("unchecked") - @Override - public List getPreInitObservers(Class observerType) - { - List matchingObservers = new ArrayList(); - for (LiteAPI api : this.apis) - { - for (Observer observer : this.getPreInitObservers(api)) - { - if (observerType.isAssignableFrom(observer.getClass()) && !matchingObservers.contains(observer)) - { - matchingObservers.add((T)observer); - } - } - } - - return matchingObservers; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.manager.APIProvider - * #registerInterfaceProviders( - * com.mumfrey.liteloader.core.InterfaceManager) - */ - @Override - public void registerInterfaces(InterfaceRegistry interfaceManager) - { - for (LiteAPI api : this.apis) - { - interfaceManager.registerAPI(api); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.manager.APIAdapter#getCoreProviders() - */ - @Override - public List getCoreProviders() - { - if (this.coreProviders == null) - { - List coreProviders = new ArrayList(); - - for (LiteAPI api : this.apis) - { - List apiCoreProviders = api.getCoreProviders(); - if (apiCoreProviders != null) - { - coreProviders.addAll(apiCoreProviders); - } - } - - this.coreProviders = Collections.unmodifiableList(coreProviders); - } - - return this.coreProviders; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.manager.APIProvider#getAPIs() - */ - @Override - public LiteAPI[] getAPIs() - { - return this.apis; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.manager.APIProvider - * #isAPIAvailable(java.lang.String) - */ - @Override - public boolean isAPIAvailable(String identifier) - { - if (identifier != null && identifier.contains("@")) - { - Matcher idAndRevisionPatternMatcher = APIProvider.idAndRevisionPattern.matcher(identifier); - if (idAndRevisionPatternMatcher.matches()) - { - return this.isAPIAvailable(idAndRevisionPatternMatcher.group(1), Integer.parseInt(idAndRevisionPatternMatcher.group(2))); - } - } - - return this.apiMap.containsKey(identifier); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.manager.APIProvider - * #isAPIAvailable(java.lang.String, int) - */ - @Override - public boolean isAPIAvailable(String identifier, int minRevision) - { - LiteAPI api = this.apiMap.get(identifier); - if (api == null) return false; - - return api.getRevision() >= minRevision; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.manager.APIProvider - * #getAPI(java.lang.String) - */ - @Override - public LiteAPI getAPI(String identifier) - { - return this.apiMap.get(identifier); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.manager.APIProvider - * #getAPI(java.lang.Class) - */ - @SuppressWarnings("unchecked") - @Override - public T getAPI(Class apiClass) - { - try - { - for (LiteAPI api : this.apis) - { - if (apiClass.isAssignableFrom(api.getClass())) - { - return (T)api; - } - } - } - catch (NullPointerException ex1) {} - catch (ClassCastException ex2) {} - - return null; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIRegistry.java b/liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIRegistry.java deleted file mode 100644 index e921b37a..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/api/manager/APIRegistry.java +++ /dev/null @@ -1,182 +0,0 @@ -package com.mumfrey.liteloader.api.manager; - -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.minecraft.launchwrapper.Launch; - -import com.mumfrey.liteloader.api.LiteAPI; -import com.mumfrey.liteloader.api.exceptions.InvalidAPIStateException; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -/** - * This is where we register API classes during early startup before baking the - * registered list into an APIProvider instance - * - * @author Adam Mummery-Smith - */ -public final class APIRegistry -{ - private Set registeredAPIClasses = new LinkedHashSet(); - private Map instances = new LinkedHashMap(); - - private final LoaderEnvironment environment; - - private final LoaderProperties properties; - - private APIProviderBasic baked; - - /** - * @param environment - * @param properties - */ - public APIRegistry(LoaderEnvironment environment, LoaderProperties properties) - { - this.environment = environment; - this.properties = properties; - } - - /** - * Register an API class, throws an exception if the API list has already - * been baked. - * - * @param apiClass - */ - public void registerAPI(String apiClass) throws InvalidAPIStateException - { - if (this.baked != null) - { - throw new InvalidAPIStateException("Unable to register API provider '" + apiClass - + "' because the API state is now frozen, this probably means you are registering an API too late in the initialisation process"); - } - - if (!this.registeredAPIClasses.contains(apiClass)) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Registering API provider class %s", apiClass); - this.registeredAPIClasses.add(apiClass); - } - } - - /** - * Get all currently registered API classes - */ - public String[] getRegisteredAPIs() - { - return this.registeredAPIClasses.toArray(new String[0]); - } - - /** - * @param apiClassName - */ - private LiteAPI spawnAPI(String apiClassName) - { - try - { - LiteLoaderLogger.info("Spawning API provider class '%s' ...", apiClassName); - - @SuppressWarnings("unchecked") - Class apiClass = (Class)Class.forName(apiClassName, true, Launch.classLoader); - - LiteAPI api = apiClass.newInstance(); - String identifier = api.getIdentifier(); - - if (!this.instances.containsKey(identifier)) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "API provider class '%s' provides API '%s'", apiClassName, identifier); - this.instances.put(identifier, api); - return api; - } - - Class conflictingAPIClass = this.instances.get(identifier).getClass(); - LiteLoaderLogger.severe("API identifier clash while registering '%s', identifier '%s' clashes with '%s'", apiClassName, - identifier, conflictingAPIClass); - } - catch (ClassNotFoundException ex) - { - LiteLoaderLogger.severe("API class '%s' could not be created, the specified class could not be loaded", apiClassName); - } - catch (Exception ex) - { - LiteLoaderLogger.severe(ex, "Error while instancing API class '%s'", apiClassName); - } - - return null; - } - - /** - * Populate and return the API instance array - */ - private LiteAPI[] getAllAPIs() - { - List allAPIs = new ArrayList(); - - for (String apiClass : this.registeredAPIClasses) - { - LiteAPI api = this.spawnAPI(apiClass); - if (api != null) - { - allAPIs.add(api); - } - } - - for (LiteAPI api : allAPIs) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Initialising API '%s' ...", api.getIdentifier()); - api.init(this.environment, this.properties); - } - - return allAPIs.toArray(new LiteAPI[allAPIs.size()]); - } - - /** - * Bakes all currently registered API classes to a new APIProvider - * containing the API instances. - * - * @throws InvalidAPIStateException if the API list was already baked - */ - public APIProvider bake() throws InvalidAPIStateException - { - if (this.baked != null) - { - throw new InvalidAPIStateException("Unable to bake the API provider list because the API list is already baked"); - } - - LiteAPI[] apis = this.getAllAPIs(); - return this.baked = new APIProviderBasic(apis); - } - - /** - * Gets the current APIProvider instance - * @throws InvalidAPIStateException if the provider list was not yet baked - */ - public APIProvider getProvider() throws InvalidAPIStateException - { - if (this.baked == null) - { - throw new InvalidAPIStateException("Call to APIRegistry.getProvider() failed because the provider list has not been baked"); - } - - return this.baked; - } - - /** - * Gets the current APIAdapter instance - * @throws InvalidAPIStateException if the provider list was not yet baked - */ - public APIAdapter getAdapter() throws InvalidAPIStateException - { - if (this.baked == null) - { - throw new InvalidAPIStateException("Call to APIRegistry.APIAdapter() failed because the provider list has not been baked"); - } - - return this.baked; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/GameEngine.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/GameEngine.java deleted file mode 100644 index 34d92fe6..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/GameEngine.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.mumfrey.liteloader.common; - -import java.util.List; - -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.profiler.Profiler; -import net.minecraft.server.MinecraftServer; - -/** - * @author Adam Mummery-Smith - * - * @param Type of the client runtime, "Minecraft" on client and null - * on the server - * @param Type of the server runtime, "IntegratedServer" on the - * client, "MinecraftServer" on the server - */ -public interface GameEngine -{ - /** - * True if the environment is a client environment - */ - public abstract boolean isClient(); - - /** - * True if the current environment is a server environment, always true on - * dedicated and true in single player. - */ - public abstract boolean isServer(); - - /** - * True if the client is "in game", always true on server - */ - public abstract boolean isInGame(); - - /** - * True if the game loop's "isRunning" flag is true - */ - public abstract boolean isRunning(); - - /** - * True if the current world is single player, always false on the server - */ - public abstract boolean isSinglePlayer(); - - /** - * Get the underlying client instance, returns a dummy on the server - */ - public abstract TClient getClient(); - - /** - * Get the underlying server instance - */ - public abstract TServer getServer(); - - /** - * Get the resources manager - */ - public abstract Resources getResources(); - - /** - * Get the profiler instance - */ - public abstract Profiler getProfiler(); - - /** - * Get the keybinding list, only supported on client will throw an exception - * on the server. - */ - public abstract List getKeyBindings(); - - /** - * Set the keybinding list, only supported on client will throw an exception - * on the server. - * - * @param keyBindings - */ - public abstract void setKeyBindings(List keyBindings); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/LoadingProgress.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/LoadingProgress.java deleted file mode 100644 index aba6b538..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/LoadingProgress.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.mumfrey.liteloader.common; - -/** - * @author Adam Mummery-Smith - */ -public abstract class LoadingProgress -{ - private static LoadingProgress instance; - - protected LoadingProgress() - { - LoadingProgress.instance = this; - } - - public static void setEnabled(boolean enabled) - { - if (LoadingProgress.instance != null) LoadingProgress.instance._setEnabled(enabled); - } - - public static void dispose() - { - if (LoadingProgress.instance != null) LoadingProgress.instance._dispose(); - } - - public static void incLiteLoaderProgress() - { - if (LoadingProgress.instance != null) LoadingProgress.instance._incLiteLoaderProgress(); - } - - public static void setMessage(String format, String... args) - { - if (LoadingProgress.instance != null) LoadingProgress.instance._setMessage(String.format(format, (Object[])args)); - } - - public static void setMessage(String message) - { - if (LoadingProgress.instance != null) LoadingProgress.instance._setMessage(message); - } - - public static void incLiteLoaderProgress(String format, String... args) - { - if (LoadingProgress.instance != null) LoadingProgress.instance._incLiteLoaderProgress(String.format(format, (Object[])args)); - } - - public static void incLiteLoaderProgress(String message) - { - if (LoadingProgress.instance != null) LoadingProgress.instance._incLiteLoaderProgress(message); - } - - public static void incTotalLiteLoaderProgress(int by) - { - if (LoadingProgress.instance != null) LoadingProgress.instance._incTotalLiteLoaderProgress(by); - } - - protected abstract void _setEnabled(boolean enabled); - - protected abstract void _dispose(); - - protected abstract void _incLiteLoaderProgress(); - - protected abstract void _setMessage(String message); - - protected abstract void _incLiteLoaderProgress(String message); - - protected abstract void _incTotalLiteLoaderProgress(int by); -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/Resources.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/Resources.java deleted file mode 100644 index 4b616ca2..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/Resources.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mumfrey.liteloader.common; - -public interface Resources -{ - /** - * Refresh resource pack list - * - * @param force - */ - public abstract void refreshResources(boolean force); - - /** - * Get the resource manager for the current environment, returns the - * SimpleReloadableResourceManager on client and ModResourceManager on the - * server. - */ - public abstract TResourceManager getResourceManager(); - - /** - * @param resourcePack - */ - public abstract boolean registerResourcePack(TResourcePack resourcePack); - - /** - * @param resourcePack - */ - public abstract boolean unRegisterResourcePack(TResourcePack resourcePack); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/ducks/IChatPacket.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/ducks/IChatPacket.java deleted file mode 100644 index e58fa85e..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/ducks/IChatPacket.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.mumfrey.liteloader.common.ducks; - -import net.minecraft.util.IChatComponent; - -public interface IChatPacket -{ - public abstract IChatComponent getChatComponent(); - - public abstract void setChatComponent(IChatComponent chatComponent); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/ducks/IPacketClientSettings.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/ducks/IPacketClientSettings.java deleted file mode 100644 index 9795a5f7..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/ducks/IPacketClientSettings.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.mumfrey.liteloader.common.ducks; - -public interface IPacketClientSettings -{ - public abstract int getViewDistance(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinC15PacketClientSettings.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinC15PacketClientSettings.java deleted file mode 100644 index b5c14f79..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinC15PacketClientSettings.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.mumfrey.liteloader.common.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import com.mumfrey.liteloader.common.ducks.IPacketClientSettings; - -import net.minecraft.network.play.client.C15PacketClientSettings; - -@Mixin(C15PacketClientSettings.class) -public abstract class MixinC15PacketClientSettings implements IPacketClientSettings -{ - @Shadow private int view; - - @Override - public int getViewDistance() - { - return this.view; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinItemInWorldManager.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinItemInWorldManager.java deleted file mode 100644 index b37ae3fb..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinItemInWorldManager.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.mumfrey.liteloader.common.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import com.mumfrey.liteloader.core.Proxy; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.item.ItemStack; -import net.minecraft.server.management.ItemInWorldManager; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.World; - -@Mixin(ItemInWorldManager.class) -public abstract class MixinItemInWorldManager -{ - @Inject( - method = "onBlockClicked(Lnet/minecraft/util/BlockPos;Lnet/minecraft/util/EnumFacing;)V", - cancellable = true, - at = @At("HEAD") - ) - private void onBlockClicked(BlockPos pos, EnumFacing side, CallbackInfo ci) - { - Proxy.onBlockClicked(ci, (ItemInWorldManager)(Object)this, pos, side); - } - - @Inject( - method = "activateBlockOrUseItem(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;Lnet/minecraft/item/ItemStack;" - + "Lnet/minecraft/util/BlockPos;Lnet/minecraft/util/EnumFacing;FFF)Z", - cancellable = true, - at = @At("HEAD") - ) - private void onUseItem(EntityPlayer player, World worldIn, ItemStack stack, BlockPos pos, EnumFacing side, float offsetX, float offsetY, - float offsetZ, CallbackInfoReturnable cir) - { - Proxy.onUseItem(cir, player, worldIn, stack, pos, side, offsetX, offsetY, offsetZ); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinMinecraftServer.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinMinecraftServer.java deleted file mode 100644 index 1ffa13fd..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinMinecraftServer.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.mumfrey.liteloader.common.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; - -import com.mumfrey.liteloader.core.Proxy; - -import net.minecraft.server.MinecraftServer; - -@Mixin(MinecraftServer.class) -public abstract class MixinMinecraftServer -{ - @Inject(method = "updateTimeLightAndEntities()V", at = @At("HEAD")) - private void onServerTick(CallbackInfo ci) - { - Proxy.onServerTick((MinecraftServer)(Object)this); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinS02PacketChat.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinS02PacketChat.java deleted file mode 100644 index 3a913c67..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinS02PacketChat.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.mumfrey.liteloader.common.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; - -import com.mumfrey.liteloader.common.ducks.IChatPacket; - -import net.minecraft.network.play.server.S02PacketChat; -import net.minecraft.util.IChatComponent; - -@Mixin(S02PacketChat.class) -public abstract class MixinS02PacketChat implements IChatPacket -{ - @Shadow private IChatComponent chatComponent; - - @Override - public IChatComponent getChatComponent() - { - return this.chatComponent; - } - - @Override - public void setChatComponent(IChatComponent chatComponent) - { - this.chatComponent = chatComponent; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinServerConfigurationManager.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinServerConfigurationManager.java deleted file mode 100644 index 52b9db40..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinServerConfigurationManager.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.mumfrey.liteloader.common.mixin; - -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Surrogate; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import com.mojang.authlib.GameProfile; -import com.mumfrey.liteloader.core.Proxy; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.NetHandlerPlayServer; -import net.minecraft.network.NetworkManager; -import net.minecraft.server.management.ServerConfigurationManager; - -@Mixin(ServerConfigurationManager.class) -public abstract class MixinServerConfigurationManager -{ - @Inject( - method = "initializeConnectionToPlayer(Lnet/minecraft/network/NetworkManager;Lnet/minecraft/entity/player/EntityPlayerMP;)V", - at = @At("RETURN") - ) - private void onInitializePlayerConnection(NetworkManager netManager, EntityPlayerMP player, CallbackInfo ci) - { - Proxy.onInitializePlayerConnection((ServerConfigurationManager)(Object)this, netManager, player); - } - - // Because, forge - @Surrogate - private void onInitializePlayerConnection(NetworkManager netManager, EntityPlayerMP player, NetHandlerPlayServer nhps, CallbackInfo ci) - { - Proxy.onInitializePlayerConnection((ServerConfigurationManager)(Object)this, netManager, player); - } - - @Inject(method = "playerLoggedIn(Lnet/minecraft/entity/player/EntityPlayerMP;)V", at = @At("RETURN")) - private void onPlayerLogin(EntityPlayerMP player, CallbackInfo ci) - { - Proxy.onPlayerLogin((ServerConfigurationManager)(Object)this, player); - } - - @Inject(method = "playerLoggedOut(Lnet/minecraft/entity/player/EntityPlayerMP;)V", at = @At("RETURN")) - private void onPlayerLogout(EntityPlayerMP player, CallbackInfo ci) - { - Proxy.onPlayerLogout((ServerConfigurationManager)(Object)this, player); - } - - @Inject( - method = "createPlayerForUser(Lcom/mojang/authlib/GameProfile;)Lnet/minecraft/entity/player/EntityPlayerMP;", - cancellable = true, - at = @At("RETURN") - ) - private void onSpawnPlayer(GameProfile profile, CallbackInfoReturnable cir) - { - Proxy.onSpawnPlayer(cir, (ServerConfigurationManager)(Object)this, profile); - } - - @Inject( - method = "recreatePlayerEntity(Lnet/minecraft/entity/player/EntityPlayerMP;IZ)Lnet/minecraft/entity/player/EntityPlayerMP;", - cancellable = true, - at = @At("RETURN") - ) - private void onRespawnPlayer(EntityPlayerMP player, int dimension, boolean conqueredEnd, CallbackInfoReturnable cir) - { - Proxy.onRespawnPlayer(cir, (ServerConfigurationManager)(Object)this, player, dimension, conqueredEnd); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/transformers/LiteLoaderPacketTransformer.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/transformers/LiteLoaderPacketTransformer.java deleted file mode 100644 index 1ac2dbc9..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/transformers/LiteLoaderPacketTransformer.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.mumfrey.liteloader.common.transformers; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.core.runtime.Packets; -import com.mumfrey.liteloader.transformers.event.EventInjectionTransformer; -import com.mumfrey.liteloader.transformers.event.InjectionPoint; -import com.mumfrey.liteloader.transformers.event.MethodInfo; -import com.mumfrey.liteloader.transformers.event.inject.MethodHead; - -public class LiteLoaderPacketTransformer extends EventInjectionTransformer -{ - @Override - protected void addEvents() - { - InjectionPoint methodHead = new MethodHead(); - MethodInfo handlePacket = new MethodInfo(Obf.PacketEvents, "handlePacket"); - - for (Packets packet : Packets.packets) - { - MethodInfo processPacket = new MethodInfo(packet, Obf.processPacket, Void.TYPE, Obf.INetHandler); - this.addEvent(new PacketEvent(packet), processPacket, methodHead).addListener(handlePacket); - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/transformers/PacketEvent.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/transformers/PacketEvent.java deleted file mode 100644 index 0faf231d..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/transformers/PacketEvent.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.mumfrey.liteloader.common.transformers; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.InsnList; -import org.objectweb.asm.tree.InsnNode; -import org.objectweb.asm.tree.IntInsnNode; -import org.objectweb.asm.tree.LdcInsnNode; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.VarInsnNode; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.core.runtime.Packets; -import com.mumfrey.liteloader.transformers.event.Event; -import com.mumfrey.liteloader.transformers.event.EventInfo; - -/** - * Special event used to hook all packets - * - * @author Adam Mummery-Smith - */ -public class PacketEvent extends Event -{ - /** - * Soft index for this packet, used as a lookup for speed when determining - * handlers. - */ - private int packetIndex; - - PacketEvent(Packets packet) - { - super("on" + packet.getShortName(), true, 1000); - this.packetIndex = packet.getIndex(); - this.verbose = false; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.transformers.event.Event - * #getEventInfoClassName() - */ - @Override - public String getEventInfoClassName() - { - return "com/mumfrey/liteloader/common/transformers/PacketEventInfo"; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.transformers.event.Event - * #invokeEventInfoConstructor(org.objectweb.asm.tree.InsnList, - * boolean) - */ - @Override - protected int invokeEventInfoConstructor(InsnList insns, boolean cancellable, boolean pushReturnValue, int marshallVar) - { - int ctorMAXS = 0; - - insns.add(new LdcInsnNode(this.name)); ctorMAXS++; - insns.add(this.methodIsStatic ? new InsnNode(Opcodes.ACONST_NULL) : new VarInsnNode(Opcodes.ALOAD, 0)); ctorMAXS++; - insns.add(new InsnNode(cancellable ? Opcodes.ICONST_1 : Opcodes.ICONST_0)); ctorMAXS++; - insns.add(new IntInsnNode(Opcodes.BIPUSH, this.packetIndex)); - insns.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, this.eventInfoClass, Obf.constructor.name, - EventInfo.getConstructorDescriptor().replace(")", "I)"), false)); - - return ctorMAXS; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/transformers/PacketEventInfo.java b/liteloader/src/main/java/com/mumfrey/liteloader/common/transformers/PacketEventInfo.java deleted file mode 100644 index d498dc41..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/transformers/PacketEventInfo.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.mumfrey.liteloader.common.transformers; - -import com.mumfrey.liteloader.transformers.event.EventInfo; - -import net.minecraft.network.Packet; - -public class PacketEventInfo extends EventInfo -{ - private final int packetId; - - @SuppressWarnings("unchecked") - public PacketEventInfo(String name, Object source, boolean cancellable, int packetId) - { - super(name, (S)source, cancellable); - - this.packetId = packetId; - } - - public int getPacketId() - { - return this.packetId; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/BadContainerInfo.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/BadContainerInfo.java deleted file mode 100644 index 8841b084..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/BadContainerInfo.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.mumfrey.liteloader.core; - -import com.mumfrey.liteloader.core.api.LoadableModFile; -import com.mumfrey.liteloader.interfaces.Loadable; - -/** - * ModInfo for invalid containers - * - * @author Adam Mummery-Smith - */ -public class BadContainerInfo extends NonMod -{ - /** - * Reason the container could not be loaded - */ - private final String reason; - - public BadContainerInfo(Loadable container, String reason) - { - super(container, false); - this.reason = reason; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#isToggleable() - */ - @Override - public boolean isToggleable() - { - return false; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#isValid() - */ - @Override - public boolean isValid() - { - return false; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getDescription() - */ - @Override - public String getDescription() - { - return "\247c" + this.reason; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getVersion() - */ - @Override - public String getVersion() - { - if (this.container instanceof LoadableModFile) - { - return "supported: \247c" + ((LoadableModFile)this.container).getTargetVersion() + "\247r"; - } - - return "supported: \247cUnknown"; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/ClientPluginChannels.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/ClientPluginChannels.java deleted file mode 100644 index a450a897..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/ClientPluginChannels.java +++ /dev/null @@ -1,196 +0,0 @@ -package com.mumfrey.liteloader.core; - -import net.minecraft.network.INetHandler; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.play.server.S3FPacketCustomPayload; - -import com.mumfrey.liteloader.PluginChannelListener; -import com.mumfrey.liteloader.api.Listener; -import com.mumfrey.liteloader.core.event.HandlerList; -import com.mumfrey.liteloader.interfaces.FastIterableDeque; -import com.mumfrey.liteloader.permissions.PermissionsManagerClient; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Handler for client plugin channels - * - * @author Adam Mummery-Smith - */ -public abstract class ClientPluginChannels extends PluginChannels -{ - private static ClientPluginChannels instance; - - protected ClientPluginChannels() - { - if (ClientPluginChannels.instance != null) throw new RuntimeException("Plugin Channels Startup Error", - new InstantiationException("Only a single instance of ClientPluginChannels is allowed")); - ClientPluginChannels.instance = this; - } - - @Override - protected FastIterableDeque createHandlerList() - { - return new HandlerList(PluginChannelListener.class); - } - - protected static ClientPluginChannels getInstance() - { - return ClientPluginChannels.instance; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider#initProvider() - */ - @Override - public void initProvider() - { - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider#getListenerBaseType() - */ - @Override - public Class getListenerBaseType() - { - return Listener.class; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider - * #registerInterfaces( - * com.mumfrey.liteloader.core.InterfaceRegistrationDelegate) - */ - @Override - public void registerInterfaces(InterfaceRegistrationDelegate delegate) - { - delegate.registerInterface(PluginChannelListener.class); - } - - void addClientPluginChannelListener(PluginChannelListener pluginChannelListener) - { - super.addPluginChannelListener(pluginChannelListener); - } - - /** - * Callback for the plugin channel hook - * - * @param customPayload - */ - public abstract void onPluginChannelMessage(S3FPacketCustomPayload customPayload); - - /** - * @param channel - * @param data - */ - protected void onPluginChannelMessage(String channel, PacketBuffer data) - { - if (PluginChannels.CHANNEL_REGISTER.equals(channel)) - { - this.onRegisterPacketReceived(data); - } - else if (this.pluginChannels.containsKey(channel)) - { - try - { - PermissionsManagerClient permissionsManager = LiteLoader.getClientPermissionsManager(); - if (permissionsManager != null) - { - permissionsManager.onCustomPayload(channel, data); - } - } - catch (Exception ex) {} - - this.onModPacketReceived(channel, data); - } - } - - /** - * @param channel - * @param data - */ - protected void onModPacketReceived(String channel, PacketBuffer data) - { - for (PluginChannelListener pluginChannelListener : this.pluginChannels.get(channel)) - { - try - { - pluginChannelListener.onCustomPayload(channel, data); - throw new RuntimeException(); - } - catch (Exception ex) - { - int failCount = 1; - if (this.faultingPluginChannelListeners.containsKey(pluginChannelListener)) - { - failCount = this.faultingPluginChannelListeners.get(pluginChannelListener).intValue() + 1; - } - - if (failCount >= PluginChannels.WARN_FAULT_THRESHOLD) - { - LiteLoaderLogger.warning("Plugin channel listener %s exceeded fault threshold on channel %s with %s", - pluginChannelListener.getName(), channel, ex.getClass().getSimpleName()); - this.faultingPluginChannelListeners.remove(pluginChannelListener); - } - else - { - this.faultingPluginChannelListeners.put(pluginChannelListener, Integer.valueOf(failCount)); - } - } - } - } - - protected void sendRegisteredPluginChannels(INetHandler netHandler) - { - // Add the permissions manager channels - this.addPluginChannelsFor(LiteLoader.getClientPermissionsManager()); - - try - { - // Enumerate mods for plugin channels - for (PluginChannelListener pluginChannelListener : this.pluginChannelListeners) - { - this.addPluginChannelsFor(pluginChannelListener); - } - - PacketBuffer registrationData = this.getRegistrationData(); - if (registrationData != null) - { - this.sendRegistrationData(netHandler, registrationData); - } - } - catch (Exception ex) - { - LiteLoaderLogger.warning(ex, "Error dispatching REGISTER packet to server %s", ex.getClass().getSimpleName()); - } - } - - /** - * @param netHandler - * @param registrationData - */ - protected abstract void sendRegistrationData(INetHandler netHandler, PacketBuffer registrationData); - - /** - * Send a message to the server on a plugin channel - * - * @param channel Channel to send, must not be a reserved channel name - * @param data - */ - public static boolean sendMessage(String channel, PacketBuffer data, ChannelPolicy policy) - { - if (ClientPluginChannels.instance != null) - { - return ClientPluginChannels.instance.send(channel, data, policy); - } - - return false; - } - - /** - * Send a message to the server on a plugin channel - * - * @param channel Channel to send, must not be a reserved channel name - * @param data - */ - protected abstract boolean send(String channel, PacketBuffer data, ChannelPolicy policy); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/CommonPluginChannelListener.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/CommonPluginChannelListener.java deleted file mode 100644 index 8efc5156..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/CommonPluginChannelListener.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.util.List; - -import com.mumfrey.liteloader.api.Listener; - -/** - * Common interface for the client/server plugin channel listeners. Do not - * implement this interface directly, nothing will happen! - * - * @author Adam Mummery-Smith - */ -public interface CommonPluginChannelListener extends Listener -{ - /** - * Return a list of the plugin channels the mod wants to register. - * - * @return plugin channel names as a list, it is recommended to use - * {@link com.google.common.collect.ImmutableList#of} for this purpose - */ - public abstract List getChannels(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/Containers.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/Containers.java deleted file mode 100644 index 6bac1968..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/Containers.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.mumfrey.liteloader.api.ContainerRegistry; -import com.mumfrey.liteloader.interfaces.Loadable; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.interfaces.TweakContainer; - -/** - * Implementation of ContainerRegistry for LiteLoaderEnumerator - * - * @author Adam Mummery-Smith - */ -class Containers implements ContainerRegistry -{ - /** - * Mod containers which are disabled - */ - private final Map>> disabledContainers = new HashMap>>(); - - /** - * Mapping of identifiers to mod containers - */ - private final Map> enabledContainers = new HashMap>(); - - /** - * Map of containers which cannot be loaded to reasons - */ - private final Set>> badContainers = new HashSet>>(); - - /** - * Tweaks to inject - */ - private final List> tweakContainers = new ArrayList>(); - - /** - * Other tweak-containing jars which we have injected - */ - private final List>> injectedTweaks = new ArrayList>>(); - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ContainerRegistry#getDisabledContainers() - */ - @Override - public Collection>> getDisabledContainers() - { - return this.disabledContainers.values(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ContainerRegistry#getEnabledContainers() - */ - @Override - public Collection> getEnabledContainers() - { - return this.enabledContainers.values(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ContainerRegistry#getBadContainers() - */ - @Override - public Collection>> getBadContainers() - { - return this.badContainers; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ContainerRegistry#getTweakContainers() - */ - @Override - public List> getTweakContainers() - { - return this.tweakContainers; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ContainerRegistry#getInjectedTweaks() - */ - @Override - public List>> getInjectedTweaks() - { - return this.injectedTweaks; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ContainerRegistry - * #isDisabledContainer(com.mumfrey.liteloader.interfaces.LoadableMod) - */ - @Override - public boolean isDisabledContainer(LoadableMod container) - { - return this.disabledContainers.containsValue(container); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ContainerRegistry - * #getEnabledContainer(java.lang.String) - */ - @Override - public LoadableMod getEnabledContainer(String identifier) - { - LoadableMod container = this.enabledContainers.get(identifier); - return container != null ? container : LoadableMod.NONE; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ContainerRegistry - * #registerBadContainer(com.mumfrey.liteloader.interfaces.Loadable, - * java.lang.String) - */ - @Override - public void registerBadContainer(Loadable container, String reason) - { - this.badContainers.add(new BadContainerInfo(container, reason)); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ContainerRegistry - * #registerEnabledContainer( - * com.mumfrey.liteloader.interfaces.LoadableMod) - */ - @Override - public void registerEnabledContainer(LoadableMod container) - { - this.disabledContainers.remove(container.getIdentifier()); - this.enabledContainers.put(container.getIdentifier(), container); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ContainerRegistry - * #registerDisabledContainer( - * com.mumfrey.liteloader.interfaces.LoadableMod, - * com.mumfrey.liteloader.api.ContainerRegistry.DisabledReason) - */ - @Override - public void registerDisabledContainer(LoadableMod container, DisabledReason reason) - { - this.enabledContainers.remove(container.getIdentifier()); - this.disabledContainers.put(container.getIdentifier(), new NonMod(container, false)); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ContainerRegistry - * #registerTweakContainer( - * com.mumfrey.liteloader.interfaces.TweakContainer) - */ - @Override - public void registerTweakContainer(TweakContainer container) - { - this.tweakContainers.add(container); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.ContainerRegistry - * #registerInjectedTweak( - * com.mumfrey.liteloader.interfaces.TweakContainer) - */ - @Override - public void registerInjectedTweak(TweakContainer container) - { - this.injectedTweaks.add(new NonMod(container, true)); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/EnabledModsList.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/EnabledModsList.java deleted file mode 100644 index d50e1b56..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/EnabledModsList.java +++ /dev/null @@ -1,252 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.util.List; -import java.util.Map; -import java.util.TreeMap; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; - -/** - * Serialisable (via GSON) object which stores list of enabled/disabled mods for - * each profile. - * - * @author Adam Mummery-Smith - */ -public final class EnabledModsList -{ - @SuppressWarnings("unused") - private static final transient long serialVersionUID = -6449451105617763769L; - - /** - * Gson object for serialisation/deserialisation - */ - private static transient Gson gson = new GsonBuilder().setPrettyPrinting().create(); - - /** - * This is the node which gets serialised - */ - private TreeMap> mods; - - /** - * By default, when we discover a mod which is NOT in the list for the - * current profile, we will ENABLE the mod and add it to the list. However, - * when we receive a list of mods on the command line, we instead want to - * disable any additional unlisted mods, we also don't want to save - * the mods list because the command line is supposed to be an override - * rather than a new mask. These two values provide this behaviour. - */ - private transient Boolean defaultEnabledValue = Boolean.TRUE; - private transient boolean allowSave = true; - - /** - * JSON file containing the list of enabled/disabled mods by profile - */ - private transient File enabledModsFile = null; - - private EnabledModsList() - { - // Private because we are always instanced by the static createFrom() method below - } - - /** - * Check whether a particular mod is enabled - * - * @param profileName - * @param identifier - */ - public boolean isEnabled(String profileName, String identifier) - { - Map profile = this.getProfile(profileName); - identifier = identifier.toLowerCase().trim(); - - if (!profile.containsKey(identifier)) - { - profile.put(identifier, this.defaultEnabledValue); - } - - return profile.get(identifier); - } - - /** - * Set the enablement state of a mod in the specified profile - * - * @param profileName - * @param identifier - * @param enabled - */ - public void setEnabled(String profileName, String identifier, boolean enabled) - { - Map profile = this.getProfile(profileName); - profile.put(identifier.toLowerCase().trim(), Boolean.valueOf(enabled)); - - this.allowSave = true; - } - - /** - * Reads the mods list passed in on the command line - * - * @param profileName - * @param modNameFilter - */ - public void processModsList(String profileName, List modNameFilter) - { - Map profile = this.getProfile(profileName); - - try - { - if (modNameFilter != null) - { - for (String modName : profile.keySet()) - { - profile.put(modName, Boolean.FALSE); - } - - this.defaultEnabledValue = Boolean.FALSE; - this.allowSave = false; - - for (String filterEntry : modNameFilter) - { - profile.put(filterEntry.toLowerCase().trim(), Boolean.TRUE); - } - } - } - catch (Exception ex) - { - this.defaultEnabledValue = Boolean.TRUE; - this.allowSave = true; - } - } - - /** - * Internal method which returns the map for the specified profile - * - * @param profileName - */ - private Map getProfile(String profileName) - { - if (profileName == null) profileName = "default"; - if (this.mods == null) this.mods = new TreeMap>(); - - if (!this.mods.containsKey(profileName)) - { - this.mods.put(profileName, new TreeMap()); - } - - return this.mods.get(profileName); - } - - /** - * Factory method which tries to deserialise the enablement list from the - * file or if failing creates and returns a new instance. - * - * @param file JSON file to create the EnabledModsList from - * @return a new EnabledModsList instance - */ - public static EnabledModsList createFrom(File file) - { - if (file.exists()) - { - FileReader reader = null; - - try - { - reader = new FileReader(file); - EnabledModsList instance = gson.fromJson(reader, EnabledModsList.class); - instance.setEnabledModsFile(file); - return instance; - } - catch (Exception ex) - { - ex.printStackTrace(); - } - finally - { - try - { - if (reader != null) - { - reader.close(); - } - } - catch (IOException ex) - { - ex.printStackTrace(); - } - } - } - - EnabledModsList instance = new EnabledModsList(); - instance.setEnabledModsFile(file); - return instance; - } - - /** - * Save the enablement list to the specified file - * - * @param file - */ - public void saveTo(File file) - { - if (!this.allowSave) return; - - FileWriter writer = null; - - try - { - writer = new FileWriter(file); - gson.toJson(this, writer); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - finally - { - try - { - if (writer != null) - { - writer.close(); - } - } - catch (IOException ex) - { - ex.printStackTrace(); - } - } - } - - /** - * Save to the file we were loaded from - */ - public void save() - { - if (this.enabledModsFile != null) - { - this.saveTo(this.enabledModsFile); - } - } - - /** - * Get whether saving this list is allowed - */ - public boolean saveAllowed() - { - return this.allowSave; - } - - public File getEnabledModsFile() - { - return this.enabledModsFile; - } - - public void setEnabledModsFile(File enabledModsFile) - { - this.enabledModsFile = enabledModsFile; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/IEventState.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/IEventState.java deleted file mode 100644 index a976adf7..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/IEventState.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.mumfrey.liteloader.core; - -import net.minecraft.server.MinecraftServer; - - -public interface IEventState -{ - public abstract void onTick(MinecraftServer server); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/InterfaceRegistrationDelegate.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/InterfaceRegistrationDelegate.java deleted file mode 100644 index 47c167e8..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/InterfaceRegistrationDelegate.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.util.ArrayList; -import java.util.List; - -import com.mumfrey.liteloader.api.Listener; -import com.mumfrey.liteloader.api.InterfaceProvider; -import com.mumfrey.liteloader.core.LiteLoaderInterfaceManager.InterfaceHandler; -import com.mumfrey.liteloader.interfaces.InterfaceRegistry; - -/** - * Delegate passed in to an InterfaceProvider's registerInterfaces method - - * @author Adam Mummery-Smith - */ -public class InterfaceRegistrationDelegate -{ - /** - * Registry which this delegate is delegating for - */ - private final InterfaceRegistry registry; - - /** - * InterfaceProvider being queried - */ - private final InterfaceProvider provider; - - /** - * The registry temporarily stores the list of handlers here - */ - private final List handlers = new ArrayList(); - - /** - * @param registry - * @param provider - */ - InterfaceRegistrationDelegate(InterfaceRegistry registry, InterfaceProvider provider) - { - this.registry = registry; - this.provider = provider; - } - - /** - * @param handler - */ - void addHandler(InterfaceHandler handler) - { - this.handlers.add(handler); - } - - /** - * - */ - List getHandlers() - { - return this.handlers; - } - - /** - * - */ - void registerInterfaces() - { - this.provider.registerInterfaces(this); - } - - /** - * @param interfaceType - */ - public void registerInterface(Class interfaceType) - { - this.registry.registerInterface(this.provider, interfaceType); - } - - /** - * @param interfaceType - * @param priority - */ - public void registerInterface(Class interfaceType, int priority) - { - this.registry.registerInterface(this.provider, interfaceType, priority); - } - - /** - * @param interfaceType - * @param priority - * @param exclusive - */ - public void registerInterface(Class interfaceType, int priority, boolean exclusive) - { - this.registry.registerInterface(this.provider, interfaceType, priority, exclusive); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoader.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoader.java deleted file mode 100644 index 088723f5..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoader.java +++ /dev/null @@ -1,1023 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import javax.activity.InvalidActivityException; - -import org.spongepowered.asm.mixin.MixinEnvironment; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.api.*; -import com.mumfrey.liteloader.api.manager.APIAdapter; -import com.mumfrey.liteloader.api.manager.APIProvider; -import com.mumfrey.liteloader.common.GameEngine; -import com.mumfrey.liteloader.common.LoadingProgress; -import com.mumfrey.liteloader.core.api.LiteLoaderCoreAPI; -import com.mumfrey.liteloader.core.event.EventProxy; -import com.mumfrey.liteloader.core.event.HandlerList; -import com.mumfrey.liteloader.crashreport.CallableLaunchWrapper; -import com.mumfrey.liteloader.crashreport.CallableLiteLoaderBrand; -import com.mumfrey.liteloader.crashreport.CallableLiteLoaderMods; -import com.mumfrey.liteloader.interfaces.*; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderEnvironment.EnvironmentType; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.messaging.MessageBus; -import com.mumfrey.liteloader.modconfig.ConfigManager; -import com.mumfrey.liteloader.modconfig.Exposable; -import com.mumfrey.liteloader.permissions.PermissionsManagerClient; -import com.mumfrey.liteloader.permissions.PermissionsManagerServer; -import com.mumfrey.liteloader.transformers.event.EventTransformer; -import com.mumfrey.liteloader.util.Input; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -import net.minecraft.crash.CrashReport; -import net.minecraft.crash.CrashReportCategory; -import net.minecraft.launchwrapper.LaunchClassLoader; -import net.minecraft.network.EnumConnectionState; -import net.minecraft.network.INetHandler; -import net.minecraft.network.play.server.S01PacketJoinGame; -import net.minecraft.profiler.Profiler; -import net.minecraft.world.World; - -/** - * LiteLoader is a simple loader which loads and provides useful callbacks to - * lightweight mods - * - * @author Adam Mummery-Smith - */ -public final class LiteLoader -{ - /** - * LiteLoader is a singleton, this is the singleton instance - */ - private static LiteLoader instance; - - /** - * Tweak system class loader - */ - private static LaunchClassLoader classLoader; - - /** - * Reference to the game engine instance - */ - private GameEngine engine; - - /** - * Minecraft Profiler - */ - private Profiler profiler; - - /** - * Loader environment instance - */ - private final LoaderEnvironment environment; - - /** - * Loader Properties adapter - */ - private final LoaderProperties properties; - - /** - * Mod enumerator instance - */ - private final LoaderEnumerator enumerator; - - /** - * Mods - */ - protected final LiteLoaderMods mods; - - /** - * API Provider instance - */ - private final APIProvider apiProvider; - - /** - * API Adapter instance - */ - private final APIAdapter apiAdapter; - - /** - * Our core API instance - */ - private final LiteLoaderCoreAPI api; - - /** - * Factory which can be used to instance main loader helper objects - */ - private final ObjectFactory objectFactory; - - /** - * Core providers - */ - private final FastIterableDeque coreProviders = new HandlerList(CoreProvider.class); - private final FastIterableDeque tickObservers = new HandlerList(TickObserver.class); - private final FastIterableDeque worldObservers = new HandlerList(WorldObserver.class); - private final FastIterableDeque shutdownObservers = new HandlerList(ShutdownObserver.class); - private final FastIterableDeque postRenderObservers = new HandlerList(PostRenderObserver.class); - - /** - * Mod panel manager, deliberately raw - */ - @SuppressWarnings("rawtypes") - private PanelManager panelManager; - - /** - * Interface Manager - */ - private LiteLoaderInterfaceManager interfaceManager; - - /** - * Event manager - */ - private LiteLoaderEventBroker events; - - /** - * Plugin channel manager - */ - private final ClientPluginChannels clientPluginChannels; - - /** - * Server channel manager - */ - private final ServerPluginChannels serverPluginChannels; - - /** - * Permission Manager - */ - private final PermissionsManagerClient permissionsManagerClient; - - private final PermissionsManagerServer permissionsManagerServer; - - /** - * Mod configuration manager - */ - private final ConfigManager configManager; - - /** - * Flag which keeps track of whether late initialisation has completed - */ - private boolean modInitComplete; - - /** - * - */ - private Input input; - - /** - * - */ - private final List translators = new ArrayList(); - - /** - * ctor - * - * @param environment - * @param properties - */ - private LiteLoader(LoaderEnvironment environment, LoaderProperties properties) - { - this.environment = environment; - this.properties = properties; - this.enumerator = environment.getEnumerator(); - - this.configManager = new ConfigManager(); - - this.mods = new LiteLoaderMods(this, environment, properties, this.configManager); - - this.apiProvider = environment.getAPIProvider(); - this.apiAdapter = environment.getAPIAdapter(); - - this.api = this.apiProvider.getAPI(LiteLoaderCoreAPI.class); - if (this.api == null) - { - throw new IllegalStateException("The core API was not registered. Startup halted"); - } - - this.objectFactory = this.api.getObjectFactory(); - - this.input = this.objectFactory.getInput(); - - this.clientPluginChannels = this.objectFactory.getClientPluginChannels(); - this.serverPluginChannels = this.objectFactory.getServerPluginChannels(); - - this.permissionsManagerClient = this.objectFactory.getClientPermissionManager(); - this.permissionsManagerServer = this.objectFactory.getServerPermissionManager(); - - this.initTranslators(); - } - - /** - * - */ - protected void initTranslators() - { - for (LiteAPI api : this.apiProvider.getAPIs()) - { - List customisationProviders = api.getCustomisationProviders(); - if (customisationProviders != null) - { - for (CustomisationProvider provider : customisationProviders) - { - if (provider instanceof TranslationProvider) - { - this.translators.add((TranslationProvider)provider); - } - } - } - } - } - - /** - * Set up reflection methods required by the loader - */ - private void onInit() - { - try - { - this.coreProviders.addAll(this.apiAdapter.getCoreProviders()); - this.tickObservers.addAll(this.apiAdapter.getAllObservers(TickObserver.class)); - this.worldObservers.addAll(this.apiAdapter.getAllObservers(WorldObserver.class)); - this.shutdownObservers.addAll(this.apiAdapter.getAllObservers(ShutdownObserver.class)); - this.postRenderObservers.addAll(this.apiAdapter.getAllObservers(PostRenderObserver.class)); - - this.coreProviders.all().onInit(); - - this.enumerator.onInit(); - this.mods.init(this.apiAdapter.getAllObservers(ModLoadObserver.class)); - } - catch (Throwable th) - { - LiteLoaderLogger.severe(th, "Error initialising LiteLoader", th); - } - } - - /** - * - */ - private void onPostInit() - { - LoadingProgress.setMessage("LiteLoader POSTINIT..."); - - this.initLifetimeObjects(); - - this.postInitCoreProviders(); - - // Spawn mod instances and initialise them - this.loadAndInitMods(); - - this.coreProviders.all().onPostInitComplete(this.mods); - - // Save stuff - this.properties.writeProperties(); - } - - /** - * Get the singleton instance of LiteLoader, initialises the loader if - * necessary. - * - * @return LiteLoader instance - */ - public static final LiteLoader getInstance() - { - return LiteLoader.instance; - } - - /** - * Get the tweak system classloader - */ - public static LaunchClassLoader getClassLoader() - { - return LiteLoader.classLoader; - } - - /** - * Get LiteLoader version - */ - public static final String getVersion() - { - return LiteLoaderVersion.CURRENT.getLoaderVersion(); - } - - /** - * Get LiteLoader version - */ - public static final String getVersionDisplayString() - { - return String.format("LiteLoader %s", LiteLoaderVersion.CURRENT.getLoaderVersion()); - } - - /** - * Get the loader revision - */ - public static final int getRevision() - { - return LiteLoaderVersion.CURRENT.getLoaderRevision(); - } - - /** - * Get all active API instances - */ - public static final LiteAPI[] getAPIs() - { - LiteAPI[] apis = LiteLoader.instance.apiProvider.getAPIs(); - LiteAPI[] apisCopy = new LiteAPI[apis.length]; - System.arraycopy(apis, 0, apisCopy, 0, apis.length); - return apisCopy; - } - - /** - * Get an API instance by identifier (returns null if no instance matching - * the supplied identifier exists). - * - * @param identifier - */ - public static final LiteAPI getAPI(String identifier) - { - return LiteLoader.instance.apiProvider.getAPI(identifier); - } - - /** - * @param identifier - */ - public static boolean isAPIAvailable(String identifier) - { - return LiteLoader.getAPI(identifier) != null; - } - - @SuppressWarnings("unchecked") - public static final C getCustomisationProvider(LiteAPI api, Class providerType) - { - List customisationProviders = api.getCustomisationProviders(); - if (customisationProviders != null) - { - for (CustomisationProvider provider : customisationProviders) - { - if (providerType.isAssignableFrom(provider.getClass())) return (C)provider; - } - } - - return null; - } - - /** - * Get the client-side permissions manager - */ - public static PermissionsManagerClient getClientPermissionsManager() - { - return LiteLoader.instance.permissionsManagerClient; - } - - /** - * Get the server-side permissions manager - */ - public static PermissionsManagerServer getServerPermissionsManager() - { - return LiteLoader.instance.permissionsManagerServer; - } - - /** - * Get the current game engine wrapper - */ - public static GameEngine getGameEngine() - { - return LiteLoader.instance.engine; - } - - /** - * Get the interface manager - */ - public static LiteLoaderInterfaceManager getInterfaceManager() - { - return LiteLoader.instance.interfaceManager; - } - - /** - * Get the client-side plugin channel manager - */ - public static ClientPluginChannels getClientPluginChannels() - { - return LiteLoader.instance.clientPluginChannels; - } - - /** - * Get the server-side plugin channel manager - */ - public static ServerPluginChannels getServerPluginChannels() - { - return LiteLoader.instance.serverPluginChannels; - } - - /** - * Get the input manager - */ - public static Input getInput() - { - return LiteLoader.instance.input; - } - - /** - * Get the mod panel manager - */ - @SuppressWarnings({ "cast", "unchecked" }) - public static PanelManager getModPanelManager() - { - return (PanelManager)LiteLoader.instance.panelManager; - } - - /** - * Get the "mods" folder - */ - public static File getModsFolder() - { - return LiteLoader.instance.environment.getModsFolder(); - } - - /** - * Get the common (version-independent) config folder - */ - public static File getCommonConfigFolder() - { - return LiteLoader.instance.environment.getCommonConfigFolder(); - } - - /** - * Get the config folder for this version - */ - public static File getConfigFolder() - { - return LiteLoader.instance.environment.getVersionedConfigFolder(); - } - - /** - * Get the game directory - */ - public static File getGameDirectory() - { - return LiteLoader.instance.environment.getGameDirectory(); - } - - /** - * Get the "assets" root directory - */ - public static File getAssetsDirectory() - { - return LiteLoader.instance.environment.getAssetsDirectory(); - } - - /** - * Get the name of the profile which launched the game - */ - public static String getProfile() - { - return LiteLoader.instance.environment.getProfile(); - } - - /** - * Get the type of environment (client or dedicated server) - */ - public static EnvironmentType getEnvironmentType() - { - return LiteLoader.instance.environment.getType(); - } - - /** - * Used to get the name of the modpack being used - * - * @return name of the modpack in use or null if no pack - */ - public static String getBranding() - { - return LiteLoader.instance.properties.getBranding(); - } - - /** - * Get whether the current environment is MCP - */ - public static boolean isDevelopmentEnvironment() - { - return "true".equals(System.getProperty("mcpenv")); - } - - /** - * Dump debugging information to the console - */ - public static void dumpDebugInfo() - { - if (LiteLoaderLogger.DEBUG) - { - EventTransformer.dumpInjectionState(); - MixinEnvironment.getCurrentEnvironment().audit(); - LiteLoaderLogger.info("Debug info dumped to console"); - } - else - { - LiteLoaderLogger.info("Debug dump not available, developer flag not enabled"); - } - } - - /** - * Used for crash reporting, returns a text list of all loaded mods - * - * @return List of loaded mods as a string - */ - public String getLoadedModsList() - { - return this.mods.getLoadedModsList(); - } - - /** - * Get a list containing all loaded mods - */ - public List getLoadedMods() - { - List loadedMods = new ArrayList(); - - for (ModInfo> loadedMod : this.mods.getLoadedMods()) - { - loadedMods.add(loadedMod.getMod()); - } - - return loadedMods; - } - - /** - * Get a list containing all mod files which were NOT loaded - */ - public List> getDisabledMods() - { - List> disabledMods = new ArrayList>(); - - for (ModInfo disabledMod : this.mods.getDisabledMods()) - { - disabledMods.add(disabledMod.getContainer()); - } - - return disabledMods; - } - - /** - * Get the list of injected tweak containers - */ - @SuppressWarnings("unchecked") - public Collection> getInjectedTweaks() - { - Collection> tweaks = new ArrayList>(); - - for (ModInfo> tweak : this.mods.getInjectedTweaks()) - { - tweaks.add((Loadable)tweak.getContainer()); - } - - return tweaks; - } - - /** - * Get a reference to a loaded mod, if the mod exists - * - * @param modName Mod's name, identifier or class name - * @throws InvalidActivityException - */ - public T getMod(String modName) throws InvalidActivityException, IllegalArgumentException - { - if (!this.modInitComplete) - { - throw new InvalidActivityException("Attempted to get a reference to a mod before loader startup is complete"); - } - - return this.mods.getMod(modName); - } - - /** - * Get a reference to a loaded mod, if the mod exists - * - * @param modClass Mod class - */ - public T getMod(Class modClass) - { - if (!this.modInitComplete) - { - throw new RuntimeException("Attempted to get a reference to a mod before loader startup is complete"); - } - - return this.mods.getMod(modClass); - } - - /** - * Get whether the specified mod is installed - * - * @param modName - */ - public boolean isModInstalled(String modName) - { - if (!this.modInitComplete || modName == null) return false; - - return this.mods.isModInstalled(modName); - } - - /** - * Get a metadata value for the specified mod - * - * @param modNameOrId - * @param metaDataKey - * @param defaultValue - * @throws IllegalArgumentException Thrown by getMod if argument is null - */ - public String getModMetaData(String modNameOrId, String metaDataKey, String defaultValue) throws IllegalArgumentException - { - return this.mods.getModMetaData(modNameOrId, metaDataKey, defaultValue); - } - - /** - * Get a metadata value for the specified mod - * - * @param mod - * @param metaDataKey - * @param defaultValue - */ - public String getModMetaData(LiteMod mod, String metaDataKey, String defaultValue) - { - return this.mods.getModMetaData(mod, metaDataKey, defaultValue); - } - - /** - * Get a metadata value for the specified mod - * - * @param modClass - * @param metaDataKey - * @param defaultValue - */ - public String getModMetaData(Class modClass, String metaDataKey, String defaultValue) - { - return this.mods.getModMetaData(modClass, metaDataKey, defaultValue); - } - - /** - * Get the mod identifier, this is used for versioning, exclusivity, and - * enablement checks. - * - * @param modClass - */ - public String getModIdentifier(Class modClass) - { - return this.mods.getModIdentifier(modClass); - } - - /** - * Get the mod identifier, this is used for versioning, exclusivity, and - * enablement checks. - * - * @param mod - */ - public String getModIdentifier(LiteMod mod) - { - return this.mods.getModIdentifier(mod); - } - - /** - * Get the container (mod file, classpath jar or folder) for the specified - * mod. - * - * @param modClass - */ - public LoadableMod getModContainer(Class modClass) - { - return this.mods.getModContainer(modClass); - } - - /** - * Get the container (mod file, classpath jar or folder) for the specified - * mod. - * - * @param mod - */ - public LoadableMod getModContainer(LiteMod mod) - { - return this.mods.getModContainer(mod); - } - - /** - * Get the mod which matches the specified identifier - * - * @param identifier - */ - public Class getModFromIdentifier(String identifier) - { - return this.mods.getModFromIdentifier(identifier); - } - - /** - * @param identifier Identifier of the mod to enable - */ - public void enableMod(String identifier) - { - this.mods.setModEnabled(identifier, true); - } - - /** - * @param identifier Identifier of the mod to disable - */ - public void disableMod(String identifier) - { - this.mods.setModEnabled(identifier, false); - } - - /** - * @param identifier Identifier of the mod to enable/disable - * @param enabled - */ - public void setModEnabled(String identifier, boolean enabled) - { - this.mods.setModEnabled(identifier, enabled); - } - - /** - * @param modName - */ - public boolean isModEnabled(String modName) - { - return this.mods.isModEnabled(modName); - } - - /** - * @param modName - */ - public boolean isModActive(String modName) - { - return this.mods.isModActive(modName); - } - - /** - * @param exposable - */ - public void writeConfig(Exposable exposable) - { - this.configManager.invalidateConfig(exposable); - } - - /** - * Register an arbitrary Exposable - * - * @param exposable Exposable object to register - * @param fileName Override config file name to use (leave null to use value - * from ExposableConfig specified value) - */ - public void registerExposable(Exposable exposable, String fileName) - { - this.configManager.registerExposable(exposable, fileName, true); - this.configManager.initConfig(exposable); - } - - /** - * Initialise lifetime objects like the game engine, event broker and - * interface manager. - */ - private void initLifetimeObjects() - { - // Cache game engine reference - this.engine = this.objectFactory.getGameEngine(); - - // Cache profiler instance - this.profiler = this.objectFactory.getGameEngine().getProfiler(); - - // Create the event broker - this.events = this.objectFactory.getEventBroker(); - if (this.events != null) - { - this.events.setMods(this.mods); - } - - // Get the mod panel manager - this.panelManager = this.objectFactory.getPanelManager(); - if (this.panelManager != null) - { - this.panelManager.init(this.mods, this.configManager); - } - - // Create the interface manager - this.interfaceManager = new LiteLoaderInterfaceManager(this.apiAdapter); - } - - /** - * - */ - private void postInitCoreProviders() - { - this.coreProviders.all().onPostInit(this.engine); - - this.interfaceManager.registerInterfaces(); - - for (CoreProvider provider : this.coreProviders) - { - if (provider instanceof Listener) - { - this.interfaceManager.registerListener((Listener)provider); - } - } - } - - private void loadAndInitMods() - { - int totalMods = this.enumerator.modsToLoadCount(); - int totalTweaks = this.enumerator.getInjectedTweaks().size(); - LiteLoaderLogger.info(Verbosity.REDUCED, "Discovered %d total mod(s), injected %d tweak(s)", totalMods, totalTweaks); - - if (totalMods > 0) - { - this.mods.loadMods(); - this.mods.initMods(); - } - else - { - LiteLoaderLogger.info(Verbosity.REDUCED, "No mod classes were found. Not loading any mods."); - } - - // Initialises the required hooks for loaded mods - this.interfaceManager.onPostInit(); - - this.modInitComplete = true; - this.mods.onPostInit(); - } - - void onPostInitMod(LiteMod mod) - { - // add mod to permissions manager if permissible - if (this.permissionsManagerClient != null) - { - this.permissionsManagerClient.registerMod(mod); - } - } - - /** - * Called after mod late init - */ - void onStartupComplete() - { - // Set the loader branding in ClientBrandRetriever using reflection - LiteLoaderBootstrap.setBranding("LiteLoader"); - - this.coreProviders.all().onStartupComplete(); - - if (this.panelManager != null) - { - this.panelManager.onStartupComplete(); - } - - MessageBus.getInstance().onStartupComplete(); - - // Force packet injections - EnumConnectionState.values(); - } - - /** - * Called on login - * - * @param netHandler - * @param loginPacket - */ - void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket) - { - if (this.permissionsManagerClient != null) - { - this.permissionsManagerClient.onJoinGame(netHandler, loginPacket); - } - - this.coreProviders.all().onJoinGame(netHandler, loginPacket); - } - - /** - * Called when the world reference is changed - * - * @param world - */ - void onWorldChanged(World world) - { - if (world != null && this.permissionsManagerClient != null) - { - // For bungeecord - this.permissionsManagerClient.scheduleRefresh(); - } - - this.worldObservers.all().onWorldChanged(world); - } - - /** - * @param mouseX - * @param mouseY - * @param partialTicks - */ - void onPostRender(int mouseX, int mouseY, float partialTicks) - { - this.profiler.startSection("core"); - this.postRenderObservers.all().onPostRender(mouseX, mouseY, partialTicks); - this.profiler.endSection(); - } - - /** - * @param clock - * @param partialTicks - * @param inGame - */ - void onTick(boolean clock, float partialTicks, boolean inGame) - { - if (clock) - { - // Tick the permissions manager - if (this.permissionsManagerClient != null) - { - this.profiler.startSection("permissionsmanager"); - this.permissionsManagerClient.onTick(this.engine, partialTicks, inGame); - this.profiler.endSection(); - } - - // Tick the config manager - this.profiler.startSection("configmanager"); - this.configManager.onTick(); - this.profiler.endSection(); - - if (!this.engine.isRunning()) - { - this.onShutDown(); - return; - } - } - - this.profiler.startSection("observers"); - - this.tickObservers.all().onTick(clock, partialTicks, inGame); - - this.profiler.endSection(); - } - - private void onShutDown() - { - LiteLoaderLogger.info(Verbosity.REDUCED, "LiteLoader is shutting down, shutting down core providers and syncing configuration"); - - this.shutdownObservers.all().onShutDown(); - - this.configManager.syncConfig(); - } - - public static String translate(String key, Object... args) - { - for (TranslationProvider translator : LiteLoader.instance.translators) - { - String translated = translator.translate(key, args); - if (translated != null) - { - return translated; - } - } - - return key; - } - - /** - * @param objCrashReport This is an object so that we don't need to - * transform the obfuscated name in the transformer - */ - public static void populateCrashReport(Object objCrashReport) - { - if (objCrashReport instanceof CrashReport) - { - EventProxy.populateCrashReport((CrashReport)objCrashReport); - LiteLoader.populateCrashReport((CrashReport)objCrashReport); - } - } - - private static void populateCrashReport(CrashReport crashReport) - { - CrashReportCategory category = crashReport.getCategory(); // crashReport.makeCategoryDepth("Mod System Details", 1); - category.addCrashSectionCallable("Mod Pack", new CallableLiteLoaderBrand(crashReport)); - category.addCrashSectionCallable("LiteLoader Mods", new CallableLiteLoaderMods(crashReport)); - category.addCrashSectionCallable("LaunchWrapper", new CallableLaunchWrapper(crashReport)); - } - - static final void createInstance(LoaderEnvironment environment, LoaderProperties properties, LaunchClassLoader classLoader) - { - if (LiteLoader.instance == null) - { - LiteLoader.classLoader = classLoader; - LiteLoader.instance = new LiteLoader(environment, properties); - } - } - - static final void invokeInit() - { - LiteLoaderLogger.info(Verbosity.REDUCED, "LiteLoader begin INIT..."); - - LiteLoader.instance.onInit(); - } - - static final void invokePostInit() - { - LiteLoaderLogger.info(Verbosity.REDUCED, "LiteLoader begin POSTINIT..."); - - LiteLoader.instance.onPostInit(); - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderBootstrap.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderBootstrap.java deleted file mode 100644 index 50fd7919..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderBootstrap.java +++ /dev/null @@ -1,775 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.io.*; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.List; -import java.util.Properties; - -import org.apache.logging.log4j.core.Layout; -import org.apache.logging.log4j.core.Logger; -import org.apache.logging.log4j.core.appender.FileAppender; -import org.apache.logging.log4j.core.layout.PatternLayout; -import org.spongepowered.asm.mixin.MixinEnvironment; - -import com.mumfrey.liteloader.api.LiteAPI; -import com.mumfrey.liteloader.api.manager.APIAdapter; -import com.mumfrey.liteloader.api.manager.APIProvider; -import com.mumfrey.liteloader.api.manager.APIRegistry; -import com.mumfrey.liteloader.common.LoadingProgress; -import com.mumfrey.liteloader.core.api.LiteLoaderCoreAPI; -import com.mumfrey.liteloader.interfaces.LoaderEnumerator; -import com.mumfrey.liteloader.launch.*; -import com.mumfrey.liteloader.util.ObfuscationUtilities; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -import net.minecraft.launchwrapper.ITweaker; -import net.minecraft.launchwrapper.Launch; -import net.minecraft.launchwrapper.LaunchClassLoader; - -/** - * LiteLoaderBootstrap is responsible for managing the early part of the - * LiteLoader startup process, this is to ensure that NONE of the Minecraft - * classes which by necessity the Loader references get loaded before the - * PREINIT stage has completed. This allows us to load transforming tweakers in - * the PREINIT stage without all hell breaking loose because class names have - * changed between initialisation stages! - * - *

This class handles setting up requisite resources like the logger, - * enumerator and plug-in API modules and passes init calls through to the - * LiteLoader instance at the appropriate points during startup. Because this - * class is the first part of the loader to get loaded, we also keep central - * references like the paths, version and loader properties in here.

- * - * @author Adam Mummery-Smith - */ -class LiteLoaderBootstrap implements LoaderBootstrap, LoaderEnvironment, LoaderProperties -{ - /** - * Base game directory, passed in from the tweaker - */ - private final File gameDirectory; - - /** - * Assets directory, passed in from the tweaker - */ - private final File assetsDirectory; - - /** - * Active profile, passed in from the tweaker - */ - private final String profile; - - /** - * "Mods" folder to use - */ - private final File modsFolder; - - /** - * "Mods" folder to use - */ - private final File versionedModsFolder; - - /** - * Base "liteconfig" folder under which all other lite mod configs and - * liteloader configs are placed. - */ - private final File configBaseFolder; - - /** - * Folder containing version-independent configuration - */ - private final File commonConfigFolder; - - /** - * Folder containing version-specific configuration - */ - private final File versionConfigFolder; - - /** - * File to write log entries to - */ - private File logFile; - - /** - * File containing the properties - */ - private File propertiesFile; - - /** - * JSON file containing the list of enabled/disabled mods by profile - */ - private File enabledModsFile; - - /** - * Internal properties loaded from inside the jar - */ - private Properties internalProperties = new Properties(); - - /** - * LiteLoader properties - */ - private Properties localProperties = new Properties(); - - /** - * Pack brand from properties, used to put the modpack/compilation name in - * crash reports - */ - private String branding = null; - - private boolean loadTweaks = true; - - private LaunchClassLoader classLoader; - - private final ITweaker tweaker; - - private final APIRegistry apiRegistry; - - private final APIProvider apiProvider; - - private final APIAdapter apiAdapter; - - private final EnvironmentType environmentType; - - /** - * The mod enumerator instance - */ - private LiteLoaderEnumerator enumerator; - - /** - * List of mods passed into the command line - */ - private EnabledModsList enabledModsList; - - /** - * @param env - * @param tweaker - */ - public LiteLoaderBootstrap(StartupEnvironment env, ITweaker tweaker) - { - this.environmentType = EnvironmentType.values()[env.getEnvironmentTypeId()]; - this.tweaker = tweaker; - - this.apiRegistry = new APIRegistry(this.getEnvironment(), this.getProperties()); - - this.gameDirectory = env.getGameDirectory(); - this.assetsDirectory = env.getAssetsDirectory(); - this.profile = env.getProfile(); - this.modsFolder = env.getModsFolder(); - - this.versionedModsFolder = new File(this.modsFolder, LiteLoaderVersion.CURRENT.getMinecraftVersion()); - this.configBaseFolder = new File(this.gameDirectory, "liteconfig"); - this.logFile = new File(this.configBaseFolder, "liteloader.log"); - this.propertiesFile = new File(this.configBaseFolder, "liteloader.properties"); - this.enabledModsFile = new File(this.configBaseFolder, "liteloader.profiles.json"); - - this.commonConfigFolder = new File(this.configBaseFolder, "common"); - this.versionConfigFolder = this.inflectVersionedConfigPath(LiteLoaderVersion.CURRENT); - - if (!this.modsFolder.exists()) this.modsFolder.mkdirs(); - if (!this.versionedModsFolder.exists()) this.versionedModsFolder.mkdirs(); - if (!this.configBaseFolder.exists()) this.configBaseFolder.mkdirs(); - if (!this.commonConfigFolder.exists()) this.commonConfigFolder.mkdirs(); - if (!this.versionConfigFolder.exists()) this.versionConfigFolder.mkdirs(); - - this.initAPIs(env.getAPIsToLoad()); - this.apiProvider = this.apiRegistry.getProvider(); - this.apiAdapter = this.apiRegistry.getAdapter(); - } - - /** - * @param version - */ - @Override - public File inflectVersionedConfigPath(LiteLoaderVersion version) - { - if (version.equals(LiteLoaderVersion.LEGACY)) - { - return this.modsFolder; - } - - return new File(this.configBaseFolder, String.format("config.%s", version.getMinecraftVersion())); - } - - /** - * - */ - private void initAPIs(List apisToLoad) - { - if (apisToLoad != null) - { - for (String apiClassName : apisToLoad) - this.registerAPI(apiClassName); - } - - this.apiRegistry.bake(); - } - - /** - * @param apiClassName - */ - public void registerAPI(String apiClassName) - { - this.apiRegistry.registerAPI(apiClassName); - } - - @Override - public APIProvider getAPIProvider() - { - return this.apiProvider; - } - - @Override - public APIAdapter getAPIAdapter() - { - return this.apiAdapter; - } - - @Override - public EnabledModsList getEnabledModsList() - { - return this.enabledModsList; - } - - @Override - public LoaderEnumerator getEnumerator() - { - return this.enumerator; - } - - @Override - public EnvironmentType getType() - { - return this.environmentType; - } - - @Override - public LoaderEnvironment getEnvironment() - { - return this; - } - - @Override - public LoaderProperties getProperties() - { - return this; - } - - @Override - public boolean addCascadedTweaker(String tweakClass, int priority) - { - if (this.tweaker instanceof LiteLoaderTweaker) - { - return ((LiteLoaderTweaker)this.tweaker).addCascadedTweaker(tweakClass, priority); - } - - return false; - } - - @Override - public ClassTransformerManager getTransformerManager() - { - if (this.tweaker instanceof LiteLoaderTweaker) - { - return ((LiteLoaderTweaker)this.tweaker).getTransformerManager(); - } - - return null; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.launch.ILoaderBootstrap - * #preInit(net.minecraft.launchwrapper.LaunchClassLoader, boolean) - */ - @Override - public void preInit(LaunchClassLoader classLoader, boolean loadTweaks, List modsToLoad) - { - this.classLoader = classLoader; - this.loadTweaks = loadTweaks; - - LiteLoaderLogger.info(Verbosity.REDUCED, "LiteLoader begin PREINIT..."); - - // Set up the bootstrap - if (!this.prepare()) return; - - LiteLoaderLogger.info(Verbosity.REDUCED, "LiteLoader %s starting up...", LiteLoaderVersion.CURRENT.getLoaderVersion()); - - // Print the branding version if any was provided - if (this.branding != null) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Active Pack: %s", this.branding); - } - - LiteLoaderLogger.info(Verbosity.REDUCED, "Java reports OS=\"%s\"", System.getProperty("os.name").toLowerCase()); - - this.enabledModsList = EnabledModsList.createFrom(this.enabledModsFile); - this.enabledModsList.processModsList(this.profile, modsToLoad); - - this.enumerator = this.spawnEnumerator(classLoader); - this.enumerator.onPreInit(); - - this.initMixins(); - - LiteLoaderLogger.info(Verbosity.REDUCED, "LiteLoader PREINIT complete"); - } - - private void initMixins() - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Initialising LiteLoader Mixins"); - this.getAPIAdapter().initMixins(); - } - - /** - * @param classLoader - */ - protected LiteLoaderEnumerator spawnEnumerator(LaunchClassLoader classLoader) - { - return new LiteLoaderEnumerator(this, this, classLoader); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.launch.LoaderBootstrap#beginGame() - */ - @Override - public void preBeginGame() - { - LiteAPI api = this.getAPIProvider().getAPI("liteloader"); - if (api instanceof LiteLoaderCoreAPI) - { - ((LiteLoaderCoreAPI)api).getObjectFactory().preBeginGame(); - } - - LoadingProgress.setEnabled(this.getAndStoreBooleanProperty(LoaderProperties.OPTION_LOADING_BAR, true)); - - if (ObfuscationUtilities.fmlIsPresent()) - { - LiteLoaderLogger.info("FML detected, switching to searge mappings"); - MixinEnvironment.getDefaultEnvironment().setObfuscationContext("searge"); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.launch.ILoaderBootstrap - * #init(java.util.List, net.minecraft.launchwrapper.LaunchClassLoader) - */ - @Override - public void init() - { - // PreInit failed - if (this.enumerator == null) return; - - LiteLoader.createInstance(this.getEnvironment(), this.getProperties(), this.classLoader); - LiteLoader.invokeInit(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.launch.ILoaderBootstrap#postInit() - */ - @Override - public void postInit() - { - // PreInit failed - if (this.enumerator == null) return; - - LiteLoader.invokePostInit(); - } - - /** - * Set up reflection methods required by the loader - */ - private boolean prepare() - { - try - { - // Prepare the properties - this.prepareProperties(); - - // Prepare the log writer - this.prepareLogger(); - - this.prepareBranding(); - } - catch (Throwable th) - { - LiteLoaderLogger.severe(th, "Error initialising LiteLoader Bootstrap"); - return false; - } - - return true; - } - - /** - * @throws SecurityException - * @throws IOException - */ - private void prepareLogger() throws SecurityException - { - LiteLoaderLogger.info("Setting up logger..."); - - Logger logger = LiteLoaderLogger.getLogger(); - Layout layout = PatternLayout.createLayout("[%d{HH:mm:ss}] [%t/%level]: %msg%n", - logger.getContext().getConfiguration(), null, "UTF-8", "True"); - FileAppender fileAppender = FileAppender.createAppender(this.logFile.getAbsolutePath(), "False", "False", - "LiteLoader", "True", "True", "True", layout, null, "False", "", logger.getContext().getConfiguration()); - fileAppender.start(); - logger.addAppender(fileAppender); - } - - /** - * Prepare the loader properties - */ - private void prepareProperties() - { - LiteLoaderLogger.info("Initialising Loader properties..."); - - try - { - InputStream propertiesStream = LiteLoaderBootstrap.class.getResourceAsStream("/liteloader.properties"); - - if (propertiesStream != null) - { - this.internalProperties.load(propertiesStream); - propertiesStream.close(); - } - } - catch (Throwable th) - { - this.internalProperties = new Properties(); - } - - try - { - this.localProperties = new Properties(this.internalProperties); - InputStream localPropertiesStream = this.getLocalPropertiesStream(); - - if (localPropertiesStream != null) - { - this.localProperties.load(localPropertiesStream); - localPropertiesStream.close(); - } - } - catch (Throwable th) - { - this.localProperties = new Properties(this.internalProperties); - } - } - - /** - * Get the properties stream either from the jar or from the properties file - * in the minecraft folder - * - * @throws FileNotFoundException - */ - private InputStream getLocalPropertiesStream() throws FileNotFoundException - { - if (this.propertiesFile.exists()) - { - return new FileInputStream(this.propertiesFile); - } - - // Otherwise read settings from the config - return LiteLoaderBootstrap.class.getResourceAsStream("/liteloader.properties"); - } - - /** - * Write current properties to the properties file - */ - @Override - public void writeProperties() - { - try - { - this.localProperties.store(new FileWriter(this.propertiesFile), String.format("Properties for LiteLoader %s", LiteLoaderVersion.CURRENT)); - } - catch (Throwable th) - { - LiteLoaderLogger.warning(th, "Error writing liteloader properties"); - } - } - - /** - * - */ - private void prepareBranding() - { - this.branding = this.internalProperties.getProperty(LoaderProperties.OPTION_BRAND, null); - if (this.branding != null && this.branding.length() < 1) - { - this.branding = null; - } - - // Save appropriate branding in the local properties file - if (this.branding != null) - { - this.localProperties.setProperty(LoaderProperties.OPTION_BRAND, this.branding); - } - else - { - this.localProperties.remove(LoaderProperties.OPTION_BRAND); - } - } - - /** - * Get the game directory - */ - @Override - public File getGameDirectory() - { - return this.gameDirectory; - } - - /** - * Get the assets directory - */ - @Override - public File getAssetsDirectory() - { - return this.assetsDirectory; - } - - /** - * Get the profile directory - */ - @Override - public String getProfile() - { - return this.profile; - } - - /** - * Get the mods folder - */ - @Override - public File getModsFolder() - { - return this.modsFolder; - } - - /** - * Get the mods folder - */ - @Override - public File getVersionedModsFolder() - { - return this.versionedModsFolder; - } - - /** - * Get the base "liteconfig" folder - */ - @Override - public File getConfigBaseFolder() - { - return this.configBaseFolder; - } - - /** - * Get the common configuration folder - */ - @Override - public File getCommonConfigFolder() - { - return this.commonConfigFolder; - } - - /** - * Get the versioned configuration folder - */ - @Override - public File getVersionedConfigFolder() - { - return this.versionConfigFolder; - } - - /** - * Get a boolean propery from the properties file and also write the new - * value back to the properties file. - * - * @param propertyName - * @param defaultValue - */ - @Override - public boolean getAndStoreBooleanProperty(String propertyName, boolean defaultValue) - { - boolean result = this.localProperties.getProperty(propertyName, String.valueOf(defaultValue)).equalsIgnoreCase("true"); - this.localProperties.setProperty(propertyName, String.valueOf(result)); - return result; - } - - /** - * Get a boolean propery from the properties file and also write the new - * value back to the properties file. - * - * @param propertyName - */ - @Override - public boolean getBooleanProperty(String propertyName) - { - return this.localProperties.getProperty(propertyName, "false").equalsIgnoreCase("true"); - } - - /** - * Set a boolean property - * - * @param propertyName - * @param value - */ - @Override - public void setBooleanProperty(String propertyName, boolean value) - { - this.localProperties.setProperty(propertyName, String.valueOf(value)); - } - - @Override - public int getAndStoreIntegerProperty(String propertyName, int defaultValue) - { - int result = LiteLoaderBootstrap.tryParseInt(this.localProperties.getProperty(propertyName, String.valueOf(defaultValue)), defaultValue); - this.localProperties.setProperty(propertyName, String.valueOf(result)); - return result; - } - - @Override - public int getIntegerProperty(String propertyName) - { - return LiteLoaderBootstrap.tryParseInt(this.localProperties.getProperty(propertyName, "0"), 0); - } - - @Override - public void setIntegerProperty(String propertyName, int value) - { - this.localProperties.setProperty(propertyName, String.valueOf(value)); - } - - /** - * Store current revision for mod in the config file - * - * @param modKey - */ - @Override - public void storeLastKnownModRevision(String modKey) - { - if (this.localProperties != null) - { - this.localProperties.setProperty(modKey, String.valueOf(LiteLoaderVersion.CURRENT.getLoaderRevision())); - this.writeProperties(); - } - } - - /** - * Get last know revision for mod from the config file - * - * @param modKey - */ - @Override - public int getLastKnownModRevision(String modKey) - { - if (this.localProperties != null) - { - String storedRevision = this.localProperties.getProperty(modKey, "0"); - return Integer.parseInt(storedRevision); - } - - return 0; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.launch.LoaderEnvironment#loadTweaksEnabled() - */ - @Override - public boolean loadTweaksEnabled() - { - return this.loadTweaks; - } - - /** - * Used to get the name of the modpack being used - * - * @return name of the modpack in use or null if no pack - */ - @Override - public String getBranding() - { - return this.branding; - } - - /** - * Set the brand in ClientBrandRetriever to the specified brand - * - * @param brand - */ - static void setBranding(String brand) - { - try - { - Method mGetClientModName; - - try - { - Class cbrClass = Class.forName("net.minecraft.client.ClientBrandRetriever", false, Launch.classLoader); - mGetClientModName = cbrClass.getDeclaredMethod("getClientModName"); - } - catch (ClassNotFoundException ex) - { - return; - } - - String oldBrand = (String)mGetClientModName.invoke(null); - - if ("vanilla".equals(oldBrand)) - { - char[] newValue = brand.toCharArray(); - - Field stringValue = String.class.getDeclaredField("value"); - stringValue.setAccessible(true); - stringValue.set(oldBrand, newValue); - - try - { - Field stringCount = String.class.getDeclaredField("count"); - stringCount.setAccessible(true); - stringCount.set(oldBrand, newValue.length); - } - catch (NoSuchFieldException ex) {} // java 1.7 doesn't have this member - } - } - catch (Throwable th) - { - LiteLoaderLogger.warning(th, "Setting branding failed"); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.launch.LoaderBootstrap - * #getRequiredTransformers() - */ - @Override - public List getRequiredTransformers() - { - return this.getAPIAdapter().getRequiredTransformers(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.launch.LoaderBootstrap - * #getRequiredDownstreamTransformers() - */ - @Override - public List getRequiredDownstreamTransformers() - { - List requiredDownstreamTransformers = this.getAPIAdapter().getRequiredDownstreamTransformers(); - requiredDownstreamTransformers.add(0, "com.mumfrey.liteloader.transformers.event.EventTransformer"); - return requiredDownstreamTransformers; - } - - private static int tryParseInt(String string, int defaultValue) - { - try - { - return Integer.parseInt(string); - } - catch (NumberFormatException ex) - { - return defaultValue; - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderEnumerator.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderEnumerator.java deleted file mode 100644 index 84dd8e1b..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderEnumerator.java +++ /dev/null @@ -1,838 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Deque; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.spongepowered.asm.mixin.MixinEnvironment; -import org.spongepowered.asm.mixin.MixinEnvironment.Phase; - -import com.google.common.base.Throwables; -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.api.ContainerRegistry; -import com.mumfrey.liteloader.api.ContainerRegistry.DisabledReason; -import com.mumfrey.liteloader.api.EnumerationObserver; -import com.mumfrey.liteloader.api.EnumeratorModule; -import com.mumfrey.liteloader.api.EnumeratorPlugin; -import com.mumfrey.liteloader.api.LiteAPI; -import com.mumfrey.liteloader.api.ModClassValidator; -import com.mumfrey.liteloader.core.api.DefaultClassValidator; -import com.mumfrey.liteloader.core.api.DefaultEnumeratorPlugin; -import com.mumfrey.liteloader.core.event.HandlerList; -import com.mumfrey.liteloader.interfaces.FastIterableDeque; -import com.mumfrey.liteloader.interfaces.Injectable; -import com.mumfrey.liteloader.interfaces.Loadable; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.interfaces.LoaderEnumerator; -import com.mumfrey.liteloader.interfaces.MixinContainer; -import com.mumfrey.liteloader.interfaces.TweakContainer; -import com.mumfrey.liteloader.launch.ClassTransformerManager; -import com.mumfrey.liteloader.launch.LiteLoaderTweaker; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -import net.minecraft.launchwrapper.Launch; -import net.minecraft.launchwrapper.LaunchClassLoader; - -/** - * The enumerator performs all mod discovery functions for LiteLoader, this - * includes locating mod files to load as well as searching for mod classes - * within the class path and discovered mod files. - * - * @author Adam Mummery-Smith - */ -public class LiteLoaderEnumerator implements LoaderEnumerator -{ - public enum EnumeratorState - { - INIT(null), - DISCOVER(INIT), - INJECT(DISCOVER), - REGISTER(INJECT), - FINALISED(REGISTER); - - private final EnumeratorState previousState; - - private EnumeratorState(EnumeratorState previousState) - { - this.previousState = previousState; - } - - public boolean checkGotoState(EnumeratorState fromState) - { - if (fromState != this && fromState != this.previousState) - { - throw new IllegalStateException("Attempted to move to an invalid enumerator state " + this + ", expected to be in state " - + this.previousState + " but current state is " + fromState); - } - - return true; - } - } - - private final LoaderEnvironment environment; - - private final LoaderProperties properties; - - /** - * Reference to the launch classloader - */ - private final LaunchClassLoader classLoader; - - /** - * - */ - private final List modules = new ArrayList(); - - private final List plugins = new ArrayList(); - - private final ContainerRegistry containers = new Containers(); - - /** - * Containers which have already been checked for potential mod candidates - */ - private final Set> enumeratedContainers = new HashSet>(); - - /** - * Classes to load, mapped by class name - */ - private final Set>> modsToLoad = new LinkedHashSet>>(); - - private final ModClassValidator validator; - - private final FastIterableDeque observers = new HandlerList(EnumerationObserver.class); - - protected EnumeratorState state = EnumeratorState.INIT; - - /** - * @param environment - * @param properties - * @param classLoader - */ - public LiteLoaderEnumerator(LoaderEnvironment environment, LoaderProperties properties, LaunchClassLoader classLoader) - { - this.environment = environment; - this.properties = properties; - this.classLoader = classLoader; - this.validator = this.getValidator(environment); - - this.initModules(environment); - this.registerPlugin(new DefaultEnumeratorPlugin()); - - // Initialise observers - this.observers.addAll(environment.getAPIAdapter().getPreInitObservers(EnumerationObserver.class)); - - // Initialise the shared mod list if we haven't already - this.getSharedModList(); - } - - /** - * @param environment - */ - private ModClassValidator getValidator(LoaderEnvironment environment) - { - List prefixes = new ArrayList(); - - for (LiteAPI api : environment.getAPIProvider().getAPIs()) - { - String prefix = api.getModClassPrefix(); - if (prefix != null) - { - LiteLoaderLogger.info("Adding supported mod class prefix '%s'", prefix); - prefixes.add(prefix); - } - } - - return new DefaultClassValidator(LiteMod.class, prefixes); - } - - /** - * @param environment - */ - private void initModules(LoaderEnvironment environment) - { - for (LiteAPI api : environment.getAPIProvider().getAPIs()) - { - List apiModules = api.getEnumeratorModules(); - - if (apiModules != null) - { - for (EnumeratorModule module : apiModules) - { - this.registerModule(module); - } - } - } - } - - private void checkState(EnumeratorState state, String action) - { - if (this.state != state) - { - throw new IllegalStateException("Illegal enumerator state whilst performing " + action + ", expecting " + state + " but current state is " - + this.state); - } - } - - private void gotoState(EnumeratorState state) - { - if (state.checkGotoState(this.state)) - { - this.state = state; - } - } - - /** - * Get the loader environment - */ - public LoaderEnvironment getEnvironment() - { - return this.environment; - } - - /** - * Initialise the "shared" mod list if it's not already been created - */ - @Override - public Map> getSharedModList() - { - try - { - @SuppressWarnings("unchecked") - Map> sharedModList = (Map>) Launch.blackboard.get("modList"); - - if (sharedModList == null) - { - sharedModList = new HashMap>(); - Launch.blackboard.put("modList", sharedModList); - } - - return sharedModList; - } - catch (Exception ex) - { - LiteLoaderLogger.warning("Shared mod list was invalid or not accessible, this isn't especially bad but something isn't quite right"); - return null; - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.PluggableEnumerator - * #registerModule(com.mumfrey.liteloader.core.EnumeratorModule) - */ - @Override - public void registerModule(EnumeratorModule module) - { - this.checkState(EnumeratorState.INIT, "registerModule"); - - if (module != null && !this.modules.contains(module)) - { - LiteLoaderLogger.info("Registering discovery module %s: [%s]", module.getClass().getSimpleName(), module); - this.modules.add(module); - module.init(this.environment, this.properties); - } - } - - @Override - public void registerPlugin(EnumeratorPlugin plugin) - { - this.checkState(EnumeratorState.INIT, "registerPlugin"); - - if (plugin != null && !this.plugins.contains(plugin)) - { - LiteLoaderLogger.info("Registering enumerator plugin %s: [%s]", plugin.getClass().getSimpleName(), plugin); - this.plugins.add(plugin); - plugin.init(this.environment, this.properties); - } - } - - /** - * Get the list of all enumerated mod classes to load - */ - @Override - public Collection>> getModsToLoad() - { - this.checkState(EnumeratorState.FINALISED, "getModsToLoad"); - return Collections.unmodifiableSet(this.modsToLoad); - } - - /** - * Get the set of disabled containers - */ - @Override - public Collection>> getDisabledContainers() - { - this.checkState(EnumeratorState.FINALISED, "getDisabledContainers"); - return this.containers.getDisabledContainers(); - } - - @Override - public Collection>> getBadContainers() - { - this.checkState(EnumeratorState.FINALISED, "getBadContainers"); - return this.containers.getBadContainers(); - } - - /** - * Get the list of injected tweak containers - */ - @Override - public Collection>> getInjectedTweaks() - { - this.checkState(EnumeratorState.FINALISED, "getInjectedTweaks"); - return this.containers.getInjectedTweaks(); - } - - /** - * Get the number of mods to load - */ - @Override - public int modsToLoadCount() - { - return this.modsToLoad.size(); - } - - /** - * Get a metadata value for the specified mod - * - * @param modClass - * @param metaDataKey - * @param defaultValue - */ - @Override - public String getModMetaData(Class modClass, String metaDataKey, String defaultValue) - { - this.checkState(EnumeratorState.FINALISED, "getModMetaData"); - return this.getContainerForMod(modClass).getMetaValue(metaDataKey, defaultValue); - } - - /** - * @param identifier - */ - @Override - public LoadableMod getContainer(String identifier) - { - this.checkState(EnumeratorState.FINALISED, "getContainer"); - return this.containers.getEnabledContainer(identifier); - } - - /** - * @param modClass - */ - @Override - public LoadableMod getContainer(Class modClass) - { - this.checkState(EnumeratorState.FINALISED, "getContainer"); - return this.getContainerForMod(modClass); - } - - /** - * @param modClass - */ - private LoadableMod getContainerForMod(Class modClass) - { - for (ModInfo> mod : this.modsToLoad) - { - if (modClass.equals(mod.getModClass())) - { - return mod.getContainer(); - } - } - - return LoadableMod.NONE; - } - - /** - * Get the mod identifier (metadata key), this is used for versioning, - * exclusivity, and enablement checks. - * - * @param modClass - */ - @Override - public String getIdentifier(Class modClass) - { - String modClassName = modClass.getSimpleName(); - - for (ModInfo> mod : this.modsToLoad) - { - if (modClassName.equals(mod.getModClassSimpleName())) - { - return mod.getIdentifier(); - } - } - - return LiteLoaderEnumerator.getModClassName(modClass); - } - - @Override - public void onPreInit() - { - this.discoverContainers(); - this.injectDiscoveredTweaks(); - } - - /** - * Call enumerator modules in order to find mod containers - */ - private void discoverContainers() - { - this.gotoState(EnumeratorState.DISCOVER); - - for (EnumeratorModule module : this.modules) - { - try - { - module.enumerate(this, this.environment.getProfile()); - } - catch (Throwable th) - { - LiteLoaderLogger.warning(th, "Enumerator Module %s encountered an error whilst enumerating", module.getClass().getName()); - } - } - - this.checkDependencies(); - } - - private void injectDiscoveredTweaks() - { - this.gotoState(EnumeratorState.INJECT); - - for (TweakContainer tweakContainer : this.containers.getTweakContainers()) - { - this.addTweaksFrom(tweakContainer); - } - } - - /** - * Enumerate class path and discovered mod files to find mod classes - */ - @Override - public void onInit() - { - try - { - this.gotoState(EnumeratorState.INJECT); - this.injectIntoClassLoader(); - - this.gotoState(EnumeratorState.REGISTER); - this.registerMods(); - - this.gotoState(EnumeratorState.FINALISED); - LiteLoaderLogger.info("Mod class discovery completed"); - } - catch (IllegalStateException ex) // wut? - { - Throwables.propagate(ex); - } - catch (Throwable th) - { - LiteLoaderLogger.warning(th, "Mod class discovery failed"); - } - } - - /** - * - */ - private void injectIntoClassLoader() - { - for (EnumeratorModule module : this.modules) - { - try - { - module.injectIntoClassLoader(this, this.classLoader); - } - catch (Throwable th) - { - LiteLoaderLogger.warning(th, "Enumerator Module %s encountered an error whilst injecting", module.getClass().getName()); - } - } - } - - /** - * - */ - private void registerMods() - { - for (EnumeratorModule module : this.modules) - { - try - { - module.registerMods(this, this.classLoader); - } - catch (Throwable th) - { - LiteLoaderLogger.warning(th, "Enumerator Module %s encountered an error whilst registering mods", module.getClass().getName()); - } - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.interfaces.ModularEnumerator - * #registerModContainer(com.mumfrey.liteloader.interfaces.LoadableMod) - */ - @Override - public final boolean registerModContainer(LoadableMod container) - { - this.checkState(EnumeratorState.DISCOVER, "registerModContainer"); - - if (container == null) - { - return true; - } - - if (!this.checkEnabled(container)) - { - this.registerDisabledContainer(container, DisabledReason.USER_DISABLED); - return false; - } - - if (!this.checkAPIRequirements(container)) - { - this.registerDisabledContainer(container, DisabledReason.MISSING_API); - return false; - } - - this.registerEnabledContainer(container); - return true; - } - - @Override - public void registerBadContainer(Loadable container, String reason) - { - this.checkState(EnumeratorState.DISCOVER, "registerBadContainer"); - this.containers.registerBadContainer(container, reason); - } - - /** - * @param container - */ - protected void registerEnabledContainer(LoadableMod container) - { - this.checkState(EnumeratorState.DISCOVER, "registerEnabledContainer"); - this.containers.registerEnabledContainer(container); - this.observers.all().onRegisterEnabledContainer(this, container); - } - - /** - * @param container - */ - protected void registerDisabledContainer(LoadableMod container, DisabledReason reason) - { - this.checkState(EnumeratorState.DISCOVER, "registerDisabledContainer"); - - LiteLoaderLogger.info(Verbosity.REDUCED, reason.getMessage(container)); - this.containers.registerDisabledContainer(container, reason); - this.observers.all().onRegisterDisabledContainer(this, container, reason); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.PluggableEnumerator#addTweaksFrom( - * com.mumfrey.liteloader.core.TweakContainer) - */ - @Override - public boolean registerTweakContainer(TweakContainer container) - { - this.checkState(EnumeratorState.DISCOVER, "registerTweakContainer"); - - if (!container.isEnabled(this.environment)) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Mod %s is disabled for profile %s, not injecting tranformers", - container.getIdentifier(), this.environment.getProfile()); - return false; - } - - this.containers.registerTweakContainer(container); - this.observers.all().onRegisterTweakContainer(this, container); - return true; - } - - /** - * @param tweakContainer - */ - private void addTweaksFrom(TweakContainer tweakContainer) - { - this.checkState(EnumeratorState.INJECT, "addTweaksFrom"); - - if (this.checkDependencies(tweakContainer)) - { - if (tweakContainer.hasTweakClass()) - { - this.addTweakFrom(tweakContainer); - } - - if (tweakContainer.hasClassTransformers()) - { - this.addClassTransformersFrom(tweakContainer); - } - - if (tweakContainer.hasMixins()) - { - this.addMixinsFrom(tweakContainer); - } - } - } - - private void addTweakFrom(TweakContainer container) - { - try - { - String tweakClass = container.getTweakClassName(); - int tweakPriority = container.getTweakPriority(); - LiteLoaderLogger.info(Verbosity.REDUCED, "Mod file '%s' provides tweakClass '%s', adding to Launch queue with priority %d", - container.getName(), tweakClass, tweakPriority); - if (this.environment.addCascadedTweaker(tweakClass, tweakPriority)) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "tweakClass '%s' was successfully added", tweakClass); - container.injectIntoClassPath(this.classLoader, true); - - if (container.isExternalJar()) - { - this.containers.registerInjectedTweak(container); - } - - String[] classPathEntries = container.getClassPathEntries(); - if (classPathEntries != null) - { - for (String classPathEntry : classPathEntries) - { - try - { - File classPathJar = new File(this.environment.getGameDirectory(), classPathEntry); - URL classPathJarUrl = classPathJar.toURI().toURL(); - - LiteLoaderLogger.info("Adding Class-Path entry: %s", classPathEntry); - LiteLoaderTweaker.addURLToParentClassLoader(classPathJarUrl); - this.classLoader.addURL(classPathJarUrl); - } - catch (MalformedURLException ex) {} - } - } - } - } - catch (MalformedURLException ex) - { - } - } - - private void addClassTransformersFrom(TweakContainer container) - { - try - { - for (String classTransformerClass : container.getClassTransformerClassNames()) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Mod file '%s' provides classTransformer '%s', adding to class loader", - container.getName(), classTransformerClass); - ClassTransformerManager transformerManager = this.environment.getTransformerManager(); - if (transformerManager != null && transformerManager.injectTransformer(classTransformerClass)) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "classTransformer '%s' was successfully added", classTransformerClass); - this.injectContainerRecursive(container); - } - } - } - catch (MalformedURLException ex) - { - } - } - - private void addMixinsFrom(MixinContainer container) - { - try { - container.injectIntoClassPath(this.classLoader, true); - for (String config : container.getMixinConfigs()) - { - if (config.endsWith(".json")) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Registering mixin config %s for %s", config, container.getName()); - MixinEnvironment.getDefaultEnvironment().addConfiguration(config); - } - else if (config.contains(".json@")) - { - int pos = config.indexOf(".json@"); - String phaseName = config.substring(pos + 6); - config = config.substring(0, pos + 5); - Phase phase = Phase.forName(phaseName); - if (phase != null) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Registering mixin config %s for %s", config, container.getName()); - MixinEnvironment.getEnvironment(phase).addConfiguration(config); - } - } - } - } catch (MalformedURLException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - /** - * @param container - */ - private void injectContainerRecursive(Injectable container) throws MalformedURLException - { - if (container.injectIntoClassPath(this.classLoader, true) && container instanceof LoadableMod) - { - LoadableMod file = (LoadableMod)container; - for (String dependency : file.getDependencies()) - { - LoadableMod dependencyContainer = this.containers.getEnabledContainer(dependency); - if (dependencyContainer != null) - { - this.injectContainerRecursive(dependencyContainer); - } - } - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.PluggableEnumerator#registerMods( - * com.mumfrey.liteloader.core.LoadableMod, boolean) - */ - @Override - public void registerModsFrom(LoadableMod container, boolean registerContainer) - { - this.checkState(EnumeratorState.REGISTER, "registerModsFrom"); - - if (this.containers.isDisabledContainer(container)) - { - throw new IllegalArgumentException("Attempted to register mods from a disabled container '" + container.getName() + "'"); - } - - if (this.enumeratedContainers.contains(container)) - { - // already handled this container - return; - } - - this.enumeratedContainers.add(container); - - List> modClasses = new ArrayList>(); - - for (EnumeratorPlugin plugin : this.plugins) - { - List> classes = plugin.getClasses(container, this.classLoader, this.validator); - LiteLoaderLogger.debug("Plugin %s returned %d classes for %s", plugin.getClass(), classes.size(), container.getDisplayName()); - modClasses.addAll(classes); - } - - for (Class modClass : modClasses) - { - Mod mod = new Mod(container, modClass); - this.registerMod(mod); - } - - if (modClasses.size() > 0) - { - LiteLoaderLogger.info("Found %d potential matches", modClasses.size()); - this.containers.registerEnabledContainer(container); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.interfaces.ModularEnumerator#registerMod( - * com.mumfrey.liteloader.interfaces.ModInfo) - */ - @Override - public void registerMod(ModInfo> mod) - { - this.checkState(EnumeratorState.REGISTER, "registerMod"); - - if (this.modsToLoad.contains(mod)) - { - LiteLoaderLogger.warning("Mod name collision for mod with class '%s', maybe you have more than one copy?", mod.getModClassSimpleName()); - } - - this.modsToLoad.add(mod); - - this.observers.all().onModAdded(this, mod); - } - - private boolean checkEnabled(LoadableMod container) - { - for (EnumeratorPlugin plugin : this.plugins) - { - if (!plugin.checkEnabled(this.containers, container)) return false; - } - - return true; - } - - @Override - public boolean checkAPIRequirements(LoadableMod container) - { - for (EnumeratorPlugin plugin : this.plugins) - { - if (!plugin.checkAPIRequirements(this.containers, container)) return false; - } - - return true; - } - - /** - * Check dependencies of enabled containers - */ - private void checkDependencies() - { - Collection> enabledContainers = this.containers.getEnabledContainers(); - Deque> containers = new LinkedList>(enabledContainers); - - while (containers.size() > 0) - { - LoadableMod container = containers.pop(); - if (!this.checkDependencies(container)) - { - this.registerDisabledContainer(container, DisabledReason.MISSING_DEPENDENCY); - - // Iterate so that a container disabled by a failed dependency check will also - // disable any containers which depend upon it - containers.clear(); - containers.addAll(enabledContainers); - } - } - } - - @Override - public boolean checkDependencies(LoadableMod container) - { - for (EnumeratorPlugin plugin : this.plugins) - { - if (!plugin.checkDependencies(this.containers, container)) return false; - } - - return true; - } - - @SuppressWarnings("unchecked") - public boolean checkDependencies(TweakContainer tweakContainer) - { - if (tweakContainer instanceof LoadableMod) - { - return this.checkDependencies((LoadableMod)tweakContainer); - } - - return true; - } - - public static String getModClassName(LiteMod mod) - { - return LiteLoaderEnumerator.getModClassName(mod.getClass()); - } - - public static String getModClassName(Class mod) - { - return mod.getSimpleName().substring(7); - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderEventBroker.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderEventBroker.java deleted file mode 100644 index 46eb1051..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderEventBroker.java +++ /dev/null @@ -1,548 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import com.mojang.authlib.GameProfile; -import com.mumfrey.liteloader.*; -import com.mumfrey.liteloader.PlayerInteractionListener.MouseButton; -import com.mumfrey.liteloader.api.InterfaceProvider; -import com.mumfrey.liteloader.api.Listener; -import com.mumfrey.liteloader.api.ShutdownObserver; -import com.mumfrey.liteloader.common.GameEngine; -import com.mumfrey.liteloader.common.LoadingProgress; -import com.mumfrey.liteloader.common.ducks.IPacketClientSettings; -import com.mumfrey.liteloader.core.event.HandlerList; -import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp; -import com.mumfrey.liteloader.interfaces.FastIterable; -import com.mumfrey.liteloader.interfaces.FastIterableDeque; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.util.Position; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -import net.minecraft.command.ICommandManager; -import net.minecraft.command.ServerCommandManager; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.NetHandlerPlayServer; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.client.C03PacketPlayer; -import net.minecraft.network.play.client.C15PacketClientSettings; -import net.minecraft.network.play.server.S08PacketPlayerPosLook; -import net.minecraft.network.play.server.S23PacketBlockChange; -import net.minecraft.profiler.Profiler; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.management.ItemInWorldManager; -import net.minecraft.server.management.ServerConfigurationManager; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.MovingObjectPosition.MovingObjectType; -import net.minecraft.world.World; -import net.minecraft.world.WorldServer; -import net.minecraft.world.WorldSettings; - -/** - * @author Adam Mummery-Smith - * - * @param Type of the client runtime, "Minecraft" on client and null - * on the server - * @param Type of the server runtime, "IntegratedServer" on the client - * "MinecraftServer" on the server - */ -public abstract class LiteLoaderEventBroker implements InterfaceProvider, ShutdownObserver -{ - /** - * @author Adam Mummery-Smith - * - * @param - */ - public static class ReturnValue - { - private T value; - private boolean isSet; - - public ReturnValue(T value) - { - this.value = value; - } - - public ReturnValue() - { - } - - public boolean isSet() - { - return this.isSet; - } - - public T get() - { - return this.value; - } - - public void set(T value) - { - this.isSet = true; - this.value = value; - } - } - - public static enum InteractType - { - RIGHT_CLICK, - LEFT_CLICK, - LEFT_CLICK_BLOCK, - PLACE_BLOCK_MAYBE, - DIG_BLOCK_MAYBE - } - - /** - * Singleton - */ - static LiteLoaderEventBroker broker; - - /** - * Reference to the loader instance - */ - protected final LiteLoader loader; - - /** - * Reference to the game - */ - protected final GameEngine engine; - - /** - * Profiler - */ - protected final Profiler profiler; - - protected LiteLoaderMods mods; - - private Map playerStates = new HashMap(); - private FastIterableDeque playerStateList = new HandlerList(IEventState.class); - - /** - * List of mods which provide server commands - */ - private FastIterable serverCommandProviders - = new HandlerList(ServerCommandProvider.class); - - /** - * List of mods which monitor server player events - */ - private FastIterable serverPlayerListeners - = new HandlerList(ServerPlayerListener.class); - - /** - * List of mods which handle player interaction events - */ - private FastIterable playerInteractionListeners - = new HandlerList(PlayerInteractionListener.class, ReturnLogicOp.AND); - - /** - * List of mods which handle player movement events - */ - private FastIterable playerMoveListeners - = new HandlerList(PlayerMoveListener.class, ReturnLogicOp.AND_BREAK_ON_FALSE); - - /** - * List of mods which monitor server ticks - */ - private FastIterable serverTickListeners - = new HandlerList(ServerTickable.class); - - /** - * List of mods which want to be notified when the game is shutting down - */ - private FastIterable shutdownListeners - = new HandlerList(ShutdownListener.class); - - /** - * ctor - * - * @param loader - * @param engine - * @param properties - */ - public LiteLoaderEventBroker(LiteLoader loader, GameEngine engine, LoaderProperties properties) - { - this.loader = loader; - this.engine = engine; - this.profiler = engine.getProfiler(); - - LiteLoaderEventBroker.broker = this; - } - - /** - * @param mods - */ - void setMods(LiteLoaderMods mods) - { - this.mods = mods; - } - - /** - * - */ - protected void onStartupComplete() - { - LoadingProgress.setMessage("Checking mods..."); - this.mods.onStartupComplete(); - - LoadingProgress.setMessage("Initialising CoreProviders..."); - this.loader.onStartupComplete(); - - LoadingProgress.setMessage("Starting Game..."); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider#getListenerBaseType() - */ - @Override - public Class getListenerBaseType() - { - return LiteMod.class; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider#registerInterfaces( - * com.mumfrey.liteloader.core.InterfaceRegistrationDelegate) - */ - @Override - public void registerInterfaces(InterfaceRegistrationDelegate delegate) - { - delegate.registerInterface(ServerCommandProvider.class); - delegate.registerInterface(ServerPlayerListener.class); - delegate.registerInterface(PlayerInteractionListener.class); - delegate.registerInterface(PlayerMoveListener.class); - delegate.registerInterface(CommonPluginChannelListener.class); - delegate.registerInterface(ServerTickable.class); - delegate.registerInterface(ShutdownListener.class); - } - - /** - * Add a listener to the relevant listener lists - * - * @param listener - */ - public void addCommonPluginChannelListener(CommonPluginChannelListener listener) - { - if (!(listener instanceof PluginChannelListener) && !(listener instanceof ServerPluginChannelListener)) - { - LiteLoaderLogger.warning("Interface error for mod '%1s'. Implementing CommonPluginChannelListener has no effect! " - + "Use PluginChannelListener or ServerPluginChannelListener instead", listener.getName()); - } - } - - /** - * @param serverCommandProvider - */ - public void addServerCommandProvider(ServerCommandProvider serverCommandProvider) - { - this.serverCommandProviders.add(serverCommandProvider); - } - - /** - * @param serverPlayerListener - */ - public void addServerPlayerListener(ServerPlayerListener serverPlayerListener) - { - this.serverPlayerListeners.add(serverPlayerListener); - } - - /** - * @param playerInteractionListener - */ - public void addPlayerInteractionListener(PlayerInteractionListener playerInteractionListener) - { - this.playerInteractionListeners.add(playerInteractionListener); - } - - /** - * @param playerMoveListener - */ - public void addPlayerMoveListener(PlayerMoveListener playerMoveListener) - { - this.playerMoveListeners.add(playerMoveListener); - } - - /** - * @param serverTickable - */ - public void addServerTickable(ServerTickable serverTickable) - { - this.serverTickListeners.add(serverTickable); - } - - /** - * @param shutdownListener - */ - public void addShutdownListener(ShutdownListener shutdownListener) - { - this.shutdownListeners.add(shutdownListener); - } - - /** - * @param instance - * @param folderName - * @param worldName - * @param worldSettings - */ - public void onStartServer(MinecraftServer instance, String folderName, String worldName, WorldSettings worldSettings) - { - ICommandManager commandManager = instance.getCommandManager(); - - if (commandManager instanceof ServerCommandManager) - { - ServerCommandManager serverCommandManager = (ServerCommandManager)commandManager; - this.serverCommandProviders.all().provideCommands(serverCommandManager); - } - - LiteLoader.getServerPluginChannels().onServerStartup(); - - this.playerStates.clear(); - } - - /** - * @param scm - * @param player - * @param profile - */ - public void onSpawnPlayer(ServerConfigurationManager scm, EntityPlayerMP player, GameProfile profile) - { - this.serverPlayerListeners.all().onPlayerConnect(player, profile); - PlayerEventState playerState = this.getPlayerState(player); - playerState.onSpawned(); - } - - /** - * @param scm - * @param player - */ - public void onPlayerLogin(ServerConfigurationManager scm, EntityPlayerMP player) - { - LiteLoader.getServerPluginChannels().onPlayerJoined(player); - } - - /** - * @param scm - * @param netManager - * @param player - */ - public void onInitializePlayerConnection(ServerConfigurationManager scm, NetworkManager netManager, EntityPlayerMP player) - { - this.serverPlayerListeners.all().onPlayerLoggedIn(player); - } - - /** - * @param scm - * @param player - * @param oldPlayer - * @param dimension - * @param won - */ - public void onRespawnPlayer(ServerConfigurationManager scm, EntityPlayerMP player, EntityPlayerMP oldPlayer, int dimension, boolean won) - { - this.serverPlayerListeners.all().onPlayerRespawn(player, oldPlayer, dimension, won); - } - - /** - * @param scm - * @param player - */ - public void onPlayerLogout(ServerConfigurationManager scm, EntityPlayerMP player) - { - this.serverPlayerListeners.all().onPlayerLogout(player); - this.removePlayer(player); - } - - /** - * @param clock - * @param partialTicks - * @param inGame - */ - protected void onTick(boolean clock, float partialTicks, boolean inGame) - { - this.loader.onTick(clock, partialTicks, inGame); - } - - /** - * @param mouseX - * @param mouseY - * @param partialTicks - */ - protected void onPostRender(int mouseX, int mouseY, float partialTicks) - { - this.loader.onPostRender(mouseX, mouseY, partialTicks); - } - - protected void onWorldChanged(World world) - { - this.loader.onWorldChanged(world); - } - - public void onServerTick(MinecraftServer server) - { - this.playerStateList.all().onTick(server); - this.serverTickListeners.all().onTick(server); - } - - public boolean onPlaceBlock(NetHandlerPlayServer netHandler, EntityPlayerMP playerMP, BlockPos pos, EnumFacing facing) - { - if (!this.onPlayerInteract(InteractType.PLACE_BLOCK_MAYBE, playerMP, pos, facing)) - { - S23PacketBlockChange cancellation = new S23PacketBlockChange(playerMP.worldObj, pos.offset(facing)); - netHandler.playerEntity.playerNetServerHandler.sendPacket(cancellation); - playerMP.sendContainerToPlayer(playerMP.inventoryContainer); - return false; - } - - return true; - } - - public boolean onClickedAir(NetHandlerPlayServer netHandler) - { - return this.onPlayerInteract(InteractType.LEFT_CLICK, netHandler.playerEntity, null, EnumFacing.SOUTH); - } - - public boolean onPlayerDigging(NetHandlerPlayServer netHandler, BlockPos pos, EntityPlayerMP playerMP) - { - if (!this.onPlayerInteract(InteractType.DIG_BLOCK_MAYBE, playerMP, pos, EnumFacing.SOUTH)) - { - S23PacketBlockChange cancellation = new S23PacketBlockChange(playerMP.worldObj, pos); - netHandler.playerEntity.playerNetServerHandler.sendPacket(cancellation); - return false; - } - - return true; - } - - public boolean onUseItem(BlockPos pos, EnumFacing side, EntityPlayerMP playerMP) - { - if (!this.onPlayerInteract(InteractType.PLACE_BLOCK_MAYBE, playerMP, pos, side)) - { - S23PacketBlockChange cancellation = new S23PacketBlockChange(playerMP.worldObj, pos); - playerMP.playerNetServerHandler.sendPacket(cancellation); - return false; - } - - return true; - } - - public boolean onBlockClicked(BlockPos pos, EnumFacing side, ItemInWorldManager manager) - { - if (!this.onPlayerInteract(InteractType.LEFT_CLICK_BLOCK, manager.thisPlayerMP, pos, side)) - { - S23PacketBlockChange cancellation = new S23PacketBlockChange(manager.theWorld, pos); - manager.thisPlayerMP.playerNetServerHandler.sendPacket(cancellation); - return false; - } - - return true; - } - - public boolean onPlayerInteract(InteractType action, EntityPlayerMP player, BlockPos position, EnumFacing side) - { - PlayerEventState eventState = this.getPlayerState(player); - return eventState.onPlayerInteract(action, player, position, side); - } - - void onPlayerClickedAir(EntityPlayerMP player, MouseButton button, BlockPos tracePos, EnumFacing traceSideHit, MovingObjectType traceHitType) - { - this.playerInteractionListeners.all().onPlayerClickedAir(player, button, tracePos, traceSideHit, traceHitType); - } - - boolean onPlayerClickedBlock(EntityPlayerMP player, MouseButton button, BlockPos hitPos, EnumFacing sideHit) - { - return this.playerInteractionListeners.all().onPlayerClickedBlock(player, button, hitPos, sideHit); - } - - public boolean onPlayerMove(NetHandlerPlayServer netHandler, C03PacketPlayer packet, EntityPlayerMP playerMP, WorldServer world) - { - Position from = new Position(playerMP, true); - - double toX = playerMP.posX; - double toY = playerMP.posY; - double toZ = playerMP.posZ; - float toYaw = playerMP.rotationYaw; - float toPitch = playerMP.rotationPitch; - - if (packet.isMoving()) - { - toX = packet.getPositionX(); - toY = packet.getPositionY(); - toZ = packet.getPositionZ(); - } - - if (packet.getRotating()) - { - toYaw = packet.getYaw(); - toPitch = packet.getPitch(); - } - - Position to = new Position(toX, toY, toZ, toYaw, toPitch); - ReturnValue pos = new ReturnValue(to); - - if (!this.playerMoveListeners.all().onPlayerMove(playerMP, from, to, pos)) - { - playerMP.setPositionAndRotation(from.xCoord, from.yCoord, from.zCoord, playerMP.prevRotationYaw, playerMP.prevRotationPitch); - playerMP.playerNetServerHandler.sendPacket(new S08PacketPlayerPosLook(from.xCoord, from.yCoord, from.zCoord, - playerMP.prevRotationYaw, playerMP.prevRotationPitch, Collections.emptySet())); - return false; - } - - if (pos.isSet()) - { - Position newPos = pos.get(); - netHandler.setPlayerLocation(newPos.xCoord, newPos.yCoord, newPos.zCoord, newPos.yaw, newPos.pitch); - return false; - } - - return true; - } - - void onPlayerSettingsReceived(EntityPlayerMP player, C15PacketClientSettings packet) - { - PlayerEventState playerState = this.getPlayerState(player); - playerState.setTraceDistance(((IPacketClientSettings)packet).getViewDistance()); - playerState.setLocale(packet.getLang()); - } - - public PlayerEventState getPlayerState(EntityPlayerMP player) - { - PlayerEventState playerState = this.playerStates.get(player.getUniqueID()); - if (playerState == null) - { - playerState = new PlayerEventState(player, this); - this.playerStates.put(player.getUniqueID(), playerState); - this.playerStateList.add(playerState); - } - return playerState; - } - - protected void removePlayer(EntityPlayerMP player) - { - PlayerEventState playerState = this.playerStates.remove(player.getUniqueID()); - if (playerState != null) - { - this.playerStateList.remove(playerState); - } - } - - @Override - public void onShutDown() - { - for (ShutdownListener listener : this.shutdownListeners) - { - try - { - listener.onShutDown(); - } - catch (Throwable th) - { - th.printStackTrace(); - } - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderInterfaceManager.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderInterfaceManager.java deleted file mode 100644 index 2bbcd3bc..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderInterfaceManager.java +++ /dev/null @@ -1,526 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import com.mumfrey.liteloader.api.Listener; -import com.mumfrey.liteloader.api.InterfaceObserver; -import com.mumfrey.liteloader.api.InterfaceProvider; -import com.mumfrey.liteloader.api.LiteAPI; -import com.mumfrey.liteloader.api.Observer; -import com.mumfrey.liteloader.api.exceptions.InvalidProviderException; -import com.mumfrey.liteloader.api.manager.APIAdapter; -import com.mumfrey.liteloader.core.event.HandlerList; -import com.mumfrey.liteloader.interfaces.FastIterable; -import com.mumfrey.liteloader.interfaces.InterfaceRegistry; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -/** - * The interface manager handles the allocation of interface consumers - * (implementors) to interface providers. During startup, registered providers - * are enumerated and handler mappings are created for every consumable - * interface the provider supports. Later on, consumers are enumerated against - * the available handler mappings and registered with the providers by calling - * the appropriate registration method. - * - * @author Adam Mummery-Smith - */ -public class LiteLoaderInterfaceManager implements InterfaceRegistry -{ - static int handlerAllocationOrder = 0; - - /** - * InterfaceHandler describes a mapping of a consumable interface to an - * InterfaceProvider instance and appropriate consumer registration method - * (which will be invoked via reflection). - * - * @author Adam Mummery-Smith - */ - class InterfaceHandler - { - /** - * Priority, for sorting handlers, NYI - */ - public final int priority; - - /** - * Order, for sorting handlers, NYI - */ - public final int order; - - /** - * Indicates that this handler must be the exclusive hander for this - * interface - */ - public final boolean exclusive; - - /** - * Interface Provider which handles this mapping - */ - public final InterfaceProvider provider; - - /** - * Type of interface for this mapping - */ - public final Class interfaceType; - - /** - * List of registered listeners, so we can avoid registering the same - * listener multiple times - */ - private final List registeredListeners = new ArrayList(); - - /** - * Callback method used to - */ - private final Method registrationMethod; - - /** - * @param provider - * @param interfaceType - * @param exclusive - * @param priority - */ - public InterfaceHandler(InterfaceProvider provider, Class interfaceType, boolean exclusive, int priority) - { - this.provider = provider; - this.interfaceType = interfaceType; - this.exclusive = exclusive; - this.priority = priority; - this.order = LiteLoaderInterfaceManager.handlerAllocationOrder++; - this.registrationMethod = this.findRegistrationMethod(provider, interfaceType); - } - - /** - * @param provider - * @param interfaceType - */ - @SuppressWarnings("unchecked") - private Method findRegistrationMethod(InterfaceProvider provider, Class interfaceType) - { - Method registrationMethod = null; - - Class providerClass = provider.getClass(); - while (registrationMethod == null && providerClass != null) - { - registrationMethod = this.findRegistrationMethod(providerClass, interfaceType); - providerClass = (Class)providerClass.getSuperclass(); - } - - return registrationMethod; - } - - private Method findRegistrationMethod(Class providerClass, Class interfaceType) - { - for (Method method : providerClass.getDeclaredMethods()) - { - if (method.getParameterTypes().length == 1 && method.getParameterTypes()[0].equals(interfaceType)) - { - LiteLoaderLogger.debug("Found method %s for registering %s with provider %s", - method.getName(), interfaceType, providerClass.getSimpleName()); - return method; - } - } - - return null; - } - - /** - * After instantiation, called to check that a valid registration method - * was located - */ - public boolean isValid() - { - return this.registrationMethod != null; - } - - /** - * Proxy method which calls the registration method in the - * InterfaceProvider using reflection - * - * @param listener - */ - public boolean registerListener(Listener listener) - { - if (this.interfaceType.isAssignableFrom(listener.getClass()) && this.provider.getListenerBaseType().isAssignableFrom(listener.getClass())) - { - if (this.registeredListeners.contains(listener)) - { - return false; - } - - try - { - LiteLoaderLogger.debug("Calling registration method %s for %s on %s with %s", this.registrationMethod.getName(), - this.interfaceType.getSimpleName(), this.provider.getClass().getSimpleName(), listener.getClass().getSimpleName()); - this.registrationMethod.invoke(this.provider, listener); - - this.registeredListeners.add(listener); - - LiteLoaderInterfaceManager.this.observers.all().onRegisterListener(this.provider, this.interfaceType, listener); - - return true; - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - return false; - } - } - - /** - * API Provider instance - */ - private final APIAdapter apiAdapter; - - /** - * Map of providers to the API which supplied them - */ - private final Map providerToAPIMap = new HashMap(); - - /** - * All providers - */ - private final List allProviders = new ArrayList(); - - /** - * All consumers - */ - private final List listeners = new ArrayList(); - - /** - * Registered interface handler mappings - */ - private final List interfaceHandlers = new ArrayList(); - - /** - * Interface observers - */ - protected final FastIterable observers = new HandlerList(InterfaceObserver.class); - - /** - * True once the initial init phase (in which all registered providers are - * initialised) is completed, we use this flag to indicate that any new - * providers should be immediately initialised. - */ - private boolean initDone = false; - - /** - * The last startup phase causes all currently registered consumers to be - * enumerated and offered to all currently registered listeners, once this - * initial registration is done any new consumers should immediately - * offered to all registered listeners. - */ - private boolean registrationDone = false; - - /** - * Registratiob Delegate which is active for the current registration - * process. - */ - private InterfaceRegistrationDelegate activeRegistrationDelegate; - - /** - * @param apiAdapter - */ - LiteLoaderInterfaceManager(APIAdapter apiAdapter) - { - this.apiAdapter = apiAdapter; - } - - /** - * Callback from the core - */ - void onPostInit() - { - this.registerQueuedListeners(); - this.initProviders(); - } - - void registerInterfaces() - { - this.apiAdapter.registerInterfaces(this); - } - - /** - * @param api - */ - @Override - public void registerAPI(LiteAPI api) - { - List apiInterfaceProviders = api.getInterfaceProviders(); - if (apiInterfaceProviders != null) - { - for (InterfaceProvider provider : apiInterfaceProviders) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Registering interface provider %s for API %s", - provider.getClass().getName(), api.getName()); - if (this.registerProvider(provider)) - { - this.providerToAPIMap.put(provider, api); - } - } - } - - List observers = this.apiAdapter.getObservers(api); - - if (observers != null) - { - for (Observer observer : observers) - { - if (observer instanceof InterfaceObserver) - { - this.registerObserver((InterfaceObserver)observer); - } - } - } - } - - /** - * Register a new interface provider - * - * @param provider - */ - public boolean registerProvider(InterfaceProvider provider) - { - if (provider != null && !this.allProviders.contains(provider)) - { - try - { - if (this.activeRegistrationDelegate != null) - { - throw new IllegalStateException("registerProvider() was called whilst a registration process was still active"); - } - - InterfaceRegistrationDelegate delegate = new InterfaceRegistrationDelegate(this, provider); - this.activeRegistrationDelegate = delegate; - this.activeRegistrationDelegate.registerInterfaces(); - this.activeRegistrationDelegate = null; - - if (this.initDone) - { - provider.initProvider(); - } - - this.allProviders.add(provider); - - this.interfaceHandlers.addAll(delegate.getHandlers()); - - return true; - } - catch (Throwable th) - { - LiteLoaderLogger.warning(th, "Error while registering interface provider %s: %s", - provider.getClass().getSimpleName(), th.getClass().getSimpleName()); - } - } - - this.activeRegistrationDelegate = null; - return false; - } - - /** - * @param observer - */ - public void registerObserver(InterfaceObserver observer) - { - this.observers.add(observer); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.interfaces.InterfaceRegistry - * #registerInterface( - * com.mumfrey.liteloader.api.InterfaceProvider, java.lang.Class) - */ - @Override - public void registerInterface(InterfaceProvider provider, Class interfaceType) - { - this.registerInterface(provider, interfaceType, 0); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.interfaces.InterfaceRegistry - * #registerInterface(com.mumfrey.liteloader.api.InterfaceProvider, - * java.lang.Class, int) - */ - @Override - public void registerInterface(InterfaceProvider provider, Class interfaceType, int priority) - { - this.registerInterface(provider, interfaceType, priority, false); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.interfaces.InterfaceRegistry - * #registerInterface(com.mumfrey.liteloader.api.InterfaceProvider, - * java.lang.Class, int, boolean) - */ - @Override - public void registerInterface(InterfaceProvider provider, Class interfaceType, int priority, boolean exclusive) - { - InterfaceHandler handler = new InterfaceHandler(provider, interfaceType, exclusive, priority); - if (handler.isValid()) - { - // Check if a this provider is already registered - if (this.getProvidersFor(interfaceType).contains(provider)) - { - throw new InvalidProviderException("Attempting to register duplicate mapping for provider " - + provider.getClass() + " to " + interfaceType); - } - - if (exclusive) - { - this.removeHandlersFor(interfaceType, priority); - } - - if (this.registrationDone) - { - this.interfaceHandlers.add(handler); - - for (Listener consumer : this.listeners) - { - handler.registerListener(consumer); - } - } - else if (this.activeRegistrationDelegate != null) - { - this.activeRegistrationDelegate.addHandler(handler); - } - } - else - { - throw new InvalidProviderException("Provider " + provider.getClass() + " does not expose a registration method for " + interfaceType); - } - } - - /** - * @param interfaceType - */ - public List getProvidersFor(Class interfaceType) - { - List handlers = new ArrayList(); - - for (InterfaceHandler handler : this.interfaceHandlers) - { - if (handler.interfaceType == interfaceType) - { - handlers.add(handler.provider); - } - } - - if (this.activeRegistrationDelegate != null) - { - for (InterfaceHandler handler : this.activeRegistrationDelegate.getHandlers()) - { - if (handler.interfaceType == interfaceType) - { - handlers.add(handler.provider); - } - } - } - - return handlers; - } - - /** - * @param interfaceType - * @param priority - */ - private void removeHandlersFor(Class interfaceType, int priority) - { - Iterator iter = this.interfaceHandlers.iterator(); - while (iter.hasNext()) - { - InterfaceHandler handler = iter.next(); - if (handler.interfaceType.equals(interfaceType)) - { - if (handler.exclusive) - { - throw new RuntimeException("Attempt to register an exclusive handler when an exclusive handler already exists for " - + interfaceType); - } - - iter.remove(); - } - } - } - - /** - * Returns the API which supplied a particular provider, if the provider was - * supplied by an API, otherwise returns null. - * - * @param provider - */ - public LiteAPI getAPIForProvider(InterfaceProvider provider) - { - return this.providerToAPIMap.get(provider); - } - - /** - * Initialises all registered providers - */ - private void initProviders() - { - if (this.initDone) return; - this.initDone = true; - - for (InterfaceProvider provider : this.allProviders) - { - provider.initProvider(); - } - } - - /** - * Offers an interface listener to the manager, the listener will actually - * be registered with the interface handlers at the end of the startup - * process. - * - * @param listener - */ - public void offer(Listener listener) - { - if (listener instanceof InterfaceProvider) - { - this.registerProvider((InterfaceProvider)listener); - } - - this.listeners.add(listener); - - if (this.registrationDone) - { - this.registerListener(listener); - } - } - - /** - * Registers all enqueued consumers as listeners - */ - private void registerQueuedListeners() - { - for (Listener consumer : this.listeners) - { - this.registerListener(consumer); - } - - this.registrationDone = true; - } - - /** - * Registers a listener with all registered handlers - * - * @param listener - */ - public void registerListener(Listener listener) - { - for (InterfaceHandler handler : this.interfaceHandlers) - { - handler.registerListener(listener); - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderMods.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderMods.java deleted file mode 100644 index 7b13779c..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderMods.java +++ /dev/null @@ -1,795 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.io.File; -import java.util.Collection; -import java.util.Collections; -import java.util.Deque; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.api.ModLoadObserver; -import com.mumfrey.liteloader.common.LoadingProgress; -import com.mumfrey.liteloader.core.event.HandlerList; -import com.mumfrey.liteloader.interfaces.FastIterableDeque; -import com.mumfrey.liteloader.interfaces.Loadable; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.interfaces.LoaderEnumerator; -import com.mumfrey.liteloader.interfaces.TweakContainer; -import com.mumfrey.liteloader.launch.ClassTransformerManager; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.modconfig.ConfigManager; -import com.mumfrey.liteloader.modconfig.ConfigStrategy; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -/** - * Separated from the core loader class for encapsulation purposes - * - * @author Adam Mummery-Smith - */ -public class LiteLoaderMods -{ - public static final String MOD_SYSTEM = "liteloader"; - - /** - * Reference to the loader - */ - protected final LiteLoader loader; - - /** - * Loader environment instance - */ - protected final LoaderEnvironment environment; - - /** - * Loader Properties adapter - */ - private final LoaderProperties properties; - - /** - * Mod enumerator instance - */ - protected final LoaderEnumerator enumerator; - - /** - * Configuration manager - */ - private final ConfigManager configManager; - - /** - * Mod load observers - */ - private FastIterableDeque observers = new HandlerList(ModLoadObserver.class); - - /** - * List of loaded mods, for crash reporting - */ - private String loadedModsList = "none"; - - /** - * Global list of mods which we can load - */ - protected final List allMods = new LinkedList(); - - /** - * Global list of mods which are still waiting for initialisiation - */ - protected final Deque initMods = new LinkedList(); - - /** - * Global list of mods which we have loaded - */ - protected final List loadedMods = new LinkedList(); - - /** - * Global list of mods which we found but ignored (eg. outdated, invalid) - */ - protected final List badMods = new LinkedList(); - - /** - * Mods which are loaded but disabled - */ - protected final List> disabledMods = new LinkedList>(); - - /** - * Bad containers - */ - protected final List> badContainers = new LinkedList>(); - - private int startupErrorCount, criticalErrorCount; - - LiteLoaderMods(LiteLoader loader, LoaderEnvironment environment, LoaderProperties properties, ConfigManager configManager) - { - this.loader = loader; - this.environment = environment; - this.enumerator = environment.getEnumerator(); - this.properties = properties; - this.configManager = configManager; - } - - void init(List observers) - { - this.observers.addAll(observers); - this.disabledMods.addAll(this.enumerator.getDisabledContainers()); - this.badContainers.addAll(this.enumerator.getBadContainers()); - } - - void onPostInit() - { - this.updateSharedModList(); - - this.environment.getEnabledModsList().save(); - } - - public EnabledModsList getEnabledModsList() - { - return this.environment.getEnabledModsList(); - } - - public List getAllMods() - { - return Collections.unmodifiableList(this.allMods); - } - - /** - * Used for crash reporting, returns a text list of all loaded mods - * - * @return List of loaded mods as a string - */ - public String getLoadedModsList() - { - return this.loadedModsList; - } - - /** - * Get a list containing all loaded mods - */ - public List>> getLoadedMods() - { - return this.loadedMods; - } - - /** - * Get a list containing all mod files which were NOT loaded - */ - public List> getDisabledMods() - { - return this.disabledMods; - } - - /** - * Get a list of all bad containers - */ - public List> getBadContainers() - { - return this.badContainers; - } - - /** - * Get the list of injected tweak containers - */ - public Collection>> getInjectedTweaks() - { - return this.enumerator.getInjectedTweaks(); - } - - public int getStartupErrorCount() - { - return this.startupErrorCount; - } - - public int getCriticalErrorCount() - { - return this.criticalErrorCount; - } - - public ModInfo getModInfo(LiteMod instance) - { - for (Mod mod : this.allMods) - { - if (instance == mod.getMod()) - { - return mod; - } - } - - return null; - } - - /** - * Get whether the specified mod is installed - * - * @param modName - */ - public boolean isModInstalled(String modName) - { - try - { - return this.getMod(modName) != null; - } - catch (IllegalArgumentException ex) - { - return false; - } - } - - /** - * Get a reference to a loaded mod, if the mod exists - * - * @param modName Mod's name, identifier or class name - */ - @SuppressWarnings("unchecked") - public T getMod(String modName) - { - if (modName == null) - { - throw new IllegalArgumentException("Attempted to get a reference to a mod without specifying a mod name"); - } - - for (Mod mod : this.allMods) - { - if (mod.matchesName(modName)) - { - return (T)mod.getMod(); - } - } - - return null; - } - - /** - * Get a reference to a loaded mod, if the mod exists - * - * @param modClass Mod class - */ - @SuppressWarnings("unchecked") - public T getMod(Class modClass) - { - for (Mod mod : this.allMods) - { - if (mod.getModClass().equals(modClass)) - { - return (T)mod.getMod(); - } - } - - return null; - } - - /** - * Get the mod which matches the specified identifier - * - * @param identifier - */ - public Class getModFromIdentifier(String identifier) - { - if (identifier == null) return null; - - for (Mod mod : this.allMods) - { - if (mod.matchesIdentifier(identifier)) - { - return mod.getModClass(); - } - } - - return null; - } - - /** - * Get a metadata value for the specified mod - * - * @param modNameOrId - * @param metaDataKey - * @param defaultValue - */ - public String getModMetaData(String modNameOrId, String metaDataKey, String defaultValue) throws IllegalArgumentException - { - return this.getModMetaData(this.getMod(modNameOrId), metaDataKey, defaultValue); - } - - /** - * Get a metadata value for the specified mod - * - * @param mod - * @param metaDataKey - * @param defaultValue - */ - public String getModMetaData(LiteMod mod, String metaDataKey, String defaultValue) - { - if (mod == null || metaDataKey == null) return defaultValue; - return this.enumerator.getModMetaData(mod.getClass(), metaDataKey, defaultValue); - } - - /** - * Get a metadata value for the specified mod - * - * @param modClass - * @param metaDataKey - * @param defaultValue - */ - public String getModMetaData(Class modClass, String metaDataKey, String defaultValue) - { - if (modClass == null || metaDataKey == null) return defaultValue; - return this.enumerator.getModMetaData(modClass, metaDataKey, defaultValue); - } - - /** - * Get the mod identifier, this is used for versioning, exclusivity, and - * enablement checks. - * - * @param modClass - */ - public String getModIdentifier(Class modClass) - { - return this.enumerator.getIdentifier(modClass); - } - - /** - * Get the mod identifier, this is used for versioning, exclusivity, and - * enablement checks. - * - * @param mod - */ - public String getModIdentifier(LiteMod mod) - { - return mod == null ? null : this.enumerator.getIdentifier(mod.getClass()); - } - - /** - * Get the container (mod file, classpath jar or folder) for the specified - * mod. - * - * @param modClass - */ - public LoadableMod getModContainer(Class modClass) - { - return this.enumerator.getContainer(modClass); - } - - /** - * Get the container (mod file, classpath jar or folder) for the specified - * mod. - * - * @param mod - */ - public LoadableMod getModContainer(LiteMod mod) - { - return mod == null ? null : this.enumerator.getContainer(mod.getClass()); - } - - /** - * @param identifier Identifier of the mod to enable - */ - public void enableMod(String identifier) - { - this.setModEnabled(identifier, true); - } - - /** - * @param identifier Identifier of the mod to disable - */ - public void disableMod(String identifier) - { - this.setModEnabled(identifier, false); - } - - /** - * @param identifier Identifier of the mod to enable/disable - * @param enabled - */ - public void setModEnabled(String identifier, boolean enabled) - { - this.environment.getEnabledModsList().setEnabled(this.environment.getProfile(), identifier, enabled); - this.environment.getEnabledModsList().save(); - } - - /** - * @param identifier - */ - public boolean isModEnabled(String identifier) - { - return this.environment.getEnabledModsList().isEnabled(LiteLoader.getProfile(), identifier); - } - - public boolean isModEnabled(String profile, String identifier) - { - return this.environment.getEnabledModsList().isEnabled(profile, identifier); - } - - /** - * @param identifier - */ - public boolean isModActive(String identifier) - { - if (identifier == null) return false; - - for (Mod mod : this.loadedMods) - { - if (mod.matchesIdentifier(identifier)) - { - return true; - } - } - - return false; - } - - /** - * Create mod instances from the enumerated classes - */ - void loadMods() - { - LoadingProgress.incTotalLiteLoaderProgress(this.enumerator.getModsToLoad().size()); - - for (ModInfo> mod : this.enumerator.getModsToLoad()) - { - LoadingProgress.incLiteLoaderProgress("Loading mod from %s...", mod.getModClassSimpleName()); - LoadableMod container = mod.getContainer(); - - try - { - String identifier = mod.getIdentifier(); - if (identifier == null || this.environment.getEnabledModsList().isEnabled(this.environment.getProfile(), identifier)) - { - if (!this.enumerator.checkDependencies(container)) - { - this.onModLoadFailed(container, identifier, "the mod was missing a required dependency", null); - continue; - } - - if (mod instanceof Mod) - { - this.loadMod((Mod)mod); - } - else - { - this.loadMod(identifier, mod.getModClass(), container); - } - } - else - { - this.onModLoadFailed(container, identifier, "excluded by filter", null); - } - } - catch (Throwable th) - { - this.onModLoadFailed(container, mod.getModClassName(), "an error occurred", th); - this.registerModStartupError(mod, th); - } - - this.observers.all().onPostModLoaded(mod); - } - } - - /** - * @param identifier - * @param modClass - * @param container - * @throws InstantiationException - * @throws IllegalAccessException - */ - void loadMod(String identifier, Class modClass, LoadableMod container) throws InstantiationException, IllegalAccessException - { - Mod mod = new Mod(container, modClass, identifier); - this.loadMod(mod); - } - - /** - * @param mod - * @throws InstantiationException - * @throws IllegalAccessException - */ - void loadMod(Mod mod) throws InstantiationException, IllegalAccessException - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Loading mod from %s", mod.getModClassName()); - - LiteMod newMod = mod.newInstance(); - - this.onModLoaded(mod); - - String modName = mod.getDisplayName(); - LiteLoaderLogger.info("Successfully added mod %s version %s", modName, newMod.getVersion()); - } - - /** - * @param mod - */ - void onModLoaded(Mod mod) - { - this.observers.all().onModLoaded(mod.getMod()); - - this.allMods.add(mod); - this.initMods.add(mod); - - LoadingProgress.incTotalLiteLoaderProgress(1); - } - - /** - * @param container - * @param identifier - * @param reason - * @param th - */ - void onModLoadFailed(LoadableMod container, String identifier, String reason, Throwable th) - { - LiteLoaderLogger.warning("Not loading mod %s, %s", identifier, reason); - - for (ModInfo mod : this.disabledMods) - { - if (mod.getContainer().equals(container)) - { - return; - } - } - - if (container != LoadableMod.NONE) - { - this.disabledMods.add(new NonMod(container, false)); - } - - this.observers.all().onModLoadFailed(container, identifier, reason, th); - } - - /** - * Initialise the mods which were loaded - */ - void initMods() - { - this.loadedModsList = ""; - int loadedModsCount = 0; - - while (this.initMods.size() > 0) - { - Mod mod = this.initMods.removeFirst(); - - try - { - this.initMod(mod); - loadedModsCount++; - } - catch (Throwable th) - { - this.registerModStartupError(mod, th); - LiteLoaderLogger.warning(th, "Error initialising mod '%s'", mod.getDisplayName()); - } - } - - this.loadedModsList = String.format("%s loaded mod(s)%s", loadedModsCount, this.loadedModsList); - } - - /** - * @param mod - */ - private void initMod(Mod mod) - { - LiteMod instance = mod.getMod(); - - LiteLoaderLogger.info(Verbosity.REDUCED, "Initialising mod %s version %s", instance.getName(), instance.getVersion()); - LoadingProgress.incLiteLoaderProgress("Initialising mod %s version %s...", instance.getName(), instance.getVersion()); - - this.onPreInitMod(instance); - - // initialise the mod - instance.init(LiteLoader.getCommonConfigFolder()); - - this.onPostInitMod(instance); - - this.loadedMods.add(mod); - this.loadedModsList += String.format("\n - %s version %s", mod.getDisplayName(), mod.getVersion()); - } - - /** - * @param instance - */ - private void onPreInitMod(LiteMod instance) - { - this.observers.all().onPreInitMod(instance); - - // register mod config panel if configurable - this.configManager.registerMod(instance); - - try - { - this.handleModVersionUpgrade(instance); - } - catch (Throwable th) - { - LiteLoaderLogger.warning("Error performing settings upgrade for %s. Settings may not be properly migrated", instance.getName()); - } - - // Init mod config if there is any - this.configManager.initConfig(instance); - } - - /** - * @param instance - */ - private void onPostInitMod(LiteMod instance) - { - this.observers.all().onPostInitMod(instance); - - // add the mod to all relevant listener queues - LiteLoader.getInterfaceManager().offer(instance); - - this.loader.onPostInitMod(instance); - } - - /** - * @param instance - */ - private void handleModVersionUpgrade(LiteMod instance) - { - String modKey = this.getModNameForConfig(instance.getClass(), instance.getName()); - - int currentRevision = LiteLoaderVersion.CURRENT.getLoaderRevision(); - int lastKnownRevision = this.properties.getLastKnownModRevision(modKey); - - LiteLoaderVersion lastModVersion = LiteLoaderVersion.getVersionFromRevision(lastKnownRevision); - if (currentRevision > lastModVersion.getLoaderRevision()) - { - File newConfigPath = LiteLoader.getConfigFolder(); - File oldConfigPath = this.environment.inflectVersionedConfigPath(lastModVersion); - - LiteLoaderLogger.info("Performing config upgrade for mod %s. Upgrading %s to %s...", - instance.getName(), lastModVersion, LiteLoaderVersion.CURRENT); - - this.observers.all().onMigrateModConfig(instance, newConfigPath, oldConfigPath); - - // Migrate versioned config if any is present - this.configManager.migrateModConfig(instance, newConfigPath, oldConfigPath); - - // Let the mod upgrade - instance.upgradeSettings(LiteLoaderVersion.CURRENT.getMinecraftVersion(), newConfigPath, oldConfigPath); - - this.properties.storeLastKnownModRevision(modKey); - LiteLoaderLogger.info("Config upgrade succeeded for mod %s", instance.getName()); - } - else if (currentRevision < lastKnownRevision && ConfigManager.getConfigStrategy(instance) == ConfigStrategy.Unversioned) - { - LiteLoaderLogger.warning("Mod %s has config from unknown loader revision %d. This may cause unexpected behaviour.", - instance.getName(), lastKnownRevision); - } - } - - /** - * Used by the version upgrade code, gets a version of the mod name suitable - * for inclusion in the properties file - * - * @param modName - */ - String getModNameForConfig(Class modClass, String modName) - { - if (modName == null || modName.isEmpty()) - { - modName = modClass.getSimpleName().toLowerCase(); - } - - return String.format("version.%s", modName.toLowerCase().replaceAll("[^a-z0-9_\\-\\.]", "")); - } - - void onStartupComplete() - { - this.validateModTransformers(); - } - - /** - * Check that all specified mod transformers were injected successfully, tag - * mods with failed transformers as critically errored. - */ - private void validateModTransformers() - { - ClassTransformerManager transformerManager = this.environment.getTransformerManager(); - Set injectedTransformers = transformerManager.getInjectedTransformers(); - - for (Mod mod : this.loadedMods) - { - if (mod.hasClassTransformers()) - { - List modTransformers = ((TweakContainer)mod.getContainer()).getClassTransformerClassNames(); - for (String modTransformer : modTransformers) - { - if (!injectedTransformers.contains(modTransformer)) - { - List throwables = transformerManager.getTransformerStartupErrors(modTransformer); - if (throwables != null) - { - for (Throwable th : throwables) - { - this.registerModStartupError(mod, th, true); - } - } - else - { - this.registerModStartupError(mod, new RuntimeException("Missing class transformer " + modTransformer), true); - } - } - } - } - } - } - - /** - * @param instance - * @param th - */ - public void onLateInitFailed(LiteMod instance, Throwable th) - { - ModInfo mod = this.getModInfo(instance); - if (mod != null) - { - this.registerModStartupError(mod, th); - } - } - - private void registerModStartupError(ModInfo mod, Throwable th) - { - // This is a critical error if a mod has already injected a transformer, since it may have injected - // callbacks which it is not in a position to handle! - boolean critical = this.hasModInjectedTransformers(mod); - - this.registerModStartupError(mod, th, critical); - } - - private boolean hasModInjectedTransformers(ModInfo mod) - { - if (!mod.hasClassTransformers()) return false; - - Set injectedTransformers = this.environment.getTransformerManager().getInjectedTransformers(); - List modTransformers = ((TweakContainer)mod.getContainer()).getClassTransformerClassNames(); - - for (String modTransformer : modTransformers) - { - if (injectedTransformers.contains(modTransformer)) - { - return true; - } - } - - return false; - } - - private void registerModStartupError(ModInfo mod, Throwable th, boolean critical) - { - this.startupErrorCount++; - if (critical) this.criticalErrorCount++; - mod.registerStartupError(th); - - if (!this.loadedMods.contains(mod) && !this.disabledMods.contains(mod)) - { - this.disabledMods.add(mod); - } - } - - void updateSharedModList() - { - Map> modList = this.enumerator.getSharedModList(); - if (modList == null) return; - - for (Mod mod : this.allMods) - { - String modKey = String.format("%s:%s", LiteLoaderMods.MOD_SYSTEM, mod.getIdentifier()); - modList.put(modKey, this.packModInfoToMap(mod)); - } - } - - private Map packModInfoToMap(Mod mod) - { - Map modInfo = new HashMap(); - - modInfo.put("modsystem", LiteLoaderMods.MOD_SYSTEM); - modInfo.put("id", mod.getIdentifier()); - modInfo.put("version", mod.getVersion()); - modInfo.put("name", mod.getDisplayName()); - modInfo.put("url", mod.getURL()); - modInfo.put("authors", mod.getAuthor()); - modInfo.put("description", mod.getDescription()); - - return modInfo; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderUpdateSite.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderUpdateSite.java deleted file mode 100644 index 8438867e..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderUpdateSite.java +++ /dev/null @@ -1,171 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; - -import com.google.common.io.ByteSink; -import com.google.common.io.Files; -import com.mumfrey.liteloader.launch.ClassPathUtilities; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.update.UpdateSite; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -public class LiteLoaderUpdateSite extends UpdateSite -{ - private static final String UPDATE_SITE_URL = "http://dl.liteloader.com/versions/"; - private static final String UPDATE_SITE_VERSIONS_JSON = "versions.json"; - private static final String UPDATE_SITE_ARTEFACT_NAME = "com.mumfrey:liteloader"; - - private String mcVersion; - - private File mcDir; - private File jarFile = null; - - private boolean updateForced = false; - - public LiteLoaderUpdateSite(String targetVersion, long currentTimeStamp) - { - super(LiteLoaderUpdateSite.UPDATE_SITE_URL, LiteLoaderUpdateSite.UPDATE_SITE_VERSIONS_JSON, targetVersion, - LiteLoaderUpdateSite.UPDATE_SITE_ARTEFACT_NAME, currentTimeStamp); - - this.mcVersion = targetVersion; - } - - public boolean canForceUpdate(LoaderProperties properties) - { - if (!properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_FORCE_UPDATE, false)) - { - return false; - } - - if (this.hasJarFile()) return true; - return this.findJarFile(); - } - - /** - * - */ - private boolean findJarFile() - { - // Find the jar containing liteloader - File jarFile = ClassPathUtilities.getPathToResource(LiteLoader.class, "/" + LiteLoader.class.getName().replace('.', '/') + ".class"); - if (!jarFile.isFile()) return false; - - // Validate that the jar is in the expected name and location - this.mcDir = this.walkAndValidateParents(jarFile, "liteloader-" + this.mcVersion + ".jar", this.mcVersion, - "liteloader", "mumfrey", "com", "libraries"); - if (this.mcDir == null) return false; - - // Check that the jar we found is actually on the current classpath - if (!ClassPathUtilities.isJarOnClassPath(jarFile)) return false; - this.jarFile = jarFile; - return true; - } - - private File walkAndValidateParents(File file, String... breadcrumbs) - { - try - { - for (String breadcrumb : breadcrumbs) - { - if (file == null || !file.exists() || !file.getName().equals(breadcrumb)) return null; - file = file.getParentFile(); - } - - return file; - } - catch (Exception ex) - { - ex.printStackTrace(); - } - - return null; - } - - - public boolean canCheckForUpdate() - { - return !this.updateForced; - } - - public boolean hasJarFile() - { - return this.jarFile != null; - } - - public File getJarFile() - { - return this.jarFile; - } - - public boolean forceUpdate() - { - if (this.jarFile != null) - { - LiteLoaderLogger.info("Attempting to force update, extracting jar assassin..."); - - File jarAssassinOutput = new File(this.jarFile.getParentFile(), "liteloader-update-agent.jar"); - - if (!LiteLoaderUpdateSite.extractFile("/update/liteloader-update-agent.jar", jarAssassinOutput) || !jarAssassinOutput.isFile()) - { - LiteLoaderLogger.info("Couldn't extract jarassassin jar, can't force update"); - return false; - } - - File joptSimple = new File(this.mcDir, "libraries/net/sf/jopt-simple/jopt-simple/4.5/jopt-simple-4.5.jar"); - - ProcessBuilder jarAssassinProcBuilder = new ProcessBuilder( - LiteLoaderUpdateSite.getJavaExecutable().getAbsolutePath(), - "-cp", joptSimple.getAbsolutePath(), - "-jar", jarAssassinOutput.getAbsolutePath(), - "--jarFile", this.jarFile.getAbsolutePath()).directory(this.jarFile.getParentFile()); - try - { - System.err.println(jarAssassinProcBuilder.command()); - - @SuppressWarnings("unused") - Process jarAssassin = jarAssassinProcBuilder.start(); - - ClassPathUtilities.deleteClassPathJar(this.jarFile.getAbsolutePath()); - - return true; - } - catch (Throwable th) - { - LiteLoaderLogger.info("Couldn't execute jarassassin jar, can't force update"); - return false; - } - } - - return false; - } - - protected static boolean extractFile(String resourceName, File outputFile) - { - try - { - final InputStream inputStream = LiteLoaderUpdateSite.class.getResourceAsStream(resourceName); - final ByteSink outputSupplier = Files.asByteSink(outputFile); - outputSupplier.writeFrom(inputStream); - } - catch (NullPointerException ex) - { - return false; - } - catch (IOException ex) - { - return false; - } - - return true; - } - - protected static File getJavaExecutable() - { - File javaBin = new File(new File(System.getProperty("java.home")), "bin"); - File javaWin = new File(javaBin, "javaw.exe"); - String osName = System.getProperty("os.name").toLowerCase(); - return osName.contains("win") && javaWin.isFile() ? javaWin : new File(javaBin, "java"); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderVersion.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderVersion.java deleted file mode 100644 index ac79d1b1..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/LiteLoaderVersion.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.util.HashSet; -import java.util.Set; - -/** - * LiteLoader version table - * - * @author Adam Mummery-Smith - * @version 1.8.0_00 - */ -public enum LiteLoaderVersion -{ - LEGACY(0, 0, "-", "Unknown", "-"), - FUTURE(Integer.MAX_VALUE, Long.MAX_VALUE, "-", "Future", "-"), - - MC_1_5_2_R1(9, 0, "1.5.2", "1.5.2", "1.5.2" ), - MC_1_6_1_R0(11, 0, "1.6.1", "1.6.1", "1.6.1", "1.6.r1"), - MC_1_6_1_R1(11, 0, "1.6.1", "1.6.1", "1.6.1", "1.6.r1"), - MC_1_6_2_R0(12, 0, "1.6.2", "1.6.2", "1.6.2", "1.6.r2"), - MC_1_6_2_R1(12, 1374025480, "1.6.2", "1.6.2_01", "1.6.2", "1.6.r2"), - MC_1_6_2_R2(13, 1374709543, "1.6.2", "1.6.2_02", "1.6.2", "1.6.r2"), - MC_1_6_2_R3(14, 1375228794, "1.6.2", "1.6.2_03", "1.6.2", "1.6.r2"), - MC_1_6_2_R4(15, 1375662298, "1.6.2", "1.6.2_04", "1.6.2", "1.6.r2"), - MC_1_6_3_R0(16, 1375662298, "1.6.3", "1.6.3", "1.6.3", "1.6.r3"), - MC_1_6_4_R0(17, 1380279938, "1.6.4", "1.6.4", "1.6.4", "1.6.r4"), - MC_1_6_4_R1(18, 1380796916, "1.6.4", "1.6.4_01", "1.6.4", "1.6.r4"), - MC_1_6_4_R2(19, 1380796916, "1.6.4", "1.6.4_02", "1.6.4", "1.6.r4"), - MC_1_7_2_R0(20, 1386027226, "1.7.2", "1.7.2", "1.7.2", "1.7.r1"), - MC_1_7_2_R1(21, 1388455995, "1.7.2", "1.7.2_01", "1.7.2_01"), - MC_1_7_2_R2(22, 1391815963, "1.7.2", "1.7.2_02", "1.7.2_02"), - MC_1_7_2_R3(23, 1391890695, "1.7.2", "1.7.2_03", "1.7.2_02", "1.7.2_03"), - MC_1_7_2_R4(24, 1392487926, "1.7.2", "1.7.2_04", "1.7.2_02", "1.7.2_03", "1.7.2_04"), - MC_1_7_2_R5(25, 0, "1.7.2", "1.7.2_05", "1.7.2_02", "1.7.2_03", "1.7.2_04", "1.7.2_05"), - MC_1_7_2_R6(26, 0, "1.7.2", "1.7.2_06", "1.7.2_06"), - MC_1_7_10_R0(27, 1404330030, "1.7.10", "1.7.10", "1.7.10"), - MC_1_7_10_R1(28, 1404673785, "1.7.10", "1.7.10_01", "1.7.10"), - MC_1_7_10_R2(29, 1405369406, "1.7.10", "1.7.10_02", "1.7.10"), - MC_1_7_10_R3(30, 1407687918, "1.7.10", "1.7.10_03", "1.7.10", "1.7.10_03"), - MC_1_7_10_R4(31, 1414368553, "1.7.10", "1.7.10_04", "1.7.10", "1.7.10_03", "1.7.10_04"), - MC_1_8_0_R0(32, 0, "1.8", "1.8.0", "1.8", "1.8.0"); - - /** - * Current loader version - */ - public static final LiteLoaderVersion CURRENT = LiteLoaderVersion.MC_1_8_0_R0; - - private static final LiteLoaderUpdateSite updateSite = new LiteLoaderUpdateSite(LiteLoaderVersion.CURRENT.getMinecraftVersion(), - LiteLoaderVersion.CURRENT.getReleaseTimestamp()); - - private final int revision; - - private final long timestamp; - - private final String minecraftVersion; - - private final String loaderVersion; - - private final Set supportedVersions = new HashSet(); - - private LiteLoaderVersion(int revision, long timestamp, String minecraftVersion, String loaderVersion, String... supportedVersions) - { - this.revision = revision; - this.timestamp = timestamp; - this.minecraftVersion = minecraftVersion; - this.loaderVersion = loaderVersion; - - for (String supportedVersion : supportedVersions) - this.supportedVersions.add(supportedVersion); - } - - public int getLoaderRevision() - { - return this.revision; - } - - public long getReleaseTimestamp() - { - return this.timestamp; - } - - public String getMinecraftVersion() - { - return this.minecraftVersion; - } - - public String getLoaderVersion() - { - return this.loaderVersion; - } - - public static LiteLoaderVersion getVersionFromRevision(int revision) - { - if (revision > LiteLoaderVersion.CURRENT.revision) - { - return LiteLoaderVersion.FUTURE; - } - - for (LiteLoaderVersion version : LiteLoaderVersion.values()) - { - if (version.getLoaderRevision() == revision) - { - return version; - } - } - - return LiteLoaderVersion.LEGACY; - } - - public static int getRevisionFromVersion(String versionString) - { - for (LiteLoaderVersion version : LiteLoaderVersion.values()) - { - if (version.getLoaderVersion().equals(versionString)) - { - return version.getLoaderRevision(); - } - } - - return LiteLoaderVersion.LEGACY.getLoaderRevision(); - } - - public boolean isVersionSupported(String version) - { - return this.supportedVersions.contains(version); - } - - @Override - public String toString() - { - return this.loaderVersion; - } - - public static LiteLoaderUpdateSite getUpdateSite() - { - return LiteLoaderVersion.updateSite; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/Mod.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/Mod.java deleted file mode 100644 index f9a5f626..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/Mod.java +++ /dev/null @@ -1,205 +0,0 @@ -package com.mumfrey.liteloader.core; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.interfaces.LoadableMod; - -/** - * ModInfo for an active mod instance - * - * @author Adam Mummery-Smith - */ -class Mod extends ModInfo> -{ - /** - * Mod class - */ - private final Class modClass; - - /** - * Mod's key identifier, usually the class simplename - */ - private final String key; - - /** - * Mod's identifier (from metadata) - */ - private final String identifier; - - /** - * Mod instance - */ - private LiteMod instance; - - /** - * Mod display name, initially read from metadata then replaced with real - * name once instanced. - */ - private String name; - - /** - * Mod display name, initially read from version then replaced with real - * version once instanced. - */ - private String version; - - /** - * @param container - * @param modClass - */ - public Mod(LoadableMod container, Class modClass) - { - this(container, modClass, container != null ? container.getIdentifier() : LiteLoaderEnumerator.getModClassName(modClass)); - } - - /** - * @param container - * @param modClass - * @param identifier - */ - public Mod(LoadableMod container, Class modClass, String identifier) - { - super(container != null ? container : LoadableMod.NONE, true); - - this.modClass = modClass; - this.key = modClass.getSimpleName(); - this.identifier = identifier.toLowerCase(); - this.name = this.container.getDisplayName(); - this.version = this.container.getVersion(); - } - - /** - * Called by the mod manager to instance the mod - * - * @throws InstantiationException - * @throws IllegalAccessException - */ - LiteMod newInstance() throws InstantiationException, IllegalAccessException - { - if (this.instance != null) - { - throw new InstantiationException("Attempted to create an instance of " + this.key + " but the instance was already created"); - } - - this.instance = this.modClass.newInstance(); - - String name = this.instance.getName(); - if (name != null) this.name = name; - - String version = this.instance.getVersion(); - if (version != null) this.version = version; - - return this.instance; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#isToggleable() - */ - @Override - public boolean isToggleable() - { - return true; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getMod() - */ - @Override - public LiteMod getMod() - { - return this.instance; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getModClass() - */ - @Override - public Class getModClass() - { - return this.modClass; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getDisplayName() - */ - @Override - public String getDisplayName() - { - return this.name; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getVersion() - */ - @Override - public String getVersion() - { - return this.version; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getModClassName() - */ - @Override - public String getModClassName() - { - return this.modClass.getName(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getModClassSimpleName() - */ - @Override - public String getModClassSimpleName() - { - return this.key; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getIdentifier() - */ - @Override - public String getIdentifier() - { - return this.identifier; - } - - /** - * Get whether any of the valid identifiers match the supplied name - * - * @param name - */ - public boolean matchesName(String name) - { - return (name.equalsIgnoreCase(this.instance.getName()) || name.equalsIgnoreCase(this.identifier) || name.equalsIgnoreCase(this.key)); - } - - /** - * Get whether ths mod identifier matches the supplied identifier - * - * @param identifier - */ - public boolean matchesIdentifier(String identifier) - { - return identifier.equalsIgnoreCase(this.identifier); - } - - /* (non-Javadoc) - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object other) - { - if (other == null) return false; - if (!(other instanceof Mod)) return false; - return ((Mod)other).key.equals(this.key); - } - - /* (non-Javadoc) - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() - { - return this.key.hashCode(); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/ModInfo.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/ModInfo.java deleted file mode 100644 index 5f3c6eaf..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/ModInfo.java +++ /dev/null @@ -1,230 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import com.google.common.collect.ImmutableSet; -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.interfaces.Loadable; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.interfaces.MixinContainer; -import com.mumfrey.liteloader.interfaces.TweakContainer; - -/** - * ModInfo is used to keep runtime information about a mod (or other injectable) - * together with relevant environmental information (such as startup errors) and - * its container. - * - * @author Adam Mummery-Smith - * - * @param type of container - */ -public abstract class ModInfo> -{ - /** - * List of built-in APIs, used to filter for 3rd-party APIs - */ - protected static final Set BUILT_IN_APIS = ImmutableSet.of("liteloader"); - - /** - * Container instance - */ - protected final TContainer container; - - /** - * True if this mod is active/injected or not active/errored - */ - protected final boolean active; - - /** - * Startup errors encountered whilst loading this mod - */ - private final List startupErrors = new ArrayList(); - - /** - * @param container - * @param active - */ - protected ModInfo(TContainer container, boolean active) - { - this.container = container; - this.active = active; - } - - /** - * Get whether this mod is currently active - */ - public final boolean isActive() - { - return this.active; - } - - /** - * Get whether this mod is valid - */ - public boolean isValid() - { - return true; - } - - /** - * Get whether this mod can be toggled - */ - public boolean isToggleable() - { - return this.container.isToggleable(); - } - - /** - * Get whether this mod has a container - */ - public final boolean hasContainer() - { - return this.container != LoadableMod.NONE; - } - - /** - * Get the container for this mod - */ - public final TContainer getContainer() - { - return this.container; - } - - /** - * Callback to allow the mod manager to register a startup error - */ - void registerStartupError(Throwable th) - { - this.startupErrors.add(th); - } - - /** - * Get startup errors for this instance - */ - public List getStartupErrors() - { - return Collections.unmodifiableList(this.startupErrors); - } - - /** - * Get the display name for this mod - */ - public String getDisplayName() - { - return this.container.getDisplayName(); - } - - /** - * Get the mod version - */ - public String getVersion() - { - return this.container.getVersion(); - } - - /** - * Get the nod identifier - */ - public String getIdentifier() - { - return this.container.getIdentifier(); - } - - /** - * Get the mod URL - */ - public String getURL() - { - return this.container instanceof LoadableMod ? ((LoadableMod)this.container).getMetaValue("url", "") : null; - } - - /** - * Get the mod author(s) - */ - public String getAuthor() - { - return this.container.getAuthor(); - } - - /** - * Get the mod description - */ - public String getDescription() - { - return this.container.getDescription(null); - } - - /** - * If this container has a tweak - */ - public boolean hasTweakClass() - { - return (this.container instanceof TweakContainer && ((TweakContainer)this.container).hasTweakClass()); - } - - /** - * If this has transformers (NOT robots in disguise, the other kind) - */ - public boolean hasClassTransformers() - { - return (this.container instanceof TweakContainer && ((TweakContainer)this.container).hasClassTransformers()); - } - - /** - * If this has JSON event transformers - */ - public boolean hasEventTransformers() - { - return (this.container instanceof TweakContainer && ((TweakContainer)this.container).hasEventTransformers()); - } - - /** - * If this has mixins - */ - public boolean hasMixins() - { - return (this.container instanceof MixinContainer && ((MixinContainer)this.container).hasMixins()); - } - - /** - * Get whether this mod uses external (3rd-party) API - */ - public boolean usesAPI() - { - if (this.container instanceof LoadableMod) - { - for (String requiredAPI : ((LoadableMod)this.container).getRequiredAPIs()) - { - if (!ModInfo.BUILT_IN_APIS.contains(requiredAPI)) - { - return true; - } - } - } - - return false; - } - - /** - * Get the mod instance - */ - public abstract LiteMod getMod(); - - /** - * Get the mod class - */ - public abstract Class getModClass(); - - /** - * Get the mod class full name - */ - public abstract String getModClassName(); - - /** - * Get the mod class simple name - */ - public abstract String getModClassSimpleName(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/NonMod.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/NonMod.java deleted file mode 100644 index 45857623..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/NonMod.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.mumfrey.liteloader.core; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.interfaces.Loadable; - -/** - * ModInfo for unloaded containers and injected tweaks - * - * @author Adam Mummery-Smith - */ -public class NonMod extends ModInfo> -{ - /** - * @param container - * @param active - */ - public NonMod(Loadable container, boolean active) - { - super(container, active); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getMod() - */ - @Override - public LiteMod getMod() - { - return null; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getModClass() - */ - @Override - public Class getModClass() - { - return null; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getModClassName() - */ - @Override - public String getModClassName() - { - return null; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ModInfo#getModClassSimpleName() - */ - @Override - public String getModClassSimpleName() - { - return null; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/PacketEvents.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/PacketEvents.java deleted file mode 100644 index 108c3439..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/PacketEvents.java +++ /dev/null @@ -1,317 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.INetHandler; -import net.minecraft.network.NetHandlerPlayServer; -import net.minecraft.network.Packet; -import net.minecraft.network.login.server.S02PacketLoginSuccess; -import net.minecraft.network.play.client.C01PacketChatMessage; -import net.minecraft.network.play.client.C15PacketClientSettings; -import net.minecraft.network.play.client.C17PacketCustomPayload; -import net.minecraft.network.play.server.S01PacketJoinGame; -import net.minecraft.network.play.server.S02PacketChat; -import net.minecraft.network.play.server.S3FPacketCustomPayload; -import net.minecraft.util.IThreadListener; - -import com.mumfrey.liteloader.PacketHandler; -import com.mumfrey.liteloader.ServerChatFilter; -import com.mumfrey.liteloader.api.InterfaceProvider; -import com.mumfrey.liteloader.api.Listener; -import com.mumfrey.liteloader.common.transformers.PacketEventInfo; -import com.mumfrey.liteloader.core.event.HandlerList; -import com.mumfrey.liteloader.core.event.HandlerList.ReturnLogicOp; -import com.mumfrey.liteloader.core.runtime.Packets; -import com.mumfrey.liteloader.interfaces.FastIterable; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Packet event handling - * - * @author Adam Mummery-Smith - */ -public abstract class PacketEvents implements InterfaceProvider -{ - protected static PacketEvents instance; - - class PacketHandlerList extends HandlerList - { - private static final long serialVersionUID = 1L; - - /** - * ctor - */ - PacketHandlerList() - { - super(PacketHandler.class, ReturnLogicOp.AND_BREAK_ON_FALSE); - } - } - - /** - * Reference to the loader instance - */ - protected final LiteLoader loader; - - private PacketHandlerList[] packetHandlers = new PacketHandlerList[Packets.count()]; - - private FastIterable serverChatFilters = new HandlerList(ServerChatFilter.class, - ReturnLogicOp.AND_BREAK_ON_FALSE); - - private final int loginSuccessPacketId = Packets.S02PacketLoginSuccess.getIndex(); - private final int serverChatPacketId = Packets.S02PacketChat.getIndex(); - private final int clientChatPacketId = Packets.C01PacketChatMessage.getIndex(); - private final int joinGamePacketId = Packets.S01PacketJoinGame.getIndex(); - private final int serverPayloadPacketId = Packets.S3FPacketCustomPayload.getIndex(); - private final int clientPayloadPacketId = Packets.C17PacketCustomPayload.getIndex(); - private final int clientSettingsPacketId = Packets.C15PacketClientSettings.getIndex(); - - /** - * ctor - */ - public PacketEvents() - { - PacketEvents.instance = this; - this.loader = LiteLoader.getInstance(); - } - - @Override - public Class getListenerBaseType() - { - return Listener.class; - } - - @Override - public void registerInterfaces(InterfaceRegistrationDelegate delegate) - { - delegate.registerInterface(PacketHandler.class); - delegate.registerInterface(ServerChatFilter.class); - } - - @Override - public void initProvider() - { - } - - /** - * @param serverChatFilter - */ - public void registerServerChatFilter(ServerChatFilter serverChatFilter) - { - this.serverChatFilters.add(serverChatFilter); - } - - /** - * Register a new packet handler - * - * @param handler - */ - public void registerPacketHandler(PacketHandler handler) - { - List> handledPackets = handler.getHandledPackets(); - if (handledPackets != null) - { - for (Class packetClass : handledPackets) - { - String packetClassName = packetClass.getName(); - int packetId = Packets.indexOf(packetClassName); - if (packetId == -1 || packetId >= this.packetHandlers.length) - { - LiteLoaderLogger.warning("PacketHandler %s attempted to register a handler for unupported packet class %s", - handler.getName(), packetClassName); - continue; - } - - if (this.packetHandlers[packetId] == null) - { - this.packetHandlers[packetId] = new PacketHandlerList(); - } - - this.packetHandlers[packetId].add(handler); - } - } - } - - /** - * Event callback - * - * @param e - * @param netHandler - */ - public static void handlePacket(PacketEventInfo e, INetHandler netHandler) - { - PacketEvents.instance.handlePacket(e, netHandler, e.getPacketId()); - } - - private void handlePacket(PacketEventInfo e, INetHandler netHandler, int packetId) - { - Packets packetInfo = Packets.packets[e.getPacketId()]; - IThreadListener threadListener = this.getPacketContextListener(packetInfo.getContext()); - if (threadListener != null && !threadListener.isCallingFromMinecraftThread()) - { - this.handleAsyncPacketEvent(e, netHandler, packetId); - return; - } - - if (this.handlePacketEvent(e, netHandler, packetId) || this.packetHandlers[packetId] == null || e.isCancelled()) - { - return; - } - - if (this.packetHandlers[packetId].all().handlePacket(netHandler, e.getSource())) - { - return; - } - - e.cancel(); - } - - /** - * @param context - */ - protected abstract IThreadListener getPacketContextListener(Packets.Context context); - - /** - * @param e - * @param netHandler - * @param packetId - */ - protected void handleAsyncPacketEvent(PacketEventInfo e, INetHandler netHandler, int packetId) - { - Packet packet = e.getSource(); - - if (packetId == this.loginSuccessPacketId) - { - this.handlePacket(e, netHandler, (S02PacketLoginSuccess)packet); - } - } - - /** - * @param e - * @param netHandler - * @param packetId - * @return true if the packet was handled by a local handler and shouldn't - * be forwarded to later handlers - */ - protected boolean handlePacketEvent(PacketEventInfo e, INetHandler netHandler, int packetId) - { - Packet packet = e.getSource(); - - if (packetId == this.serverChatPacketId) - { - this.handlePacket(e, netHandler, (S02PacketChat)packet); - return true; - } - - if (packetId == this.clientChatPacketId) - { - this.handlePacket(e, netHandler, (C01PacketChatMessage)packet); - return true; - } - - if (packetId == this.joinGamePacketId) - { - this.handlePacket(e, netHandler, (S01PacketJoinGame)packet); - return true; - } - - if (packetId == this.serverPayloadPacketId) - { - this.handlePacket(e, netHandler, (S3FPacketCustomPayload)packet); - return true; - } - - if (packetId == this.clientPayloadPacketId) - { - this.handlePacket(e, netHandler, (C17PacketCustomPayload)packet); - return true; - } - - if (packetId == this.clientSettingsPacketId) - { - this.handlePacket(e, netHandler, (C15PacketClientSettings)packet); - return true; - } - - return false; - } - - /** - * @param e - * @param netHandler - * @param packet - */ - protected abstract void handlePacket(PacketEventInfo e, INetHandler netHandler, S02PacketLoginSuccess packet); - - /** - * S02PacketChat::processPacket() - * - * @param netHandler - * @param packet - */ - protected abstract void handlePacket(PacketEventInfo e, INetHandler netHandler, S02PacketChat packet); - - /** - * S02PacketChat::processPacket() - * - * @param netHandler - * @param packet - */ - protected void handlePacket(PacketEventInfo e, INetHandler netHandler, C01PacketChatMessage packet) - { - EntityPlayerMP player = netHandler instanceof NetHandlerPlayServer ? ((NetHandlerPlayServer)netHandler).playerEntity : null; - - if (!this.serverChatFilters.all().onChat(player, packet, packet.getMessage())) - { - e.cancel(); - } - } - - /** - * S01PacketJoinGame::processPacket() - * - * @param netHandler - * @param packet - */ - protected void handlePacket(PacketEventInfo e, INetHandler netHandler, S01PacketJoinGame packet) - { - this.loader.onJoinGame(netHandler, packet); - } - - /** - * S3FPacketCustomPayload::processPacket() - * - * @param netHandler - * @param packet - */ - protected void handlePacket(PacketEventInfo e, INetHandler netHandler, S3FPacketCustomPayload packet) - { - LiteLoader.getClientPluginChannels().onPluginChannelMessage(packet); - } - - /** - * C17PacketCustomPayload::processPacket() - * - * @param netHandler - * @param packet - */ - protected void handlePacket(PacketEventInfo e, INetHandler netHandler, C17PacketCustomPayload packet) - { - LiteLoader.getServerPluginChannels().onPluginChannelMessage(netHandler, packet); - } - - /** - * C15PacketClientSettings::processPacket() - * - * @param e - * @param netHandler - * @param packet - */ - private void handlePacket(PacketEventInfo e, INetHandler netHandler, C15PacketClientSettings packet) - { - if (netHandler instanceof NetHandlerPlayServer) - { - LiteLoaderEventBroker.broker.onPlayerSettingsReceived(((NetHandlerPlayServer)netHandler).playerEntity, packet); - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/PlayerEventState.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/PlayerEventState.java deleted file mode 100644 index 8e6bbe7c..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/PlayerEventState.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.mumfrey.liteloader.core; - -import java.lang.ref.WeakReference; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.MovingObjectPosition.MovingObjectType; - -import com.mumfrey.liteloader.PlayerInteractionListener.MouseButton; -import com.mumfrey.liteloader.core.LiteLoaderEventBroker.InteractType; -import com.mumfrey.liteloader.util.EntityUtilities; - -public class PlayerEventState implements IEventState -{ - private static long MISS = new BlockPos(-1, -1, -1).toLong(); - - private WeakReference playerRef; - - private final LiteLoaderEventBroker broker; - - private double traceDistance = 256.0; - - private int suppressLeftTicks; - private int suppressRightTicks; - private boolean leftClick; - private boolean rightClick; - - private MovingObjectPosition hit; - - private String locale = "en_US"; - - public PlayerEventState(EntityPlayerMP player, LiteLoaderEventBroker broker) - { - this.playerRef = new WeakReference(player); - this.broker = broker; - } - - public void setTraceDistance(int renderDistance) - { - this.traceDistance = renderDistance * 16.0; - } - - public double getTraceDistance() - { - return this.traceDistance; - } - - public void setLocale(String lang) - { - if (lang.matches("^[a-z]{2}_[A-Z]{2}$")) - { - this.locale = lang; - } - } - - public String getLocale() - { - return this.locale; - } - - public EntityPlayerMP getPlayer() - { - return this.playerRef.get(); - } - - public void onSpawned() - { - } - - @Override - public void onTick(MinecraftServer server) - { - if (this.leftClick && this.suppressLeftTicks == 0) - { - this.broker.onPlayerClickedAir(this.getPlayer(), MouseButton.LEFT, this.hit.getBlockPos(), this.hit.sideHit, this.hit.typeOfHit); - } - - if (this.rightClick && this.suppressRightTicks == 0) - { - this.broker.onPlayerClickedAir(this.getPlayer(), MouseButton.RIGHT, this.hit.getBlockPos(), this.hit.sideHit, this.hit.typeOfHit); - } - - if (this.suppressLeftTicks > 0) this.suppressLeftTicks--; - if (this.suppressRightTicks > 0) this.suppressRightTicks--; - - this.leftClick = false; - this.rightClick = false; - } - - public boolean onPlayerInteract(InteractType action, EntityPlayerMP player, BlockPos position, EnumFacing side) - { - this.hit = EntityUtilities.rayTraceFromEntity(player, this.traceDistance, 0.0F); - - if (action == InteractType.LEFT_CLICK) - { - this.leftClick = true; - return true; - } - - if (action == InteractType.RIGHT_CLICK) - { - this.rightClick = true; - return true; - } - - if ((action == InteractType.LEFT_CLICK_BLOCK || action == InteractType.DIG_BLOCK_MAYBE) && this.suppressLeftTicks == 0) - { - this.suppressLeftTicks += 2; - return this.broker.onPlayerClickedBlock(player, MouseButton.LEFT, position, side); - } - - if (action == InteractType.PLACE_BLOCK_MAYBE) - { - if (this.suppressRightTicks > 0) - { - return true; - } - - if (position.toLong() == PlayerEventState.MISS) - { - MovingObjectPosition actualHit = EntityUtilities.rayTraceFromEntity(player, player.capabilities.isCreativeMode ? 5.0 : 4.5, 0.0F); - if (actualHit.typeOfHit == MovingObjectType.MISS) - { - this.rightClick = true; - return true; - } - } - - this.suppressRightTicks++; - this.suppressLeftTicks++; - return this.broker.onPlayerClickedBlock(player, MouseButton.RIGHT, position, side); - } - - return true; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/PluginChannels.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/PluginChannels.java deleted file mode 100644 index 1622695b..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/PluginChannels.java +++ /dev/null @@ -1,237 +0,0 @@ -package com.mumfrey.liteloader.core; - -import io.netty.buffer.Unpooled; - -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.minecraft.network.INetHandler; -import net.minecraft.network.PacketBuffer; - -import com.google.common.base.Charsets; -import com.mumfrey.liteloader.api.InterfaceProvider; -import com.mumfrey.liteloader.interfaces.FastIterableDeque; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Manages plugin channel connections and subscriptions for LiteLoader - * - * @author Adam Mummery-Smith - */ -public abstract class PluginChannels implements InterfaceProvider -{ - // reserved channel consts - protected static final String CHANNEL_REGISTER = "REGISTER"; - protected static final String CHANNEL_UNREGISTER = "UNREGISTER"; - - /** - * Number of faults for a specific listener before a warning is generated - */ - protected static final int WARN_FAULT_THRESHOLD = 1000; - - /** - * Mapping of plugin channel names to listeners - */ - protected final HashMap> pluginChannels = new HashMap>(); - - /** - * List of mods which implement PluginChannelListener interface - */ - protected final FastIterableDeque pluginChannelListeners; - - /** - * Plugin channels that we know the server supports - */ - protected final Set remotePluginChannels = new HashSet(); - - /** - * Keep track of faulting listeners so that we can periodically log a - * message if a listener is throwing LOTS of exceptions. - */ - protected final Map faultingPluginChannelListeners = new HashMap(); - - /** - * Package private - */ - PluginChannels() - { - this.pluginChannelListeners = this.createHandlerList(); - } - - /** - * Spawn the handler list instance for this channel manager - */ - protected abstract FastIterableDeque createHandlerList(); - - /** - * Get the current set of registered client-side channels - */ - public Set getLocalChannels() - { - return Collections.unmodifiableSet(this.pluginChannels.keySet()); - } - - /** - * Get the current set of registered server channels - */ - public Set getRemoteChannels() - { - return Collections.unmodifiableSet(this.remotePluginChannels); - } - - /** - * Check whether a server plugin channel is registered - * - * @param channel - * @return true if the channel is registered at the server side - */ - public boolean isRemoteChannelRegistered(String channel) - { - return this.remotePluginChannels.contains(channel); - } - - /** - * @param pluginChannelListener - */ - protected void addPluginChannelListener(L pluginChannelListener) - { - this.pluginChannelListeners.add(pluginChannelListener); - } - - /** - * Connecting to a new server, clear plugin channels - * - * @param netHandler - */ - protected void clearPluginChannels(INetHandler netHandler) - { - this.pluginChannels.clear(); - this.remotePluginChannels.clear(); - this.faultingPluginChannelListeners.clear(); - } - - /** - * @param data - */ - protected void onRegisterPacketReceived(PacketBuffer data) - { - try - { - byte[] bytes = new byte[data.readableBytes()]; - data.readBytes(bytes); - String channels = new String(bytes, Charsets.UTF_8); - for (String channel : channels.split("\u0000")) - { - this.remotePluginChannels.add(channel); - } - } - catch (Exception ex) - { - LiteLoaderLogger.warning(ex, "Error decoding REGISTER packet from remote host %s", ex.getClass().getSimpleName()); - } - } - - /** - * - */ - protected PacketBuffer getRegistrationData() - { - // If any mods have registered channels, send the REGISTER packet - if (this.pluginChannels.keySet().size() > 0) - { - StringBuilder channelList = new StringBuilder(); - boolean separator = false; - - for (String channel : this.pluginChannels.keySet()) - { - if (separator) channelList.append("\u0000"); - channelList.append(channel); - separator = true; - } - - PacketBuffer buffer = new PacketBuffer(Unpooled.buffer()); - buffer.writeBytes(channelList.toString().getBytes(Charsets.UTF_8)); - return buffer; - } - - return null; - } - - /** - * Adds plugin channels for the specified listener to the local channels - * collection - * - * @param pluginChannelListener - */ - protected void addPluginChannelsFor(L pluginChannelListener) - { - List channels = pluginChannelListener.getChannels(); - - if (channels != null) - { - for (String channel : channels) - { - if (channel.length() > 16 || channel.toUpperCase().equals(CHANNEL_REGISTER) || channel.toUpperCase().equals(CHANNEL_UNREGISTER)) - { - continue; - } - - if (!this.pluginChannels.containsKey(channel)) - { - this.pluginChannels.put(channel, new LinkedList()); - } - - this.pluginChannels.get(channel).add(pluginChannelListener); - } - } - } - - /** - * Policy for dispatching plugin channel packets - * - * @author Adam Mummery-Smith - */ - public enum ChannelPolicy - { - /** - * Dispatch the message, throw an exception if the channel is not - * registered - */ - DISPATCH, - - /** - * Dispatch the message, return false if the channel is not registered - */ - DISPATCH_IF_REGISTERED, - - /** - * Dispatch the message - */ - DISPATCH_ALWAYS; - - /** - * True if this policy allows outbound traffic on the specified channel - * - * @param channel - */ - public boolean allows(PluginChannels channels, String channel) - { - if (this == ChannelPolicy.DISPATCH_ALWAYS) return true; - return channels.isRemoteChannelRegistered(channel); - } - - /** - * True if this policy does not throw an exception for unregistered - * outbound channels - */ - public boolean isSilent() - { - return (this != ChannelPolicy.DISPATCH_IF_REGISTERED); - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/Proxy.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/Proxy.java deleted file mode 100644 index f494b5fe..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/Proxy.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.mumfrey.liteloader.core; - -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import com.mojang.authlib.GameProfile; - -import net.minecraft.entity.player.EntityPlayer; -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.item.ItemStack; -import net.minecraft.network.NetHandlerPlayServer; -import net.minecraft.network.NetworkManager; -import net.minecraft.network.play.client.C03PacketPlayer; -import net.minecraft.network.play.client.C07PacketPlayerDigging; -import net.minecraft.network.play.client.C08PacketPlayerBlockPlacement; -import net.minecraft.network.play.client.C0APacketAnimation; -import net.minecraft.server.MinecraftServer; -import net.minecraft.server.management.ItemInWorldManager; -import net.minecraft.server.management.ServerConfigurationManager; -import net.minecraft.util.BlockPos; -import net.minecraft.util.EnumFacing; -import net.minecraft.world.World; -import net.minecraft.world.WorldServer; - -public abstract class Proxy -{ - private static LiteLoaderEventBroker broker; - - protected Proxy() {} - - protected static void onStartupComplete() - { - Proxy.broker = LiteLoaderEventBroker.broker; - - if (Proxy.broker == null) - { - throw new RuntimeException("LiteLoader failed to start up properly." - + " The game is in an unstable state and must shut down now. Check the developer log for startup errors"); - } - } - - public static void onInitializePlayerConnection(ServerConfigurationManager source, NetworkManager netManager, EntityPlayerMP player) - { - Proxy.broker.onInitializePlayerConnection(source, netManager, player); - } - - public static void onPlayerLogin(ServerConfigurationManager source, EntityPlayerMP player) - { - Proxy.broker.onPlayerLogin(source, player); - } - - public static void onPlayerLogout(ServerConfigurationManager source, EntityPlayerMP player) - { - Proxy.broker.onPlayerLogout(source, player); - } - - public static void onSpawnPlayer(CallbackInfoReturnable cir, ServerConfigurationManager source, GameProfile profile) - { - Proxy.broker.onSpawnPlayer(source, cir.getReturnValue(), profile); - } - - public static void onRespawnPlayer(CallbackInfoReturnable cir, ServerConfigurationManager source, EntityPlayerMP oldPlayer, - int dimension, boolean won) - { - Proxy.broker.onRespawnPlayer(source, cir.getReturnValue(), oldPlayer, dimension, won); - } - - public static void onServerTick(MinecraftServer mcServer) - { - Proxy.broker.onServerTick(mcServer); - } - - public static void onPlaceBlock(CallbackInfo ci, NetHandlerPlayServer netHandler, C08PacketPlayerBlockPlacement packet) - { - if (!Proxy.broker.onPlaceBlock(netHandler, netHandler.playerEntity, packet.getPosition(), - EnumFacing.getFront(packet.getPlacedBlockDirection()))) - { - ci.cancel(); - } - } - - public static void onClickedAir(CallbackInfo ci, NetHandlerPlayServer netHandler, C0APacketAnimation packet) - { - if (!Proxy.broker.onClickedAir(netHandler)) - { - ci.cancel(); - } - } - - public static void onPlayerDigging(CallbackInfo ci, NetHandlerPlayServer netHandler, C07PacketPlayerDigging packet) - { - if (packet.getStatus() == C07PacketPlayerDigging.Action.START_DESTROY_BLOCK) - { - if (!Proxy.broker.onPlayerDigging(netHandler, packet.getPosition(), netHandler.playerEntity)) - { - ci.cancel(); - } - } - } - - public static void onUseItem(CallbackInfoReturnable ci, EntityPlayer player, World world, ItemStack itemStack, BlockPos pos, - EnumFacing side, float par8, float par9, float par10) - { - if (!(player instanceof EntityPlayerMP)) - { - return; - } - - if (!Proxy.broker.onUseItem(pos, side, (EntityPlayerMP)player)) - { - ci.setReturnValue(false); - } - } - - public static void onBlockClicked(CallbackInfo ci, ItemInWorldManager manager, BlockPos pos, EnumFacing side) - { - if (!Proxy.broker.onBlockClicked(pos, side, manager)) - { - ci.cancel(); - } - } - - public static void onPlayerMoved(CallbackInfo ci, NetHandlerPlayServer netHandler, C03PacketPlayer packet, WorldServer world, double oldPosX, - double oldPosY, double oldPosZ) - { - if (!Proxy.broker.onPlayerMove(netHandler, packet, netHandler.playerEntity, world)) - { - ci.cancel(); - } - } - - public static void onPlayerMoved(CallbackInfo ci, NetHandlerPlayServer netHandler, C03PacketPlayer packet, WorldServer world, double oldPosX, - double oldPosY, double oldPosZ, double deltaMoveSq, double deltaX, double deltaY, double deltaZ) - { - if (!Proxy.broker.onPlayerMove(netHandler, packet, netHandler.playerEntity, world)) - { - ci.cancel(); - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/ServerPluginChannels.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/ServerPluginChannels.java deleted file mode 100644 index b95bf5ae..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/ServerPluginChannels.java +++ /dev/null @@ -1,262 +0,0 @@ -package com.mumfrey.liteloader.core; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.INetHandler; -import net.minecraft.network.NetHandlerPlayServer; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.play.client.C17PacketCustomPayload; -import net.minecraft.network.play.server.S3FPacketCustomPayload; - -import com.mumfrey.liteloader.ServerPluginChannelListener; -import com.mumfrey.liteloader.api.Listener; -import com.mumfrey.liteloader.core.event.HandlerList; -import com.mumfrey.liteloader.core.exceptions.UnregisteredChannelException; -import com.mumfrey.liteloader.interfaces.FastIterableDeque; -import com.mumfrey.liteloader.permissions.PermissionsManagerServer; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Handler for server plugin channels - * - * @author Adam Mummery-Smith - */ -public class ServerPluginChannels extends PluginChannels -{ - private static ServerPluginChannels instance; - - public ServerPluginChannels() - { - if (ServerPluginChannels.instance != null) - { - InstantiationException inner = new InstantiationException("Only a single instance of ServerPluginChannels is allowed"); - throw new RuntimeException("Plugin Channels Startup Error", inner); - } - ServerPluginChannels.instance = this; - } - - @Override - protected FastIterableDeque createHandlerList() - { - return new HandlerList(ServerPluginChannelListener.class); - } - - public static ServerPluginChannels getInstance() - { - return instance; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider#initProvider() - */ - @Override - public void initProvider() - { - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider#getListenerBaseType() - */ - @Override - public Class getListenerBaseType() - { - return Listener.class; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider#registerInterfaces( - * com.mumfrey.liteloader.core.InterfaceRegistrationDelegate) - */ - @Override - public void registerInterfaces(InterfaceRegistrationDelegate delegate) - { - delegate.registerInterface(ServerPluginChannelListener.class); - } - - void addServerPluginChannelListener(ServerPluginChannelListener pluginChannelListener) - { - super.addPluginChannelListener(pluginChannelListener); - } - - void onServerStartup() - { - this.clearPluginChannels(null); - - // Enumerate mods for plugin channels - for (ServerPluginChannelListener pluginChannelListener : this.pluginChannelListeners) - { - this.addPluginChannelsFor(pluginChannelListener); - } - } - - void onPlayerJoined(EntityPlayerMP player) - { - this.sendRegisteredPluginChannels(player); - } - - /** - * Callback for the plugin channel hook - * - * @param netHandler - * @param customPayload - */ - public void onPluginChannelMessage(INetHandler netHandler, C17PacketCustomPayload customPayload) - { - if (customPayload != null && customPayload.getChannelName() != null) - { - String channel = customPayload.getChannelName(); - PacketBuffer data = customPayload.getBufferData(); - - EntityPlayerMP sender = ((NetHandlerPlayServer)netHandler).playerEntity; - this.onPluginChannelMessage(sender, channel, data); - } - } - - /** - * @param channel - * @param data - */ - private final void onPluginChannelMessage(EntityPlayerMP sender, String channel, PacketBuffer data) - { - if (PluginChannels.CHANNEL_REGISTER.equals(channel)) - { - this.onRegisterPacketReceived(data); - } - else if (this.pluginChannels.containsKey(channel)) - { - try - { - PermissionsManagerServer permissionsManager = LiteLoader.getServerPermissionsManager(); - if (permissionsManager != null) - { - permissionsManager.onCustomPayload(sender, channel, data); - } - } - catch (Exception ex) {} - - this.onModPacketReceived(sender, channel, data); - } - } - - /** - * @param sender - * @param channel - * @param data - */ - protected void onModPacketReceived(EntityPlayerMP sender, String channel, PacketBuffer data) - { - for (ServerPluginChannelListener pluginChannelListener : this.pluginChannels.get(channel)) - { - try - { - pluginChannelListener.onCustomPayload(sender, channel, data); - throw new RuntimeException(); - } - catch (Exception ex) - { - int failCount = 1; - if (this.faultingPluginChannelListeners.containsKey(pluginChannelListener)) - { - failCount = this.faultingPluginChannelListeners.get(pluginChannelListener).intValue() + 1; - } - - if (failCount >= PluginChannels.WARN_FAULT_THRESHOLD) - { - LiteLoaderLogger.warning("Plugin channel listener %s exceeded fault threshold on channel %s with %s", - pluginChannelListener.getName(), channel, ex.getClass().getSimpleName()); - this.faultingPluginChannelListeners.remove(pluginChannelListener); - } - else - { - this.faultingPluginChannelListeners.put(pluginChannelListener, Integer.valueOf(failCount)); - } - } - } - } - - protected void sendRegisteredPluginChannels(EntityPlayerMP player) - { - try - { - PacketBuffer registrationData = this.getRegistrationData(); - if (registrationData != null) - { - this.sendRegistrationData(player, registrationData); - } - } - catch (Exception ex) - { - LiteLoaderLogger.warning(ex, "Error dispatching REGISTER packet to client %s", player.getDisplayName()); - } - } - - /** - * @param recipient - * @param registrationData - */ - private void sendRegistrationData(EntityPlayerMP recipient, PacketBuffer registrationData) - { - ServerPluginChannels.dispatch(recipient, new S3FPacketCustomPayload(CHANNEL_REGISTER, registrationData)); - } - - /** - * Send a message to the specified client on a plugin channel - * - * @param recipient - * @param channel Channel to send, must not be a reserved channel name - * @param data - */ - public static boolean sendMessage(EntityPlayerMP recipient, String channel, PacketBuffer data, ChannelPolicy policy) - { - if (ServerPluginChannels.instance != null) - { - return ServerPluginChannels.instance.send(recipient, channel, data, policy); - } - - return false; - } - - /** - * Send a message to the specified client on a plugin channel - * - * @param recipient Recipient to send to - * @param channel Channel to send, must not be a reserved channel name - * @param data - */ - private boolean send(EntityPlayerMP recipient, String channel, PacketBuffer data, ChannelPolicy policy) - { - if (recipient == null) return false; - - if (channel == null || channel.length() > 16 || CHANNEL_REGISTER.equals(channel) || CHANNEL_UNREGISTER.equals(channel)) - { - throw new RuntimeException("Invalid channel name specified"); - } - - if (!policy.allows(this, channel)) - { - if (policy.isSilent()) return false; - throw new UnregisteredChannelException(channel); - } - - S3FPacketCustomPayload payload = new S3FPacketCustomPayload(channel, data); - return ServerPluginChannels.dispatch(recipient, payload); - } - - /** - * @param recipient - * @param payload - */ - static boolean dispatch(EntityPlayerMP recipient, S3FPacketCustomPayload payload) - { - try - { - if (recipient != null && recipient.playerNetServerHandler != null) - { - recipient.playerNetServerHandler.sendPacket(payload); - return true; - } - } - catch (Exception ex) {} - - return false; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/DefaultClassValidator.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/api/DefaultClassValidator.java deleted file mode 100644 index 0a2266d2..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/DefaultClassValidator.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.mumfrey.liteloader.core.api; - -import java.util.List; - -import com.mumfrey.liteloader.api.ModClassValidator; - -public class DefaultClassValidator implements ModClassValidator -{ - private final Class superClass; - - private final List supportedPrefixes; - - public DefaultClassValidator(Class superClass, List supportedPrefixes) - { - this.supportedPrefixes = supportedPrefixes; - this.superClass = superClass; - } - - @Override - public boolean validateName(String className) - { - return this.supportedPrefixes == null - || this.supportedPrefixes.size() == 0 - || DefaultClassValidator.startsWithAny(className, this.supportedPrefixes); - } - - @Override - public boolean validateClass(ClassLoader classLoader, Class candidateClass) - { - return (candidateClass != null - && !this.superClass.equals(candidateClass) - && this.superClass.isAssignableFrom(candidateClass) - && !candidateClass.isInterface()); - } - - private static boolean startsWithAny(String string, List candidates) - { - for (String candidate : candidates) - { - if (string.startsWith(candidate)) - { - return true; - } - } - - return false; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/DefaultEnumeratorPlugin.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/api/DefaultEnumeratorPlugin.java deleted file mode 100644 index 1aee5970..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/DefaultEnumeratorPlugin.java +++ /dev/null @@ -1,190 +0,0 @@ -package com.mumfrey.liteloader.core.api; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import com.mumfrey.liteloader.api.ContainerRegistry; -import com.mumfrey.liteloader.api.EnumeratorPlugin; -import com.mumfrey.liteloader.api.ModClassValidator; -import com.mumfrey.liteloader.api.manager.APIProvider; -import com.mumfrey.liteloader.core.exceptions.OutdatedLoaderException; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -public class DefaultEnumeratorPlugin implements EnumeratorPlugin -{ - private LoaderEnvironment environment; - - @Override - public void init(LoaderEnvironment environment, LoaderProperties properties) - { - this.environment = environment; - } - - @Override - public boolean checkEnabled(ContainerRegistry containers, LoadableMod container) - { - return container.isEnabled(this.environment); - } - - @Override - public boolean checkAPIRequirements(ContainerRegistry containers, LoadableMod container) - { - boolean result = true; - APIProvider apiProvider = this.environment.getAPIProvider(); - - for (String identifier : container.getRequiredAPIs()) - { - if (!apiProvider.isAPIAvailable(identifier)) - { - container.registerMissingAPI(identifier); - result = false; - } - } - - return result; - } - - @Override - public boolean checkDependencies(ContainerRegistry containers, LoadableMod base) - { - if (base == null || !base.hasDependencies()) return true; - - HashSet circularDependencySet = new HashSet(); - circularDependencySet.add(base.getIdentifier()); - - boolean result = this.checkDependencies(containers, base, base, circularDependencySet); - LiteLoaderLogger.info(Verbosity.REDUCED, "Dependency check for %s %s", base.getIdentifier(), result ? "passed" : "failed"); - - return result; - } - - private boolean checkDependencies(ContainerRegistry containers, LoadableMod base, LoadableMod container, Set circularDependencySet) - { - if (container.getDependencies().size() == 0) - { - return true; - } - - boolean result = true; - - for (String dependency : container.getDependencies()) - { - if (!circularDependencySet.contains(dependency)) - { - circularDependencySet.add(dependency); - - LoadableMod dependencyContainer = containers.getEnabledContainer(dependency); - if (dependencyContainer != LoadableMod.NONE) - { - String identifier = dependency; - if (this.environment.getEnabledModsList().isEnabled(this.environment.getProfile(), identifier)) - { - result &= this.checkDependencies(containers, base, dependencyContainer, circularDependencySet); - } - else - { -// LiteLoaderLogger.warning("Dependency %s required by %s is currently disabled", dependency, base.getIdentifier()); - base.registerMissingDependency(dependency); - result = false; - } - } - else - { -// LiteLoaderLogger.info("Dependency %s for %s is was not located, no container ", dependency, base.getIdentifier()); - base.registerMissingDependency(dependency); - result = false; - } - } - } - - return result; - } - - /** - * Enumerate classes on the classpath which are subclasses of the specified - * class - */ - @Override - public List> getClasses(LoadableMod container, ClassLoader classloader, ModClassValidator validator) - { - List> classes = new ArrayList>(); - - if (container != null) - { - try - { - for (String fullClassName : container.getContainedClassNames()) - { - boolean isDefaultPackage = fullClassName.lastIndexOf('.') == -1; - String className = isDefaultPackage ? fullClassName : fullClassName.substring(fullClassName.lastIndexOf('.') + 1); - if (validator.validateName(className)) - { - Class clazz = DefaultEnumeratorPlugin.checkClass(classloader, validator, fullClassName); - if (clazz != null && !classes.contains(clazz)) - { - classes.add(clazz); - } - } - } - } - catch (OutdatedLoaderException ex) - { - classes.clear(); - LiteLoaderLogger.info(Verbosity.REDUCED, "Error searching in '%s', missing API component '%s', your loader is probably out of date", - container, ex.getMessage()); - } - catch (Throwable th) - { - LiteLoaderLogger.warning(th, "Enumeration error"); - } - } - - return classes; - } - - @SuppressWarnings("unchecked") - private static Class checkClass(ClassLoader classLoader, ModClassValidator validator, String className) - throws OutdatedLoaderException - { - if (className.indexOf('$') > -1) - { - return null; - } - - try - { - Class candidateClass = classLoader.loadClass(className); - - if (validator.validateClass(classLoader, candidateClass)) - { - return (Class)candidateClass; - } - } - catch (Throwable th) - { - th.printStackTrace(); - - if (th.getCause() != null) - { - String missingClassName = th.getCause().getMessage(); - if (th.getCause() instanceof NoClassDefFoundError && missingClassName != null) - { - if (missingClassName.startsWith("com/mumfrey/liteloader/")) - { - throw new OutdatedLoaderException(missingClassName.substring(missingClassName.lastIndexOf('/') + 1)); - } - } - } - - LiteLoaderLogger.warning(th, "checkAndAddClass error while checking '%s'", className); - } - - return null; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/EnumeratorModuleClassPath.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/api/EnumeratorModuleClassPath.java deleted file mode 100644 index ecf5ec37..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/EnumeratorModuleClassPath.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.mumfrey.liteloader.core.api; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.launchwrapper.LaunchClassLoader; - -import com.mumfrey.liteloader.api.EnumeratorModule; -import com.mumfrey.liteloader.common.LoadingProgress; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.interfaces.ModularEnumerator; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -/** - * Enumerator module which searches for mods on the classpath - * - * @author Adam Mummery-Smith - */ -public class EnumeratorModuleClassPath implements EnumeratorModule -{ - /** - * Array of class path entries specified to the JVM instance - */ - private final String[] classPathEntries; - - /** - * URLs to add once init is completed - */ - private final List> loadableMods = new ArrayList>(); - - private boolean loadTweaks; - - public EnumeratorModuleClassPath() - { - // Read the JVM class path into the local array - this.classPathEntries = this.readClassPath(); - } - - @Override - public String toString() - { - return ""; - } - - @Override - public void init(LoaderEnvironment environment, LoaderProperties properties) - { - this.loadTweaks = properties.loadTweaksEnabled(); - } - - @Override - public void writeSettings(LoaderEnvironment environment, LoaderProperties properties) - { - } - - /** - * Reads the class path entries that were supplied to the JVM and returns - * them as an array. - */ - private String[] readClassPath() - { - LiteLoaderLogger.info("Enumerating class path..."); - - String classPath = System.getProperty("java.class.path"); - String classPathSeparator = System.getProperty("path.separator"); - String[] classPathEntries = classPath.split(classPathSeparator); - - LiteLoaderLogger.info("Class path separator=\"%s\"", classPathSeparator); - LiteLoaderLogger.info("Class path entries=(\n classpathEntry=%s\n)", classPath.replace(classPathSeparator, "\n classpathEntry=")); - return classPathEntries; - } - - @Override - public void enumerate(ModularEnumerator enumerator, String profile) - { - if (this.loadTweaks) - { - LiteLoaderLogger.info("Discovering tweaks on class path..."); - - for (String classPathPart : this.classPathEntries) - { - try - { - File packagePath = new File(classPathPart); - if (packagePath.exists()) - { - LoadableModClassPath classPathMod = new LoadableModClassPath(packagePath); - if (enumerator.registerModContainer(classPathMod)) - { - this.loadableMods.add(classPathMod); - if (classPathMod.requiresPreInitInjection()) - { - enumerator.registerTweakContainer(classPathMod); - } - } - else - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Mod %s is disabled or missing a required dependency, not injecting tranformers", - classPathMod.getIdentifier()); - } - } - } - catch (Throwable th) - { - LiteLoaderLogger.warning(th, "Error encountered whilst inspecting %s", classPathPart); - } - } - } - } - - @Override - public void injectIntoClassLoader(ModularEnumerator enumerator, LaunchClassLoader classLoader) - { - } - - /** - * @param classLoader - */ - @Override - public void registerMods(ModularEnumerator enumerator, LaunchClassLoader classLoader) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Discovering mods on class path..."); - LoadingProgress.incTotalLiteLoaderProgress(this.loadableMods.size()); - - for (LoadableMod classPathMod : this.loadableMods) - { - LiteLoaderLogger.info("Searching %s...", classPathMod); - LoadingProgress.incLiteLoaderProgress("Searching for mods in " + classPathMod.getModName() + "..."); - try - { - enumerator.registerModsFrom(classPathMod, true); - } - catch (Exception ex) - { - LiteLoaderLogger.warning(ex, "Error encountered whilst searching in %s...", classPathMod); - } - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/EnumeratorModuleFolder.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/api/EnumeratorModuleFolder.java deleted file mode 100644 index 7313fed0..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/EnumeratorModuleFolder.java +++ /dev/null @@ -1,411 +0,0 @@ -package com.mumfrey.liteloader.core.api; - -import java.io.File; -import java.io.FilenameFilter; -import java.net.MalformedURLException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.TreeSet; - -import net.minecraft.launchwrapper.LaunchClassLoader; - -import com.google.common.base.Charsets; -import com.mumfrey.liteloader.api.EnumeratorModule; -import com.mumfrey.liteloader.common.LoadingProgress; -import com.mumfrey.liteloader.core.LiteLoaderVersion; -import com.mumfrey.liteloader.interfaces.LoadableFile; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.interfaces.ModularEnumerator; -import com.mumfrey.liteloader.interfaces.TweakContainer; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -/** - * Enumerator module which searches for mods and tweaks in a folder - * - * @author Adam Mummery-Smith - */ -public class EnumeratorModuleFolder implements FilenameFilter, EnumeratorModule -{ - /** - * Ordered sets used to sort mods by version/revision - */ - protected final Map>> versionOrderingSets = new HashMap>>(); - - /** - * Mods to add once init is completed - */ - protected final List> loadableMods = new ArrayList>(); - - protected LiteLoaderCoreAPI coreAPI; - - protected File directory; - - protected boolean readJarFiles; - protected boolean loadTweaks; - protected boolean forceInjection; - - /** - * True if this is a versioned folder and the enumerator should also try to - * load tweak jars which would normally be ignored. - */ - protected final boolean loadTweakJars; - - public EnumeratorModuleFolder(LiteLoaderCoreAPI coreAPI, File directory, boolean loadTweakJars) - { - this.coreAPI = coreAPI; - this.directory = directory; - this.loadTweakJars = loadTweakJars; - } - - @Override - public void init(LoaderEnvironment environment, LoaderProperties properties) - { - this.loadTweaks = properties.loadTweaksEnabled(); - this.readJarFiles = properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_SEARCH_JARFILES, true); - this.forceInjection = properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_FORCE_INJECTION, false); - - this.coreAPI.writeDiscoverySettings(); - } - - /** - * Write settings - */ - @Override - public void writeSettings(LoaderEnvironment environment, LoaderProperties properties) - { - properties.setBooleanProperty(LoaderProperties.OPTION_SEARCH_JARFILES, this.readJarFiles); - properties.setBooleanProperty(LoaderProperties.OPTION_FORCE_INJECTION, this.forceInjection); - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() - { - return this.directory.getAbsolutePath(); - } - - /** - * Get the directory this module will inspect - */ - public File getDirectory() - { - return this.directory; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.Enumerator#getLoadableMods() - */ - public List> getLoadableMods() - { - return this.loadableMods; - } - - /** - * For FilenameFilter interface - * - * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String) - */ - @Override - public boolean accept(File dir, String fileName) - { - fileName = fileName.toLowerCase(); - - if (fileName.endsWith(".litemod.zip")) - { - LiteLoaderLogger.warning("Found %s with unsupported extension .litemod.zip." - + " Please change file extension to .litemod to allow this file to be loaded!", fileName); - return true; - } - - return fileName.endsWith(".litemod") || fileName.endsWith(".jar"); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.Enumerator - * #enumerate(com.mumfrey.liteloader.core.EnabledModsList, - * java.lang.String) - */ - @Override - public void enumerate(ModularEnumerator enumerator, String profile) - { - if (this.directory.exists() && this.directory.isDirectory()) - { - LiteLoaderLogger.info("Discovering valid mod files in folder %s", this.directory.getPath()); - - this.findValidFiles(enumerator); - this.sortAndRegisterFiles(enumerator); - } - } - - /** - * Search the folder for (potentially) valid files - */ - private void findValidFiles(ModularEnumerator enumerator) - { - for (File file : this.directory.listFiles(this.getFilenameFilter())) - { - LoadableFile candidateFile = new LoadableFile(file); - candidateFile.setForceInjection(this.forceInjection); - try - { - this.inspectFile(enumerator, candidateFile); - } - catch (Exception ex) - { - LiteLoaderLogger.warning(ex, "An error occurred whilst inspecting %s", candidateFile); - } - } - } - - /** - * Check whether a particular file is valid, and add it to the candiates - * list if it appears to be acceptable. - * - * @param enumerator - * @param candidateFile - */ - protected void inspectFile(ModularEnumerator enumerator, LoadableFile candidateFile) - { - if (this.isValidFile(enumerator, candidateFile)) - { - String metaData = candidateFile.getFileContents(LoadableMod.METADATA_FILENAME, Charsets.UTF_8); - if (metaData != null) - { - LoadableMod modFile = this.getModFile(candidateFile, metaData); - this.addModFile(enumerator, modFile); - return; - } - else if (this.isValidTweakContainer(candidateFile)) - { - TweakContainer container = this.getTweakFile(candidateFile); - this.addTweakFile(enumerator, container); - return; - } - else - { - LiteLoaderLogger.info("Ignoring %s", candidateFile); -// enumerator.registerBadContainer(candidateFile, "No metadata"); - } - } -// else -// { -// enumerator.registerBadContainer(candidateFile, "Not a valid file"); -// } - } - - /** - * Check whether the specified file is a valid mod container - * - * @param enumerator - * @param candidateFile - */ - protected boolean isValidFile(ModularEnumerator enumerator, LoadableFile candidateFile) - { - String filename = candidateFile.getName().toLowerCase(); - if (filename.endsWith(".litemod.zip")) - { - enumerator.registerBadContainer(candidateFile, "Invalid file extension .litemod.zip"); - return false; - } - else if (filename.endsWith(".litemod")) - { - return true; - } - else if (filename.endsWith(".jar")) - { - Set modSystems = candidateFile.getModSystems(); - boolean hasLiteLoader = modSystems.contains("LiteLoader"); - if (modSystems.size() > 0) - { - LiteLoaderLogger.info("%s supports mod systems %s", candidateFile, modSystems); - if (!hasLiteLoader) return false; - } - - return this.loadTweakJars || this.readJarFiles || hasLiteLoader; - } - - return false; - } - - /** - * Called only if the file is not a valid mod container (has no mod - * metadata) to check whether it could instead be a potential tweak - * container. - * - * @param candidateFile - */ - protected boolean isValidTweakContainer(LoadableFile candidateFile) - { - return this.loadTweakJars && this.loadTweaks && candidateFile.getName().toLowerCase().endsWith(".jar"); - } - - /** - * Get the {@link FilenameFilter} to use to filter candidate files - */ - protected FilenameFilter getFilenameFilter() - { - return this; - } - - /** - * @param modFile - */ - protected boolean isFileSupported(LoadableMod modFile) - { - return LiteLoaderVersion.CURRENT.isVersionSupported(modFile.getTargetVersion()); - } - - /** - * @param candidateFile - * @param metaData - */ - protected LoadableMod getModFile(LoadableFile candidateFile, String metaData) - { - return new LoadableModFile(candidateFile, metaData); - } - - /** - * @param candidateFile - */ - protected TweakContainer getTweakFile(LoadableFile candidateFile) - { - return candidateFile; - } - - /** - * @param enumerator - * @param modFile - */ - protected void addModFile(ModularEnumerator enumerator, LoadableMod modFile) - { - if (modFile.hasValidMetaData()) - { - // Only add the mod if the version matches, we add candidates to the versionOrderingSets in - // order to determine the most recent version available. - if (this.isFileSupported(modFile)) - { - if (!this.versionOrderingSets.containsKey(modFile.getName())) - { - this.versionOrderingSets.put(modFile.getModName(), new TreeSet>()); - } - - LiteLoaderLogger.info("Considering valid mod file: %s", modFile); - this.versionOrderingSets.get(modFile.getModName()).add(modFile); - } - else - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Not adding invalid or version-mismatched mod file: %s", modFile); - enumerator.registerBadContainer(modFile, "Version not supported"); - } - } - } - - /** - * @param enumerator - * @param container - */ - protected void addTweakFile(ModularEnumerator enumerator, TweakContainer container) - { - enumerator.registerTweakContainer(container); - } - - /** - * @param enumerator - */ - protected void sortAndRegisterFiles(ModularEnumerator enumerator) - { - // Copy the first entry in every version set into the modfiles list - for (Entry>> modFileEntry : this.versionOrderingSets.entrySet()) - { - LoadableMod newestVersion = modFileEntry.getValue().iterator().next(); - this.registerFile(enumerator, newestVersion); - } - - this.versionOrderingSets.clear(); - } - - /** - * @param enumerator - * @param modFile - */ - @SuppressWarnings("unchecked") - protected void registerFile(ModularEnumerator enumerator, LoadableMod modFile) - { - if (enumerator.registerModContainer(modFile)) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Adding newest valid mod file '%s' at revision %.4f", modFile, modFile.getRevision()); - this.loadableMods.add(modFile); - } - else - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Not adding valid mod file '%s', the specified mod is disabled or missing a required dependency", - modFile); - } - - if (this.loadTweaks) - { - try - { - if (modFile instanceof TweakContainer) - { - this.addTweakFile(enumerator, (TweakContainer)modFile); - } - } - catch (Throwable th) - { - LiteLoaderLogger.warning("Error adding tweaks from '%s'", modFile); - } - } - } - - @Override - public void injectIntoClassLoader(ModularEnumerator enumerator, LaunchClassLoader classLoader) - { - LiteLoaderLogger.info("Injecting external mods into class path..."); - - for (LoadableMod loadableMod : this.loadableMods) - { - try - { - if (loadableMod.injectIntoClassPath(classLoader, false)) - { - LiteLoaderLogger.info("Successfully injected mod file '%s' into classpath", loadableMod); - } - } - catch (MalformedURLException ex) - { - LiteLoaderLogger.warning("Error injecting '%s' into classPath. The mod will not be loaded", loadableMod); - } - } - } - - @Override - public void registerMods(ModularEnumerator enumerator, LaunchClassLoader classLoader) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Discovering mods in valid mod files..."); - LoadingProgress.incTotalLiteLoaderProgress(this.loadableMods.size()); - - for (LoadableMod modFile : this.loadableMods) - { - LoadingProgress.incLiteLoaderProgress("Searching for mods in " + modFile.getModName() + "..."); - LiteLoaderLogger.info("Searching %s...", modFile); - try - { - enumerator.registerModsFrom(modFile, true); - } - catch (Exception ex) - { - LiteLoaderLogger.warning("Error encountered whilst searching in %s...", modFile); - } - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/LiteLoaderCoreAPI.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/api/LiteLoaderCoreAPI.java deleted file mode 100644 index fcd7610c..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/LiteLoaderCoreAPI.java +++ /dev/null @@ -1,176 +0,0 @@ -package com.mumfrey.liteloader.core.api; - -import java.io.File; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.spongepowered.asm.mixin.MixinEnvironment.CompatibilityLevel; - -import com.mumfrey.liteloader.api.EnumeratorModule; -import com.mumfrey.liteloader.api.LiteAPI; -import com.mumfrey.liteloader.api.MixinConfigProvider; -import com.mumfrey.liteloader.core.LiteLoaderVersion; -import com.mumfrey.liteloader.interfaces.ObjectFactory; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.launch.LoaderProperties; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * LiteLoader's API impl. - * - * @author Adam Mummery-Smith - */ -public abstract class LiteLoaderCoreAPI implements LiteAPI, MixinConfigProvider -{ - protected static final String PKG_LITELOADER = "com.mumfrey.liteloader"; - protected static final String PKG_LITELOADER_COMMON = LiteLoaderCoreAPI.PKG_LITELOADER + ".common"; - - protected LoaderEnvironment environment; - - protected LoaderProperties properties; - - protected boolean searchClassPath; - protected boolean searchModsFolder; - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#getIdentifier() - */ - @Override - public String getIdentifier() - { - return "liteloader"; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#getName() - */ - @Override - public String getName() - { - return "LiteLoader core API"; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#getVersion() - */ - @Override - public String getVersion() - { - return LiteLoaderVersion.CURRENT.getLoaderVersion(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#getRevision() - */ - @Override - public int getRevision() - { - return LiteLoaderVersion.CURRENT.getLoaderRevision(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#getModClassPrefix() - */ - @Override - public String getModClassPrefix() - { - return "LiteMod"; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#init( - * com.mumfrey.liteloader.launch.LoaderEnvironment, - * com.mumfrey.liteloader.launch.LoaderProperties) - */ - @Override - public void init(LoaderEnvironment environment, LoaderProperties properties) - { - this.environment = environment; - this.properties = properties; - } - - /** - * Get the discovery settings from the properties file - */ - void readDiscoverySettings() - { - this.searchModsFolder = this.properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_SEARCH_MODS, true); - this.searchClassPath = this.properties.getAndStoreBooleanProperty(LoaderProperties.OPTION_SEARCH_CLASSPATH, true); - - if (!this.searchModsFolder && !this.searchClassPath) - { - LiteLoaderLogger.warning("Invalid configuration, no search locations defined. Enabling all search locations."); - - this.searchModsFolder = true; - this.searchClassPath = true; - } - } - - /** - * Write settings - */ - void writeDiscoverySettings() - { - this.properties.setBooleanProperty(LoaderProperties.OPTION_SEARCH_MODS, this.searchModsFolder); - this.properties.setBooleanProperty(LoaderProperties.OPTION_SEARCH_CLASSPATH, this.searchClassPath); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.LiteAPI#getEnumeratorModules() - */ - @Override - public List getEnumeratorModules() - { - this.readDiscoverySettings(); - - List enumeratorModules = new ArrayList(); - - if (this.searchClassPath) - { - enumeratorModules.add(new EnumeratorModuleClassPath()); - } - - if (this.searchModsFolder) - { - File modsFolder = this.environment.getModsFolder(); - enumeratorModules.add(new EnumeratorModuleFolder(this, modsFolder, false)); - - File versionedModsFolder = this.environment.getVersionedModsFolder(); - enumeratorModules.add(new EnumeratorModuleFolder(this, versionedModsFolder, true)); - } - - return Collections.unmodifiableList(enumeratorModules); - } - - /** - * Get the ObjectFactory - */ - public abstract ObjectFactory getObjectFactory(); - - @Override - public MixinConfigProvider getMixins() - { - return this; - } - - @Override - public CompatibilityLevel getCompatibilityLevel() - { - return null; - } - - @Override - public String[] getMixinConfigs() - { - return new String[] { - "mixins.liteloader.core.json" - }; - } - - @Override - public String[] getErrorHandlers() - { - return null; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/LoadableModClassPath.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/api/LoadableModClassPath.java deleted file mode 100644 index 778036f4..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/LoadableModClassPath.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.mumfrey.liteloader.core.api; - -import java.io.File; -import java.net.MalformedURLException; - -import net.minecraft.launchwrapper.LaunchClassLoader; - -import com.mumfrey.liteloader.core.LiteLoaderVersion; - -/** - * Mod file reference for a file loaded from class path - * - * @author Adam Mummery-Smith - */ -public class LoadableModClassPath extends LoadableModFile -{ - private static final long serialVersionUID = -4759310661966590773L; - - private boolean modNameRequired = false; - - LoadableModClassPath(File file) - { - this(file, null); - } - - LoadableModClassPath(File file, String fallbackName) - { - super(file, LoadableModFile.getVersionMetaDataString(file)); - - if (this.modName == null) - { - if (fallbackName != null) - { - this.modName = fallbackName; - } - else if (this.isFile()) - { - this.modName = this.getName().substring(0, this.getName().lastIndexOf('.')); - } - else - { - String parentFileName = this.getParentFile() != null ? this.getParentFile().getName().toLowerCase() : ""; - this.modName = String.format("%s.%s", parentFileName, this.getName().toLowerCase()); - this.modNameRequired = true; - } - } - - if (this.targetVersion == null) this.targetVersion = LiteLoaderVersion.CURRENT.getMinecraftVersion(); - } - - @Override - protected void readJarMetaData() - { - // Nope - } - - @Override - protected String getDefaultName() - { - return null; - } - - @Override - public String getDisplayName() - { - return this.getModName(); - } - - @Override - public boolean injectIntoClassPath(LaunchClassLoader classLoader, boolean injectIntoParent) throws MalformedURLException - { - // Can't inject a class path entry into the class path! - return false; - } - - @Override - public boolean isInjected() - { - return true; - } - - @Override - public void addContainedMod(String modName) - { - if (this.modNameRequired) - { - this.modNameRequired = false; - this.modName = modName; - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/LoadableModFile.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/api/LoadableModFile.java deleted file mode 100644 index 011e9afc..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/api/LoadableModFile.java +++ /dev/null @@ -1,598 +0,0 @@ -package com.mumfrey.liteloader.core.api; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.regex.Matcher; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import joptsimple.internal.Strings; - -import com.google.common.base.Charsets; -import com.google.common.io.ByteStreams; -import com.google.gson.Gson; -import com.google.gson.JsonSyntaxException; -import com.mumfrey.liteloader.api.manager.APIProvider; -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.interfaces.LoadableFile; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.launch.InjectionStrategy; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Wrapper for file which represents a mod file to load with associated version - * information and metadata. Retrieve this from litemod.json at enumeration - * time. We also override comparable to provide our own custom sorting logic - * based on version info. - * - * @author Adam Mummery-Smith - */ -public class LoadableModFile extends LoadableFile implements LoadableMod -{ - private static final long serialVersionUID = -7952147161905688459L; - - /** - * Maximum recursion depth for mod discovery - */ - private static final int MAX_DISCOVERY_DEPTH = 16; - - /** - * Gson parser for JSON - */ - protected static Gson gson = new Gson(); - - /** - * True if the metadata information is parsed successfully, the mod will be - * added. - */ - protected boolean valid = false; - - /** - * Name of the mod specified in the JSON file, this can be any string but - * should be the same between mod versions. - */ - protected String modName; - - /** - * Loader version - */ - protected String targetVersion; - - /** - * Name of the class transof - */ - protected List classTransformerClassNames = new ArrayList(); - - /** - * File time stamp, used as sorting criteria when no revision information is - * found. - */ - protected long timeStamp; - - /** - * Revision number from the json file - */ - protected float revision = 0.0F; - - /** - * True if the revision number was successfully read, used as a semaphore so - * that we know when revision is a valid number. - */ - protected boolean hasRevision = false; - - /** - * ALL of the parsed metadata from the file, associated with the mod later - * on for retrieval via the loader. - */ - protected Map metaData = new HashMap(); - - /** - * Dependencies declared in the metadata - */ - private Set dependencies = new HashSet(); - - /** - * Dependencies which are missing - */ - private Set missingDependencies = new HashSet();; - - /** - * Required APIs declared in the metadata - */ - private Set requiredAPIs = new HashSet(); - - /** - * Required APIs which are missing - */ - private Set missingAPIs = new HashSet(); - - /** - * Classes in this container - */ - protected List classNames = null; - - /** - * @param file - * @param metaData - */ - protected LoadableModFile(File file, String metaData) - { - super(file.getAbsolutePath()); - this.init(metaData); - } - - /** - * @param file - * @param metaData - */ - protected LoadableModFile(LoadableFile file, String metaData) - { - super(file); - this.init(metaData); - } - - /** - * @param metaData - */ - @SuppressWarnings("unchecked") - protected void init(String metaData) - { - this.timeStamp = this.lastModified(); - this.tweakPriority = 0; - - if (!Strings.isNullOrEmpty(metaData)) - { - try - { - this.metaData = LoadableModFile.gson.fromJson(metaData, HashMap.class); - } - catch (JsonSyntaxException jsx) - { - LiteLoaderLogger.warning("Error reading %s in %s, JSON syntax exception: %s", - LoadableMod.METADATA_FILENAME, this.getAbsolutePath(), jsx.getMessage()); - return; - } - - this.valid = this.parseMetaData(); - } - } - - protected boolean parseMetaData() - { - try - { - this.modName = this.getMetaValue("name", this.getDefaultName()); - this.displayName = this.getMetaValue("displayName", this.modName); - this.version = this.getMetaValue("version", "Unknown"); - this.author = this.getMetaValue("author", "Unknown"); - - if (!this.parseVersions()) return false; - - this.injectionStrategy = InjectionStrategy.parseStrategy(this.getMetaValue("injectAt", null)); - - this.tweakClassName = this.getMetaValue("tweakClass", this.tweakClassName); - - this.getMetaValuesInto(this.classTransformerClassNames, "classTransformerClasses", ","); - this.getMetaValuesInto(this.dependencies, "dependsOn", ","); - this.getMetaValuesInto(this.requiredAPIs, "requiredAPIs", ","); - this.getMetaValuesInto(this.mixinConfigs, "mixinConfigs", ","); - } - catch (ClassCastException ex) - { - LiteLoaderLogger.debug(ex); - LiteLoaderLogger.warning("Error parsing version metadata file in %s, check the format of the file", this.getAbsolutePath()); - } - - return true; - } - - public boolean parseVersions() - { - this.targetVersion = this.getMetaValue("mcversion", null); - if (this.targetVersion == null) - { - LiteLoaderLogger.warning("Mod in %s has no loader version number reading %s", this.getAbsolutePath(), LoadableMod.METADATA_FILENAME); - return false; - } - - try - { - this.revision = Float.parseFloat(this.getMetaValue("revision", null)); - this.hasRevision = true; - } - catch (NullPointerException ex) {} - catch (Exception ex) - { - LiteLoaderLogger.warning("Mod in %s has an invalid revision number reading %s", this.getAbsolutePath(), LoadableMod.METADATA_FILENAME); - } - - return true; - } - - protected String getDefaultName() - { - return this.getName().replaceAll("[^a-zA-Z]", ""); - } - - @Override - public String getModName() - { - return this.modName; - } - - @Override - public String getIdentifier() - { - return this.modName.toLowerCase(); - } - - @Override - public String getDescription(String key) - { - if (this.missingAPIs.size() > 0) - { - return LiteLoader.translate("gui.description.missingapis", "\n" + this.compileMissingAPIList()); - } - - if (this.missingDependencies.size() > 0) - { - return LiteLoader.translate("gui.description.missingdeps", "\n" + this.missingDependencies.toString()); - } - - String descriptionKey = "description"; - if (key != null && key.length() > 0) - { - descriptionKey += "." + key.toLowerCase(); - } - - return this.getMetaValue(descriptionKey, this.getMetaValue("description", "")); - } - - private String compileMissingAPIList() - { - StringBuilder missingAPIList = new StringBuilder(); - - for (String missingAPI : this.missingAPIs) - { - if (missingAPI != null) - { - if (missingAPI.contains("@")) - { - Matcher matcher = APIProvider.idAndRevisionPattern.matcher(missingAPI); - if (matcher.matches()) - { - missingAPIList.append(" ").append(matcher.group(1)).append(" (revision ").append(matcher.group(2)).append(")\n"); - continue; - } - } - - missingAPIList.append(" ").append(missingAPI).append("\n"); - } - } - - return missingAPIList.toString(); - } - - @Override - public boolean isEnabled(LoaderEnvironment environment) - { - return this.missingDependencies.size() == 0 && this.missingAPIs.size() == 0 && super.isEnabled(environment); - } - - @Override - public boolean isExternalJar() - { - return false; - } - - @Override - public boolean isToggleable() - { - return true; - } - - @Override - public boolean hasValidMetaData() - { - return this.valid; - } - - @Override - public String getTargetVersion() - { - return this.targetVersion; - } - - @Override - public float getRevision() - { - return this.revision; - } - - protected Object getMetaValue(String metaKey) - { - Object metaValue = this.metaData.get(metaKey); - if (metaValue != null) return metaValue; - return this.metaData.get(metaKey.toLowerCase()); - } - - @Override - public String getMetaValue(String metaKey, String defaultValue) - { - Object metaValue = this.getMetaValue(metaKey); - return metaValue != null ? metaValue.toString() : defaultValue; - } - - @SuppressWarnings("unchecked") - public String[] getMetaValues(String metaKey, String separator) - { - Object metaValue = this.getMetaValue(metaKey); - - if (metaValue instanceof String) - { - return ((String)metaValue).split(separator); - } - else if (metaValue instanceof ArrayList) - { - return ((ArrayList)metaValue).toArray(new String[0]); - } - - return new String[0]; - } - - protected void getMetaValuesInto(Collection collection, String metaKey, String separator) - { - for (String name : this.getMetaValues(metaKey, separator)) - { - if (!Strings.isNullOrEmpty(name)) - { - collection.add(name); - } - } - } - - @Override - public Set getMetaDataKeys() - { - return Collections.unmodifiableSet(this.metaData.keySet()); - } - - @Override - public boolean hasClassTransformers() - { - return this.classTransformerClassNames.size() > 0; - } - - @Override - public List getClassTransformerClassNames() - { - return this.classTransformerClassNames; - } - - @Override - public boolean hasResources() - { - return true; - } - - @Override - public boolean hasDependencies() - { - return this.dependencies.size() > 0; - } - - @Override - public Set getDependencies() - { - return this.dependencies; - } - - @Override - public void registerMissingDependency(String dependency) - { - this.missingDependencies.add(dependency); - } - - @Override - public Set getMissingDependencies() - { - return this.missingDependencies; - } - - @Override - public Set getRequiredAPIs() - { - return this.requiredAPIs; - } - - @Override - public void registerMissingAPI(String identifier) - { - this.missingAPIs.add(identifier); - } - - @Override - public Set getMissingAPIs() - { - return this.missingAPIs; - } - - @Override - public List getContainedClassNames() - { - if (this.classNames == null) - { - this.classNames = this.enumerateClassNames(); - } - - return this.classNames; - } - - protected List enumerateClassNames() - { - if (this.isDirectory()) - { - return LoadableModFile.enumerateDirectory(new ArrayList(), this, "", 0); - } - - return LoadableModFile.enumerateZipFile(this); - } - - @Override - public void addContainedMod(String modName) - { - } - - @Override - public int compareTo(File other) - { - if (other == null || !(other instanceof LoadableModFile)) return -1; - - LoadableModFile otherMod = (LoadableModFile)other; - - // If the other object has a revision, compare revisions - if (otherMod.hasRevision) - { - return this.hasRevision && this.revision - otherMod.revision > 0 ? -1 : 1; - } - - // If we have a revision and the other object doesn't, then we are higher - if (this.hasRevision) - { - return -1; - } - - // Give up and use timestamp - return (int)(otherMod.timeStamp - this.timeStamp); - } - - protected static List enumerateZipFile(File file) - { - List classes = new ArrayList(); - - ZipFile zipFile; - try - { - zipFile = new ZipFile(file); - } - catch (IOException ex) - { - return classes; - } - - @SuppressWarnings("unchecked") - Enumeration entries = (Enumeration)zipFile.entries(); - while (entries.hasMoreElements()) - { - ZipEntry entry = entries.nextElement(); - String entryName = entry.getName(); - if (entry.getSize() > 0 && entryName.endsWith(".class")) - { - classes.add(entryName.substring(0, entryName.length() - 6).replace('/', '.')); - } - } - - try - { - zipFile.close(); - } - catch (IOException ex) {} - - return classes; - } - - /** - * Recursive function to enumerate classes inside a classpath folder - * - * @param classes - * @param packagePath - * @param packageName - */ - protected static List enumerateDirectory(List classes, File packagePath, String packageName, int depth) - { - // Prevent crash due to broken recursion - if (depth > MAX_DISCOVERY_DEPTH) - { - return classes; - } - - File[] classFiles = packagePath.listFiles(); - - for (File classFile : classFiles) - { - if (classFile.isDirectory()) - { - LoadableModFile.enumerateDirectory(classes, classFile, packageName + classFile.getName() + ".", depth + 1); - } - else - { - if (classFile.getName().endsWith(".class")) - { - String classFileName = classFile.getName(); - classes.add(packageName + classFileName.substring(0, classFileName.length() - 6)); - } - } - } - - return classes; - } - - /** - * @param zip - * @param entry - * @throws IOException - */ - public static String zipEntryToString(ZipFile zip, ZipEntry entry) throws IOException - { - InputStream stream = null; - Charset charset = Charsets.UTF_8; - int bomOffset = 0; - byte[] bytes; - - try - { - stream = zip.getInputStream(entry); - bytes = ByteStreams.toByteArray(stream); - } - finally - { - if (stream != null) stream.close(); - } - - if (bytes == null || bytes.length == 0) return ""; - - // Handle unicode by looking for BOM - if (bytes.length > 1) - { - if (bytes[0] == (byte)0xFF && bytes[1] == (byte)0xFE) - { - charset = Charsets.UTF_16LE; - bomOffset = 2; - } - else if (bytes[0] == (byte)0xFE && bytes[1] == (byte)0xFF) - { - charset = Charsets.UTF_16BE; - bomOffset = 2; - } - } - - return new String(bytes, bomOffset, bytes.length - bomOffset, charset); - } - - protected static String getVersionMetaDataString(File file) - { - return LoadableFile.getFileContents(file, LoadableMod.METADATA_FILENAME, Charsets.UTF_8); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/event/Cancellable.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/event/Cancellable.java deleted file mode 100644 index c88d5ca7..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/event/Cancellable.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mumfrey.liteloader.core.event; - -/** - * Interface for (potentially) cancellable things :) - * - * @author Adam Mummery-Smith - */ -public interface Cancellable -{ - /** - * Get whether this is actually cancellable - */ - public abstract boolean isCancellable(); - - /** - * Get whether this is cancelled - */ - public abstract boolean isCancelled(); - - /** - * If the object is cancellable, cancels the object, implementors may throw - * an EventCancellationException if the object is not actually cancellable. - * - * @throws EventCancellationException (optional) may be thrown if the object - * is not actually cancellable - */ - public abstract void cancel() throws EventCancellationException; -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/event/EventCancellationException.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/event/EventCancellationException.java deleted file mode 100644 index de7f18a5..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/event/EventCancellationException.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.mumfrey.liteloader.core.event; - -public class EventCancellationException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public EventCancellationException() - { - } - - public EventCancellationException(String message) - { - super(message); - } - - public EventCancellationException(Throwable cause) - { - super(cause); - } - - public EventCancellationException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/event/EventProxy.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/event/EventProxy.java deleted file mode 100644 index 00288a22..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/event/EventProxy.java +++ /dev/null @@ -1,212 +0,0 @@ -package com.mumfrey.liteloader.core.event; - -import java.util.concurrent.Callable; - -import javax.management.RuntimeErrorException; - -import net.minecraft.crash.CrashReport; -import net.minecraft.crash.CrashReportCategory; - -import org.objectweb.asm.Type; - -import com.mumfrey.liteloader.transformers.ByteCodeUtilities; -import com.mumfrey.liteloader.transformers.event.EventInfo; - -/** - * EventProxy is a special class used by the EventInjectionTransformer, it is a - * stub class into which all of the injected event callback methods are - * injected. Each event handler method contains a try/catch block which invokes - * one of the error reporting methods contained below when an error occurs, in - * order to provide more meaningful information to the user and to mod makers. - * - * @author Adam Mummery-Smith - */ -public final class EventProxy -{ - static String error; - static StringBuilder errorDetails; - - static - { - new Exception().printStackTrace(); - if (true) throw new InstantiationError("EventProxy was loaded before transformation, this is bad!"); - } - - /** - * Private because we never instance this class! - */ - private EventProxy() {} - - // The event injection subsystem creates event stubs in this class which (if written in java) would - // look something like the following: - // - // public static void $event00000(EventInfo e) - // { - // try - // { - // // Handlers sorted by priority - // com.example.mod.EventHandler.onWhateverEvent(e); - // com.example.anothermod.FooClass.onBarEvent(e); - // } - // catch (NoClassDefFoundError err) - // { - // onMissingClass(err, e); - // } - // catch (NoSuchMethodError err) - // { - // onMissingHandler(err, e); - // } - // } - - protected static void onMissingClass(Error err, EventInfo e) - { - EventProxy.error = "Missing Event Handler Class!"; - EventProxy.errorDetails = new StringBuilder(); - - EventProxy.addCrashDetailLine("\n"); - EventProxy.addCrashDetailLine("You are seeing this message because an event callback was injected by the Event"); - EventProxy.addCrashDetailLine("Injection Subsystem but the specified callback class was not defined! The"); - EventProxy.addCrashDetailLine("details of the missing callback are as follows:"); - EventProxy.addDetailLineBreak(); - EventProxy.addCrashDetailLine(" Event Name: " + e.getName()); - EventProxy.addCrashDetailLine(" Cancellable: " + e.isCancellable()); - EventProxy.addDetailLineBreak(); - EventProxy.addCrashDetailLine(" Callback class: " + err.getMessage().replace('/', '.')); - EventProxy.addDetailLineBreak(); - EventProxy.addCrashDetailLine("If you are the mod author then in order to fix the error you must provide an"); - EventProxy.addCrashDetailLine("implementation for the specified class, or check that the class name and package"); - EventProxy.addCrashDetailLine("are correct."); - EventProxy.addDetailLineBreak(); - EventProxy.addCrashDetailLine("This is an unrecoverable error, please report it to the mod author and remove"); - EventProxy.addCrashDetailLine("the offending mod."); - EventProxy.addStackTrace(err); - - throw new RuntimeErrorException(err, "Missing event handler class for event " + e.getName() + ", see crash report for details"); - } - - protected static void onMissingHandler(Error err, EventInfo e) - { - String descriptor = err.getMessage(); - int dotPos = descriptor.lastIndexOf('.'); - int bracketPos = descriptor.indexOf('('); - - String signature = descriptor.substring(bracketPos); - String sourceClass = e.getSource() != null ? e.getSource().getClass().getSimpleName() : "?"; - - EventProxy.error = "Missing Event Handler Method!"; - EventProxy.errorDetails = new StringBuilder(); - - EventProxy.addCrashDetailLine("\n"); - EventProxy.addCrashDetailLine("You are seeing this message because an event callback was injected by the Event"); - EventProxy.addCrashDetailLine("Injection Subsystem but the specified callback method was not defined. The"); - EventProxy.addCrashDetailLine("details of the missing callback are as follows:"); - EventProxy.addDetailLineBreak(); - EventProxy.addCrashDetailLine(" Event Name: " + e.getName()); - EventProxy.addCrashDetailLine(" Cancellable: " + e.isCancellable()); - EventProxy.addDetailLineBreak(); - EventProxy.addCrashDetailLine(" Callback class: " + descriptor.substring(0, dotPos)); - EventProxy.addCrashDetailLine(" Callback method: " + descriptor.substring(dotPos + 1, bracketPos)); - EventProxy.addDetailLineBreak(); - EventProxy.addCrashDetailLine("If you are the mod author then in order to fix the error you must add a suitable"); - EventProxy.addCrashDetailLine("callback method in the above class. The method signature should be as follows:"); - EventProxy.addDetailLineBreak(); - EventProxy.addCrashDetailLine(EventProxy.generateHandlerTemplate(descriptor.substring(dotPos + 1, bracketPos), signature, sourceClass)); - EventProxy.addDetailLineBreak(); - EventProxy.addCrashDetailLine("This is an unrecoverable error, please report it to the mod author and remove"); - EventProxy.addCrashDetailLine("the offending mod."); - EventProxy.addStackTrace(err); - - throw new RuntimeErrorException(err, "Missing event handler method for event " + e.getName() + ", see crash report for details"); - } - - private static void addStackTrace(Error err) - { - EventProxy.addDetailLineBreak(); - EventProxy.errorDetails.append("Stacktrace:").append('\n'); - EventProxy.addDetailLineBreak(); - - StackTraceElement[] stackTrace = err.getStackTrace(); - for (int i = 0; i < stackTrace.length; i++) - { - EventProxy.addCrashDetailLine(String.format(" %3d) %s", i + 1, stackTrace[i])); - } - } - - protected static String generateHandlerTemplate(String methodName, String signature, String sourceClass) - { - Type[] argTypes = Type.getArgumentTypes(signature); - - StringBuilder tpl = new StringBuilder(); - tpl.append(" public static void ").append(methodName).append('('); - for (int var = 0; var < argTypes.length; var++) - { - if (EventProxy.appendTypeName(tpl, argTypes[var], sourceClass)) tpl.append("[]"); - if (var == 0) tpl.append(" e"); - if (var > 0) tpl.append(" arg").append(String.valueOf(var)); - if (var < argTypes.length - 1) tpl.append(", "); - } - tpl.append(")\n\t {\n\t // handler code here\n\t }"); - - String template = tpl.toString(); - if (template.contains(", ReturnType>")) - { - template = template.replace("static void", "static void"); - } - return template; - } - - private static boolean appendTypeName(StringBuilder tpl, Type type, String sourceClass) - { - switch (type.getSort()) - { - case Type.ARRAY: - EventProxy.appendTypeName(tpl, type.getElementType(), sourceClass); - return true; - case Type.OBJECT: - String typeName = type.getClassName(); - typeName = typeName.substring(typeName.lastIndexOf('.') + 1); - tpl.append(typeName); - if (typeName.endsWith("ReturnEventInfo")) - { - tpl.append('<').append(sourceClass).append(", ReturnType>"); - } - else if (typeName.endsWith("EventInfo")) - { - tpl.append('<').append(sourceClass).append('>'); - } - return false; - default: - tpl.append(ByteCodeUtilities.getTypeName(type)); - return false; - } - } - - private static void addDetailLineBreak() - { - System.err.println(); - EventProxy.errorDetails.append('\n'); - } - - private static void addCrashDetailLine(String string) - { - System.err.println(string); - EventProxy.errorDetails.append('\t').append(string).append('\n'); - } - - public static void populateCrashReport(CrashReport crashReport) - { - if (EventProxy.error != null) - { - CrashReportCategory category = crashReport.makeCategoryDepth("Event Handler Error", 1); - - category.addCrashSectionCallable(EventProxy.error, new Callable() - { - @Override - public String call() throws Exception - { - return EventProxy.errorDetails.toString(); - } - }); - } - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/event/HandlerList.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/event/HandlerList.java deleted file mode 100644 index 9eb77168..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/event/HandlerList.java +++ /dev/null @@ -1,1112 +0,0 @@ -package com.mumfrey.liteloader.core.event; - -import java.io.Closeable; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Constructor; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -import net.minecraft.launchwrapper.IClassTransformer; -import net.minecraft.launchwrapper.Launch; - -import org.apache.commons.io.FileUtils; -import org.apache.logging.log4j.core.helpers.Booleans; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Label; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.*; -import org.objectweb.asm.util.CheckClassAdapter; - -import com.mumfrey.liteloader.Priority; -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.interfaces.FastIterableDeque; -import com.mumfrey.liteloader.transformers.ByteCodeUtilities; -import com.mumfrey.liteloader.util.SortableValue; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * HandlerList is a generic class which supports baking a list of event handlers - * into a dynamic inner class for invocation at runtime. - * - * @author Adam Mummery-Smith - * - * @param - */ -public class HandlerList extends LinkedList implements FastIterableDeque -{ - private static final long serialVersionUID = 1L; - - private static final int MAX_UNCOLLECTED_CLASSES = 5000; - - private static int uncollectedHandlerLists = 0; - - /** - * Enum for logic operations supported between handlers which return bool - */ - public enum ReturnLogicOp - { - /** - * Logical OR applied between handlers, return FALSE unless one or more - * handlers returns TRUE - */ - OR(true, false), - - /** - * Logical OR, returns TRUE at the first handler to return TRUE and - * doesn't process any further handlers. - */ - OR_BREAK_ON_TRUE(true, true), - - /** - * Logical OR, but with the difference than an EMPTY handler list will - * return TRUE. - */ - OR_ASSUME_TRUE(true, false, true), - - /** - * Logical AND, returns TRUE if the list is empty or if all handlers - * return TRUE. - */ - AND(false, false), - - /** - * Logical AND, returns FALSE at the first handler to return FALSE and - * doesn't process any further handlers. - */ - AND_BREAK_ON_FALSE(false, true); - - private final boolean isOr; - - private final boolean breakOnMatch; - - private final boolean assumeTrue; - - private ReturnLogicOp(boolean isOr, boolean breakOnMatch) - { - this(isOr, breakOnMatch, false); - } - - private ReturnLogicOp(boolean isOr, boolean breakOnMatch, boolean assumeTrue) - { - this.isOr = isOr; - this.breakOnMatch = breakOnMatch; - this.assumeTrue = assumeTrue; - } - - boolean isOr() - { - return this.isOr; - } - - public boolean breakOnMatch() - { - return this.breakOnMatch; - } - - boolean assumeTrue() - { - return this.assumeTrue; - } - } - - /** - * Type of the interface for objects in this handler list - */ - private final Class type; - - /** - * - */ - private final ReturnLogicOp logicOp; - - /** - * Current baked handler list, we cook them at gas mark 5 for 30 minutes in - * a disposable classloader whic also handles the transformation for us. - */ - private BakedHandlerList bakedHandler; - - /** - * True to sort the list when baking - */ - private boolean sorted = true; - - /** - * @param type - */ - public HandlerList(Class type) - { - this(type, ReturnLogicOp.AND_BREAK_ON_FALSE); - } - - /** - * @param type - * @param logicOp Logical operation to apply to interface methods which - * return boolean - */ - public HandlerList(Class type, ReturnLogicOp logicOp) - { - this(type, logicOp, true); - } - - /** - * @param type - * @param logicOp Logical operation to apply to interface methods which - * return boolean - * @param sorted True to sort the list when baking (doesn't sort the - * underlying list) - */ - public HandlerList(Class type, ReturnLogicOp logicOp, boolean sorted) - { - if (!type.isInterface()) - { - throw new IllegalArgumentException("HandlerList type argument must be an interface"); - } - - this.type = type; - this.logicOp = logicOp; - this.sorted = sorted; - } - - /** - * True if the list will be sorted by priority on bake - */ - public boolean isSorted() - { - return this.sorted; - } - - /** - * Set whether to sort list entries before baking them - */ - public void setSorted(boolean sorted) - { - this.sorted = sorted; - this.invalidate(); - } - - @SuppressWarnings("unchecked") - protected List getSortedList() - { - if (!this.sorted) return this; - - SortableValue[] sortable = new SortableValue[this.size()]; - for (int s = 0; s < this.size(); s++) - { - T value = this.get(s); - sortable[s] = new SortableValue(this.getPriority(value), s, value); - } - - Arrays.sort(sortable); - - List sortedList = new ArrayList(this.size()); - for (int s = 0; s < sortable.length; s++) - { - sortedList.add(sortable[s].getValue()); - } - - return sortedList; - } - - private int getPriority(T value) - { - Priority priority = value.getClass().getAnnotation(Priority.class); - if (priority != null) - { - return priority.value(); - } - - return 1000; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.interfaces.FastIterable#all() - */ - @Override - public T all() - { - if (this.bakedHandler == null) - { - this.bake(); - } - - return this.bakedHandler.get(); - } - - /** - * Bake the current handler list - */ - protected void bake() - { - HandlerListClassLoader classLoader = new HandlerListClassLoader(this.type, this.logicOp, this.getDecorator()); - this.bakedHandler = classLoader.newHandler(this); - if (classLoader instanceof Closeable) - { - try - { - ((Closeable)classLoader).close(); - } - catch (IOException ex) {} - } - } - - protected IHandlerListDecorator getDecorator() - { - return null; - } - - /** - * Invalidate current baked list - */ - @Override - public void invalidate() - { - if (this.bakedHandler == null) - { - return; - } - - this.bakedHandler = null; - HandlerList.uncollectedHandlerLists++; - if (HandlerList.uncollectedHandlerLists > HandlerList.MAX_UNCOLLECTED_CLASSES) - { - System.gc(); - HandlerList.uncollectedHandlerLists = 0; - } - } - - /* (non-Javadoc) - * @see java.util.LinkedList#add(java.lang.Object) - */ - @Override - public boolean add(T listener) - { - if (!this.contains(listener)) - { - super.add(listener); - this.invalidate(); - } - - return true; - } - - /* (non-Javadoc) - * @see java.util.LinkedList#offer(java.lang.Object) - */ - @Override - public boolean offer(T listener) - { - return this.add(listener); - } - - /* (non-Javadoc) - * @see java.util.LinkedList#offerFirst(java.lang.Object) - */ - @Override - public boolean offerFirst(T listener) - { - this.addFirst(listener); - return true; - } - - /* (non-Javadoc) - * @see java.util.LinkedList#offerLast(java.lang.Object) - */ - @Override - public boolean offerLast(T listener) - { - this.addLast(listener); - return true; - } - - /* (non-Javadoc) - * @see java.util.LinkedList#add(int, java.lang.Object) - */ - @Override - public void add(int index, T listener) - { - if (!this.contains(listener)) - { - super.add(index, listener); - this.invalidate(); - } - } - - /* (non-Javadoc) - * @see java.util.LinkedList#addFirst(java.lang.Object) - */ - @Override - public void addFirst(T listener) - { - if (!this.contains(listener)) - { - super.addFirst(listener); - this.invalidate(); - } - } - - /* (non-Javadoc) - * @see java.util.LinkedList#addLast(java.lang.Object) - */ - @Override - public void addLast(T listener) - { - if (!this.contains(listener)) - { - super.addLast(listener); - this.invalidate(); - } - } - - /* (non-Javadoc) - * @see java.util.LinkedList#addAll(java.util.Collection) - */ - @Override - public boolean addAll(Collection listeners) - { - for (T listener : listeners) - { - if (!this.contains(listener)) - { - super.add(listener); - } - } - - this.invalidate(); - return true; - } - - /* (non-Javadoc) - * @see java.util.LinkedList#addAll(int, java.util.Collection) - */ - @Override - public boolean addAll(int index, Collection listeners) - { - throw new UnsupportedOperationException("'addAll' is not supported for HandlerList"); - } - - /* (non-Javadoc) - * @see java.util.LinkedList#remove() - */ - @Override - public T remove() - { - return this.removeFirst(); - } - - /* (non-Javadoc) - * @see java.util.LinkedList#remove(int) - */ - @Override - public T remove(int index) - { - T removed = super.remove(index); - this.invalidate(); - return removed; - } - - /* (non-Javadoc) - * @see java.util.LinkedList#remove(java.lang.Object) - */ - @Override - public boolean remove(Object listener) - { - boolean removed = super.remove(listener); - this.invalidate(); - return removed; - } - - /* (non-Javadoc) - * @see java.util.LinkedList#removeFirst() - */ - @Override - public T removeFirst() - { - T removed = super.removeFirst(); - this.invalidate(); - return removed; - } - - /* (non-Javadoc) - * @see java.util.LinkedList#removeFirstOccurrence(java.lang.Object) - */ - @Override - public boolean removeFirstOccurrence(Object listener) - { - return this.remove(listener); - } - - /* (non-Javadoc) - * @see java.util.LinkedList#removeLast() - */ - @Override - public T removeLast() - { - T removed = super.removeLast(); - this.invalidate(); - return removed; - } - - /* (non-Javadoc) - * @see java.util.LinkedList#removeLastOccurrence(java.lang.Object) - */ - @Override - public boolean removeLastOccurrence(Object listener) - { - boolean removed = super.removeLastOccurrence(listener); - this.invalidate(); - return removed; - } - - /* (non-Javadoc) - * @see java.util.AbstractCollection#removeAll(java.util.Collection) - */ - @Override - public boolean removeAll(Collection listeners) - { - boolean removed = super.removeAll(listeners); - this.invalidate(); - return removed; - } - - /* (non-Javadoc) - * @see java.util.LinkedList#poll() - */ - @Override - public T poll() - { - T polled = super.poll(); - this.invalidate(); - return polled; - } - - /* (non-Javadoc) - * @see java.util.LinkedList#pollFirst() - */ - @Override - public T pollFirst() - { - T polled = super.pollFirst(); - this.invalidate(); - return polled; - } - - /* (non-Javadoc) - * @see java.util.LinkedList#pollLast() - */ - @Override - public T pollLast() - { - T polled = super.pollLast(); - this.invalidate(); - return polled; - } - - /* (non-Javadoc) - * @see java.util.LinkedList#push(java.lang.Object) - */ - @Override - public void push(T listener) - { - this.addFirst(listener); - } - - /* (non-Javadoc) - * @see java.util.LinkedList#pop() - */ - @Override - public T pop() - { - return this.removeFirst(); - } - - /* (non-Javadoc) - * @see java.util.LinkedList#set(int, java.lang.Object) - */ - @Override - public T set(int index, T listener) - { - T oldValue = null; - - if (!this.contains(listener)) - { - oldValue = super.set(index, listener); - this.invalidate(); - } - - return oldValue; - } - - /** - * Base class for baked handler lists - * - * @author Adam Mummery-Smith - * - * @param - */ - public abstract static class BakedHandlerList - { - public abstract T get(); - - public abstract BakedHandlerList populate(List listeners); - } - - /** - * Exception to throw when failing to bake a handler list - * - * @author Adam Mummery-Smith - */ - static class BakingFailedException extends RuntimeException - { - private static final long serialVersionUID = 1L; - - public BakingFailedException(Throwable cause) - { - super("An unexpected error occurred while baking the handler list", cause); - } - } - - /** - * ClassLoader which generates the baked handler list - * - * @author Adam Mummery-Smith - * @param - */ - static class HandlerListClassLoader extends URLClassLoader - { - private static final String HANDLER_VAR_PREFIX = "handler$"; - - public static final boolean DUMP = Booleans.parseBoolean(System.getProperty("liteloader.debug.dump"), false); - - public static final boolean VALIDATE = Booleans.parseBoolean(System.getProperty("liteloader.debug.validate"), false); - - /** - * Unique index number, just to ensure no name clashes - */ - private static int handlerIndex; - - /** - * Interface type which this classloader is generating handler for - */ - private final Class type; - - /** - * Calculated class ref for the class type so that we don't have to keep - * calling getName().replace('.', '/') - */ - private final String typeRef; - - /** - * Logic operation to apply when running a callback with a boolean - */ - private final ReturnLogicOp logicOp; - - /** - * Bytecode decorator - */ - private final IHandlerListDecorator decorator; - - /** - * Size of the handler list - */ - private int size; - - /** - * @param type - * @param logicOp - */ - HandlerListClassLoader(Class type, ReturnLogicOp logicOp, IHandlerListDecorator decorator) - { - super(new URL[0], Launch.classLoader); - this.type = type; - this.typeRef = type.getName().replace('.', '/'); - this.logicOp = logicOp; - this.decorator = decorator; - } - - /** - * Create and return a new baked handler list - */ - @SuppressWarnings("unchecked") - public BakedHandlerList newHandler(HandlerList list) - { - this.size = list.size(); - List sortedList = list.getSortedList(); - - if (this.decorator != null) - { - this.decorator.prepare(sortedList); - } - - Class> handlerClass = null; - - try - { - // Inflect the class name and attempt to generate the class - String className = HandlerListClassLoader.getNextClassName(Obf.HandlerList.name, this.type.getSimpleName()); - handlerClass = (Class>)this.loadClass(className); - } - catch (ClassNotFoundException ex) - { - throw new BakingFailedException(ex); - } - - try - { - // Create an instance of the class, populate the entries from the supplied list and return it - BakedHandlerList handlerList = this.createInstance(handlerClass); - return handlerList.populate(sortedList); - } - catch (InstantiationException ex) - { - throw new BakingFailedException(ex); - } - } - - /** - * Create an instance of the baked class - * - * @param handlerClass Baked HandlerList class - * @return new instance of the Baked HandlerList class - * @throws InstantiationException if the handler can't be created for - * some reason - */ - private BakedHandlerList createInstance(Class> handlerClass) throws InstantiationException - { - try - { - if (this.decorator != null) - { - return this.decorator.createInstance(handlerClass); - } - - Constructor> ctor = handlerClass.getDeclaredConstructor(); - ctor.setAccessible(true); - return ctor.newInstance(); - } - catch (Exception ex) - { - InstantiationException ie = new InstantiationException("Error instantiating class " + handlerClass); - ie.setStackTrace(ex.getStackTrace()); - throw ie; - } - } - - /* (non-Javadoc) - * @see java.net.URLClassLoader#findClass(java.lang.String) - */ - @Override - protected Class findClass(String name) throws ClassNotFoundException - { - try - { - // Read the basic class template - byte[] bytes = ByteCodeUtilities.applyTransformers(this.getTemplate().name, - Launch.classLoader.getClassBytes(this.getTemplate().name)); - ClassReader classReader = new ClassReader(bytes); - ClassNode classNode = new ClassNode(); - classReader.accept(classNode, ClassReader.EXPAND_FRAMES); - - // Apply all transformations to the class, injects our custom code - this.transform(name, classNode); - - // Write the class - ClassWriter classWriter = new ClassWriter(classReader, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); - classNode.accept(classWriter); - bytes = classWriter.toByteArray(); - - if (HandlerListClassLoader.VALIDATE) - { - classNode.accept(new CheckClassAdapter(new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES))); - } - - if (HandlerListClassLoader.DUMP) - { - FileUtils.writeByteArrayToFile(new File(".classes/" + name.replace('.', '/') + ".class"), bytes); - } - - // Delegate to ClassLoader's usual behaviour to load the class we just generated - return this.defineClass(name, bytes, 0, bytes.length); - } - catch (Throwable th) - { - th.printStackTrace(); - return null; - } - } - - private Obf getTemplate() - { - if (this.decorator != null) - { - return this.decorator.getTemplate(); - } - - return Obf.BakedHandlerList; - } - - /** - * Perform all class bytecode transformations - * - * @param name - * @param classNode - * @throws IOException - */ - private void transform(String name, ClassNode classNode) throws IOException - { - LiteLoaderLogger.info("Baking listener list for %s with %d listeners", this.type.getSimpleName(), this.size); - LiteLoaderLogger.debug("Generating: %s", name); - - this.populateClass(name, classNode); - this.transformMethods(name, classNode); - - Set generatedMethods = new HashSet(); - this.injectInterfaceMethods(classNode, this.type.getName(), generatedMethods); - } - - /** - * Populate the class node itself - * - * @param name - * @param classNode - */ - private void populateClass(String name, ClassNode classNode) - { - classNode.access = classNode.access & ~Opcodes.ACC_ABSTRACT; - classNode.name = name.replace('.', '/'); - classNode.superName = this.getTemplate().ref; - classNode.interfaces.add(this.typeRef); - classNode.sourceFile = name.substring(name.lastIndexOf('.') + 1) + ".java"; - - for (int handlerIndex = 0; handlerIndex < this.size; handlerIndex++) - { - classNode.fields.add(new FieldNode(Opcodes.ACC_PRIVATE, HandlerListClassLoader.HANDLER_VAR_PREFIX + handlerIndex, - "L" + this.typeRef + ";", null, null)); - } - - if (this.decorator != null) - { - this.decorator.populateClass(name, classNode); - } - } - - /** - * Transform existing methods in the template class - * - * @param name - * @param classNode - */ - private void transformMethods(String name, ClassNode classNode) - { - for (Iterator methodIterator = classNode.methods.iterator(); methodIterator.hasNext();) - { - MethodNode method = methodIterator.next(); - if (Obf.constructor.name.equals(method.name)) - { - this.processCtor(classNode, method); - } - else if ("get".equals(method.name)) - { - this.processGet(classNode, method); - } - else if ("populate".equals(method.name)) - { - this.processPopulate(classNode, method); - } - } - } - - /** - * Transform the constructor - * - * @param classNode - * @param method - */ - private void processCtor(ClassNode classNode, MethodNode method) - { - for (Iterator iter = method.instructions.iterator(); iter.hasNext();) - { - AbstractInsnNode insn = iter.next(); - if (insn instanceof MethodInsnNode) - { - MethodInsnNode methodInsn = (MethodInsnNode)insn; - if (methodInsn.getOpcode() == Opcodes.INVOKESPECIAL && methodInsn.name.equals(Obf.constructor.name)) - { - methodInsn.owner = this.getTemplate().ref; - } - } - } - - if (this.decorator != null) - { - this.decorator.processCtor(classNode, method); - } - } - - /** - * Transform .get() - * - * @param classNode - * @param method - */ - private void processGet(ClassNode classNode, MethodNode method) - { - method.access = method.access & ~Opcodes.ACC_ABSTRACT; - method.instructions.clear(); - - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - method.instructions.add(new InsnNode(Opcodes.ARETURN)); - - method.maxStack = 1; - method.maxLocals = 1; - } - - /** - * Transform .processPopulate() - * - * @param classNode - * @param method - */ - private void processPopulate(ClassNode classNode, MethodNode method) - { - method.access = method.access & ~Opcodes.ACC_ABSTRACT; - method.instructions.clear(); - - for (int handlerIndex = 0; handlerIndex < this.size; handlerIndex++) - { - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1)); - method.instructions.add(handlerIndex > Short.MAX_VALUE ? new LdcInsnNode(new Integer(handlerIndex)) - : new IntInsnNode(Opcodes.SIPUSH, handlerIndex)); - method.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;", true)); - method.instructions.add(new TypeInsnNode(Opcodes.CHECKCAST, this.typeRef)); - method.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, classNode.name, HandlerListClassLoader.HANDLER_VAR_PREFIX + handlerIndex, - "L" + this.typeRef + ";")); - } - - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - method.instructions.add(new InsnNode(Opcodes.ARETURN)); - - method.maxStack = 3; - method.maxLocals = 2; - } - - /** - * Recurse down the interface inheritance hierarchy and inject methods - * to handle each interface. - * - * @param classNode - * @param interfaceName - * @param generatedMethods - * @throws IOException - */ - private void injectInterfaceMethods(ClassNode classNode, String interfaceName, Set generatedMethods) throws IOException - { - ClassReader interfaceReader = new ClassReader(HandlerListClassLoader.getInterfaceBytes(interfaceName)); - ClassNode interfaceNode = new ClassNode(); - interfaceReader.accept(interfaceNode, 0); - - for (MethodNode interfaceMethod : interfaceNode.methods) - { - String signature = interfaceMethod.name + interfaceMethod.desc; - if (generatedMethods.contains(signature)) continue; - generatedMethods.add(signature); - classNode.methods.add(interfaceMethod); - this.populateInterfaceMethod(classNode, interfaceMethod); - } - - for (String parentInterface : interfaceNode.interfaces) - { - this.injectInterfaceMethods(classNode, parentInterface.replace('/', '.'), generatedMethods); - } - } - - /** - * Inject the supplied interface method into the target class and - * populate it with method calls to the list members - * - * @param classNode - * @param method - */ - private void populateInterfaceMethod(ClassNode classNode, MethodNode method) - { - Type returnType = Type.getReturnType(method.desc); - Type[] args = Type.getArgumentTypes(method.desc); - - if (returnType.equals(Type.BOOLEAN_TYPE)) - { - method.access = Opcodes.ACC_PUBLIC; - this.populateBooleaninvocationChain(classNode, method, args); - } - else - { - method.access = Opcodes.ACC_PUBLIC; - this.populateVoidinvocationChain(classNode, method, args, returnType); - } - - if (this.decorator != null) - { - this.decorator.populateInterfaceMethod(classNode, method); - } - } - - /** - * @param classNode - * @param method - * @param args - */ - private void populateVoidinvocationChain(ClassNode classNode, MethodNode method, Type[] args, Type returnType) - { - int returnSize = returnType.getSize(); - for (int handlerIndex = 0; handlerIndex < this.size; handlerIndex++) - { - this.invokeHandler(handlerIndex, classNode, method, args); - if (returnSize > 0) - { - method.instructions.add(new InsnNode(returnSize == 1 ? Opcodes.POP : Opcodes.POP2)); - } - } - - if (returnSize > 0) - { - if (returnType.getSort() == Type.OBJECT) - { - method.instructions.add(new InsnNode(Opcodes.ACONST_NULL)); - } - else if (returnSize == 1) - { - method.instructions.add(new InsnNode(Opcodes.ICONST_0)); - } - else if (returnSize == 2) - { - method.instructions.add(new InsnNode(Opcodes.DCONST_0)); - } - } - - method.instructions.add(new InsnNode(returnType.getOpcode(Opcodes.IRETURN))); - - int argsSize = ByteCodeUtilities.getArgsSize(args); - method.maxLocals = argsSize + 1; - method.maxStack = argsSize + 1; - } - - /** - * @param classNode - * @param method - * @param args - */ - private void populateBooleaninvocationChain(ClassNode classNode, MethodNode method, Type[] args) - { - boolean isOrOperation = this.logicOp.isOr(); - boolean breakOnMatch = this.logicOp.breakOnMatch(); - int initialValue = isOrOperation && (!this.logicOp.assumeTrue() || this.size > 0) ? Opcodes.ICONST_0 : Opcodes.ICONST_1; - int localIndex = ByteCodeUtilities.getArgsSize(args) + 1; - - method.instructions.add(new InsnNode(initialValue)); - method.instructions.add(new VarInsnNode(Opcodes.ISTORE, localIndex)); - - for (int handlerIndex = 0; handlerIndex < this.size; handlerIndex++) - { - this.invokeHandler(handlerIndex, classNode, method, args); // invoke the method, this will leave the return value on the stack - - int jumpCondition = isOrOperation ? Opcodes.IFEQ : Opcodes.IFNE; // jump if zero for OR, jump if one for AND - int semaphore = isOrOperation ? Opcodes.ICONST_1 : Opcodes.ICONST_0; // will push TRUE for OR, will push FALSE for AND - - LabelNode lbl = new LabelNode(); - method.instructions.add(new JumpInsnNode(jumpCondition, lbl)); // jump over the set/return based on the condition - method.instructions.add(new InsnNode(semaphore)); // push TRUE or FALSE onto the stack - // set local or return - method.instructions.add(breakOnMatch ? new InsnNode(Opcodes.IRETURN) : new VarInsnNode(Opcodes.ISTORE, localIndex)); - method.instructions.add(lbl); // jump here - } - - method.instructions.add(new VarInsnNode(Opcodes.ILOAD, localIndex)); - method.instructions.add(new InsnNode(Opcodes.IRETURN)); - - method.maxLocals = localIndex + 2; - method.maxStack = localIndex + 1; - } - - /** - * @param handlerIndex - * @param classNode - * @param method - * @param args - */ - private void invokeHandler(int handlerIndex, ClassNode classNode, MethodNode method, Type[] args) - { - LabelNode lineNumberLabel = new LabelNode(new Label()); - method.instructions.add(lineNumberLabel); - method.instructions.add(new LineNumberNode(100 + handlerIndex, lineNumberLabel)); - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - method.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, classNode.name, HandlerListClassLoader.HANDLER_VAR_PREFIX + handlerIndex, - "L" + this.typeRef + ";")); - - if (this.decorator != null) - { - this.decorator.preInvokeInterfaceMethod(handlerIndex, classNode, method, args); - } - - this.invokeInterfaceMethod(method, args); - - if (this.decorator != null) - { - this.decorator.postInvokeInterfaceMethod(handlerIndex, classNode, method, args); - } - } - - /** - * Inject instructions into the supplied method to invoke the same - * method on the supplied interface. - * - * @param method - * @param args - */ - private void invokeInterfaceMethod(MethodNode method, Type[] args) - { - int argNumber = 1; - for (Type type : args) - { - method.instructions.add(new VarInsnNode(type.getOpcode(Opcodes.ILOAD), argNumber)); - argNumber += type.getSize(); - } - - method.instructions.add(new MethodInsnNode(Opcodes.INVOKEINTERFACE, this.typeRef, method.name, method.desc, true)); - } - - /** - * @param baseName - * @param typeName - */ - private static String getNextClassName(String baseName, String typeName) - { - return String.format("%s$%s%d", baseName, typeName, HandlerListClassLoader.handlerIndex++); - } - - /** - * @param name - * @throws IOException - */ - private static byte[] getInterfaceBytes(String name) throws IOException - { - byte[] bytes = Launch.classLoader.getClassBytes(name); - - for (final IClassTransformer transformer : Launch.classLoader.getTransformers()) - { - bytes = transformer.transform(name, name, bytes); - } - - return bytes; - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/event/IHandlerListDecorator.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/event/IHandlerListDecorator.java deleted file mode 100644 index 7dc184eb..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/event/IHandlerListDecorator.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.mumfrey.liteloader.core.event; - -import java.util.List; - -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.MethodNode; - -import com.mumfrey.liteloader.core.event.HandlerList.BakedHandlerList; -import com.mumfrey.liteloader.core.runtime.Obf; - -/** - * Essentially a "mini plugin" for HandlerListClassLoader which allows - * alterations of the generated bytecode. - * - * @author Adam Mummery-Smith - * - * @param - */ -public interface IHandlerListDecorator -{ - /** - * Get the template class name - */ - public abstract Obf getTemplate(); - - /** - * Prepare the decorator to accept the specified list of invokees - */ - public abstract void prepare(List sortedList); - - /** - * Create an instance of the handler class - */ - public abstract BakedHandlerList createInstance(Class> handlerClass) throws Exception; - - /** - * Called when populating the classNode - */ - public abstract void populateClass(String name, ClassNode classNode); - - /** - * Called when processing the ctor - */ - public abstract void processCtor(ClassNode classNode, MethodNode method); - - /** - * Called immediately before the interface method invocation bytecode is - * injected. - */ - public abstract void preInvokeInterfaceMethod(int handlerIndex, ClassNode classNode, MethodNode method, Type[] args); - - /** - * Called immediately after the interface method invocation bytecode is - * injected. - */ - public abstract void postInvokeInterfaceMethod(int handlerIndex, ClassNode classNode, MethodNode method, Type[] args); - - /** - * Called at the end of populateInterfaceMethod - */ - public abstract void populateInterfaceMethod(ClassNode classNode, MethodNode method); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/event/ProfilingHandlerList.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/event/ProfilingHandlerList.java deleted file mode 100644 index c8fbd451..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/event/ProfilingHandlerList.java +++ /dev/null @@ -1,237 +0,0 @@ -package com.mumfrey.liteloader.core.event; - -import java.lang.reflect.Constructor; -import java.util.ArrayList; -import java.util.List; - -import net.minecraft.profiler.Profiler; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.InsnNode; -import org.objectweb.asm.tree.LdcInsnNode; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.MethodNode; -import org.objectweb.asm.tree.VarInsnNode; - -import com.mumfrey.liteloader.api.Listener; -import com.mumfrey.liteloader.core.runtime.Obf; - -/** - * A HandlerList which calls Profiler.beginSection and Profiler.endSection - * before every invocation. - * - * @author Adam Mummery-Smith - * - * @param - */ -public class ProfilingHandlerList extends HandlerList -{ - private static final long serialVersionUID = 1L; - - /** - * Profiler to pass in to baked handler lists - */ - private final Profiler profiler; - - /** - * @param type - * @param profiler - */ - public ProfilingHandlerList(Class type, Profiler profiler) - { - super(type); - this.profiler = profiler; - } - - /** - * @param type - * @param logicOp - * @param profiler - */ - public ProfilingHandlerList(Class type, ReturnLogicOp logicOp, Profiler profiler) - { - super(type, logicOp); - this.profiler = profiler; - } - - /** - * @param type - * @param logicOp - * @param sorted - * @param profiler - */ - public ProfilingHandlerList(Class type, ReturnLogicOp logicOp, boolean sorted, Profiler profiler) - { - super(type, logicOp, sorted); - this.profiler = profiler; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.event.HandlerList#getDecorator() - */ - @Override - protected IHandlerListDecorator getDecorator() - { - return new ProfilingHandlerListDecorator(this.profiler); - } - - /** - * Decorator which adds the profiler section calls to the invocation lists - */ - static class ProfilingHandlerListDecorator implements IHandlerListDecorator - { - private final Profiler profiler; - - private final List names = new ArrayList();; - - protected ProfilingHandlerListDecorator(Profiler profiler) - { - this.profiler = profiler; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.event.IHandlerListDecorator - * #getTemplate() - */ - @Override - public Obf getTemplate() - { - return Obf.BakedProfilingHandlerList; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.event.IHandlerListDecorator - * #prepare(java.util.List) - */ - @Override - public void prepare(List sortedList) - { - this.names.clear(); - - for (Listener l : sortedList) - { - String name = l.getName(); - this.names.add(name != null ? name : l.getClass().getSimpleName()); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.event.IHandlerListDecorator - * #createInstance(java.lang.Class) - */ - @Override - public BakedHandlerList createInstance(Class> handlerClass) throws Exception - { - try - { - Constructor> ctor = handlerClass.getDeclaredConstructor(Profiler.class); - ctor.setAccessible(true); - return ctor.newInstance(this.profiler); - } - catch (Exception ex) - { - ex.printStackTrace(); - throw ex; - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.event.IHandlerListDecorator - * #populateClass(java.lang.String, - * org.objectweb.asm.tree.ClassNode) - */ - @Override - public void populateClass(String name, ClassNode classNode) - { - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.event.IHandlerListDecorator - * #processCtor(org.objectweb.asm.tree.ClassNode, - * org.objectweb.asm.tree.MethodNode) - */ - @Override - public void processCtor(ClassNode classNode, MethodNode method) - { - // Actually replace the ctor code because it's easier - method.instructions.clear(); - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 1)); - method.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, Obf.BakedProfilingHandlerList.ref, Obf.constructor.name, - method.desc, false)); - method.instructions.add(new InsnNode(Opcodes.RETURN)); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.event.IHandlerListDecorator - * #preInvokeInterfaceMethod(int, org.objectweb.asm.tree.ClassNode, - * org.objectweb.asm.tree.MethodNode, org.objectweb.asm.Type[]) - */ - @Override - public void preInvokeInterfaceMethod(int handlerIndex, ClassNode classNode, MethodNode method, Type[] args) - { - // Call this.startSection - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - method.instructions.add(new LdcInsnNode(this.names.get(handlerIndex))); - method.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, classNode.superName, "startSection", "(Ljava/lang/String;)V", false)); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.event.IHandlerListDecorator - * #postInvokeInterfaceMethod(int, org.objectweb.asm.tree.ClassNode, - * org.objectweb.asm.tree.MethodNode, org.objectweb.asm.Type[]) - */ - @Override - public void postInvokeInterfaceMethod(int handlerIndex, ClassNode classNode, MethodNode method, Type[] args) - { - // Call this.endSection - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - method.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, classNode.superName, "endSection", "()V", false)); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.event.IHandlerListDecorator - * #populateInterfaceMethod(org.objectweb.asm.tree.ClassNode, - * org.objectweb.asm.tree.MethodNode) - */ - @Override - public void populateInterfaceMethod(ClassNode classNode, MethodNode method) - { - } - } - - /** - * Template class for the profiling handler lists - * - * @author Adam Mummery-Smith - * - * @param - */ - public abstract static class BakedList extends HandlerList.BakedHandlerList - { - private final Profiler profiler; - - public BakedList(Profiler profiler) - { - this.profiler = profiler; - } - - @Override - public abstract T get(); - - @Override - public abstract BakedHandlerList populate(List listeners); - - protected void startSection(String name) - { - this.profiler.startSection(name); - } - - protected void endSection() - { - this.profiler.endSection(); - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/OutdatedLoaderException.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/OutdatedLoaderException.java deleted file mode 100644 index fe15f1df..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/OutdatedLoaderException.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mumfrey.liteloader.core.exceptions; - -/** - * Exception thrown when a mod class references a liteloader interface which - * does not exist, which more than likely means that it requires a more - * up-to-date version of the loader than is currently installed. - * - * @author Adam Mummery-Smith - */ -public class OutdatedLoaderException extends Exception -{ - private static final long serialVersionUID = 8770358290208830747L; - - /** - * @param missingAPI Name of the referenced class which is missing - */ - public OutdatedLoaderException(String missingAPI) - { - super(missingAPI); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/ProfilerCrossThreadAccessException.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/ProfilerCrossThreadAccessException.java deleted file mode 100644 index a1ec1896..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/ProfilerCrossThreadAccessException.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.mumfrey.liteloader.core.exceptions; - -/** - * Exception to throw if startSection or endSection are called from a thread - * other than the Minecraft main thread. This should NEVER happen and is an - * attempt to identify the culprit of some profiler stack corruption causes. - * - * @author Adam Mummery-Smith - */ -public class ProfilerCrossThreadAccessException extends RuntimeException -{ - private static final long serialVersionUID = 3225047722943528251L; - - public ProfilerCrossThreadAccessException(String message) - { - super("Calling thread name \"" + message + "\""); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/ProfilerStackCorruptionException.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/ProfilerStackCorruptionException.java deleted file mode 100644 index 2cda09a2..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/ProfilerStackCorruptionException.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.mumfrey.liteloader.core.exceptions; - -/** - * Exception to throw when a mod corrupts the profiler stack, this avoids - * throwing a (somewhat cryptic) NoSuchElementException inside HookProfiler - * - * @author Adam Mummery-Smith - */ -public class ProfilerStackCorruptionException extends RuntimeException -{ - private static final long serialVersionUID = -7745831270297368169L; - - public ProfilerStackCorruptionException(String message) - { - super(message); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/UnregisteredChannelException.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/UnregisteredChannelException.java deleted file mode 100644 index 6b4cd82b..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/exceptions/UnregisteredChannelException.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mumfrey.liteloader.core.exceptions; - -public class UnregisteredChannelException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public UnregisteredChannelException(String message) - { - super(message); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/runtime/Methods.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/runtime/Methods.java deleted file mode 100644 index 1dc81595..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/runtime/Methods.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.mumfrey.liteloader.core.runtime; - -import java.io.File; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; - -import com.mumfrey.liteloader.transformers.event.MethodInfo; - -/** - * - * @author Adam Mummery-Smith - */ -public abstract class Methods -{ - // CHECKSTYLE:OFF - - // Client & General - @Deprecated public static final MethodInfo startGame = new MethodInfo(Obf.Minecraft, Obf.startGame, Void.TYPE); - @Deprecated public static final MethodInfo runGameLoop = new MethodInfo(Obf.Minecraft, Obf.runGameLoop, Void.TYPE); - @Deprecated public static final MethodInfo runTick = new MethodInfo(Obf.Minecraft, Obf.runTick, Void.TYPE); - @Deprecated public static final MethodInfo updateFramebufferSize = new MethodInfo(Obf.Minecraft, Obf.updateFramebufferSize, Void.TYPE); - @Deprecated public static final MethodInfo framebufferRender = new MethodInfo(Obf.FrameBuffer, Obf.framebufferRender, Void.TYPE, Integer.TYPE, Integer.TYPE); - @Deprecated public static final MethodInfo framebufferRenderExt = new MethodInfo(Obf.FrameBuffer, Obf.framebufferRenderExt, Void.TYPE, Integer.TYPE, Integer.TYPE, Boolean.TYPE); - @Deprecated public static final MethodInfo bindFramebufferTexture = new MethodInfo(Obf.FrameBuffer, Obf.bindFramebufferTexture, Void.TYPE); - @Deprecated public static final MethodInfo sendChatMessage = new MethodInfo(Obf.EntityPlayerSP, Obf.sendChatMessage, Void.TYPE, String.class); - @Deprecated public static final MethodInfo renderWorld = new MethodInfo(Obf.EntityRenderer, Obf.renderWorld, Void.TYPE, Float.TYPE, Long.TYPE); - @Deprecated public static final MethodInfo renderWorldPass = new MethodInfo(Obf.EntityRenderer, Obf.renderWorldPass, Void.TYPE, Integer.TYPE, Float.TYPE, Long.TYPE); - @Deprecated public static final MethodInfo updateCameraAndRender = new MethodInfo(Obf.EntityRenderer, Obf.updateCameraAndRender, Void.TYPE, Float.TYPE); - @Deprecated public static final MethodInfo renderGameOverlay = new MethodInfo(Obf.GuiIngame, Obf.renderGameOverlay, Void.TYPE, Float.TYPE); - @Deprecated public static final MethodInfo drawChat = new MethodInfo(Obf.GuiNewChat, Obf.drawChat, Void.TYPE, Integer.TYPE); - @Deprecated public static final MethodInfo integratedServerCtor = new MethodInfo(Obf.IntegratedServer, Obf.constructor, Void.TYPE, Obf.Minecraft, String.class, String.class, Obf.WorldSettings); - @Deprecated public static final MethodInfo initPlayerConnection = new MethodInfo(Obf.ServerConfigurationManager, Obf.initializeConnectionToPlayer, Void.TYPE, Obf.NetworkManager, Obf.EntityPlayerMP); - @Deprecated public static final MethodInfo playerLoggedIn = new MethodInfo(Obf.ServerConfigurationManager, Obf.playerLoggedIn, Void.TYPE, Obf.EntityPlayerMP); - @Deprecated public static final MethodInfo playerLoggedOut = new MethodInfo(Obf.ServerConfigurationManager, Obf.playerLoggedOut, Void.TYPE, Obf.EntityPlayerMP); - @Deprecated public static final MethodInfo spawnPlayer = new MethodInfo(Obf.ServerConfigurationManager, Obf.spawnPlayer, Obf.EntityPlayerMP, Obf.GameProfile); - @Deprecated public static final MethodInfo respawnPlayer = new MethodInfo(Obf.ServerConfigurationManager, Obf.respawnPlayer, Obf.EntityPlayerMP, Obf.EntityPlayerMP, Integer.TYPE, Boolean.TYPE); - @Deprecated public static final MethodInfo glClear = new MethodInfo(Obf.GlStateManager, Obf.clear, Void.TYPE, Integer.TYPE); - @Deprecated public static final MethodInfo getProfile = new MethodInfo(Obf.Session, Obf.getProfile, Obf.GameProfile); - @Deprecated public static final MethodInfo saveScreenshot = new MethodInfo(Obf.ScreenShotHelper, Obf.saveScreenshot, Obf.IChatComponent, File.class, String.class, Integer.TYPE, Integer.TYPE, Obf.FrameBuffer); - @Deprecated public static final MethodInfo isFramebufferEnabled = new MethodInfo(Obf.OpenGlHelper, Obf.isFramebufferEnabled, Boolean.TYPE); - @Deprecated public static final MethodInfo doRenderEntity = new MethodInfo(Obf.RenderManager, Obf.doRenderEntity, Boolean.TYPE, Obf.Entity, Double.TYPE, Double.TYPE, Double.TYPE, Float.TYPE, Float.TYPE, Boolean.TYPE); - @Deprecated public static final MethodInfo doRender = new MethodInfo(Obf.Render, Obf.doRender, Void.TYPE, Obf.Entity, Double.TYPE, Double.TYPE, Double.TYPE, Float.TYPE, Float.TYPE); - @Deprecated public static final MethodInfo doRenderShadowAndFire = new MethodInfo(Obf.Render, Obf.doRenderShadowAndFire, Void.TYPE, Obf.Entity, Double.TYPE, Double.TYPE, Double.TYPE, Float.TYPE, Float.TYPE); - @Deprecated public static final MethodInfo realmsPlay = new MethodInfo(Obf.RealmsMainScreen, "play", Void.TYPE, Long.TYPE); - @Deprecated public static final MethodInfo realmsStopFetcher = new MethodInfo(Obf.RealmsMainScreen, "stopRealmsFetcherAndPinger", Void.TYPE); - @Deprecated public static final MethodInfo onBlockClicked = new MethodInfo(Obf.ItemInWorldManager, Obf.onBlockClicked, Void.TYPE, Obf.BlockPos, Obf.EnumFacing); - @Deprecated public static final MethodInfo activateBlockOrUseItem = new MethodInfo(Obf.ItemInWorldManager, Obf.activateBlockOrUseItem, Boolean.TYPE, Obf.EntityPlayer, Obf.World, Obf.ItemStack, Obf.BlockPos, Obf.EnumFacing, Float.TYPE, Float.TYPE, Float.TYPE); - @Deprecated public static final MethodInfo processBlockPlacement = new MethodInfo(Obf.NetHandlerPlayServer, Obf.processPlayerBlockPlacement, Void.TYPE, Packets.C08PacketPlayerBlockPlacement); - @Deprecated public static final MethodInfo handleAnimation = new MethodInfo(Obf.NetHandlerPlayServer, Obf.handleAnimation, Void.TYPE, Packets.C0APacketAnimation); - @Deprecated public static final MethodInfo processPlayerDigging = new MethodInfo(Obf.NetHandlerPlayServer, Obf.processPlayerDigging, Void.TYPE, Packets.C07PacketPlayerDigging); - @Deprecated public static final MethodInfo serverJobs = new MethodInfo(Obf.MinecraftServer, Obf.updateTimeLightAndEntities, Void.TYPE); - @Deprecated public static final MethodInfo checkThreadAndEnqueue = new MethodInfo(Obf.PacketThreadUtil, Obf.checkThreadAndEnqueue); - @Deprecated public static final MethodInfo processPlayer = new MethodInfo(Obf.NetHandlerPlayServer, Obf.processPlayer, Void.TYPE, Packets.C03PacketPlayer); - @Deprecated public static final MethodInfo renderSky = new MethodInfo(Obf.RenderGlobal, Obf.renderSky, Void.TYPE, Float.TYPE, Integer.TYPE); - @Deprecated public static final MethodInfo renderCloudsCheck = new MethodInfo(Obf.EntityRenderer, Obf.renderCloudsCheck, Void.TYPE, Obf.RenderGlobal, Float.TYPE, Integer.TYPE); - @Deprecated public static final MethodInfo setupFog = new MethodInfo(Obf.EntityRenderer, Obf.setupFog, Void.TYPE, Integer.TYPE, Float.TYPE); - - // Profiler - @Deprecated public static final MethodInfo startSection = new MethodInfo(Obf.Profiler, Obf.startSection, Void.TYPE, String.class); - @Deprecated public static final MethodInfo endSection = new MethodInfo(Obf.Profiler, Obf.endSection, Void.TYPE); - @Deprecated public static final MethodInfo endStartSection = new MethodInfo(Obf.Profiler, Obf.endStartSection, Void.TYPE, String.class); - - // Dedicated Server - @Deprecated public static final MethodInfo startServer = new MethodInfo(Obf.DedicatedServer, Obf.startServer, Boolean.TYPE); - @Deprecated public static final MethodInfo startServerThread = new MethodInfo(Obf.MinecraftServer, Obf.startServerThread, Void.TYPE); - - private Methods() {} - - private static final Map methodMap = new HashMap(); - - static - { - try - { - for (Field fd : Methods.class.getFields()) - { - if (fd.getType().equals(MethodInfo.class)) - { - Methods.methodMap.put(fd.getName(), (MethodInfo)fd.get(null)); - } - } - } - catch (IllegalAccessException ex) {} - } - - public static MethodInfo getByName(String name) - { - return Methods.methodMap.get(name); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/runtime/Obf.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/runtime/Obf.java deleted file mode 100644 index 07cb0a1d..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/runtime/Obf.java +++ /dev/null @@ -1,432 +0,0 @@ -package com.mumfrey.liteloader.core.runtime; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Field; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -/** - * Centralised obfuscation table for LiteLoader - * - * @author Adam Mummery-Smith - * TODO Obfuscation 1.8 - */ -public class Obf -{ - // Non-obfuscated references, here for convenience - // ----------------------------------------------------------------------------------------- - public static final Obf EventProxy = new Obf("com.mumfrey.liteloader.core.event.EventProxy" ); - public static final Obf HandlerList = new Obf("com.mumfrey.liteloader.core.event.HandlerList" ); - public static final Obf BakedHandlerList = new Obf("com.mumfrey.liteloader.core.event.HandlerList$BakedHandlerList" ); - public static final Obf BakedProfilingHandlerList = new Obf("com.mumfrey.liteloader.core.event.ProfilingHandlerList$BakedList" ); - public static final Obf PacketEvents = new Obf("com.mumfrey.liteloader.core.PacketEvents" ); - public static final Obf PacketEventsClient = new Obf("com.mumfrey.liteloader.client.PacketEventsClient" ); - public static final Obf LoadingBar = new Obf("com.mumfrey.liteloader.client.gui.startup.LoadingBar" ); - public static final Obf GameProfile = new Obf("com.mojang.authlib.GameProfile" ); - public static final Obf MinecraftMain = new Obf("net.minecraft.client.main.Main" ); - public static final Obf MinecraftServer = new Obf("net.minecraft.server.MinecraftServer" ); - public static final Obf GL11 = new Obf("org.lwjgl.opengl.GL11" ); - public static final Obf RealmsMainScreen = new Obf("com.mojang.realmsclient.RealmsMainScreen" ); - public static final Obf init = new Obf("init" ); - public static final Obf postInit = new Obf("postInit" ); - public static final Obf constructor = new Obf("" ); - - // Overlays and Accessor Interfaces - // ----------------------------------------------------------------------------------------- - public static final Obf IMinecraft = new Obf("com.mumfrey.liteloader.client.overlays.IMinecraft" ); - public static final Obf IGuiTextField = new Obf("com.mumfrey.liteloader.client.overlays.IGuiTextField" ); - public static final Obf IEntityRenderer = new Obf("com.mumfrey.liteloader.client.overlays.IEntityRenderer" ); - public static final Obf ISoundHandler = new Obf("com.mumfrey.liteloader.client.overlays.ISoundHandler" ); - - // CHECKSTYLE:OFF - - // Classes - // ----------------------------------------------------------------------------------------- - public static final Obf Minecraft = new Obf("net.minecraft.client.Minecraft", "bsu" ); - public static final Obf EntityRenderer = new Obf("net.minecraft.client.renderer.EntityRenderer", "cji" ); - public static final Obf Blocks = new Obf("net.minecraft.init.Blocks", "aty" ); - public static final Obf CrashReport$6 = new Obf("net.minecraft.crash.CrashReport$6", "h" ); - public static final Obf INetHandler = new Obf("net.minecraft.network.INetHandler", "hg" ); - public static final Obf Items = new Obf("net.minecraft.init.Items", "amk" ); - - // Fields - // ----------------------------------------------------------------------------------------- - public static final Obf tileEntityNameToClassMap = new Obf("field_145855_i", "f" ); - public static final Obf tileEntityClassToNameMap = new Obf("field_145853_j", "g" ); - - // Methods - // ----------------------------------------------------------------------------------------- - public static final Obf startGame = new Obf("func_71384_a", "aj" ); - public static final Obf startSection = new Obf("func_76320_a", "a" ); - public static final Obf endSection = new Obf("func_76319_b", "b" ); - public static final Obf endStartSection = new Obf("func_76318_c", "c" ); - public static final Obf processPacket = new Obf("func_148833_a", "a" ); - - // Legacy - // ----------------------------------------------------------------------------------------- - @Deprecated public static final Obf GuiIngame = new Obf("net.minecraft.client.gui.GuiIngame", "btz" ); - @Deprecated public static final Obf Profiler = new Obf("net.minecraft.profiler.Profiler", "uw" ); - @Deprecated public static final Obf IntegratedServer = new Obf("net.minecraft.server.integrated.IntegratedServer", "cyk" ); - @Deprecated public static final Obf WorldSettings = new Obf("net.minecraft.world.WorldSettings", "arb" ); - @Deprecated public static final Obf ServerConfigurationManager = new Obf("net.minecraft.server.management.ServerConfigurationManager", "sn" ); - @Deprecated public static final Obf EntityPlayerMP = new Obf("net.minecraft.entity.player.EntityPlayerMP", "qw" ); - @Deprecated public static final Obf NetworkManager = new Obf("net.minecraft.network.NetworkManager", "gr" ); - @Deprecated public static final Obf DedicatedServer = new Obf("net.minecraft.server.dedicated.DedicatedServer", "po" ); - @Deprecated public static final Obf EntityPlayerSP = new Obf("net.minecraft.client.entity.EntityPlayerSP", "cio" ); - @Deprecated public static final Obf FrameBuffer = new Obf("net.minecraft.client.shader.Framebuffer", "ckw" ); - @Deprecated public static final Obf GuiNewChat = new Obf("net.minecraft.client.gui.GuiNewChat", "buh" ); - @Deprecated public static final Obf GlStateManager = new Obf("net.minecraft.client.renderer.GlStateManager", "cjm" ); - @Deprecated public static final Obf Session = new Obf("net.minecraft.util.Session", "btw" ); - @Deprecated public static final Obf IChatComponent = new Obf("net.minecraft.util.IChatComponent", "ho" ); - @Deprecated public static final Obf ScreenShotHelper = new Obf("net.minecraft.util.ScreenShotHelper", "btt" ); - @Deprecated public static final Obf OpenGlHelper = new Obf("net.minecraft.client.renderer.OpenGlHelper", "dax" ); - @Deprecated public static final Obf Entity = new Obf("net.minecraft.entity.Entity", "wv" ); - @Deprecated public static final Obf RenderManager = new Obf("net.minecraft.client.renderer.entity.RenderManager", "cpt" ); - @Deprecated public static final Obf Render = new Obf("net.minecraft.client.renderer.entity.Render", "cpu" ); - @Deprecated public static final Obf GuiTextField = new Obf("net.minecraft.client.gui.GuiTextField", "bul" ); - @Deprecated public static final Obf SoundHandler = new Obf("net.minecraft.client.audio.SoundHandler", "czh" ); - @Deprecated public static final Obf BlockPos = new Obf("net.minecraft.util.BlockPos", "dt" ); - @Deprecated public static final Obf EnumFacing = new Obf("net.minecraft.util.EnumFacing", "ej" ); - @Deprecated public static final Obf ItemInWorldManager = new Obf("net.minecraft.server.management.ItemInWorldManager", "qx" ); - @Deprecated public static final Obf NetHandlerPlayServer = new Obf("net.minecraft.network.NetHandlerPlayServer", "rj" ); - @Deprecated public static final Obf EntityPlayer = new Obf("net.minecraft.entity.player.EntityPlayer", "ahd" ); - @Deprecated public static final Obf World = new Obf("net.minecraft.world.World", "aqu" ); - @Deprecated public static final Obf ItemStack = new Obf("net.minecraft.item.ItemStack", "amj" ); - @Deprecated public static final Obf PacketThreadUtil = new Obf("net.minecraft.network.PacketThreadUtil", "ig" ); - @Deprecated public static final Obf RenderGlobal = new Obf("net.minecraft.client.renderer.RenderGlobal", "ckn" ); - @Deprecated public static final Obf minecraftProfiler = new Obf("field_71424_I", "y" ); - @Deprecated public static final Obf entityRenderMap = new Obf("field_78729_o", "k" ); - @Deprecated public static final Obf reloadListeners = new Obf("field_110546_b", "d" ); - @Deprecated public static final Obf networkManager = new Obf("field_147393_d", "d" ); - @Deprecated public static final Obf registryObjects = new Obf("field_82596_a", "c" ); - @Deprecated public static final Obf underlyingIntegerMap = new Obf("field_148759_a", "a" ); - @Deprecated public static final Obf identityMap = new Obf("field_148749_a", "a" ); - @Deprecated public static final Obf objectList = new Obf("field_148748_b", "b" ); - @Deprecated public static final Obf mapSpecialRenderers = new Obf("field_147559_m", "m" ); - @Deprecated public static final Obf timer = new Obf("field_71428_T", "U" ); - @Deprecated public static final Obf mcProfiler = new Obf("field_71424_I", "y" ); - @Deprecated public static final Obf running = new Obf("field_71425_J", "z" ); - @Deprecated public static final Obf defaultResourcePacks = new Obf("field_110449_ao", "aw" ); - @Deprecated public static final Obf serverName = new Obf("field_71475_ae", "am" ); - @Deprecated public static final Obf serverPort = new Obf("field_71477_af", "an" ); - @Deprecated public static final Obf shaderResourceLocations = new Obf("field_147712_ad", "ab" ); - @Deprecated public static final Obf shaderIndex = new Obf("field_147713_ae", "ac" ); - @Deprecated public static final Obf useShader = new Obf("field_175083_ad", "ad" ); - @Deprecated public static final Obf viewDistance = new Obf("field_149528_b", "b" ); - @Deprecated public static final Obf entityPosY = new Obf("field_70163_u", "t" ); - @Deprecated public static final Obf chatComponent = new Obf("field_148919_a", "a" ); - @Deprecated public static final Obf runGameLoop = new Obf("func_71411_J", "as" ); - @Deprecated public static final Obf runTick = new Obf("func_71407_l", "r" ); - @Deprecated public static final Obf updateCameraAndRender = new Obf("func_78480_b", "b" ); - @Deprecated public static final Obf renderWorld = new Obf("func_78471_a", "a" ); - @Deprecated public static final Obf renderGameOverlay = new Obf("func_175180_a", "a" ); - @Deprecated public static final Obf spawnPlayer = new Obf("func_148545_a", "f" ); - @Deprecated public static final Obf respawnPlayer = new Obf("func_72368_a", "a" ); - @Deprecated public static final Obf initializeConnectionToPlayer = new Obf("func_72355_a", "a" ); - @Deprecated public static final Obf playerLoggedIn = new Obf("func_72377_c", "c" ); - @Deprecated public static final Obf playerLoggedOut = new Obf("func_72367_e", "e" ); - @Deprecated public static final Obf startServer = new Obf("func_71197_b", "i" ); - @Deprecated public static final Obf startServerThread = new Obf("func_71256_s", "B" ); - @Deprecated public static final Obf sendChatMessage = new Obf("func_71165_d", "e" ); - @Deprecated public static final Obf updateFramebufferSize = new Obf("func_147119_ah", "av" ); - @Deprecated public static final Obf framebufferRender = new Obf("func_147615_c", "c" ); - @Deprecated public static final Obf framebufferRenderExt = new Obf("func_178038_a", "a" ); - @Deprecated public static final Obf bindFramebufferTexture = new Obf("func_147612_c", "c" ); - @Deprecated public static final Obf drawChat = new Obf("func_146230_a", "a" ); - @Deprecated public static final Obf clear = new Obf("func_179086_m", "m" ); - @Deprecated public static final Obf renderWorldPass = new Obf("func_175068_a", "a" ); - @Deprecated public static final Obf getProfile = new Obf("func_148256_e", "a" ); - @Deprecated public static final Obf saveScreenshot = new Obf("func_148260_a", "a" ); - @Deprecated public static final Obf isFramebufferEnabled = new Obf("func_148822_b", "i" ); - @Deprecated public static final Obf doRenderEntity = new Obf("func_147939_a", "a" ); - @Deprecated public static final Obf doRender = new Obf("func_76986_a", "a" ); - @Deprecated public static final Obf doRenderShadowAndFire = new Obf("func_76979_b", "b" ); - @Deprecated public static final Obf resize = new Obf("func_71370_a", "a" ); - @Deprecated public static final Obf loadShader = new Obf("func_175069_a", "a" ); - @Deprecated public static final Obf getFOVModifier = new Obf("func_78481_a", "a" ); - @Deprecated public static final Obf setupCameraTransform = new Obf("func_78479_a", "a" ); - @Deprecated public static final Obf loadSoundResource = new Obf("func_147693_a", "a" ); - @Deprecated public static final Obf onBlockClicked = new Obf("func_180784_a", "a" ); - @Deprecated public static final Obf activateBlockOrUseItem = new Obf("func_180236_a", "a" ); - @Deprecated public static final Obf processPlayerBlockPlacement = new Obf("func_147346_a", "a" ); - @Deprecated public static final Obf handleAnimation = new Obf("func_175087_a", "a" ); - @Deprecated public static final Obf processPlayerDigging = new Obf("func_147345_a", "a" ); - @Deprecated public static final Obf updateTimeLightAndEntities = new Obf("func_71190_q", "z" ); - @Deprecated public static final Obf checkThreadAndEnqueue = new Obf("func_180031_a", "a" ); - @Deprecated public static final Obf processPlayer = new Obf("func_147347_a", "a" ); - @Deprecated public static final Obf renderSky = new Obf("func_174976_a", "a" ); - @Deprecated public static final Obf renderCloudsCheck = new Obf("func_180437_a", "a" ); - @Deprecated public static final Obf setupFog = new Obf("func_78468_a", "a" ); - - // CHECKSTYLE:ON - - public static final int MCP = 0; - public static final int SRG = 1; - public static final int OBF = 2; - - private static Properties mcpNames; - - private static final Map obfs = new HashMap(); - - static - { - try - { - for (Field fd : Obf.class.getFields()) - { - if (fd.getType().equals(Obf.class)) - { - Obf.obfs.put(fd.getName(), (Obf)fd.get(null)); - } - } - } - catch (IllegalAccessException ex) {} - } - - /** - * Array of names, indexed by MCP, SRG, OBF constants - */ - public final String[] names; - - /** - * Class, field or method name in unobfuscated (MCP) format - */ - public final String name; - - /** - * Class name in bytecode notation with slashes instead of dots - */ - public final String ref; - - /** - * Class, field or method name in searge format - */ - public final String srg; - - /** - * Class, field or method name in obfuscated (original) format - */ - public final String obf; - - /** - * @param mcpName - */ - protected Obf(String mcpName) - { - this(mcpName, mcpName, mcpName); - } - - /** - * @param seargeName - * @param obfName - */ - protected Obf(String seargeName, String obfName) - { - this(seargeName, obfName, null); - } - - /** - * @param seargeName - * @param obfName - * @param mcpName - */ - protected Obf(String seargeName, String obfName, String mcpName) - { - this.name = mcpName != null ? mcpName : this.getDeobfuscatedName(seargeName); - this.ref = this.name.replace('.', '/'); - this.srg = seargeName; - this.obf = obfName; - - this.names = new String[] { this.name, this.srg, this.obf }; - } - - /** - * @param type - */ - public String getDescriptor(int type) - { - return String.format("L%s;", this.names[type].replace('.', '/')); - } - - /** - * Test whether any of this Obf's dimensions match the supplied name - * - * @param name - */ - public boolean matches(String name) - { - return this.obf.equals(name) || this.srg.equals(name)|| this.name.equals(name); - } - - /** - * Test whether any of this Obf's dimensions match the supplied name or - * ordinal - * - * @param name - * @param ordinal - */ - public boolean matches(String name, int ordinal) - { - if (this.isOrdinal() && ordinal > -1) - { - return this.getOrdinal() == ordinal; - } - - return this.matches(name); - } - - /** - * Returns true if this is an ordinal pointer - */ - public boolean isOrdinal() - { - return false; - } - - /** - * Get the ordinal for this entry - */ - public int getOrdinal() - { - return -1; - } - - @Override - public String toString() - { - return String.format("%s[%s,%s,%s]@%d", this.getClass().getSimpleName(), this.name, this.srg, this.obf, this.getOrdinal()); - } - - /** - * @param seargeName - */ - protected String getDeobfuscatedName(String seargeName) - { - return Obf.getDeobfName(seargeName); - } - - /** - * @param seargeName - */ - static String getDeobfName(String seargeName) - { - if (Obf.mcpNames == null) - { - Obf.mcpNames = new Properties(); - InputStream is = Obf.class.getResourceAsStream("/obfuscation.properties"); - if (is != null) - { - try - { - Obf.mcpNames.load(is); - } - catch (IOException ex) {} - - try - { - is.close(); - } - catch (IOException ex) {} - } - } - - return Obf.mcpNames.getProperty(seargeName, seargeName); - } - - /** - * @param name - */ - public static Obf getByName(String name) - { - return Obf.obfs.get(name); - } - - public static Obf getByName(Class obf, String name) - { - try - { - for (Field fd : obf.getFields()) - { - if (Obf.class.isAssignableFrom(fd.getType())) - { - String fieldName = fd.getName(); - Obf entry = (Obf)fd.get(null); - if (name.equals(fieldName) || name.equals(entry.name)) - { - return entry; - } - } - } - } - catch (Exception ex) {} - - return Obf.getByName(name); - } - - public static String lookupMCPName(String obfName) - { - for (Obf obf : Obf.obfs.values()) - { - if (obfName.equals(obf.obf)) - { - return obf.name; - } - } - - return obfName; - } - - /** - * Ordinal reference, can be passed to some methods which accept an - * {@link Obf} to indicate an offset into a class rather than a named - * reference. - * - * @author Adam Mummery-Smith - */ - public static class Ord extends Obf - { - /** - * Field/method offset - */ - private final int ordinal; - - /** - * @param name Field/method name - * @param ordinal Field/method ordinal - */ - public Ord(String name, int ordinal) - { - super(name); - this.ordinal = ordinal; - } - - /** - * @param ordinal Field ordinal - */ - public Ord(int ordinal) - { - super("ord#" + ordinal); - this.ordinal = ordinal; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.runtime.Obf#isOrdinal() - */ - @Override - public boolean isOrdinal() - { - return true; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.runtime.Obf#getOrdinal() - */ - @Override - public int getOrdinal() - { - return this.ordinal; - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/core/runtime/Packets.java b/liteloader/src/main/java/com/mumfrey/liteloader/core/runtime/Packets.java deleted file mode 100644 index 48765098..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/core/runtime/Packets.java +++ /dev/null @@ -1,321 +0,0 @@ -package com.mumfrey.liteloader.core.runtime; - -import java.util.HashMap; -import java.util.Map; - -/** - * Packet obfuscation table - * - * @author Adam Mummery-Smith - * TODO Obfuscation 1.8 - */ -public final class Packets extends Obf -{ - /** - * Since we need to catch and deal with the fact that a packet is first - * marshalled across threads via PacketThreadUtil, we will need to know - * which owner object to check against the current thread in order to detect - * when the packet instance is being processed by the main message loop. The - * Context object describes in which context (client or server) that a - * particular packet will be processed in on the receiving end, and - * thus which object to check threading against. - * - * @author Adam Mummery-Smith - */ - public enum Context - { - CLIENT, - SERVER - } - - // CHECKSTYLE:OFF - - private static Map packetMap = new HashMap(); - - public static Packets S08PacketPlayerPosLook = new Packets("net.minecraft.network.play.server.S08PacketPlayerPosLook", "ii", Context.CLIENT); - public static Packets S0EPacketSpawnObject = new Packets("net.minecraft.network.play.server.S0EPacketSpawnObject", "il", Context.CLIENT); - public static Packets S11PacketSpawnExperienceOrb = new Packets("net.minecraft.network.play.server.S11PacketSpawnExperienceOrb", "im", Context.CLIENT); - public static Packets S2CPacketSpawnGlobalEntity = new Packets("net.minecraft.network.play.server.S2CPacketSpawnGlobalEntity", "in", Context.CLIENT); - public static Packets S0FPacketSpawnMob = new Packets("net.minecraft.network.play.server.S0FPacketSpawnMob", "io", Context.CLIENT); - public static Packets S10PacketSpawnPainting = new Packets("net.minecraft.network.play.server.S10PacketSpawnPainting", "ip", Context.CLIENT); - public static Packets S0CPacketSpawnPlayer = new Packets("net.minecraft.network.play.server.S0CPacketSpawnPlayer", "iq", Context.CLIENT); - public static Packets S0BPacketAnimation = new Packets("net.minecraft.network.play.server.S0BPacketAnimation", "ir", Context.CLIENT); - public static Packets S37PacketStatistics = new Packets("net.minecraft.network.play.server.S37PacketStatistics", "is", Context.CLIENT); - public static Packets S25PacketBlockBreakAnim = new Packets("net.minecraft.network.play.server.S25PacketBlockBreakAnim", "it", Context.CLIENT); - public static Packets S35PacketUpdateTileEntity = new Packets("net.minecraft.network.play.server.S35PacketUpdateTileEntity", "iu", Context.CLIENT); - public static Packets S24PacketBlockAction = new Packets("net.minecraft.network.play.server.S24PacketBlockAction", "iv", Context.CLIENT); - public static Packets S23PacketBlockChange = new Packets("net.minecraft.network.play.server.S23PacketBlockChange", "iw", Context.CLIENT); - public static Packets S41PacketServerDifficulty = new Packets("net.minecraft.network.play.server.S41PacketServerDifficulty", "ix", Context.CLIENT); - public static Packets S3APacketTabComplete = new Packets("net.minecraft.network.play.server.S3APacketTabComplete", "iy", Context.CLIENT); - public static Packets S02PacketChat = new Packets("net.minecraft.network.play.server.S02PacketChat", "iz", Context.CLIENT); - public static Packets S22PacketMultiBlockChange = new Packets("net.minecraft.network.play.server.S22PacketMultiBlockChange", "ja", Context.CLIENT); - public static Packets S32PacketConfirmTransaction = new Packets("net.minecraft.network.play.server.S32PacketConfirmTransaction", "jc", Context.CLIENT); - public static Packets S2EPacketCloseWindow = new Packets("net.minecraft.network.play.server.S2EPacketCloseWindow", "jd", Context.CLIENT); - public static Packets S2DPacketOpenWindow = new Packets("net.minecraft.network.play.server.S2DPacketOpenWindow", "je", Context.CLIENT); - public static Packets S30PacketWindowItems = new Packets("net.minecraft.network.play.server.S30PacketWindowItems", "jf", Context.CLIENT); - public static Packets S31PacketWindowProperty = new Packets("net.minecraft.network.play.server.S31PacketWindowProperty", "jg", Context.CLIENT); - public static Packets S2FPacketSetSlot = new Packets("net.minecraft.network.play.server.S2FPacketSetSlot", "jh", Context.CLIENT); - public static Packets S3FPacketCustomPayload = new Packets("net.minecraft.network.play.server.S3FPacketCustomPayload", "ji", Context.CLIENT); - public static Packets S40PacketDisconnect = new Packets("net.minecraft.network.play.server.S40PacketDisconnect", "jj", Context.CLIENT); - public static Packets S19PacketEntityStatus = new Packets("net.minecraft.network.play.server.S19PacketEntityStatus", "jk", Context.CLIENT); - public static Packets S49PacketUpdateEntityNBT = new Packets("net.minecraft.network.play.server.S49PacketUpdateEntityNBT", "jl", Context.CLIENT); - public static Packets S27PacketExplosion = new Packets("net.minecraft.network.play.server.S27PacketExplosion", "jm", Context.CLIENT); - public static Packets S46PacketSetCompressionLevel = new Packets("net.minecraft.network.play.server.S46PacketSetCompressionLevel", "jn", Context.CLIENT); - public static Packets S2BPacketChangeGameState = new Packets("net.minecraft.network.play.server.S2BPacketChangeGameState", "jo", Context.CLIENT); - public static Packets S00PacketKeepAlive = new Packets("net.minecraft.network.play.server.S00PacketKeepAlive", "jp", Context.CLIENT); - public static Packets S21PacketChunkData = new Packets("net.minecraft.network.play.server.S21PacketChunkData", "jq", Context.CLIENT); - public static Packets S26PacketMapChunkBulk = new Packets("net.minecraft.network.play.server.S26PacketMapChunkBulk", "js", Context.CLIENT); - public static Packets S28PacketEffect = new Packets("net.minecraft.network.play.server.S28PacketEffect", "jt", Context.CLIENT); - public static Packets S2APacketParticles = new Packets("net.minecraft.network.play.server.S2APacketParticles", "ju", Context.CLIENT); - public static Packets S29PacketSoundEffect = new Packets("net.minecraft.network.play.server.S29PacketSoundEffect", "jv", Context.CLIENT); - public static Packets S01PacketJoinGame = new Packets("net.minecraft.network.play.server.S01PacketJoinGame", "jw", Context.CLIENT); - public static Packets S34PacketMaps = new Packets("net.minecraft.network.play.server.S34PacketMaps", "jx", Context.CLIENT); - public static Packets S14PacketEntity = new Packets("net.minecraft.network.play.server.S14PacketEntity", "jy", Context.CLIENT); - public static Packets S15PacketEntityRelMove = new Packets("net.minecraft.network.play.server.S14PacketEntity$S15PacketEntityRelMove", "jz", Context.CLIENT); - public static Packets S17PacketEntityLookMove = new Packets("net.minecraft.network.play.server.S14PacketEntity$S17PacketEntityLookMove", "ka", Context.CLIENT); - public static Packets S16PacketEntityLook = new Packets("net.minecraft.network.play.server.S14PacketEntity$S16PacketEntityLook", "kb", Context.CLIENT); - public static Packets S36PacketSignEditorOpen = new Packets("net.minecraft.network.play.server.S36PacketSignEditorOpen", "kc", Context.CLIENT); - public static Packets S39PacketPlayerAbilities = new Packets("net.minecraft.network.play.server.S39PacketPlayerAbilities", "kd", Context.CLIENT); - public static Packets S42PacketCombatEvent = new Packets("net.minecraft.network.play.server.S42PacketCombatEvent", "ke", Context.CLIENT); - public static Packets S38PacketPlayerListItem = new Packets("net.minecraft.network.play.server.S38PacketPlayerListItem", "kh", Context.CLIENT); - public static Packets S0APacketUseBed = new Packets("net.minecraft.network.play.server.S0APacketUseBed", "kl", Context.CLIENT); - public static Packets S13PacketDestroyEntities = new Packets("net.minecraft.network.play.server.S13PacketDestroyEntities", "km", Context.CLIENT); - public static Packets S1EPacketRemoveEntityEffect = new Packets("net.minecraft.network.play.server.S1EPacketRemoveEntityEffect", "kn", Context.CLIENT); - public static Packets S48PacketResourcePackSend = new Packets("net.minecraft.network.play.server.S48PacketResourcePackSend", "ko", Context.CLIENT); - public static Packets S07PacketRespawn = new Packets("net.minecraft.network.play.server.S07PacketRespawn", "kp", Context.CLIENT); - public static Packets S19PacketEntityHeadLook = new Packets("net.minecraft.network.play.server.S19PacketEntityHeadLook", "kq", Context.CLIENT); - public static Packets S44PacketWorldBorder = new Packets("net.minecraft.network.play.server.S44PacketWorldBorder", "kr", Context.CLIENT); - public static Packets S43PacketCamera = new Packets("net.minecraft.network.play.server.S43PacketCamera", "ku", Context.CLIENT); - public static Packets S09PacketHeldItemChange = new Packets("net.minecraft.network.play.server.S09PacketHeldItemChange", "kv", Context.CLIENT); - public static Packets S3DPacketDisplayScoreboard = new Packets("net.minecraft.network.play.server.S3DPacketDisplayScoreboard", "kw", Context.CLIENT); - public static Packets S1CPacketEntityMetadata = new Packets("net.minecraft.network.play.server.S1CPacketEntityMetadata", "kx", Context.CLIENT); - public static Packets S1BPacketEntityAttach = new Packets("net.minecraft.network.play.server.S1BPacketEntityAttach", "ky", Context.CLIENT); - public static Packets S12PacketEntityVelocity = new Packets("net.minecraft.network.play.server.S12PacketEntityVelocity", "kz", Context.CLIENT); - public static Packets S04PacketEntityEquipment = new Packets("net.minecraft.network.play.server.S04PacketEntityEquipment", "la", Context.CLIENT); - public static Packets S1FPacketSetExperience = new Packets("net.minecraft.network.play.server.S1FPacketSetExperience", "lb", Context.CLIENT); - public static Packets S06PacketUpdateHealth = new Packets("net.minecraft.network.play.server.S06PacketUpdateHealth", "lc", Context.CLIENT); - public static Packets S3BPacketScoreboardObjective = new Packets("net.minecraft.network.play.server.S3BPacketScoreboardObjective", "ld", Context.CLIENT); - public static Packets S3EPacketTeams = new Packets("net.minecraft.network.play.server.S3EPacketTeams", "le", Context.CLIENT); - public static Packets S3CPacketUpdateScore = new Packets("net.minecraft.network.play.server.S3CPacketUpdateScore", "lf", Context.CLIENT); - public static Packets S05PacketSpawnPosition = new Packets("net.minecraft.network.play.server.S05PacketSpawnPosition", "lh", Context.CLIENT); - public static Packets S03PacketTimeUpdate = new Packets("net.minecraft.network.play.server.S03PacketTimeUpdate", "li", Context.CLIENT); - public static Packets S45PacketTitle = new Packets("net.minecraft.network.play.server.S45PacketTitle", "lj", Context.CLIENT); - public static Packets S33PacketUpdateSign = new Packets("net.minecraft.network.play.server.S33PacketUpdateSign", "ll", Context.CLIENT); - public static Packets S47PacketPlayerListHeaderFooter = new Packets("net.minecraft.network.play.server.S47PacketPlayerListHeaderFooter", "lm", Context.CLIENT); - public static Packets S0DPacketCollectItem = new Packets("net.minecraft.network.play.server.S0DPacketCollectItem", "ln", Context.CLIENT); - public static Packets S18PacketEntityTeleport = new Packets("net.minecraft.network.play.server.S18PacketEntityTeleport", "lo", Context.CLIENT); - public static Packets S20PacketEntityProperties = new Packets("net.minecraft.network.play.server.S20PacketEntityProperties", "lp", Context.CLIENT); - public static Packets S1DPacketEntityEffect = new Packets("net.minecraft.network.play.server.S1DPacketEntityEffect", "lr", Context.CLIENT); - public static Packets C14PacketTabComplete = new Packets("net.minecraft.network.play.client.C14PacketTabComplete", "lt", Context.SERVER); - public static Packets C01PacketChatMessage = new Packets("net.minecraft.network.play.client.C01PacketChatMessage", "lu", Context.SERVER); - public static Packets C16PacketClientStatus = new Packets("net.minecraft.network.play.client.C16PacketClientStatus", "lv", Context.SERVER); - public static Packets C15PacketClientSettings = new Packets("net.minecraft.network.play.client.C15PacketClientSettings", "lx", Context.SERVER); - public static Packets C0FPacketConfirmTransaction = new Packets("net.minecraft.network.play.client.C0FPacketConfirmTransaction", "ly", Context.SERVER); - public static Packets C11PacketEnchantItem = new Packets("net.minecraft.network.play.client.C11PacketEnchantItem", "lz", Context.SERVER); - public static Packets C0EPacketClickWindow = new Packets("net.minecraft.network.play.client.C0EPacketClickWindow", "ma", Context.SERVER); - public static Packets C0DPacketCloseWindow = new Packets("net.minecraft.network.play.client.C0DPacketCloseWindow", "mb", Context.SERVER); - public static Packets C17PacketCustomPayload = new Packets("net.minecraft.network.play.client.C17PacketCustomPayload", "mc", Context.SERVER); - public static Packets C02PacketUseEntity = new Packets("net.minecraft.network.play.client.C02PacketUseEntity", "md", Context.SERVER); - public static Packets C00PacketKeepAlive = new Packets("net.minecraft.network.play.client.C00PacketKeepAlive", "mf", Context.SERVER); - public static Packets C03PacketPlayer = new Packets("net.minecraft.network.play.client.C03PacketPlayer", "mg", Context.SERVER); - public static Packets C04PacketPlayerPosition = new Packets("net.minecraft.network.play.client.C03PacketPlayer$C04PacketPlayerPosition", "mh", Context.SERVER); - public static Packets C06PacketPlayerPosLook = new Packets("net.minecraft.network.play.client.C03PacketPlayer$C06PacketPlayerPosLook", "mi", Context.SERVER); - public static Packets C05PacketPlayerLook = new Packets("net.minecraft.network.play.client.C03PacketPlayer$C05PacketPlayerLook", "mj", Context.SERVER); - public static Packets C13PacketPlayerAbilities = new Packets("net.minecraft.network.play.client.C13PacketPlayerAbilities", "mk", Context.SERVER); - public static Packets C07PacketPlayerDigging = new Packets("net.minecraft.network.play.client.C07PacketPlayerDigging", "ml", Context.SERVER); - public static Packets C0BPacketEntityAction = new Packets("net.minecraft.network.play.client.C0BPacketEntityAction", "mn", Context.SERVER); - public static Packets C0CPacketInput = new Packets("net.minecraft.network.play.client.C0CPacketInput", "mp", Context.SERVER); - public static Packets C19PacketResourcePackStatus = new Packets("net.minecraft.network.play.client.C19PacketResourcePackStatus", "mq", Context.SERVER); - public static Packets C09PacketHeldItemChange = new Packets("net.minecraft.network.play.client.C09PacketHeldItemChange", "ms", Context.SERVER); - public static Packets C10PacketCreativeInventoryAction = new Packets("net.minecraft.network.play.client.C10PacketCreativeInventoryAction", "mt", Context.SERVER); - public static Packets C12PacketUpdateSign = new Packets("net.minecraft.network.play.client.C12PacketUpdateSign", "mu", Context.SERVER); - public static Packets C0APacketAnimation = new Packets("net.minecraft.network.play.client.C0APacketAnimation", "mv", Context.SERVER); - public static Packets C18PacketSpectate = new Packets("net.minecraft.network.play.client.C18PacketSpectate", "mw", Context.SERVER); - public static Packets C08PacketPlayerBlockPlacement = new Packets("net.minecraft.network.play.client.C08PacketPlayerBlockPlacement", "mx", Context.SERVER); - public static Packets C00Handshake = new Packets("net.minecraft.network.handshake.client.C00Handshake", "mz", Context.SERVER); - public static Packets S02PacketLoginSuccess = new Packets("net.minecraft.network.login.server.S02PacketLoginSuccess", "nd", Context.CLIENT); - public static Packets S01PacketEncryptionRequest = new Packets("net.minecraft.network.login.server.S01PacketEncryptionRequest", "ne", Context.CLIENT); - public static Packets S03PacketEnableCompression = new Packets("net.minecraft.network.login.server.S03PacketEnableCompression", "nf", Context.CLIENT); - public static Packets S00PacketDisconnect = new Packets("net.minecraft.network.login.server.S00PacketDisconnect", "ng", Context.CLIENT); - public static Packets C00PacketLoginStart = new Packets("net.minecraft.network.login.client.C00PacketLoginStart", "ni", Context.SERVER); - public static Packets C01PacketEncryptionResponse = new Packets("net.minecraft.network.login.client.C01PacketEncryptionResponse", "nj", Context.SERVER); - public static Packets S01PacketPong = new Packets("net.minecraft.network.status.server.S01PacketPong", "nn", Context.CLIENT); - public static Packets S00PacketServerInfo = new Packets("net.minecraft.network.status.server.S00PacketServerInfo", "no", Context.CLIENT); - public static Packets C01PacketPing = new Packets("net.minecraft.network.status.client.C01PacketPing", "nw", Context.SERVER); - public static Packets C00PacketServerQuery = new Packets("net.minecraft.network.status.client.C00PacketServerQuery", "nx", Context.SERVER); - - // CHECKSTYLE:ON - - public static final Packets[] packets = new Packets[] { - S08PacketPlayerPosLook, - S0EPacketSpawnObject, - S11PacketSpawnExperienceOrb, - S2CPacketSpawnGlobalEntity, - S0FPacketSpawnMob, - S10PacketSpawnPainting, - S0CPacketSpawnPlayer, - S0BPacketAnimation, - S37PacketStatistics, - S25PacketBlockBreakAnim, - S35PacketUpdateTileEntity, - S24PacketBlockAction, - S23PacketBlockChange, - S41PacketServerDifficulty, - S3APacketTabComplete, - S02PacketChat, - S22PacketMultiBlockChange, - S32PacketConfirmTransaction, - S2EPacketCloseWindow, - S2DPacketOpenWindow, - S30PacketWindowItems, - S31PacketWindowProperty, - S2FPacketSetSlot, - S3FPacketCustomPayload, - S40PacketDisconnect, - S19PacketEntityStatus, - S49PacketUpdateEntityNBT, - S27PacketExplosion, - S46PacketSetCompressionLevel, - S2BPacketChangeGameState, - S00PacketKeepAlive, - S21PacketChunkData, - S26PacketMapChunkBulk, - S28PacketEffect, - S2APacketParticles, - S29PacketSoundEffect, - S01PacketJoinGame, - S34PacketMaps, - S14PacketEntity, - S15PacketEntityRelMove, - S17PacketEntityLookMove, - S16PacketEntityLook, - S36PacketSignEditorOpen, - S39PacketPlayerAbilities, - S42PacketCombatEvent, - S38PacketPlayerListItem, - S0APacketUseBed, - S13PacketDestroyEntities, - S1EPacketRemoveEntityEffect, - S48PacketResourcePackSend, - S07PacketRespawn, - S19PacketEntityHeadLook, - S44PacketWorldBorder, - S43PacketCamera, - S09PacketHeldItemChange, - S3DPacketDisplayScoreboard, - S1CPacketEntityMetadata, - S1BPacketEntityAttach, - S12PacketEntityVelocity, - S04PacketEntityEquipment, - S1FPacketSetExperience, - S06PacketUpdateHealth, - S3BPacketScoreboardObjective, - S3EPacketTeams, - S3CPacketUpdateScore, - S05PacketSpawnPosition, - S03PacketTimeUpdate, - S45PacketTitle, - S33PacketUpdateSign, - S47PacketPlayerListHeaderFooter, - S0DPacketCollectItem, - S18PacketEntityTeleport, - S20PacketEntityProperties, - S1DPacketEntityEffect, - C14PacketTabComplete, - C01PacketChatMessage, - C16PacketClientStatus, - C15PacketClientSettings, - C0FPacketConfirmTransaction, - C11PacketEnchantItem, - C0EPacketClickWindow, - C0DPacketCloseWindow, - C17PacketCustomPayload, - C02PacketUseEntity, - C00PacketKeepAlive, - C03PacketPlayer, - C04PacketPlayerPosition, - C06PacketPlayerPosLook, - C05PacketPlayerLook, - C13PacketPlayerAbilities, - C07PacketPlayerDigging, - C0BPacketEntityAction, - C0CPacketInput, - C19PacketResourcePackStatus, - C09PacketHeldItemChange, - C10PacketCreativeInventoryAction, - C12PacketUpdateSign, - C0APacketAnimation, - C18PacketSpectate, - C08PacketPlayerBlockPlacement, - C00Handshake, - S02PacketLoginSuccess, - S01PacketEncryptionRequest, - S03PacketEnableCompression, - S00PacketDisconnect, - C00PacketLoginStart, - C01PacketEncryptionResponse, - S01PacketPong, - S00PacketServerInfo, - C01PacketPing, - C00PacketServerQuery, - }; - - private static int nextPacketIndex; - - private final String shortName; - - private final int index; - - private final Context context; - - private Packets(String seargeName, String obfName, Context context) - { - super(seargeName, obfName); - - this.shortName = seargeName.substring(Math.max(seargeName.lastIndexOf('.'), seargeName.lastIndexOf('$')) + 1); - this.index = Packets.nextPacketIndex++; - Packets.packetMap.put(this.shortName, this); - this.context = context; - } - - public int getIndex() - { - return this.index; - } - - public String getShortName() - { - return this.shortName; - } - - public Context getContext() - { - return this.context; - } - - public static int indexOf(String packetClassName) - { - for (Packets packet : Packets.packets) - { - if (packet.name.equals(packetClassName) || packet.shortName.equals(packetClassName) || packet.obf.equals(packetClassName)) - { - return packet.index; - } - } - - return -1; - } - - public static int count() - { - return Packets.nextPacketIndex; - } - - /** - * @param name - */ - public static Packets getByName(String name) - { - return Packets.packetMap.get(name); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/crashreport/CallableLaunchWrapper.java b/liteloader/src/main/java/com/mumfrey/liteloader/crashreport/CallableLaunchWrapper.java deleted file mode 100644 index 2937d9fa..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/crashreport/CallableLaunchWrapper.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.mumfrey.liteloader.crashreport; - -import java.util.List; -import java.util.concurrent.Callable; - -import net.minecraft.crash.CrashReport; -import net.minecraft.launchwrapper.IClassTransformer; -import net.minecraft.launchwrapper.Launch; - -public class CallableLaunchWrapper implements Callable -{ - final CrashReport crashReport; - - public CallableLaunchWrapper(CrashReport report) - { - this.crashReport = report; - } - - /* (non-Javadoc) - * @see java.util.concurrent.Callable#call() - */ - @Override - public String call() throws Exception - { - return CallableLaunchWrapper.generateTransformerList(); - } - - /** - * Generates a list of active transformers to display in the crash report - */ - public static String generateTransformerList() - { - final List transformers = Launch.classLoader.getTransformers(); - - StringBuilder sb = new StringBuilder(); - sb.append(transformers.size()); - sb.append(" active transformer(s)"); - - for (IClassTransformer transformer : transformers) - { - sb.append("\n - Transformer: "); - sb.append(transformer.getClass().getName()); - } - - return sb.toString(); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/crashreport/CallableLiteLoaderBrand.java b/liteloader/src/main/java/com/mumfrey/liteloader/crashreport/CallableLiteLoaderBrand.java deleted file mode 100644 index 16a0490a..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/crashreport/CallableLiteLoaderBrand.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.mumfrey.liteloader.crashreport; - -import java.util.concurrent.Callable; - -import net.minecraft.crash.CrashReport; - -import com.mumfrey.liteloader.core.LiteLoader; - -public class CallableLiteLoaderBrand implements Callable -{ - final CrashReport crashReport; - - public CallableLiteLoaderBrand(CrashReport report) - { - this.crashReport = report; - } - - /* (non-Javadoc) - * @see java.util.concurrent.Callable#call() - */ - @Override - public String call() throws Exception - { - String brand = null; - try - { - brand = LiteLoader.getBranding(); - } - catch (Exception ex) - { - brand = "LiteLoader startup failed"; - } - return brand == null ? "Unknown / None" : brand; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/crashreport/CallableLiteLoaderMods.java b/liteloader/src/main/java/com/mumfrey/liteloader/crashreport/CallableLiteLoaderMods.java deleted file mode 100644 index 7f482c62..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/crashreport/CallableLiteLoaderMods.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.mumfrey.liteloader.crashreport; - -import java.util.concurrent.Callable; - -import net.minecraft.crash.CrashReport; - -import com.mumfrey.liteloader.core.LiteLoader; - -public class CallableLiteLoaderMods implements Callable -{ - final CrashReport crashReport; - - public CallableLiteLoaderMods(CrashReport report) - { - this.crashReport = report; - } - - /* (non-Javadoc) - * @see java.util.concurrent.Callable#call() - */ - @Override - public String call() throws Exception - { - try - { - return LiteLoader.getInstance().getLoadedModsList(); - } - catch (Exception ex) - { - return "LiteLoader startup failed"; - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/FastIterable.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/FastIterable.java deleted file mode 100644 index b4ab6cfe..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/FastIterable.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.mumfrey.liteloader.interfaces; - -/** - * Interface for objects which can return a baked list view of their list - * contents. - * - * @author Adam Mummery-Smith - * - * @param - */ -public interface FastIterable extends Iterable -{ - /** - * Add an entry to the iterable - * - * @param entry - */ - public boolean add(T entry); - - /** - * Return the baked view of all entries - */ - public T all(); - - /** - * Invalidate (force rebake of) the baked entry list - */ - public void invalidate(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/FastIterableDeque.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/FastIterableDeque.java deleted file mode 100644 index ae879f16..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/FastIterableDeque.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.mumfrey.liteloader.interfaces; - -import java.util.Deque; - -/** - * Deque interface which is FastIterable - * - * @author Adam Mummery-Smith - * - * @param - */ -public interface FastIterableDeque extends FastIterable, Deque -{ -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/Injectable.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/Injectable.java deleted file mode 100644 index c0021b6a..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/Injectable.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.mumfrey.liteloader.interfaces; - -import java.net.MalformedURLException; -import java.net.URL; - -import com.mumfrey.liteloader.launch.InjectionStrategy; - -import net.minecraft.launchwrapper.LaunchClassLoader; - -/** - * Interface for objects which can be injected into the classpath - * - * @author Adam Mummery-Smith - */ -public interface Injectable -{ - /** - * Get the URL of this injectable resource - * @throws MalformedURLException - */ - public abstract URL getURL() throws MalformedURLException; - - /** - * Returns true if this object has been injected already - */ - public abstract boolean isInjected(); - - /** - * @param classLoader - * @param injectIntoParent - * @return whether the injection was successful or not - * @throws MalformedURLException - */ - public abstract boolean injectIntoClassPath(LaunchClassLoader classLoader, boolean injectIntoParent) throws MalformedURLException; - - /** - * Get the injection strategy for this object - */ - public abstract InjectionStrategy getInjectionStrategy(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/InterfaceRegistry.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/InterfaceRegistry.java deleted file mode 100644 index d325e8fb..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/InterfaceRegistry.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.mumfrey.liteloader.interfaces; - -import com.mumfrey.liteloader.api.Listener; -import com.mumfrey.liteloader.api.InterfaceProvider; -import com.mumfrey.liteloader.api.LiteAPI; - -/** - * - * @author Adam Mummery-Smith - */ -public interface InterfaceRegistry -{ - public abstract void registerAPI(LiteAPI api); - - public abstract void registerInterface(InterfaceProvider provider, Class interfaceType); - - public abstract void registerInterface(InterfaceProvider provider, Class interfaceType, int priority); - - public abstract void registerInterface(InterfaceProvider provider, Class interfaceType, int priority, boolean exclusive); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/Loadable.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/Loadable.java deleted file mode 100644 index a39db61b..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/Loadable.java +++ /dev/null @@ -1,100 +0,0 @@ -package com.mumfrey.liteloader.interfaces; - -import java.io.File; - -import com.mumfrey.liteloader.launch.LoaderEnvironment; - -/** - * Interface for things which are loadable, essentially mods and tweaks - * - * @author Adam Mummery-Smith - * - * @param base class type for Comparable so that implementors can specify - * their Comparable type. - */ -public interface Loadable extends Comparable -{ - /** - * Get the target resource - */ - public abstract L getTarget(); - - /** - * Get the name of the loadable (usually the file name) - */ - public abstract String getName(); - - /** - * Get the name to use when displaying this loadable, such as file name, - * identifier or friendly name - */ - public abstract String getDisplayName(); - - /** - * Get the location (path or URL) of this loadable - */ - public abstract String getLocation(); - - /** - * Get the identifier (usually "name" from metadata) of this loadable, used - * as the exclusivity key for mods and also the metadata key - */ - public abstract String getIdentifier(); - - /** - * Get the version specified in the metadata or other location - */ - public abstract String getVersion(); - - /** - * Get the author specified in the metadata - */ - public abstract String getAuthor(); - - /** - * Get the description - */ - public abstract String getDescription(String key); - - /** - * Returns true if this is an external jar containing a tweak rather than a - * mod. - */ - public abstract boolean isExternalJar(); - - /** - * Returns true if this loadable supports being enabled and disabled via the - * GUI. - */ - public abstract boolean isToggleable(); - - /** - * Get whether this loadable is currently enabled in the context of the - * supplied mods list. - * - * @param environment - */ - public abstract boolean isEnabled(LoaderEnvironment environment); - - /** - * Get whether this loadable is a file container - */ - public abstract boolean isFile(); - - /** - * Get whether this loadable is a directory container - */ - public abstract boolean isDirectory(); - - /** - * If isFile or isDirectory return true then this method returns the inner - * File instance, otherwise returns null. - */ - public abstract File toFile(); - - /** - * Get whether this container requires early injection, eg. it contains a - * tweaker, transformer or mixins - */ - public abstract boolean requiresPreInitInjection(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/LoadableFile.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/LoadableFile.java deleted file mode 100644 index dfef3c91..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/LoadableFile.java +++ /dev/null @@ -1,507 +0,0 @@ -package com.mumfrey.liteloader.interfaces; - -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.nio.charset.Charset; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.jar.Attributes; -import java.util.jar.JarFile; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -import com.google.common.io.Files; -import com.google.common.primitives.Ints; -import com.mumfrey.liteloader.core.api.LoadableModFile; -import com.mumfrey.liteloader.launch.ClassPathUtilities; -import com.mumfrey.liteloader.launch.InjectionStrategy; -import com.mumfrey.liteloader.launch.LiteLoaderTweaker; -import com.mumfrey.liteloader.launch.LoaderEnvironment; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -import net.minecraft.launchwrapper.LaunchClassLoader; - -public class LoadableFile extends File implements TweakContainer -{ - public static final String MFATT_MODTYPE = "ModType"; - public static final String MFATT_TWEAK_CLASS = "TweakClass"; - public static final String MFATT_CLASS_PATH = "Class-Path"; - public static final String MFATT_TWEAK_ORDER = "TweakOrder"; - public static final String MFATT_IMPLEMENTATION_TITLE = "Implementation-Title"; - public static final String MFATT_TWEAK_NAME = "TweakName"; - public static final String MFATT_IMPLEMENTATION_VERSION = "Implementation-Version"; - public static final String MFATT_TWEAK_VERSION = "TweakVersion"; - public static final String MFATT_IMPLEMENTATION_VENDOR = "Implementation-Vendor"; - public static final String MFATT_TWEAK_AUTHOR = "TweakAuthor"; - public static final String MFATT_MIXIN_CONFIGS = "MixinConfigs"; - public static final String MFATT_INJECTION_STRATEGY = "TweakInjectionStrategy"; - - private static final Pattern versionPattern = Pattern.compile("([0-9]+\\.)+[0-9]+([_A-Z0-9]+)?"); - - private static final long serialVersionUID = 1L; - - /** - * True once this file has been injected into the class path - */ - protected boolean injected; - - protected boolean forceInjection; - - /** - * Position to inject the mod file at in the class path, if blank injects at - * the bottom as usual, alternatively the developer can specify "top" to - * inject at the top, "base" to inject above the game jar, or "above: name" - * to inject above a specified other library matching "name". - */ - protected InjectionStrategy injectionStrategy = null; - - protected Set modSystems = new HashSet(); - - /** - * Name of the tweak class - */ - protected String tweakClassName; - - /** - * Priority for this tweaker - */ - protected int tweakPriority = 1000; - - /** - * Class path entries read from jar metadata - */ - protected String[] classPathEntries = null; - - protected String displayName; - - protected String version = "Unknown"; - - protected String author = "Unknown"; - - protected boolean hasEventTransformers; - - /** - * Mixin config resource names - */ - protected Set mixinConfigs = new HashSet(); - - /** - * Create a new tweak container wrapping the specified file - */ - public LoadableFile(File parent) - { - super(parent.getAbsolutePath()); - this.displayName = this.getName(); - this.guessVersionFromName(); - this.readJarMetaData(); - } - - /** - * ctor for subclasses - */ - protected LoadableFile(LoadableFile file) - { - super(file.getAbsolutePath()); - this.displayName = this.getName(); - this.forceInjection = file.forceInjection; - this.assignJarMetaData(file); - } - - /** - * ctor for subclasses - */ - protected LoadableFile(String pathname) - { - super(pathname); - this.displayName = this.getName(); - this.readJarMetaData(); - } - - private void guessVersionFromName() - { - Matcher versionPatternMatcher = LoadableFile.versionPattern.matcher(this.getName()); - while (versionPatternMatcher.find()) - { - this.version = versionPatternMatcher.group(); - } - } - - protected void assignJarMetaData(LoadableFile file) - { - this.modSystems = file.modSystems; - this.tweakClassName = file.tweakClassName; - this.classPathEntries = file.classPathEntries; - this.tweakPriority = file.tweakPriority; - this.displayName = file.displayName; - this.version = file.version; - this.author = file.author; - this.injectionStrategy = file.injectionStrategy; - } - - /** - * Search for tweaks in this file - */ - protected void readJarMetaData() - { - JarFile jar = null; - - if (this.isDirectory()) - { - return; - } - - try - { - jar = new JarFile(this); - if (jar.getManifest() != null) - { - LiteLoaderLogger.info("Inspecting jar metadata in '%s'", this.getName()); - Attributes mfAttributes = jar.getManifest().getMainAttributes(); - - String mfAttmodSystemList = mfAttributes.getValue(LoadableFile.MFATT_MODTYPE); - String mfAttTweakClass = mfAttributes.getValue(LoadableFile.MFATT_TWEAK_CLASS); - String mfAttClassPath = mfAttributes.getValue(LoadableFile.MFATT_CLASS_PATH); - String mfAttTweakOrder = mfAttributes.getValue(LoadableFile.MFATT_TWEAK_ORDER); - String mfAttDisplayName = mfAttributes.getValue(LoadableFile.MFATT_IMPLEMENTATION_TITLE); - String mfAttTweakName = mfAttributes.getValue(LoadableFile.MFATT_TWEAK_NAME); - String mfAttVersion = mfAttributes.getValue(LoadableFile.MFATT_IMPLEMENTATION_VERSION); - String mfAttTweakVersion = mfAttributes.getValue(LoadableFile.MFATT_TWEAK_VERSION); - String mfAttAuthor = mfAttributes.getValue(LoadableFile.MFATT_IMPLEMENTATION_VENDOR); - String mfAttTweakAuthor = mfAttributes.getValue(LoadableFile.MFATT_TWEAK_AUTHOR); - String mfAttMixinConfigs = mfAttributes.getValue(LoadableFile.MFATT_MIXIN_CONFIGS); - String mfAttInjectionStrategy = mfAttributes.getValue(LoadableFile.MFATT_INJECTION_STRATEGY); - - if (mfAttmodSystemList != null) - { - for (String modSystem : mfAttmodSystemList.split(",")) - { - modSystem = modSystem.trim(); - if (modSystem.length() > 0) - { - this.modSystems.add(modSystem); - } - } - } - - this.tweakClassName = mfAttTweakClass; - if (this.tweakClassName != null && mfAttClassPath != null) - { - this.classPathEntries = mfAttClassPath.split(" "); - } - - if (mfAttTweakOrder != null) - { - Integer tweakOrder = Ints.tryParse(mfAttTweakOrder); - if (tweakOrder != null) - { - this.tweakPriority = tweakOrder.intValue(); - } - } - - if (mfAttDisplayName != null) this.displayName = mfAttDisplayName; - if (mfAttTweakName != null) this.displayName = mfAttTweakName; - if (mfAttVersion != null) this.version = mfAttVersion; - if (mfAttTweakVersion != null) this.version = mfAttTweakVersion; - if (mfAttAuthor != null) this.author = mfAttAuthor; - if (mfAttTweakAuthor != null) this.author = mfAttTweakAuthor; - - if (mfAttMixinConfigs != null) - { - for (String config : mfAttMixinConfigs.split(",")) - { - this.mixinConfigs.add(config); - } - } - - this.injectionStrategy = InjectionStrategy.parseStrategy(mfAttInjectionStrategy, InjectionStrategy.TOP); - } - } - catch (Exception ex) - { - LiteLoaderLogger.warning("Could not parse jar metadata in '%s'", this); - } - finally - { - try - { - if (jar != null) jar.close(); - } - catch (IOException ex) {} - } - } - - public Set getModSystems() - { - return Collections.unmodifiableSet(this.modSystems); - } - - @Override - public File getTarget() - { - return this; - } - - @Override - public File toFile() - { - return this; - } - - @Override - public String getLocation() - { - return this.getAbsolutePath(); - } - - @Override - public URL getURL() throws MalformedURLException - { - return this.toURI().toURL(); - } - - @Override - public String getIdentifier() - { - return this.getName().toLowerCase(); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ITweakContainer#hasTweakClass() - */ - @Override - public boolean hasTweakClass() - { - return this.tweakClassName != null; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ITweakContainer#getTweakClassName() - */ - @Override - public String getTweakClassName() - { - return this.tweakClassName; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.TweakContainer#getTweakPriority() - */ - @Override - public int getTweakPriority() - { - return this.tweakPriority; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ITweakContainer#getClassPathEntries() - */ - @Override - public String[] getClassPathEntries() - { - return this.classPathEntries; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ITweakContainer#hasClassTransformers() - */ - @Override - public boolean hasClassTransformers() - { - return false; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.ITweakContainer - * #getClassTransformerClassNames() - */ - @Override - public List getClassTransformerClassNames() - { - return Collections.emptyList(); - } - - @Override - public boolean hasMixins() - { - return this.mixinConfigs.size() > 0; - } - - @Override - public Set getMixinConfigs() - { - return this.mixinConfigs; - } - - @Override - public boolean hasEventTransformers() - { - return this.hasEventTransformers; - } - - public void onEventsInjected() - { - this.hasEventTransformers = true; - } - - public boolean isInjectionForced() - { - return this.forceInjection; - } - - public void setForceInjection(boolean forceInjection) - { - this.forceInjection = forceInjection; - } - - @Override - public boolean requiresPreInitInjection() - { - return this.hasTweakClass() || this.hasClassTransformers() || this.hasMixins(); - } - - @Override - public boolean isInjected() - { - return this.injected; - } - - @Override - public boolean injectIntoClassPath(LaunchClassLoader classLoader, boolean injectIntoParent) throws MalformedURLException - { - if (!this.injected) - { - this.injected = true; - - boolean isOnClassPath = ClassPathUtilities.isJarOnClassPath(this, classLoader); - if (!this.forceInjection && isOnClassPath) - { - LiteLoaderLogger.info("%s already exists on the classpath, skipping injection", this); - return false; - } - - ClassPathUtilities.injectIntoClassPath(classLoader, this.getURL(), this.getInjectionStrategy()); - - if (injectIntoParent) - { - LiteLoaderTweaker.addURLToParentClassLoader(this.getURL()); - } - - return true; - - } - - return false; - } - - @Override - public InjectionStrategy getInjectionStrategy() - { - return this.injectionStrategy; - } - - @Override - public String getDisplayName() - { - return this.displayName != null ? this.displayName : this.getName(); - } - - @Override - public String getVersion() - { - return this.version; - } - - @Override - public String getAuthor() - { - return this.author; - } - - @Override - public String getDescription(String key) - { - return ""; - } - - @Override - public boolean isExternalJar() - { - return true; - } - - @Override - public boolean isToggleable() - { - return false; - } - - @Override - public boolean isEnabled(LoaderEnvironment environment) - { - return environment.getEnabledModsList().isEnabled(environment.getProfile(), this.getIdentifier()); - } - - @Override - public String toString() - { - return this.getLocation(); - } - - /** - * @param name - * @param charset - */ - public String getFileContents(String name, Charset charset) - { - return LoadableFile.getFileContents(this, name, charset); - } - - /** - * @param parent - * @param name - * @param charset - */ - public static String getFileContents(File parent, String name, Charset charset) - { - try - { - if (parent.isDirectory()) - { - File file = new File(parent, name); - if (file.isFile()) - { - return Files.toString(file, charset); - } - } - else - { - String content = null; - ZipFile zipFile = new ZipFile(parent); - ZipEntry zipEntry = zipFile.getEntry(name); - if (zipEntry != null) - { - try - { - content = LoadableModFile.zipEntryToString(zipFile, zipEntry); - } - catch (IOException ex) {} - } - - zipFile.close(); - return content; - } - } - catch (IOException ex) - { - ex.printStackTrace(); - } - - return null; - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/LoadableMod.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/LoadableMod.java deleted file mode 100644 index 19a36b1d..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/LoadableMod.java +++ /dev/null @@ -1,355 +0,0 @@ -package com.mumfrey.liteloader.interfaces; - -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import com.google.common.collect.ImmutableSet; -import com.mumfrey.liteloader.launch.InjectionStrategy; -import com.mumfrey.liteloader.launch.LoaderEnvironment; - -import net.minecraft.launchwrapper.LaunchClassLoader; - -/** - * Interface for containers which can be loaded as mods - * - * @author Adam Mummery-Smith - * - * @param base class type for Comparable so that implementors can specify - * their Comparable type - */ -public interface LoadableMod extends Loadable, Injectable -{ - static final String METADATA_FILENAME = "litemod.json"; - - /** - * Get the mod systems declared in the jar metadata - */ - public abstract Set getModSystems(); - - /** - * Get the name of the mod - */ - public abstract String getModName(); - - /** - * Get the target loader version for this mod - */ - public abstract String getTargetVersion(); - - /** - * Get the revision number for this mod - */ - public abstract float getRevision(); - - /** - * Get whether this mod's metadata is valid - */ - public abstract boolean hasValidMetaData(); - - /** - * Get whether this mod has any dependencies - */ - public abstract boolean hasDependencies(); - - /** - * Get this mod's list of dependencies - */ - public abstract Set getDependencies(); - - /** - * Callback to notify the container that it's missing a specific dependency - */ - public abstract void registerMissingDependency(String dependency); - - /** - * Get this mod's list of missing dependencies - */ - public abstract Set getMissingDependencies(); - - /** - * Get this mod's list of required APIs - */ - public abstract Set getRequiredAPIs(); - - /** - * Callback to notify the container that it's missing a specific required - * API - */ - public abstract void registerMissingAPI(String identifier); - - /** - * Get this mod's list of missing APIs - */ - public abstract Set getMissingAPIs(); - - /** - * Get the specified metadata value and return the default value if not - * present - * - * @param metaKey metadata key - * @param defaultValue metadata value - */ - public abstract String getMetaValue(String metaKey, String defaultValue); - - /** - * Get the mod metadata key set - */ - public abstract Set getMetaDataKeys(); - - /** - * Returns true if this mod can be added as a resource pack - */ - public abstract boolean hasResources(); - - /** - * Get all class names in this container - */ - public abstract List getContainedClassNames(); - - /** - * Callback from the enumerator, whenever a mod is registered to this - * container - */ - public abstract void addContainedMod(String modName); - - /** - * Container returned instead of null when a mod does not actually have a - * container or a container is requested for a mod which doesn't exist. - */ - public static final LoadableMod NONE = new EmptyModContainer(); - - /** - * Mod container for a mod which doesn't have a container - * - * @author Adam Mummery-Smith - */ - public class EmptyModContainer implements LoadableMod - { - private static final ImmutableSet EMPTY_SET = ImmutableSet.of(); - - EmptyModContainer() {} - - @Override - public File getTarget() - { - return null; - } - - @Override - public Set getModSystems() - { - return EmptyModContainer.EMPTY_SET; - } - - @Override - public String getName() - { - return "Unknown"; - } - - @Override - public String getDisplayName() - { - return "Unknown"; - } - - @Override - public String getLocation() - { - return "."; - } - - @Override - public String getIdentifier() - { - return "Unknown"; - } - - @Override - public String getVersion() - { - return "Unknown"; - } - - @Override - public String getAuthor() - { - return "Unknown"; - } - - @Override - public String getDescription(String key) - { - return ""; - } - - @Override - public boolean isExternalJar() - { - return false; - } - - @Override - public boolean isToggleable() - { - return false; - } - - @Override - public boolean isEnabled(LoaderEnvironment environment) - { - return true; - } - - @Override - public boolean isFile() - { - return false; - } - - @Override - public boolean isDirectory() - { - return false; - } - - @Override - public File toFile() - { - return null; - } - - @Override - public int compareTo(File other) - { - return 0; - } - - @Override - public URL getURL() throws MalformedURLException - { - throw new MalformedURLException("Attempted to get the URL of an empty mod"); - } - - @Override - public boolean isInjected() - { - return false; - } - - @Override - public boolean injectIntoClassPath(LaunchClassLoader classLoader, boolean injectIntoParent) throws MalformedURLException - { - return false; - } - - @Override - public InjectionStrategy getInjectionStrategy() - { - return null; - } - - @Override - public String getModName() - { - return "Unknown"; - } - - @Override - public String getTargetVersion() - { - return ""; - } - - @Override - public float getRevision() - { - return 0; - } - - @Override - public boolean hasValidMetaData() - { - return false; - } - - @Override - public String getMetaValue(String metaKey, String defaultValue) - { - return defaultValue; - } - - @Override - public Set getMetaDataKeys() - { - return Collections.emptySet(); - } - - @Override - public boolean hasResources() - { - return false; - } - - @Override - public boolean hasDependencies() - { - return false; - } - - @Override - public Set getDependencies() - { - return Collections.emptySet(); - } - - @Override - public void registerMissingDependency(String dependency) - { - } - - @Override - public Set getMissingDependencies() - { - return Collections.emptySet(); - } - - @Override - public Set getRequiredAPIs() - { - return Collections.emptySet(); - } - - @Override - public void registerMissingAPI(String identifier) - { - } - - @Override - public Set getMissingAPIs() - { - return Collections.emptySet(); - } - - @Override - public List getContainedClassNames() - { - return Collections.emptyList(); - } - - @Override - public void addContainedMod(String modName) - { - } - - @Override - public boolean requiresPreInitInjection() - { - return false; - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/LoaderEnumerator.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/LoaderEnumerator.java deleted file mode 100644 index c8538389..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/LoaderEnumerator.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.mumfrey.liteloader.interfaces; - -import java.util.Collection; -import java.util.Map; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.core.ModInfo; - -/** - * Interface for the enumerator - * - * @author Adam Mummery-Smith - */ -public interface LoaderEnumerator extends ModularEnumerator -{ - /** - * Perform pre-init tasks (container discovery) - */ - public abstract void onPreInit(); - - /** - * Perform init tasks (injection and mod discovery) - */ - public abstract void onInit(); - - /** - * Check API requirements for the supplied container - * - * @param container - */ - public abstract boolean checkAPIRequirements(LoadableMod container); - - /** - * Check intra-mod dependencies for the supplied container - * - * @param base - */ - public abstract boolean checkDependencies(LoadableMod base); - - /** - * Inflect mod identifier from the supplied mod class - * - * @param modClass - */ - public abstract String getIdentifier(Class modClass); - - /** - * Get the container which the specified mod is loaded from - * - * @param modClass - */ - public abstract LoadableMod getContainer(Class modClass); - - /** - * Get the container for the specified mod identifier - * - * @param identifier - */ - public abstract LoadableMod getContainer(String identifier); - - /** - * Get all containers identified at discover-time as disabled - */ - public abstract Collection>> getDisabledContainers(); - - /** - * Get all bad containers - */ - public abstract Collection>> getBadContainers(); - - /** - * @param modClass - * @param metaDataKey - * @param defaultValue - */ - public abstract String getModMetaData(Class modClass, String metaDataKey, String defaultValue); - - /** - * Get the total number of mods to load - */ - public abstract int modsToLoadCount(); - - /** - * Get all mods to load - */ - public abstract Collection>> getModsToLoad(); - - /** - * Get all tweakers which were injected - */ - public abstract Collection>> getInjectedTweaks(); - - /** - * Get the shared modlist data - */ - public abstract Map> getSharedModList(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/MixinContainer.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/MixinContainer.java deleted file mode 100644 index 868cb22f..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/MixinContainer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * This file is part of Sponge, licensed under the MIT License (MIT). - * - * Copyright (c) SpongePowered - * Copyright (c) contributors - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package com.mumfrey.liteloader.interfaces; - -import java.util.Set; - -public interface MixinContainer extends Loadable, Injectable -{ - - /** - * Get whether this container has any mixins - */ - public abstract boolean hasMixins(); - - /** - * Get this mod's list of mixin configs - */ - public abstract Set getMixinConfigs(); - -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/ModularEnumerator.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/ModularEnumerator.java deleted file mode 100644 index 5f94fded..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/ModularEnumerator.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.mumfrey.liteloader.interfaces; - -import java.io.File; - -import com.mumfrey.liteloader.api.EnumeratorModule; -import com.mumfrey.liteloader.api.EnumeratorPlugin; -import com.mumfrey.liteloader.core.ModInfo; - -/** - * Interface for the mod enumerator - * - * @author Adam Mummery-Smith - */ -public interface ModularEnumerator -{ - /** - * Register a pluggable module into the enumerator - * - * @param module - */ - public abstract void registerModule(EnumeratorModule module); - - /** - * Register a plugin into the enumerator - * - * @param plugin - */ - public abstract void registerPlugin(EnumeratorPlugin plugin); - - /** - * @param container - */ - public abstract boolean registerModContainer(LoadableMod container); - - /** - * @param container - * @param reason - */ - public abstract void registerBadContainer(Loadable container, String reason); - - /** - * @param container - */ - public abstract boolean registerTweakContainer(TweakContainer container); - - /** - * @param container - * @param registerContainer - */ - public abstract void registerModsFrom(LoadableMod container, boolean registerContainer); - - /** - * @param mod - */ - public abstract void registerMod(ModInfo> mod); -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/ObjectFactory.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/ObjectFactory.java deleted file mode 100644 index 7356de9b..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/ObjectFactory.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.mumfrey.liteloader.interfaces; - -import net.minecraft.server.MinecraftServer; - -import com.mumfrey.liteloader.common.GameEngine; -import com.mumfrey.liteloader.core.ClientPluginChannels; -import com.mumfrey.liteloader.core.LiteLoaderEventBroker; -import com.mumfrey.liteloader.core.PacketEvents; -import com.mumfrey.liteloader.core.ServerPluginChannels; -import com.mumfrey.liteloader.permissions.PermissionsManagerClient; -import com.mumfrey.liteloader.permissions.PermissionsManagerServer; -import com.mumfrey.liteloader.util.Input; - -/** - * Factory for generating loader managament objects based on the environment - * - * @author Adam Mummery-Smith - * - * @param Type of the client runtime, "Minecraft" on client and null - * on the server - * @param Type of the server runtime, "IntegratedServer" on the client - * "MinecraftServer" on the server - */ -public interface ObjectFactory -{ - public abstract LiteLoaderEventBroker getEventBroker(); - - public abstract PacketEvents getPacketEventBroker(); - - public abstract Input getInput(); - - public abstract GameEngine getGameEngine(); - - public abstract PanelManager getPanelManager(); - - public abstract ClientPluginChannels getClientPluginChannels(); - - public abstract ServerPluginChannels getServerPluginChannels(); - - public abstract PermissionsManagerClient getClientPermissionManager(); - - public abstract PermissionsManagerServer getServerPermissionManager(); - - public abstract void preBeginGame(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/PanelManager.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/PanelManager.java deleted file mode 100644 index b9303b42..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/PanelManager.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.mumfrey.liteloader.interfaces; - -import com.mumfrey.liteloader.api.PostRenderObserver; -import com.mumfrey.liteloader.api.TickObserver; -import com.mumfrey.liteloader.core.LiteLoaderMods; -import com.mumfrey.liteloader.modconfig.ConfigManager; - -/** - * Interface for the liteloader panel manager, abstracted because we don't have - * the class GuiScreen on the server. - * - * @author Adam Mummery-Smith - * - * @param GuiScreen class, must be generic because we don't have - * GuiScreen on the server side - */ -public interface PanelManager extends TickObserver, PostRenderObserver -{ - /** - * @param mods - * @param configManager - */ - public abstract void init(LiteLoaderMods mods, ConfigManager configManager); - - /** - * - */ - public abstract void onStartupComplete(); - - /** - * Hide the LiteLoader tab - */ - public abstract void hideTab(); - - /** - * Set the LiteLoader tab's visibility - */ - public abstract void setTabVisible(boolean show); - - /** - * Get whether the LiteLoader tab is visible - */ - public abstract boolean isTabVisible(); - - /** - * Set whether the LiteLoader tab should remain expanded - */ - public abstract void setTabAlwaysExpanded(boolean expand); - - /** - * Get whether the LiteLoader tab should remain expanded - */ - public abstract boolean isTabAlwaysExpanded(); - - /** - * Display the LiteLoader panel - * - * @param parentScreen Parent screen to display the panel on top of - */ - public abstract void displayLiteLoaderPanel(TParentScreen parentScreen); - - /** - * Get the number of startup errors - */ - public abstract int getStartupErrorCount(); - - /** - * Get the number of critical startup errors - */ - public abstract int getCriticalErrorCount(); - - /** - * Set the current notification text - */ - public abstract void setNotification(String notification); - - /** - * Set whether "force update" is enabled - */ - public abstract void setForceUpdateEnabled(boolean forceUpdate); - - /** - * Get whether "force update" is enabled - */ - public abstract boolean isForceUpdateEnabled(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/TweakContainer.java b/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/TweakContainer.java deleted file mode 100644 index 86ec510d..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/interfaces/TweakContainer.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.mumfrey.liteloader.interfaces; - -import java.util.List; - -/** - * Interface for loadables which can contain tweaks and transformers - * - * @author Adam Mummery-Smith - */ -public interface TweakContainer extends MixinContainer -{ - /** - * Get whether this tweak container has a defined tweak class in its - * metadata. - */ - public abstract boolean hasTweakClass(); - - /** - * Get the tweak class name defined in the metadata - */ - public abstract String getTweakClassName(); - - /** - * Get the priority value for this tweak - */ - public abstract int getTweakPriority(); - - /** - * Get classpath entries defined in the metadata - */ - public abstract String[] getClassPathEntries(); - - /** - * Get whether this container defines any transformer classes - */ - public abstract boolean hasClassTransformers(); - - /** - * Get class transformers defined in the metadata - */ - public abstract List getClassTransformerClassNames(); - - /** - * True if this container defines event transformers via JSON - */ - public abstract boolean hasEventTransformers(); -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/ClassPathUtilities.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/ClassPathUtilities.java deleted file mode 100644 index 272d671f..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/ClassPathUtilities.java +++ /dev/null @@ -1,478 +0,0 @@ -package com.mumfrey.liteloader.launch; - -import java.io.File; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.net.URLClassLoader; -import java.security.AccessController; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Stack; -import java.util.jar.JarFile; - -import com.mumfrey.liteloader.launch.InjectionStrategy.InjectionPosition; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -import net.minecraft.launchwrapper.Launch; -import net.minecraft.launchwrapper.LaunchClassLoader; - -/** - * Nasty horrible reflection hacks to do nasty things with the classpath - * - * @author Adam Mummery-Smith - */ -public abstract class ClassPathUtilities -{ - /** - * URLClassPath - */ - private static Class clURLClassPath; - - /** - * URLClassLoader::ucp -> instance of URLClassPath - */ - private static Field ucp; - - /** - * URLClassPath::urls -> instance of Stack - */ - private static Field classPathURLs; - - /** - * URLClassPath::path -> instance of ArrayList - */ - private static Field classPathPath; - - /** - * URLClassPath::lmap -> instance of HashMap - */ - private static Field classPathLoaderMap; - - /** - * URLClassPath::loaders -> instance of ArrayList - */ - private static Field classPathLoaderList; - - private static boolean canInject; - - private static boolean canTerminate; - - static - { - try - { - ClassPathUtilities.clURLClassPath = Class.forName("sun.misc.URLClassPath"); - - ClassPathUtilities.ucp = URLClassLoader.class.getDeclaredField("ucp"); - ClassPathUtilities.ucp.setAccessible(true); - - ClassPathUtilities.classPathURLs = ClassPathUtilities.clURLClassPath.getDeclaredField("urls"); - ClassPathUtilities.classPathURLs.setAccessible(true); - ClassPathUtilities.classPathPath = ClassPathUtilities.clURLClassPath.getDeclaredField("path"); - ClassPathUtilities.classPathPath.setAccessible(true); - ClassPathUtilities.classPathLoaderMap = ClassPathUtilities.clURLClassPath.getDeclaredField("lmap"); - ClassPathUtilities.classPathLoaderMap.setAccessible(true); - ClassPathUtilities.classPathLoaderList = ClassPathUtilities.clURLClassPath.getDeclaredField("loaders"); - ClassPathUtilities.classPathLoaderList.setAccessible(true); - ClassPathUtilities.canInject = true; - } - catch (Throwable th) - { - LiteLoaderLogger.severe(th, "ClassPathUtilities: Error initialising ClassPathUtilities, special class path injection disabled"); - th.printStackTrace(); - } - } - - /** - * Injects a URL into the classpath based on the specified injection - * strategy. - * - * @param classLoader - * @param url - */ - public static void injectIntoClassPath(URLClassLoader classLoader, URL url, InjectionStrategy strategy) - { - if (strategy == null || strategy.getPosition() == null) - { - ClassPathUtilities.addURL(classLoader, url); - return; - } - - if (strategy.getPosition() == InjectionPosition.Top) - { - ClassPathUtilities.injectIntoClassPath(classLoader, url); - } - else if (strategy.getPosition() == InjectionPosition.Base) - { - ClassPathUtilities.injectIntoClassPath(classLoader, url, LiteLoaderTweaker.getJarUrl()); - } - else if (strategy.getPosition() == InjectionPosition.Above) - { - String[] params = strategy.getParams(); - if (params.length > 0) - { - ClassPathUtilities.injectIntoClassPath(classLoader, url, params[0]); - } - } - else - { - ClassPathUtilities.addURL(classLoader, url); - } - } - - /** - * Injects a URL into the classpath at the TOP of the stack - * - * @param classLoader - * @param url - */ - public static void injectIntoClassPath(URLClassLoader classLoader, URL url) - { - ClassPathUtilities.injectIntoClassPath(classLoader, url, (URL)null); - } - - /** - * Injects a URL into the classpath at the TOP of the stack - * - * @param classLoader - * @param url - * @param above - */ - @SuppressWarnings({ "unchecked" }) - public static void injectIntoClassPath(URLClassLoader classLoader, URL url, URL above) - { - if (ClassPathUtilities.canInject) - { - LiteLoaderLogger.info("ClassPathUtilities: attempting to inject %s into %s", url, classLoader.getClass().getSimpleName()); - - try - { - Object classPath = ClassPathUtilities.ucp.get(classLoader); - - Stack urls = (Stack)ClassPathUtilities.classPathURLs.get(classPath); - ArrayList path = (ArrayList)ClassPathUtilities.classPathPath.get(classPath); - - synchronized (urls) - { - if (!path.contains(url)) - { - urls.add(url); - - if (above == null) - { - path.add(0, url); - } - else - { - for (int pos = path.size() - 1; pos > 0; pos--) - { - if (above.equals(path.get(pos))) - { - path.add(pos, url); - } - } - } - } - } - } - catch (Exception ex) - { - LiteLoaderLogger.warning("ClassPathUtilities: failed to inject %s", url); - } - } - - ClassPathUtilities.addURL(classLoader, url); - } - - /** - * @param classLoader - * @param url - * @param above - */ - public static void injectIntoClassPath(URLClassLoader classLoader, URL url, String above) - { - above = above.trim().toLowerCase(); - if (above.length() < 1) return; - - for (URL classPathUrl : classLoader.getURLs()) - { - if (classPathUrl.toString().toLowerCase().contains(above)) - { - ClassPathUtilities.injectIntoClassPath(classLoader, url, classPathUrl); - return; - } - } - } - - /** - * @param classLoader - * @param url - */ - public static void addURL(URLClassLoader classLoader, URL url) - { - if (classLoader instanceof LaunchClassLoader) - { - ((LaunchClassLoader)classLoader).addURL(url); - } - else - { - try - { - Method mAddUrl = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - mAddUrl.setAccessible(true); - mAddUrl.invoke(classLoader, url); - } - catch (Exception ex) {} - } - } - - /** - * Is the specified jar on the game launch classpath - * - * @param jarFile - */ - public static boolean isJarOnClassPath(File jarFile) - { - URLClassLoader classLoader = (URLClassLoader)Launch.class.getClassLoader(); - return ClassPathUtilities.isJarOnClassPath(jarFile, classLoader); - } - - /** - * @param jarFile - * @param classLoader - */ - public static boolean isJarOnClassPath(File jarFile, URLClassLoader classLoader) - { - try - { - String jarURL = jarFile.toURI().toURL().toString(); - - URL[] classPath = classLoader.getURLs(); - for (URL classPathEntry : classPath) - { - if (classPathEntry.toString().equals(jarURL)) - { - return true; - } - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } - - return false; - } - - /** - * Gets the file containing the specified resource - * - * @param contextClass - * @param resource - */ - public static File getPathToResource(Class contextClass, String resource) - { - URL res = contextClass.getResource(resource); - if (res == null) return null; - - boolean returnParent = true; - String jarPath = res.toString(); - if (jarPath.startsWith("jar:") && jarPath.indexOf('!') > -1) - { - jarPath = jarPath.substring(4, jarPath.indexOf('!')); - returnParent = false; - } - - if (jarPath.startsWith("file:")) - { - try - { - File targetFile = new File(new URI(jarPath)); - return returnParent ? targetFile.getParentFile() : targetFile; - } - catch (URISyntaxException ex) - { - // derp - } - } - - return null; - } - - /** - * @param contextClass - * @param resource - */ - public static boolean deleteClassPathJarContaining(Class contextClass, String resource) - { - File jarFile = ClassPathUtilities.getPathToResource(contextClass, resource); - if (jarFile != null && jarFile.exists() && jarFile.isFile() && jarFile.getName().endsWith(".jar")) - { - return ClassPathUtilities.deleteClassPathJar(jarFile.getName()); - } - - return false; - } - - /** - * @param jarFileName - */ - public static boolean deleteClassPathJar(String jarFileName) - { - try - { - // First try to find the jar reference in the class loaders - JarFile jar = ClassPathUtilities.getJarFromClassLoader(Launch.classLoader, jarFileName, false); - JarFile parentJar = ClassPathUtilities.getJarFromClassLoader((URLClassLoader)Launch.class.getClassLoader(), jarFileName, false); - - if (jar != null && parentJar != null && jar.getName().equals(parentJar.getName())) - { - final JarDeletionHandler jarDeletionHandler = new JarDeletionHandler(); - - JarFile jarInClassLoader = ClassPathUtilities.getJarFromClassLoader(Launch.classLoader, jarFileName, true); - JarFile jarInParentClassLoader = ClassPathUtilities.getJarFromClassLoader((URLClassLoader)Launch.class.getClassLoader(), - jarFileName, true); - - File jarFileInClassLoader = new File(jarInClassLoader.getName()); - File jarFileInParentClassLoader = new File(jarInParentClassLoader.getName()); - - jarDeletionHandler.setPaths(jarInClassLoader, jarInParentClassLoader, jarFileInClassLoader, jarFileInParentClassLoader); - - try - { - Boolean deleted = AccessController.doPrivileged(jarDeletionHandler); - ClassPathUtilities.canTerminate |= deleted; - return deleted; - } - catch (PrivilegedActionException ex) - { - ex.printStackTrace(); - } - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } - - return false; - } - - public static void terminateRuntime(int status) - { - if (ClassPathUtilities.canTerminate) - { - System.exit(status); - } - else - { - throw new IllegalStateException(); - } - } - - /** - * @param classLoader - * @param fileName - * @param removeFromClassPath - * @throws MalformedURLException - */ - @SuppressWarnings("unchecked") - private static JarFile getJarFromClassLoader(URLClassLoader classLoader, String fileName, boolean removeFromClassPath) - throws MalformedURLException - { - JarFile jar = null; - - try - { - Object classPath = ClassPathUtilities.ucp.get(classLoader); - Map loaderMap = (Map)ClassPathUtilities.classPathLoaderMap.get(classPath); - - Iterator iter = loaderMap.entrySet().iterator(); - while (iter.hasNext()) - { - Entry loaderEntry = (Entry)iter.next(); - - String url = loaderEntry.getKey(); - - if (url.endsWith(fileName)) - { - Object loader = loaderEntry.getValue(); - Field jarField = loader.getClass().getDeclaredField("jar"); - jarField.setAccessible(true); - - jar = (JarFile)jarField.get(loader); - - if (removeFromClassPath) - { - jarField.set(loader, null); - - Stack urls = (Stack)ClassPathUtilities.classPathURLs.get(classPath); - ArrayList path = (ArrayList)ClassPathUtilities.classPathPath.get(classPath); - ArrayList loaders = (ArrayList)ClassPathUtilities.classPathLoaderList.get(classPath); - - loaders.remove(loader); - iter.remove(); - - URL jarURL = new URL(url); - urls.remove(jarURL); - path.remove(jarURL); - } - } - } - } - catch (IllegalArgumentException ex) {} - catch (SecurityException ex) {} - catch (IllegalAccessException ex) {} - catch (NoSuchFieldException ex) - { - ex.printStackTrace(); - } - - return jar; - } -} - -class JarDeletionHandler implements PrivilegedExceptionAction -{ - JarFile jarInClassLoader, jarInParentClassLoader; - File jarFileInClassLoader, jarFileInParentClassLoader; - - void setPaths(JarFile jarInClassLoader, JarFile jarInParentClassLoader, File jarFileInClassLoader, File jarFileInParentClassLoader) - { - this.jarInClassLoader = jarInClassLoader; - this.jarInParentClassLoader = jarInParentClassLoader; - this.jarFileInClassLoader = jarFileInClassLoader; - this.jarFileInParentClassLoader = jarFileInParentClassLoader; - } - - @Override - public Boolean run() throws Exception - { - this.jarInClassLoader.close(); - this.jarInParentClassLoader.close(); - - try - { - Thread.sleep(5000); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - - boolean deletedJarFile = this.jarFileInClassLoader.delete(); - boolean deletedParentJarFile = this.jarFileInParentClassLoader.delete(); - - System.err.println("deletedJarFile=" + deletedJarFile + " deletedParentJarFile=" + deletedParentJarFile); - - return Boolean.valueOf(deletedJarFile || deletedParentJarFile); - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/ClassTransformerManager.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/ClassTransformerManager.java deleted file mode 100644 index c0c9b161..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/ClassTransformerManager.java +++ /dev/null @@ -1,235 +0,0 @@ -package com.mumfrey.liteloader.launch; - -import java.lang.reflect.Field; -import java.util.*; - -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.core.LogEvent; -import org.apache.logging.log4j.core.appender.AbstractAppender; - -import net.minecraft.launchwrapper.IClassTransformer; -import net.minecraft.launchwrapper.LaunchClassLoader; -import net.minecraft.launchwrapper.LogWrapper; - -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -/** - * Manages injection of required and optional transformers - * - * @author Adam Mummery-Smith - */ -public class ClassTransformerManager -{ - /** - * Once the game is started we can no longer inject transformers - */ - private boolean gameStarted; - - /** - * Transformers to inject after preInit but before the game starts, - * necessary for anything that needs to be downstream of forge. - */ - private Set downstreamTransformers = new LinkedHashSet(); - - /** - * Transformers passed into the constructor which are required and must be - * injected upstream. - */ - private final List requiredTransformers; - - /** - * Transformers successfully injected by us - */ - private final Set injectedTransformers = new LinkedHashSet(); - - /** - * Catalogue of transformer startup failures - */ - private final Map> transformerStartupErrors = new HashMap>(); - - private Logger attachedLog; - - private String pendingTransformer; - - class ThrowableObserver extends AbstractAppender - { - public ThrowableObserver() - { - super("Throwable Observer", null, null); - this.start(); - } - - @Override - public void append(LogEvent event) - { - ClassTransformerManager.this.observeThrowable(event.getThrown()); - } - } - - /** - * @param requiredTransformers - */ - public ClassTransformerManager(List requiredTransformers) - { - this.requiredTransformers = requiredTransformers; - - this.appendObserver(); - } - - private void appendObserver() - { - try - { - Field fLogger = LogWrapper.class.getDeclaredField("myLog"); - fLogger.setAccessible(true); - this.attachedLog = (Logger)fLogger.get(LogWrapper.log); - if (this.attachedLog instanceof org.apache.logging.log4j.core.Logger) - { - ((org.apache.logging.log4j.core.Logger)this.attachedLog).addAppender(new ThrowableObserver()); - } - } - catch (Exception ex) - { - LiteLoaderLogger.warning("Failed to append ThrowableObserver to LogWrapper, transformer startup exceptions may not be logged"); - } - } - - /** - * @param transformerClass - */ - public boolean injectTransformer(String transformerClass) - { - if (!this.gameStarted) - { - this.downstreamTransformers.add(transformerClass); - return true; - } - - return false; - } - - /** - * @param transformerClasses - */ - public boolean injectTransformers(Collection transformerClasses) - { - if (!this.gameStarted) - { - this.downstreamTransformers.addAll(transformerClasses); - return true; - } - - return false; - } - - /** - * @param transformerClasses - */ - public boolean injectTransformers(String[] transformerClasses) - { - if (!this.gameStarted) - { - this.downstreamTransformers.addAll(Arrays.asList(transformerClasses)); - return true; - } - - return false; - } - - /** - * @param classLoader - */ - void injectUpstreamTransformers(LaunchClassLoader classLoader) - { - for (String requiredTransformerClassName : this.requiredTransformers) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Injecting required class transformer '%s'", requiredTransformerClassName); - this.injectTransformer(classLoader, requiredTransformerClassName); - } - } - - /** - * @param classLoader - */ - void injectDownstreamTransformers(LaunchClassLoader classLoader) - { - this.gameStarted = true; - - if (this.downstreamTransformers.size() > 0) - { - LiteLoaderLogger.info("Injecting downstream transformers"); - } - - for (String transformerClassName : this.downstreamTransformers) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Injecting additional class transformer class '%s'", transformerClassName); - this.injectTransformer(classLoader, transformerClassName); - } - - this.downstreamTransformers.clear(); - } - - private synchronized void injectTransformer(LaunchClassLoader classLoader, String transformerClassName) - { - try - { - // Assign pendingTransformer so that logged errors during transformer init can be put in the map - this.pendingTransformer = transformerClassName; - - // Register the transformer - classLoader.registerTransformer(transformerClassName); - - // Unassign pending transformer now init is completed - this.pendingTransformer = null; - - // Check whether the transformer was successfully injected, look for it in the transformer list - if (this.findTransformer(classLoader, transformerClassName) != null) - { - this.injectedTransformers.add(transformerClassName); - } - } - catch (Throwable th) - { - LiteLoaderLogger.severe(th, "Error injecting class transformer class %s", transformerClassName); - } - } - - public void observeThrowable(Throwable th) - { - if (th != null && this.pendingTransformer != null) - { - List transformerErrors = this.transformerStartupErrors.get(this.pendingTransformer); - if (transformerErrors == null) - { - transformerErrors = new ArrayList(); - this.transformerStartupErrors.put(this.pendingTransformer, transformerErrors); - } - transformerErrors.add(th); - } - } - - private IClassTransformer findTransformer(LaunchClassLoader classLoader, String transformerClassName) - { - for (IClassTransformer transformer : classLoader.getTransformers()) - { - if (transformer.getClass().getName().equals(transformerClassName)) - { - return transformer; - } - } - - return null; - } - - public Set getInjectedTransformers() - { - return Collections.unmodifiableSet(this.injectedTransformers); - } - - public List getTransformerStartupErrors(String transformerClassName) - { - List errorList = this.transformerStartupErrors.get(transformerClassName); - return errorList != null ? Collections.unmodifiableList(errorList) : null; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/GameEnvironment.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/GameEnvironment.java deleted file mode 100644 index 7482e754..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/GameEnvironment.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mumfrey.liteloader.launch; - -import java.io.File; - -public interface GameEnvironment -{ - /** - * Get the game directory, this is the root directory of the game profile - * specified by the user in the launcher. - */ - public abstract File getGameDirectory(); - - /** - * Get the assets directory - */ - public abstract File getAssetsDirectory(); - - /** - * Get the active profile name - */ - public abstract String getProfile(); - - /** - * Get the "mods" folder, used to get the base path for enumerators and - * config for legacy mods. - */ - public abstract File getModsFolder(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/InjectionStrategy.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/InjectionStrategy.java deleted file mode 100644 index 1dee4627..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/InjectionStrategy.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.mumfrey.liteloader.launch; - -/** - * Encapsulates a strategy for injecting a URL into the classpath - * - * @author Adam Mummery-Smith - */ -public final class InjectionStrategy -{ - /** - * Defines a position for a classpath injection strategy - * - * @author Adam Mummery-Smith - */ - public enum InjectionPosition - { - /** - * Inject the URL at the bottom (end) of the classpath, lowest priority - * - this is the default. - */ - Bottom, - - /** - * Inject the URL at the base of the classpath (directly above the - * minecraft jar but below all other libs). - */ - Base, - - /** - * Inject the URL at the top (start) of the classpath, highest priority - * above all other libs. - */ - Top, - - /** - * Inject the URL above the entry which matches the URL defined by param - */ - Above; - - /** - * Parse an InjectionPosition from the specified "injectAt" string - * - * @param injectAt - */ - public static InjectionPosition parsePosition(String injectAt) - { - if ("top".equalsIgnoreCase(injectAt)) return InjectionPosition.Top; - if ("base".equalsIgnoreCase(injectAt)) return InjectionPosition.Base; - if (injectAt != null && injectAt.toLowerCase().startsWith("above:")) return InjectionPosition.Above; - return InjectionPosition.Bottom; - } - - /** - * Parse InjectionPosition params from the specified "injectAt" string - * - * @param injectAt - */ - public String[] parseParams(String injectAt) - { - if (this == InjectionPosition.Above && injectAt != null) return injectAt.substring(6).split(","); - return null; - } - } - - /** - * Top strategy - */ - public static final InjectionStrategy TOP = new InjectionStrategy(InjectionPosition.Top, null); - - /** - * Default strategy - */ - public static final InjectionStrategy DEFAULT = new InjectionStrategy(InjectionPosition.Bottom, null); - - /** - * Position for this strategy - */ - private final InjectionPosition position; - - /** - * Params for the strategy (if supported by the specified position) - */ - private final String[] params; - - /** - * Private constructor because strategy should be created from a string - * using parseStrategy() - * - * @param injectAt - */ - private InjectionStrategy(String injectAt) - { - this.position = InjectionPosition.parsePosition(injectAt); - this.params = this.position.parseParams(injectAt); - } - - /** - * Private constructor for the pre-defined public strategies TOP and DEFAULT - * - * @param position - * @param params - */ - private InjectionStrategy(InjectionPosition position, String[] params) - { - this.position = position; - this.params = params; - } - - /** - * Get the position - */ - public InjectionPosition getPosition() - { - return this.position; - } - - /** - * Get the parameters - */ - public String[] getParams() - { - return this.params; - } - - /** - * Parse an injection strategy from the specified injectAt string - * - * @param injectAt - */ - public static InjectionStrategy parseStrategy(String injectAt) - { - return InjectionStrategy.parseStrategy(injectAt, null); - } - - /** - * Parse an injection strategy from the specified injectAt string - * - * @param injectAt - */ - public static InjectionStrategy parseStrategy(String injectAt, InjectionStrategy defaultStrategy) - { - if (injectAt == null) return defaultStrategy; - return new InjectionStrategy(injectAt); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/InvalidTransformerException.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/InvalidTransformerException.java deleted file mode 100644 index 83a40965..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/InvalidTransformerException.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.mumfrey.liteloader.launch; - -/** - * Exception thrown from the NonDelegatingClassLoader if a transformer tries to - * access a class outside of the classes that are allowed for that transformer. - * - * @author Adam Mummery-Smith - */ -public class InvalidTransformerException extends ClassNotFoundException -{ - private static final long serialVersionUID = 6723030540814568734L; - - private final String accessedClass; - - public InvalidTransformerException(String accessedClass) - { - super("Tried to access " + accessedClass); - this.accessedClass = accessedClass; - } - - public String getAccessedClass() - { - return this.accessedClass; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/LiteLoaderTransformer.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/LiteLoaderTransformer.java deleted file mode 100644 index a8c12ca7..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/LiteLoaderTransformer.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.mumfrey.liteloader.launch; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldNode; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.MethodNode; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.ClassTransformer; - -public class LiteLoaderTransformer extends ClassTransformer -{ - private static final String LITELOADER_TWEAKER_CLASS = LiteLoaderTweaker.class.getName().replace('.', '/'); - - private static final String METHOD_PRE_BEGIN_GAME = "preBeginGame"; - - @Override - public byte[] transform(String name, String transformedName, byte[] basicClass) - { - if (basicClass == null) return basicClass; - - if (Obf.MinecraftMain.name.equals(transformedName)) - { - return this.transformMain(basicClass); - } - else if (Obf.Blocks.obf.equals(transformedName) - || Obf.Blocks.name.equals(transformedName) - || Obf.Items.obf.equals(transformedName) - || Obf.Items.name.equals(transformedName)) - { - return this.stripFinalModifiers(basicClass); - } - - return basicClass; - } - - private byte[] transformMain(byte[] basicClass) - { - ClassNode classNode = this.readClass(basicClass, true); - - for (MethodNode method : classNode.methods) - { - if ("main".equals(method.name)) - { - method.instructions.insert(new MethodInsnNode(Opcodes.INVOKESTATIC, LiteLoaderTransformer.LITELOADER_TWEAKER_CLASS, - LiteLoaderTransformer.METHOD_PRE_BEGIN_GAME, "()V", false)); - } - } - - return this.writeClass(classNode); - } - - private byte[] stripFinalModifiers(byte[] basicClass) - { - ClassNode classNode = this.readClass(basicClass, true); - - for (FieldNode field : classNode.fields) - { - field.access = field.access & ~Opcodes.ACC_FINAL; - } - - return this.writeClass(classNode); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/LiteLoaderTweaker.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/LiteLoaderTweaker.java deleted file mode 100644 index 9c6c58ec..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/LiteLoaderTweaker.java +++ /dev/null @@ -1,692 +0,0 @@ -package com.mumfrey.liteloader.launch; - -import java.io.File; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import org.spongepowered.asm.launch.MixinBootstrap; - -import net.minecraft.launchwrapper.ITweaker; -import net.minecraft.launchwrapper.Launch; -import net.minecraft.launchwrapper.LaunchClassLoader; - -import com.google.common.base.Preconditions; -import com.mumfrey.liteloader.launch.LoaderEnvironment.EnvironmentType; -import com.mumfrey.liteloader.transformers.event.EventInfo; -import com.mumfrey.liteloader.util.SortableValue; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -/** - * LiteLoader tweak class - * - * @author Adam Mummery-Smith - */ -public class LiteLoaderTweaker implements ITweaker -{ - public static final int ENV_TYPE_CLIENT = 0; - public static final int ENV_TYPE_DEDICATEDSERVER = 1; - - // TODO Version - 1.8 - public static final String VERSION = "1.8"; - - protected static final String bootstrapClassName = "com.mumfrey.liteloader.core.LiteLoaderBootstrap"; - - /** - * Loader startup state - * - * @author Adam Mummery-Smith - */ - enum StartupState - { - PREPARE, - PREINIT, - BEGINGAME, - INIT, - POSTINIT, - DONE; - - /** - * Current state - */ - private static StartupState currentState = StartupState.PREPARE.gotoState(); - - /** - * Whether this state is active - */ - private boolean inState; - - /** - * Whether this state is completed (can go to next state) - */ - private boolean completed; - - /** - * Get whether this state is completed - */ - public boolean isCompleted() - { - return this.completed; - } - - /** - * Get whether the tweaker is currrently in this state - */ - public boolean isInState() - { - return this.inState; - } - - /** - * Go to the next state, checks whether can move to the next state - * (previous state is marked completed) first - */ - public StartupState gotoState() - { - for (StartupState otherState : StartupState.values()) - { - if (otherState.isInState() && otherState != this) - { - if (otherState.canGotoState(this)) - { - otherState.leaveState(); - } - else - { - String message = String.format("Cannot go to state <%s> as %s %s", this.name(), otherState, - otherState.getNextState() == this ? "" : "and expects \"" + otherState.getNextState().name() + "\" instead"); - throw new IllegalStateException(message, LiteLoaderLogger.getLastThrowable()); - } - } - } - - LiteLoaderLogger.clearLastThrowable(); - StartupState.currentState = this; - - this.inState = true; - this.completed = false; - - return this; - } - - /* (non-Javadoc) - * @see java.lang.Enum#toString() - */ - @Override - public String toString() - { - return String.format("<%s> is %s %s", this.name(), - this.inState ? "[ACTIVE]" : "[INACTIVE]", - this.completed ? "and [COMPLETED]" : "but [INCOMPLETE]"); - } - - /** - * - */ - public void leaveState() - { - this.inState = false; - } - - /** - * - */ - public void completed() - { - if (!this.inState || this.completed) - { - String message = String.format("Attempted to complete state %s but the state is already completed or is not active", this.name()); - throw new IllegalStateException(message, LiteLoaderLogger.getLastThrowable()); - } - - this.completed = true; - } - - /** - * Get the state which follows this state - */ - private StartupState getNextState() - { - return this.ordinal() < StartupState.values().length - 1 ? StartupState.values()[this.ordinal() + 1] : StartupState.DONE; - } - - /** - * @param next - */ - public boolean canGotoState(StartupState next) - { - if (this.inState && next == this.getNextState()) - { - return this.completed; - } - - return !this.inState; - } - - /** - * Get the current state - */ - public static StartupState getCurrent() - { - return StartupState.currentState; - } - } - - /** - * Singleton instance, mainly for delegating from injected callbacks which - * need a static method to call. - */ - protected static LiteLoaderTweaker instance; - - /** - * Approximate location of the minecraft jar, used for "base" injection - * position in ClassPathUtilities. - */ - protected static URL jarUrl; - - /** - * "Order" value for inserted tweakers, used as disambiguating sort criteria - * for injected tweakers which have the same priority. - */ - protected int tweakOrder = 0; - - /** - * All tweakers, used to avoid injecting duplicates - */ - protected Set allCascadingTweaks = new HashSet(); - - /** - * Sorted list of tweakers, used to sort tweakers before injecting - */ - protected Set> sortedCascadingTweaks = new TreeSet>(); - - /** - * True if this is the primary tweak, not known until at least PREJOINGAME - */ - protected boolean isPrimary; - - /** - * Startup environment information, used to store info about the current - * startup in one place, also handles parsing command line arguments. - */ - protected StartupEnvironment env; - - /** - * Loader bootstrap object - */ - protected LoaderBootstrap bootstrap; - - /** - * Transformer manager - */ - protected ClassTransformerManager transformerManager; - - /* (non-Javadoc) - * @see net.minecraft.launchwrapper.ITweaker - * #acceptOptions(java.util.List, java.io.File, java.io.File, - * java.lang.String) - */ - @Override - public void acceptOptions(List args, File gameDirectory, File assetsDirectory, String profile) - { - LiteLoaderTweaker.injectTweakClass("org.spongepowered.asm.launch.MixinTweaker"); - - Launch.classLoader.addClassLoaderExclusion("org.apache."); - Launch.classLoader.addClassLoaderExclusion("com.google.common."); - Launch.classLoader.addClassLoaderExclusion("org.objectweb.asm."); - LiteLoaderTweaker.instance = this; - - this.onPrepare(args, gameDirectory, assetsDirectory, profile); - - this.onPreInit(); - } - - /* (non-Javadoc) - * @see net.minecraft.launchwrapper.ITweaker - * #injectIntoClassLoader( - * net.minecraft.launchwrapper.LaunchClassLoader) - */ - @Override - public void injectIntoClassLoader(LaunchClassLoader classLoader) - { -// classLoader.addClassLoaderExclusion("com.mumfrey.liteloader.core.runtime.Obf"); -// classLoader.addClassLoaderExclusion("com.mumfrey.liteloader.core.runtime.Packets"); - - this.transformerManager.injectUpstreamTransformers(classLoader); - - for (String transformerClassName : this.bootstrap.getRequiredDownstreamTransformers()) - { - LiteLoaderLogger.info("Queuing required class transformer '%s'", transformerClassName); - this.transformerManager.injectTransformer(transformerClassName); - } - } - - /* (non-Javadoc) - * @see net.minecraft.launchwrapper.ITweaker#getLaunchTarget() - */ - @Override - public String getLaunchTarget() - { - this.isPrimary = true; - this.onPreBeginGame(); - - return "net.minecraft.client.main.Main"; - } - - /* (non-Javadoc) - * @see net.minecraft.launchwrapper.ITweaker#getLaunchArguments() - */ - @Override - public String[] getLaunchArguments() - { - return this.env.getLaunchArguments(); - } - - /** - * Return true if this is the primary tweaker - */ - public boolean isPrimary() - { - return this.isPrimary; - } - - /** - * Get the class transformer manager - */ - public ClassTransformerManager getTransformerManager() - { - return this.transformerManager; - } - - /** - * @param args - * @param gameDirectory - * @param assetsDirectory - * @param profile - */ - private void onPrepare(List args, File gameDirectory, File assetsDirectory, String profile) - { - LiteLoaderLogger.info(Verbosity.REDUCED, "Bootstrapping LiteLoader " + LiteLoaderTweaker.VERSION); - - try - { - this.initEnvironment(args, gameDirectory, assetsDirectory, profile); - - this.bootstrap = this.spawnBootstrap(LiteLoaderTweaker.bootstrapClassName, Launch.classLoader); - - this.transformerManager = new ClassTransformerManager(this.bootstrap.getRequiredTransformers()); - - StartupState.PREPARE.completed(); - } - catch (Throwable th) - { - LiteLoaderLogger.severe(th, "Error during LiteLoader PREPARE: %s %s", th.getClass().getName(), th.getMessage()); - } - } - - /** - * Do the first stage of loader startup, which enumerates mod sources and - * finds tweakers. - */ - private void onPreInit() - { - StartupState.PREINIT.gotoState(); - - try - { - MixinBootstrap.init(); - - this.bootstrap.preInit(Launch.classLoader, true, this.env.getModFilterList()); - - this.injectDiscoveredTweakClasses(); - StartupState.PREINIT.completed(); - } - catch (Throwable th) - { - LiteLoaderLogger.severe(th, "Error during LiteLoader PREINIT: %s %s", th.getClass().getName(), th.getMessage()); - } - } - - /** - * - */ - private void onPreBeginGame() - { - if (StartupState.BEGINGAME.isCompleted()) - { - return; - } - - StartupState.BEGINGAME.gotoState(); - try - { - this.transformerManager.injectDownstreamTransformers(Launch.classLoader); - this.bootstrap.preBeginGame(); - MixinBootstrap.addProxy(); - StartupState.BEGINGAME.completed(); - } - catch (Throwable th) - { - LiteLoaderLogger.severe(th, "Error during LiteLoader BEGINGAME: %s %s", th.getClass().getName(), th.getMessage()); - } - } - - /** - * Do the second stage of loader startup - */ - private void onInit() - { - StartupState.INIT.gotoState(); - - try - { - this.bootstrap.init(); - StartupState.INIT.completed(); - } - catch (Throwable th) - { - LiteLoaderLogger.severe(th, "Error during LiteLoader INIT: %s %s", th.getClass().getName(), th.getMessage()); - } - } - - /** - * Do the second stage of loader startup - */ - private void onPostInit() - { - StartupState.POSTINIT.gotoState(); - - try - { - this.bootstrap.postInit(); - StartupState.POSTINIT.completed(); - - StartupState.DONE.gotoState(); - } - catch (Throwable th) - { - LiteLoaderLogger.severe(th, "Error during LiteLoader POSTINIT: %s %s", th.getClass().getName(), th.getMessage()); - } - } - - /** - * Set up the startup environment - * - * @param args - * @param gameDirectory - * @param assetsDirectory - * @param profile - */ - private void initEnvironment(List args, File gameDirectory, File assetsDirectory, String profile) - { - this.env = this.spawnStartupEnvironment(args, gameDirectory, assetsDirectory, profile); - - URL[] urls = Launch.classLoader.getURLs(); - LiteLoaderTweaker.jarUrl = urls[urls.length - 1]; // probably? - } - - /** - * Injects discovered tweak classes - */ - private void injectDiscoveredTweakClasses() - { - if (this.sortedCascadingTweaks.size() > 0) - { - if (StartupState.getCurrent() != StartupState.PREINIT || !StartupState.PREINIT.isInState()) - { - LiteLoaderLogger.warning("Failed to inject cascaded tweak classes because preInit is already complete"); - return; - } - - LiteLoaderLogger.info("Injecting cascaded tweakers..."); - - List tweakClasses = LiteLoaderTweaker.getTweakClasses(); - List tweakers = LiteLoaderTweaker.getTweakers(); - if (tweakClasses != null && tweakers != null) - { - for (SortableValue tweak : this.sortedCascadingTweaks) - { - String tweakClass = tweak.getValue(); - LiteLoaderLogger.info(Verbosity.REDUCED, "Injecting tweak class %s with priority %d", tweakClass, tweak.getPriority()); - LiteLoaderTweaker.injectTweakClass(tweakClass, tweakClasses, tweakers); - } - } - - // Clear sortedTweaks but not allTweaks - this.sortedCascadingTweaks.clear(); - } - } - - private static boolean injectTweakClass(String tweakClass) - { - List tweakClasses = LiteLoaderTweaker.getTweakClasses(); - List tweakers = LiteLoaderTweaker.getTweakers(); - return LiteLoaderTweaker.injectTweakClass(tweakClass, tweakClasses, tweakers); - } - - /** - * @param tweakClass - * @param tweakClasses - * @param tweakers - */ - private static boolean injectTweakClass(String tweakClass, List tweakClasses, List tweakers) - { - if (tweakClasses.contains(tweakClass)) - { - return false; - } - - for (ITweaker existingTweaker : tweakers) - { - if (tweakClass.equals(existingTweaker.getClass().getName())) - { - return false; - } - } - - tweakClasses.add(tweakClass); - return true; - } - - /** - * @param tweakClass - * @param priority - */ - public boolean addCascadedTweaker(String tweakClass, int priority) - { - if (tweakClass != null && !this.allCascadingTweaks.contains(tweakClass)) - { - if (this.getClass().getName().equals(tweakClass)) - { - return false; - } - - if (LiteLoaderTweaker.isTweakAlreadyEnqueued(tweakClass)) - { - return false; - } - - this.allCascadingTweaks.add(tweakClass); - this.sortedCascadingTweaks.add(new SortableValue(priority, this.tweakOrder++, tweakClass)); - return true; - } - - return false; - } - - /** - * The bootstrap object has to be spawned using reflection for obvious - * reasons - * - * @param bootstrapClassName - * @param classLoader - */ - protected LoaderBootstrap spawnBootstrap(String bootstrapClassName, ClassLoader classLoader) - { - if (!StartupState.PREPARE.isInState()) - { - throw new IllegalStateException("spawnBootstrap is not valid outside PREPARE"); - } - - try - { - @SuppressWarnings("unchecked") - Class bootstrapClass = (Class)Class.forName(bootstrapClassName, false, classLoader); - Constructor bootstrapCtor = bootstrapClass.getDeclaredConstructor(StartupEnvironment.class, ITweaker.class); - bootstrapCtor.setAccessible(true); - - return bootstrapCtor.newInstance(this.env, this); - } - catch (Throwable th) - { - throw new RuntimeException(th); - } - } - - /** - * @param args - * @param gameDirectory - * @param assetsDirectory - * @param profile - */ - protected StartupEnvironment spawnStartupEnvironment(List args, File gameDirectory, File assetsDirectory, String profile) - { - return new StartupEnvironment(args, gameDirectory, assetsDirectory, profile) - { - @Override - public void registerCoreAPIs(List apisToLoad) - { - apisToLoad.add(0, "com.mumfrey.liteloader.client.api.LiteLoaderCoreAPIClient"); - } - - @Override - public int getEnvironmentTypeId() - { - return LiteLoaderTweaker.ENV_TYPE_CLIENT; - } - }; - } - - /** - * Get the game jar url (probably) - */ - public static URL getJarUrl() - { - return LiteLoaderTweaker.jarUrl; - } - - /** - * @param url URL to add - */ - public static boolean addURLToParentClassLoader(URL url) - { - if (StartupState.getCurrent() == StartupState.PREINIT && StartupState.PREINIT.isInState()) - { - try - { - URLClassLoader classLoader = (URLClassLoader)Launch.class.getClassLoader(); - Method mAddUrl = URLClassLoader.class.getDeclaredMethod("addURL", URL.class); - mAddUrl.setAccessible(true); - mAddUrl.invoke(classLoader, url); - - return true; - } - catch (Exception ex) - { - LiteLoaderLogger.warning(ex, "addURLToParentClassLoader failed: %s", ex.getMessage()); - } - } - - return false; - } - - /** - * @param clazz - */ - private static boolean isTweakAlreadyEnqueued(String clazz) - { - List tweakClasses = LiteLoaderTweaker.getTweakClasses(); - List tweakers = LiteLoaderTweaker.getTweakers(); - - if (tweakClasses != null) - { - for (String tweakClass : tweakClasses) - { - if (tweakClass.equals(clazz)) return true; - } - } - - if (tweakers != null) - { - for (ITweaker tweaker : tweakers) - { - if (tweaker.getClass().getName().equals(clazz)) return true; - } - } - - return false; - } - - @SuppressWarnings("unchecked") - private static List getTweakClasses() - { - return Preconditions.>checkNotNull((List)Launch.blackboard.get("TweakClasses"), "TweakClasses"); - } - - @SuppressWarnings("unchecked") - private static List getTweakers() - { - return Preconditions.>checkNotNull((List)Launch.blackboard.get("Tweaks"), "Tweaks"); - } - - /** - * Get whether to enable the loading bar for minecraft startup - */ - public static boolean loadingBarEnabled() - { - LoaderProperties properties = LiteLoaderTweaker.instance.bootstrap.getProperties(); - return properties != null && properties.getBooleanProperty("loadingbar"); - } - - /** - * Callback from the "Main" class, do the PREBEGINGAME steps (inject - * "downstream" transformers) - */ - public static void preBeginGame() - { - LiteLoaderTweaker.instance.onPreBeginGame(); - } - - /** - * Callback from Minecraft::startGame() do early mod initialisation - */ - public static void init() - { - LiteLoaderTweaker.instance.onInit(); - } - - /** - * Callback from Minecraft::startGame() do late mod initialisation - */ - public static void postInit() - { - LiteLoaderTweaker.instance.onPostInit(); - } - - public static void dedicatedServerInit(EventInfo e) - { - LiteLoaderTweaker.instance.onInit(); - LiteLoaderTweaker.instance.onPostInit(); - } - - public static EnvironmentType getEnvironmentType() - { - return LiteLoaderTweaker.instance.bootstrap.getEnvironment().getType(); - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/LiteLoaderTweakerServer.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/LiteLoaderTweakerServer.java deleted file mode 100644 index d88e5821..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/LiteLoaderTweakerServer.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.mumfrey.liteloader.launch; - -import java.io.File; -import java.util.List; - -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -public class LiteLoaderTweakerServer extends LiteLoaderTweaker -{ - public LiteLoaderTweakerServer() - { - LiteLoaderLogger.verbosity = Verbosity.REDUCED; - } - - @Override - protected StartupEnvironment spawnStartupEnvironment(List args, File gameDirectory, File assetsDirectory, String profile) - { - return new StartupEnvironment(args, gameDirectory, assetsDirectory, profile) - { - @Override - public void registerCoreAPIs(List apisToLoad) - { - apisToLoad.add(0, "com.mumfrey.liteloader.server.api.LiteLoaderCoreAPIServer"); - } - - @Override - public int getEnvironmentTypeId() - { - return LiteLoaderTweaker.ENV_TYPE_DEDICATEDSERVER; - } - }; - } - - @Override - public String getLaunchTarget() - { - super.getLaunchTarget(); - - return "net.minecraft.server.MinecraftServer"; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/LoaderBootstrap.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/LoaderBootstrap.java deleted file mode 100644 index 99e81283..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/LoaderBootstrap.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.mumfrey.liteloader.launch; - -import java.util.List; - -import net.minecraft.launchwrapper.LaunchClassLoader; - -/** - * Interface for the loader bootstrap, this is loaded in the parent classloader - * for convenience otherwise it would be necessary to call the initialisation - * functions using reflection which just gets boring very quickly. - * - * @author Adam Mummery-Smith - */ -public interface LoaderBootstrap -{ - /** - * Pre-init, perform mod file discovery and initial setup (eg. logger, - * properties) - * - * @param classLoader - * @param loadTweaks - * @param modsToLoad - */ - public abstract void preInit(LaunchClassLoader classLoader, boolean loadTweaks, List modsToLoad); - - /** - * - */ - public abstract void preBeginGame(); - - /** - * Init, create the loader instance and load mods - */ - public abstract void init(); - - /** - * Post-init, initialise loaded mods - */ - public abstract void postInit(); - - public abstract List getRequiredTransformers(); - - public abstract List getRequiredDownstreamTransformers(); - - public abstract LoaderEnvironment getEnvironment(); - - public abstract LoaderProperties getProperties(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/LoaderEnvironment.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/LoaderEnvironment.java deleted file mode 100644 index f0feb77e..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/LoaderEnvironment.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.mumfrey.liteloader.launch; - -import java.io.File; - -import com.mumfrey.liteloader.api.manager.APIAdapter; -import com.mumfrey.liteloader.api.manager.APIProvider; -import com.mumfrey.liteloader.core.EnabledModsList; -import com.mumfrey.liteloader.core.LiteLoaderVersion; -import com.mumfrey.liteloader.interfaces.LoaderEnumerator; - -/** - * The Loader Environment, contains accessors for getting information about the - * current Loader session such as the game directories, profile, and API - * management classes. - * - * Launch namespace, so loaded by the AppClassLoader - * - * @author Adam Mummery-Smith - */ -public interface LoaderEnvironment extends GameEnvironment -{ - public enum EnvironmentType - { - CLIENT, - DEDICATEDSERVER - } - - public abstract EnvironmentType getType(); - - /** - * Get the API Adapter, the API Adapter provides functionality for working - * with all loaded APIs. - */ - public abstract APIAdapter getAPIAdapter(); - - /** - * Get the API Provider, the API Provider contains API instances for the - * current session. - */ - public abstract APIProvider getAPIProvider(); - - /** - * The enabled mods list is a serialisable class which contains information - * about which mods are enabled/disabled. - */ - public abstract EnabledModsList getEnabledModsList(); - - /** - * The enumerator manages mod container and class discovery - */ - public abstract LoaderEnumerator getEnumerator(); - - /** - * Get the version-specific mods folder - */ - public abstract File getVersionedModsFolder(); - - /** - * Get the configuration base folder - */ - public abstract File getConfigBaseFolder(); - - /** - * Get the version-agnostic mod config folder - */ - public abstract File getCommonConfigFolder(); - - /** - * Get the version-specific config folder - */ - public abstract File getVersionedConfigFolder(); - - /** - * Inflect a versioned configuration path for a specific version - * - * @param version - */ - public abstract File inflectVersionedConfigPath(LiteLoaderVersion version); - - public abstract boolean addCascadedTweaker(String tweakClass, int priority); - - public abstract ClassTransformerManager getTransformerManager(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/LoaderProperties.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/LoaderProperties.java deleted file mode 100644 index c31409d0..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/LoaderProperties.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.mumfrey.liteloader.launch; - -/** - * Interface for the object which will manage loader properties (internal and - * volatile). - * - * @author Adam Mummery-Smith - */ -public interface LoaderProperties -{ - /** - * True if the "load tweaks" option is enabled and enumerator modules - */ - public abstract boolean loadTweaksEnabled(); - - /** - * Get the mod pack branding from the non-volatile store - */ - public abstract String getBranding(); - - /** - * Set a boolean property in the properties file - * - * @param propertyName - * @param value - */ - public abstract void setBooleanProperty(String propertyName, boolean value); - - /** - * Get a boolean property from the properties file - * - * @param propertyName - */ - public abstract boolean getBooleanProperty(String propertyName); - - /** - * Get a boolean property but write and return the supplied default value if - * the property doesn't exist - * - * @param propertyName - * @param defaultValue - */ - public abstract boolean getAndStoreBooleanProperty(String propertyName, boolean defaultValue); - - /** - * Set an integer property in the properties file - * - * @param propertyName - * @param value - */ - public abstract void setIntegerProperty(String propertyName, int value); - - /** - * Get an integer property from the properties file - * - * @param propertyName - */ - public abstract int getIntegerProperty(String propertyName); - - /** - * Get an integer property but write and return the supplied default value - * if the property doesn't exist - * - * @param propertyName - * @param defaultValue - */ - public abstract int getAndStoreIntegerProperty(String propertyName, int defaultValue); - - /** - * Get a stored mod revision number from the properties file - * - * @param modKey - */ - public abstract int getLastKnownModRevision(String modKey); - - /** - * Store a mod revision number in the properties file - * - * @param modKey - */ - public abstract void storeLastKnownModRevision(String modKey); - - /** - * Write the properties to disk - */ - public abstract void writeProperties(); - - // General properties - public static final String OPTION_SOUND_MANAGER_FIX = "soundManagerFix"; - public static final String OPTION_MOD_INFO_SCREEN = "modInfoScreen"; - public static final String OPTION_NO_HIDE_TAB = "tabAlwaysExpanded"; - public static final String OPTION_BRAND = "brand"; - public static final String OPTION_LOADING_BAR = "loadingbar"; - public static final String OPTION_FORCE_UPDATE = "allowForceUpdate"; - public static final String OPTION_UPDATE_CHECK_INTR = "updateCheckInterval"; - public static final String OPTION_JINPUT_DISABLE = "disableJInput"; - - // Enumerator properties - public static final String OPTION_SEARCH_MODS = "search.mods"; - public static final String OPTION_SEARCH_CLASSPATH = "search.classpath"; - public static final String OPTION_SEARCH_JARFILES = "search.jarfiles"; - public static final String OPTION_FORCE_INJECTION = "forceInjection"; -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/NonDelegatingClassLoader.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/NonDelegatingClassLoader.java deleted file mode 100644 index b6bc2aec..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/NonDelegatingClassLoader.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.mumfrey.liteloader.launch; - -import java.net.URL; -import java.net.URLClassLoader; -import java.util.HashSet; -import java.util.Set; - -/** - * ClassLoader which only allows whitelisted classes to be loaded, used to - * pre-load packet transformer classes to ensure that they don't reference any - * external classes. - * - * @author Adam Mummery-Smith - */ -public class NonDelegatingClassLoader extends URLClassLoader -{ - /** - * Class names which we can load with this loader - */ - private final Set validClassNames = new HashSet(); - - /** - * Packages which we can load with this loader - */ - private final Set validPackages = new HashSet(); - - /** - * Class names which will be forcibly delegated to the parent ClassLoader - */ - private final Set delegatedClassNames = new HashSet(); - - /** - * Package names which will be forcibly delegated to the parent ClassLoader - */ - private final Set delegatedPackages = new HashSet(); - - private final ClassLoader parent; - - private boolean valid = true; - - private String invalidClassName = null; - - NonDelegatingClassLoader(URL[] urls, ClassLoader parent) - { - super(urls, null); - - this.parent = parent; - - this.validClassNames.add("java.lang.Object"); - this.validPackages.add("java."); - } - - public boolean isValid() - { - return this.valid; - } - - public String getInvalidClassName() - { - return this.invalidClassName; - } - - public void reset() - { - this.valid = true; - this.invalidClassName = null; - } - - public void addValidClassName(String className) - { - this.validClassNames.add(className); - } - - public void addValidPackage(String packageName) - { - if (!packageName.endsWith(".")) packageName += "."; - this.validPackages.add(packageName); - } - - public void addDelegatedClassName(String className) - { - this.delegatedClassNames.add(className); - this.validClassNames.add(className); - } - - public void addDelegatedPackage(String packageName) - { - if (!packageName.endsWith(".")) packageName += "."; - this.delegatedPackages.add(packageName); - this.validPackages.add(packageName); - } - - public Class addAndLoadClass(String name) throws ClassNotFoundException - { - this.reset(); - this.addValidClassName(name); - return this.loadClass(name); - } - - @Override - public Class loadClass(String name) throws ClassNotFoundException - { - if (this.parent != null) - { - if (this.delegatedClassNames.contains(name)) - { - return this.parent.loadClass(name); - } - - for (String delegatedPackage : this.delegatedPackages) - { - if (name.startsWith(delegatedPackage)) - { - return this.parent.loadClass(name); - } - } - } - - return super.loadClass(name); - } - - @Override - protected Class findClass(String name) throws ClassNotFoundException - { - if (name == null) return null; - - if (this.validClassNames.contains(name)) - { - return super.findClass(name); - } - - for (String validPackage : this.validPackages) - { - if (name.startsWith(validPackage)) - { - return super.findClass(name); - } - } - - this.valid = false; - this.invalidClassName = name; - - return super.findClass(name); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/launch/StartupEnvironment.java b/liteloader/src/main/java/com/mumfrey/liteloader/launch/StartupEnvironment.java deleted file mode 100644 index 23429e81..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/launch/StartupEnvironment.java +++ /dev/null @@ -1,235 +0,0 @@ -package com.mumfrey.liteloader.launch; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import net.minecraft.launchwrapper.Launch; -import joptsimple.ArgumentAcceptingOptionSpec; -import joptsimple.NonOptionArgumentSpec; -import joptsimple.OptionParser; -import joptsimple.OptionSet; - -/** - * Container for startup environment state which also parses the command line - * options. - * - * @author Adam Mummery-Smith - */ -public abstract class StartupEnvironment implements GameEnvironment -{ - private List singularLaunchArgs = new ArrayList(); - private Map launchArgs; - - private ArgumentAcceptingOptionSpec modsDirOption; - private ArgumentAcceptingOptionSpec modsOption; - private ArgumentAcceptingOptionSpec apisOption; - private NonOptionArgumentSpec unparsedOptions; - private OptionSet parsedOptions; - - private final File gameDirectory; - private final File assetsDirectory; - private final String profile; - - public StartupEnvironment(List args, File gameDirectory, File assetsDirectory, String profile) - { - this.gameDirectory = gameDirectory; - this.assetsDirectory = assetsDirectory; - this.profile = profile; - - this.initArgs(args); - } - - public abstract void registerCoreAPIs(List apisToLoad); - - public abstract int getEnvironmentTypeId(); - - /** - * @param args - */ - @SuppressWarnings("unchecked") - public void initArgs(List args) - { - // Get the launchArgs map from the blackboard, or create it if it's not there - this.launchArgs = (Map)Launch.blackboard.get("launchArgs"); - if (this.launchArgs == null) - { - this.launchArgs = new HashMap(); - Launch.blackboard.put("launchArgs", this.launchArgs); - } - - // Parse liteloader options using joptsimple - this.parseOptions(args.toArray(new String[args.size()])); - - // Parse out the arguments ourself because joptsimple doesn't really provide a good way to - // add arguments to the unparsed argument list after parsing - this.parseArgs(this.parsedOptions.valuesOf(this.unparsedOptions)); - - // Put required arguments to the blackboard if they don't already exist there - this.provideRequiredArgs(); - } - - private void parseOptions(String[] args) - { - OptionParser optionParser = new OptionParser(); - optionParser.allowsUnrecognizedOptions(); - - this.modsOption = optionParser.accepts("mods", "Comma-separated list of mods to load") - .withRequiredArg().ofType(String.class).withValuesSeparatedBy(','); - this.apisOption = optionParser.accepts("api", "Additional API classes to load") - .withRequiredArg().ofType(String.class); - this.modsDirOption = optionParser.accepts("modsDir", "Path to 'mods' folder to use instead of default") - .withRequiredArg().ofType(String.class); - - this.unparsedOptions = optionParser.nonOptions(); - this.parsedOptions = optionParser.parse(args); - } - - private void parseArgs(List args) - { - String classifier = null; - - for (String arg : args) - { - if (arg.startsWith("-")) - { - if (classifier != null) - { - this.addClassifiedArg(classifier, ""); - classifier = null; - } - else if (arg.contains("=")) - { - this.addClassifiedArg(arg.substring(0, arg.indexOf('=')), arg.substring(arg.indexOf('=') + 1)); - } - else - { - classifier = arg; - } - } - else - { - if (classifier != null) - { - this.addClassifiedArg(classifier, arg); - classifier = null; - } - else - { - this.singularLaunchArgs.add(arg); - } - } - } - - if (classifier != null) this.singularLaunchArgs.add(classifier); - } - - public void addClassifiedArg(String classifiedArg, String arg) - { - this.launchArgs.put(classifiedArg, arg); - } - - public void provideRequiredArgs() - { - if (this.launchArgs.get("--version") == null) - { - this.addClassifiedArg("--version", LiteLoaderTweaker.VERSION); - } - - if (this.launchArgs.get("--gameDir") == null && this.gameDirectory != null) - { - this.addClassifiedArg("--gameDir", this.gameDirectory.getAbsolutePath()); - } - - if (this.launchArgs.get("--assetsDir") == null && this.assetsDirectory != null) - { - this.addClassifiedArg("--assetsDir", this.assetsDirectory.getAbsolutePath()); - } - } - - public String[] getLaunchArguments() - { - List args = new ArrayList(); - - for (String singularArg : this.singularLaunchArgs) - args.add(singularArg); - - for (Entry launchArg : this.launchArgs.entrySet()) - { - args.add(launchArg.getKey().trim()); - args.add(launchArg.getValue().trim()); - } - - this.singularLaunchArgs.clear(); - this.launchArgs.clear(); - - return args.toArray(new String[args.size()]); - } - - /** - * Get the mod filter list - */ - public List getModFilterList() - { - return (this.parsedOptions.has(this.modsOption)) ? this.modsOption.values(this.parsedOptions) : null; - } - - /** - * Get API classes to load - */ - public List getAPIsToLoad() - { - List apisToLoad = new ArrayList(); - this.registerCoreAPIs(apisToLoad); - if (this.parsedOptions.has(this.apisOption)) - { - apisToLoad.addAll(this.apisOption.values(this.parsedOptions)); - } - - return apisToLoad; - } - - public File getOptionalDirectory(File baseDirectory, ArgumentAcceptingOptionSpec option, String defaultDir) - { - if (this.parsedOptions.has(option)) - { - String path = option.value(this.parsedOptions); - File dir = new File(path); - if (dir.isAbsolute()) - { - return dir; - } - - return new File(baseDirectory, path); - } - - return new File(baseDirectory, defaultDir); - } - - @Override - public File getGameDirectory() - { - return this.gameDirectory; - } - - @Override - public File getAssetsDirectory() - { - return this.assetsDirectory; - } - - @Override - public String getProfile() - { - return this.profile; - } - - @Override - public File getModsFolder() - { - return this.getOptionalDirectory(this.gameDirectory, this.modsDirOption, "mods"); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/messaging/Message.java b/liteloader/src/main/java/com/mumfrey/liteloader/messaging/Message.java deleted file mode 100644 index 6e86d5c5..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/messaging/Message.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.mumfrey.liteloader.messaging; - -import java.util.HashMap; -import java.util.Map; -import java.util.regex.Pattern; - -import com.google.common.collect.ImmutableMap; - -/** - * Class used to encapsulate a MessageBus message - * - * @author Adam Mummery-Smith - */ -public class Message -{ - /** - * Regex for matching valid channels - */ - private static final Pattern channelPattern = Pattern.compile("^[a-z0-9]([a-z0-9_\\-]*[a-z0-9])?:[a-z0-9]([a-z0-9_\\-]*[a-z0-9])?$", - Pattern.CASE_INSENSITIVE); - - private final String channel, replyChannel; - private final Messenger sender; - private final Map payload; - - Message(String channel, Object value, Messenger sender) - { - this(channel, value, sender, null); - } - - Message(String channel, Object value, Messenger sender, String replyChannel) - { - Message.validateChannel(channel); - - this.channel = channel; - this.payload = ImmutableMap.of("value", value); - this.sender = sender; - this.replyChannel = replyChannel; - } - - Message(String channel, Map payload, Messenger sender) - { - this(channel, payload, sender, null); - } - - Message(String channel, Map payload, Messenger sender, String replyChannel) - { - Message.validateChannel(channel); - - this.channel = channel; - this.payload = payload != null ? ImmutableMap.copyOf(payload) : ImmutableMap.of(); - this.sender = sender; - this.replyChannel = replyChannel; - } - - /** - * Get the channel (fully qualified) that this message was sent on - */ - public String getChannel() - { - return this.channel; - } - - /** - * Get the channel category for this message - */ - public String getCategory() - { - return this.channel.substring(0, this.channel.indexOf(':')); - } - - /** - * Get the specified reply channel (if any) for this message - may return - * null - */ - public String getReplyChannel() - { - return this.replyChannel; - } - - /** - * Get the message sender (if any) for this message - may return null - */ - public Messenger getSender() - { - return this.sender; - } - - /** - * Get the message payload - */ - public Map getPayload() - { - return this.payload; - } - - /** - * Check if this message is on the specified channel - * - * @param channel Full name of the channel to check against (case sensitive) - */ - public boolean isChannel(String channel) - { - return this.channel.equals(channel); - } - - /** - * Check if this message has the specified category - * - * @param category - */ - public boolean isCategory(String category) - { - return this.getCategory().equals(category); - } - - /** - * Get (and implicit cast) a value from this message's payload - * - * @param key - */ - @SuppressWarnings("unchecked") - public T get(String key) - { - return (T)this.payload.get(key); - } - - @SuppressWarnings("unchecked") - public T get(String key, T defaultValue) - { - Object value = this.payload.get(key); - if (value != null) - { - return (T)value; - } - return defaultValue; - } - - /** - * Gets the payload with the key "value", which is used with messages - * constructed using a string-only payload. - */ - public T getValue() - { - return this.get("value"); - } - - public static void validateChannel(String channel) throws IllegalArgumentException - { - if (channel == null) - { - throw new IllegalArgumentException("Channel name cannot be null"); - } - - if (!Message.isValidChannel(channel)) - { - throw new IllegalArgumentException("'" + channel + "' is not a valid channel name"); - } - } - - public static boolean isValidChannel(String channel) - { - return Message.channelPattern.matcher(channel).matches(); - } - - /** - * Build a KV map from interleaved keys and values, convenience function - * - * @param args - */ - public static Map buildMap(Object... args) - { - Map payload = new HashMap(); - for (int i = 0; i < args.length - 1; i += 2) - { - if (args[i] instanceof String) - { - payload.put((String)args[i], args[i + 1]); - } - } - - return payload; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/messaging/MessageBus.java b/liteloader/src/main/java/com/mumfrey/liteloader/messaging/MessageBus.java deleted file mode 100644 index 6c26412b..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/messaging/MessageBus.java +++ /dev/null @@ -1,269 +0,0 @@ -package com.mumfrey.liteloader.messaging; - -import java.util.Deque; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import com.mumfrey.liteloader.api.InterfaceProvider; -import com.mumfrey.liteloader.api.Listener; -import com.mumfrey.liteloader.core.InterfaceRegistrationDelegate; -import com.mumfrey.liteloader.core.event.HandlerList; -import com.mumfrey.liteloader.interfaces.FastIterable; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Intra-mod messaging bus, allows mods to send arbitrary notifications to each - * other without having to create an explicit dependency or resort to reflection - * - * @author Adam Mummery-Smith - */ -public final class MessageBus implements InterfaceProvider -{ - /** - * Singleton - */ - private static MessageBus instance; - - /** - * Messengers subscribed to each channel - */ - private final Map> messengers = new HashMap>(); - - /** - * Pending messages dispatched pre-startup - */ - private final Deque messageQueue = new LinkedList(); - - private boolean enableMessaging = false; - - private MessageBus() - { - } - - /** - * Get the singleton instance - */ - public static MessageBus getInstance() - { - if (MessageBus.instance == null) - { - MessageBus.instance = new MessageBus(); - } - - return MessageBus.instance; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider#getListenerBaseType() - */ - @Override - public Class getListenerBaseType() - { - return Listener.class; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider - * #registerInterfaces( - * com.mumfrey.liteloader.core.InterfaceRegistrationDelegate) - */ - @Override - public void registerInterfaces(InterfaceRegistrationDelegate delegate) - { - delegate.registerInterface(Messenger.class); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.api.InterfaceProvider#initProvider() - */ - @Override - public void initProvider() - { - } - - /** - * - */ - public void onStartupComplete() - { - this.enableMessaging = true; - - while (this.messageQueue.size() > 0) - { - Message msg = this.messageQueue.pop(); - this.dispatchMessage(msg); - } - } - - public void registerMessenger(Messenger messenger) - { - List messageChannels = messenger.getMessageChannels(); - if (messageChannels == null) - { - LiteLoaderLogger.warning("Listener %s returned a null channel list for getMessageChannels(), " - + "this could indicate a problem with the listener", messenger.getName()); - return; - } - - for (String channel : messageChannels) - { - if (channel != null && Message.isValidChannel(channel)) - { - LiteLoaderLogger.info("Listener %s is registering MessageBus channel %s", messenger.getName(), channel); - this.getMessengerList(channel).add(messenger); - } - else - { - LiteLoaderLogger.warning("Listener %s tried to register invalid MessageBus channel %s", messenger.getName(), channel); - } - } - } - - /** - * @param message - */ - private void sendMessage(Message message) - { - if (this.enableMessaging) - { - this.dispatchMessage(message); - return; - } - - this.messageQueue.push(message); - } - - /** - * @param message - */ - private void dispatchMessage(Message message) - { - try - { - FastIterable messengerList = this.messengers.get(message.getChannel()); - if (messengerList != null) - { - messengerList.all().receiveMessage(message); - } - } - catch (StackOverflowError err) - { - // A listener tried to reply on the same channel and ended up calling itself - throw new RuntimeException("Stack overflow encountered dispatching message on channel '" - + message.getChannel() + "'. Did you reply to yourself?"); - } - } - - /** - * Get messengers for the specified channel - * - * @param channel - */ - private FastIterable getMessengerList(String channel) - { - FastIterable messengerList = this.messengers.get(channel); - if (messengerList == null) - { - messengerList = new HandlerList(Messenger.class); - this.messengers.put(channel, messengerList); - } - - return messengerList; - } - - /** - * Send an empty message on the specified channel, this is useful for - * messages which are basically just notifications. - * - * @param channel - */ - public static void send(String channel) - { - Message message = new Message(channel, null, null); - MessageBus.getInstance().sendMessage(message); - } - - /** - * Send a message with a value on the specified channel - * - * @param channel - * @param value - */ - public static void send(String channel, String value) - { - Message message = new Message(channel, value, null); - MessageBus.getInstance().sendMessage(message); - } - - /** - * Send a message with a value on the specified channel from the specified - * sender. - * - * @param channel - * @param value - * @param sender - */ - public static void send(String channel, String value, Messenger sender) - { - Message message = new Message(channel, value, sender); - MessageBus.getInstance().sendMessage(message); - } - - /** - * Send a message with a value on the specified channel from the specified - * sender. - * - * @param channel - * @param value - * @param sender - * @param replyChannel - */ - public static void send(String channel, String value, Messenger sender, String replyChannel) - { - Message message = new Message(channel, value, sender, replyChannel); - MessageBus.getInstance().sendMessage(message); - } - - /** - * Send a message with a supplied payload on the specified channel - * - * @param channel - * @param payload - */ - public static void send(String channel, Map payload) - { - Message message = new Message(channel, payload, null); - MessageBus.getInstance().sendMessage(message); - } - - /** - * Send a message with a supplied payload on the specified channel from the - * specified sender. - * - * @param channel - * @param payload - * @param sender - */ - public static void send(String channel, Map payload, Messenger sender) - { - Message message = new Message(channel, payload, sender); - MessageBus.getInstance().sendMessage(message); - } - - /** - * Send a message with a supplied payload on the specified channel from the - * specified sender. - * - * @param channel - * @param payload - * @param sender - * @param replyChannel - */ - public static void send(String channel, Map payload, Messenger sender, String replyChannel) - { - Message message = new Message(channel, payload, sender, replyChannel); - MessageBus.getInstance().sendMessage(message); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/messaging/Messenger.java b/liteloader/src/main/java/com/mumfrey/liteloader/messaging/Messenger.java deleted file mode 100644 index 4793c3e8..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/messaging/Messenger.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.mumfrey.liteloader.messaging; - -import java.util.List; - -import com.mumfrey.liteloader.api.Listener; - -/** - * Interface for listeners that want to receive (or send) - * - * @author Adam Mummery-Smith - */ -public interface Messenger extends Listener -{ - /** - *

Get listening channels for this Messenger. Channel names must follow - * the format:

- * - * {category}:{channel} - * - *

where both {category} and {channel} are - * alpha-numeric identifiers which can contain underscore or dash but must - * begin and end with only alpha-numeric characters: for example the - * following channel names are valid: - * - *

    - *
  • foo:bar
  • - *
  • foo-bar:baz
  • - *
  • foo-bar:baz_derp
  • - *
- * - *

The following are invalid:

- * - *
    - *
  • foo
  • - *
  • foo_:bar
  • - *
  • _foo:bar
  • - *
- * - *

In general, your listener should listen on channels all beginning with - * the same category, which may match your mod id. Channel names and - * categories are case-sensitive.

- * - * @return List of channels to listen on - */ - public abstract List getMessageChannels(); - - /** - * Called when a message matching a channel you have elected to listen on is - * dispatched by any agent. WARNING this method is called if you - * dispatch a message on a channel you are listening to, thus you should - * avoid replying on channels you are listening to unless you - * specifically filter messages based on their sender: - * - * if (message.getSender() == this) return; - * - *

Messages may have a null sender or payload but will never have a null - * channel.

- * - * @param message - */ - public abstract void receiveMessage(Message message); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/AdvancedExposable.java b/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/AdvancedExposable.java deleted file mode 100644 index 602ae24c..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/AdvancedExposable.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.mumfrey.liteloader.modconfig; - -import java.io.File; - -import com.google.gson.GsonBuilder; - -/** - * Interface for Exposables which want a finer degree of control over the - * serialisation process. - * - * @author Adam Mummery-Smith - */ -public interface AdvancedExposable extends Exposable -{ - /** - * Allows this object to configure the GsonBuilder prior to the construction - * of the Gson instance. Use this callback to (for example) register custom - * type adapters or set other Gson options such as pretty printing. - * - * @param gsonBuilder - */ - public abstract void setupGsonSerialiser(GsonBuilder gsonBuilder); - - /** - * Allows this object to specify an alternative configuration file to the - * one determined by the writer, either return null or return configFile to - * keep the original setting, or return a new File object to set the - * location for the config file. If you specify an alternative location, you - * are responsible for ensuring that the location exists and is writable. - * - * @param configFile Default config file, generated by the ExposableOptions - * for this Exposable - * @param configFileLocation Default config file location, from the config - * strategy - * @param defaultFileName Default cfg file name, from the ExposableOptions - * @return config file location to return, return null to use the default - */ - public abstract File getConfigFile(File configFile, File configFileLocation, String defaultFileName); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigManager.java b/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigManager.java deleted file mode 100644 index 914f74a5..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigManager.java +++ /dev/null @@ -1,234 +0,0 @@ -package com.mumfrey.liteloader.modconfig; - -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import com.google.common.base.Strings; -import com.google.common.collect.Maps; -import com.google.common.io.Files; -import com.mumfrey.liteloader.Configurable; -import com.mumfrey.liteloader.LiteMod; - -/** - * Registry where we keep the mod config panel classes and config file writers - * - * @author Adam Mummery-Smith - */ -public class ConfigManager -{ - /** - * Mod config panel classes - */ - private Map, Class> configPanels = Maps.newHashMap(); - - /** - * Mod config writers - */ - private Map configWriters = new HashMap(); - - /** - * List of config writers, for faster iteration in onTick - */ - private List configWriterList = new LinkedList(); - - /** - * Register a mod, adds the config panel class to the map if the mod - * implements Configurable - */ - public void registerMod(LiteMod mod) - { - if (mod instanceof Configurable) - { - Class panelClass = ((Configurable)mod).getConfigPanelClass(); - if (panelClass != null) this.configPanels.put(mod.getClass(), panelClass); - } - - this.registerExposable(mod, null, false); - } - - /** - * @param exposable - * @param fallbackFileName - * @param ignoreMissingConfigAnnotation - */ - public void registerExposable(Exposable exposable, String fallbackFileName, boolean ignoreMissingConfigAnnotation) - { - ExposableOptions options = exposable.getClass().getAnnotation(ExposableOptions.class); - if (options != null) - { - if (fallbackFileName == null) fallbackFileName = options.filename(); - this.initConfigWriter(exposable, fallbackFileName, options.strategy(), options.aggressive()); - } - else if (ignoreMissingConfigAnnotation) - { - this.initConfigWriter(exposable, fallbackFileName, ConfigStrategy.Versioned, false); - } - } - - /** - * Create a config writer instance for the specified mod - * - * @param exposable - * @param fileName - * @param strategy - */ - private void initConfigWriter(Exposable exposable, String fileName, ConfigStrategy strategy, boolean aggressive) - { - if (this.configWriters.containsKey(exposable)) - { - return; - } - - if (Strings.isNullOrEmpty(fileName)) - { - fileName = exposable.getClass().getSimpleName().toLowerCase(); - - if (fileName.startsWith("litemod")) - { - fileName = fileName.substring(7); - } - } - - ExposableConfigWriter configWriter = ExposableConfigWriter.create(exposable, strategy, fileName, aggressive); - if (configWriter != null) - { - this.configWriters.put(exposable, configWriter); - this.configWriterList.add(configWriter); - } - } - - /** - * If the specified mod has a versioned config strategy, attempt to copy the - * config. - * - * @param mod - * @param newConfigPath - * @param oldConfigPath - */ - public void migrateModConfig(LiteMod mod, File newConfigPath, File oldConfigPath) - { - if (this.configWriters.containsKey(mod)) - { - ExposableConfigWriter writer = this.configWriters.get(mod); - if (writer.isVersioned()) - { - File newConfigFile = writer.getConfigFile(); - File legacyConfigFile = new File(oldConfigPath, newConfigFile.getName()); - - if (legacyConfigFile.exists() && !newConfigFile.exists()) - { - try - { - Files.copy(legacyConfigFile, newConfigFile); - } - catch (IOException ex) - { - ex.printStackTrace(); - } - } - } - } - } - - /** - * Check whether a config panel is available for the specified class - * - * @param modClass - */ - public boolean hasPanel(Class modClass) - { - return modClass != null && this.configPanels.containsKey(modClass); - } - - /** - * Instance a new config panel for the specified mod class if one is - * available. - * - * @param modClass - */ - public ConfigPanel getPanel(Class modClass) - { - if (modClass != null && this.configPanels.containsKey(modClass)) - { - try - { - return this.configPanels.get(modClass).newInstance(); - } - catch (InstantiationException ex) {} - catch (IllegalAccessException ex) {} - - // If instantiation fails, remove the panel - this.configPanels.remove(modClass); - } - - return null; - } - - /** - * Initialise the config writer for the specified mod - * - * @param exposable - */ - public void initConfig(Exposable exposable) - { - if (this.configWriters.containsKey(exposable)) - { - this.configWriters.get(exposable).init(); - } - } - - /** - * Invalidate the specified mod config, cause it to be written to disk or - * scheduled for writing if it has been written recently. - * - * @param exposable - */ - public void invalidateConfig(Exposable exposable) - { - if (this.configWriters.containsKey(exposable)) - { - this.configWriters.get(exposable).invalidate(); - } - } - - /** - * Tick all of the configuration writers, handles latent writes for - * anti-hammer strategy. - */ - public void onTick() - { - for (ExposableConfigWriter writer : this.configWriterList) - { - writer.onTick(); - } - } - - /** - * Force all mod configs to be flushed to disk - */ - public void syncConfig() - { - for (ExposableConfigWriter writer : this.configWriterList) - { - writer.sync(); - } - } - - /** - * @param exposable - */ - public static ConfigStrategy getConfigStrategy(Exposable exposable) - { - ExposableOptions options = exposable.getClass().getAnnotation(ExposableOptions.class); - if (options != null) - { - return options.strategy(); - } - - return ConfigStrategy.Unversioned; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigPanel.java b/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigPanel.java deleted file mode 100644 index ee09e7b0..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigPanel.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.mumfrey.liteloader.modconfig; - - -/** - * Interface for mod config panels to implement - * - * @author Adam Mummery-Smith - */ -public interface ConfigPanel -{ - /** - * Panels should return the text to display at the top of the config panel - * window. - */ - public abstract String getPanelTitle(); - - /** - * Get the height of the content area for scrolling purposes, return -1 to - * disable scrolling. - */ - public abstract int getContentHeight(); - - /** - * Called when the panel is displayed, initialise the panel (read settings, - * etc) - * - * @param host panel host - */ - public abstract void onPanelShown(ConfigPanelHost host); - - /** - * Called when the window is resized whilst the panel is active - * - * @param host panel host - */ - public abstract void onPanelResize(ConfigPanelHost host); - - /** - * Called when the panel is closed, panel should save settings - */ - public abstract void onPanelHidden(); - - /** - * Called every tick - */ - public abstract void onTick(ConfigPanelHost host); - - /** - * Draw the configuration panel - * - * @param host - * @param mouseX - * @param mouseY - * @param partialTicks - */ - public abstract void drawPanel(ConfigPanelHost host, int mouseX, int mouseY, float partialTicks); - - /** - * Called when a mouse button is pressed - * - * @param host - * @param mouseX - * @param mouseY - * @param mouseButton - */ - public abstract void mousePressed(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton); - - /** - * Called when a mouse button is released - * - * @param host - * @param mouseX - * @param mouseY - * @param mouseButton - */ - public abstract void mouseReleased(ConfigPanelHost host, int mouseX, int mouseY, int mouseButton); - - /** - * Called when the mouse is moved - * - * @param host - * @param mouseX - * @param mouseY - */ - public abstract void mouseMoved(ConfigPanelHost host, int mouseX, int mouseY); - - /** - * Called when a key is pressed - * - * @param host - * @param keyChar - * @param keyCode - */ - public abstract void keyPressed(ConfigPanelHost host, char keyChar, int keyCode); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigPanelHost.java b/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigPanelHost.java deleted file mode 100644 index 096e9810..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigPanelHost.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.mumfrey.liteloader.modconfig; - -import com.mumfrey.liteloader.LiteMod; - -/** - * Interface for object which can host configuration panels - * - * @author Adam Mummery-Smith - */ -public interface ConfigPanelHost -{ - /** - * Get the mod instance which owns the panel - */ - public abstract TModClass getMod(); - - /** - * Get the width of the configuration panel area - */ - public abstract int getWidth(); - - /** - * Get the height of the configuration panel area - */ - public abstract int getHeight(); - - /** - * Notify the panel host that the panel wishes to close - */ - public abstract void close(); - - /** - * Notify the panel host that the panel wishes to advance to the next panel - */ -// public abstract void next(); - - /** - * Notify the panel host that the panel wishes to go back to the previous - * panel. - */ -// public abstract void previous(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigStrategy.java b/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigStrategy.java deleted file mode 100644 index 450c5217..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ConfigStrategy.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.mumfrey.liteloader.modconfig; - -import java.io.File; - -import com.mumfrey.liteloader.core.LiteLoader; - -/** - * Configuration management strategy - * - * @author Adam Mummery-Smith - */ -public enum ConfigStrategy -{ - /** - * Use the unversioned "common" config folder - */ - Unversioned, - - /** - * Use the versioned config folder - */ - Versioned; - - public File getFileForStrategy(String fileName) - { - if (this == ConfigStrategy.Versioned) - { - return new File(LiteLoader.getConfigFolder(), fileName); - } - - return new File(LiteLoader.getCommonConfigFolder(), fileName); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/Exposable.java b/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/Exposable.java deleted file mode 100644 index 5133fbad..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/Exposable.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.mumfrey.liteloader.modconfig; - -/** - * Base interface for objects which can support the ExposeConfig annotations - * - * @author Adam Mummery-Smith - */ -public interface Exposable -{ -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ExposableConfigWriter.java b/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ExposableConfigWriter.java deleted file mode 100644 index f44badf2..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ExposableConfigWriter.java +++ /dev/null @@ -1,305 +0,0 @@ -package com.mumfrey.liteloader.modconfig; - -import java.io.File; -import java.io.FileReader; -import java.io.FileWriter; -import java.io.IOException; -import java.lang.reflect.Type; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.InstanceCreator; - -/** - * Manages serialisation of exposable properties to a JSON config file via Gson - * - * @author Adam Mummery-Smith - */ -public final class ExposableConfigWriter implements InstanceCreator -{ - /** - * Minimum number of milliseconds that must elapse between writes - */ - private static final long ANTI_HAMMER_DELAY = 1000L; - - /** - * Exposable instance which we will serialise exposed properties - */ - private final Exposable exposable; - - /** - * JSON file to write to - */ - private final File configFile; - - /** - * True if this is a versioned config strategy - */ - private final boolean versioned; - - /** - * Disable anti-hammer and always save when requested - */ - private final boolean aggressive; - - /** - * Gson instance - */ - private final Gson gson; - - /** - * True if a config write has been requested but anti-hammer has prevented - * the write from occurring. - */ - private volatile boolean dirty = false; - - /** - * Last time the config was written, used for anti-hammer - */ - private volatile long lastWrite = 0L; - - /** - * It's possible that writes may be requested from different threads, lock - * object to prevent cross-thread derp. - */ - private Object readWriteLock = new Object(); - - /** - * @param exposable - * @param configFile - */ - private ExposableConfigWriter(Exposable exposable, File configFile, boolean versioned, boolean aggressive) - { - this.exposable = exposable; - this.configFile = configFile; - this.versioned = versioned; - this.aggressive = aggressive; - - GsonBuilder gsonBuilder = new GsonBuilder(); - gsonBuilder.setPrettyPrinting(); - gsonBuilder.serializeNulls(); - gsonBuilder.excludeFieldsWithoutExposeAnnotation(); - gsonBuilder.registerTypeAdapter(exposable.getClass(), this); - - if (this.exposable instanceof AdvancedExposable) - { - ((AdvancedExposable)this.exposable).setupGsonSerialiser(gsonBuilder); - } - - this.gson = gsonBuilder.create(); - } - - /** - * Get the config file underlying this writer - */ - File getConfigFile() - { - return this.configFile; - } - - /** - * Returns true if this writer is using a versioned strategy - */ - boolean isVersioned() - { - return this.versioned; - } - - /** - * Returns true if anti-hammer is disabled for this writer - */ - public boolean isAggressive() - { - return this.aggressive; - } - - /** - * Returns true if this writer has been invalidated but not yet been flushed - * to disk. - */ - boolean isDirty() - { - return this.dirty; - } - - /* (non-Javadoc) - * @see com.google.gson.InstanceCreator - * #createInstance(java.lang.reflect.Type) - */ - @Override - public Exposable createInstance(Type type) - { - return this.exposable; - } - - /** - * Initialise the config, reads from file and writes the initial config file - * if not present. - */ - void init() - { - // Read the config - this.read(); - - // If the config doesn't exist yet, seed the config - if (!this.configFile.exists()) - { - this.write(); - } - } - - /** - * Read the config from the file - */ - void read() - { - synchronized (this.readWriteLock) - { - if (this.configFile.exists()) - { - FileReader reader = null; - - try - { - reader = new FileReader(this.configFile); - - // Normally GSON would produce a new object by calling the default constructor, but we - // trick it into deserialising properties on the existing object instance by implementing - // an InstanceCreator which just returns the object instance which we already have - this.gson.fromJson(reader, this.exposable.getClass()); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - finally - { - try - { - if (reader != null) - { - reader.close(); - } - } - catch (IOException ex) - { - ex.printStackTrace(); - } - } - } - } - } - - /** - * Write the config to the file - */ - void write() - { - synchronized (this.readWriteLock) - { - FileWriter writer = null; - try - { - writer = new FileWriter(this.configFile); - this.gson.toJson(this.exposable, writer); - - this.dirty = false; - this.lastWrite = System.currentTimeMillis(); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - finally - { - try - { - if (writer != null) - { - writer.close(); - } - } - catch (IOException ex) - { - ex.printStackTrace(); - } - } - } - } - - /** - * Write the config to file, respecting anti-hammer and queuing the write if - * not enough time has elapsed. - */ - void invalidate() - { - if (!this.aggressive) - { - long sinceLastWrite = System.currentTimeMillis() - this.lastWrite; - if (sinceLastWrite < ANTI_HAMMER_DELAY) - { - this.dirty = true; - return; - } - } - - this.write(); - } - - /** - * Handle latent writes if the config was previously invalidated - */ - void onTick() - { - if (!this.aggressive && this.dirty) - { - long sinceLastWrite = System.currentTimeMillis() - this.lastWrite; - if (sinceLastWrite >= ANTI_HAMMER_DELAY) - { - this.write(); - } - } - } - - /** - * Force a write if dirty - */ - void sync() - { - if (this.dirty || this.aggressive) - { - this.write(); - } - } - - /** - * Factory method which creates and intialises a new ExposableConfigWriter - * for the specified exposable object and strategy. - * - * @param exposable - * @param strategy - * @param fileName - */ - static ExposableConfigWriter create(Exposable exposable, ConfigStrategy strategy, String fileName, boolean aggressive) - { - if (!fileName.toLowerCase().endsWith(".json")) - { - fileName = fileName + ".json"; - } - - File configFile = strategy.getFileForStrategy(fileName); - - if (exposable instanceof AdvancedExposable) - { - File customConfigFile = ((AdvancedExposable)exposable).getConfigFile(configFile, configFile.getParentFile(), fileName); - if (customConfigFile != null) - { - configFile = customConfigFile; - } - } - - ExposableConfigWriter writer = new ExposableConfigWriter(exposable, configFile, strategy == ConfigStrategy.Versioned, aggressive); - - return writer; - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ExposableOptions.java b/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ExposableOptions.java deleted file mode 100644 index 03268c7f..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/modconfig/ExposableOptions.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.mumfrey.liteloader.modconfig; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation which can be a applied to mod classes to indicate that members - * decorated with the Gson Expose annotation should be serialised with Gson. - * - * @author Adam Mummery-Smith - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface ExposableOptions -{ - /** - * Configuration strategy to use - */ - ConfigStrategy strategy() default ConfigStrategy.Unversioned; - - /** - * Config file name, if not specified the mod class name is used - */ - String filename() default ""; - - /** - * Set to true to disable write anti-hammer for config file - */ - boolean aggressive() default false; -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/LocalPermissions.java b/liteloader/src/main/java/com/mumfrey/liteloader/permissions/LocalPermissions.java deleted file mode 100644 index 27f8a67c..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/LocalPermissions.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.mumfrey.liteloader.permissions; - - -public class LocalPermissions implements Permissions -{ - @Override - public boolean getPermissionSet(String permission) - { - return true; - } - - @Override - public boolean getHasPermission(String permission) - { - return true; - } - - @Override - public boolean getHasPermission(String permission, boolean defaultValue) - { - return defaultValue; - } - -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissibleAllMods.java b/liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissibleAllMods.java deleted file mode 100644 index 44a80f81..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissibleAllMods.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.mumfrey.liteloader.permissions; - -import java.io.File; -import java.util.HashSet; -import java.util.Set; - -import com.mumfrey.liteloader.Permissible; - -public class PermissibleAllMods implements Permissible -{ - private Set permissibles = new HashSet(); - - public void addPermissible(Permissible permissible) - { - this.permissibles.add(permissible); - } - - @Override - public String getName() - { - return "All Mods"; - } - - @Override - public String getVersion() - { - return "0.0"; - } - - @Override - public void init(File configPath) - { - } - - @Override - public void upgradeSettings(String version, File configPath, File oldConfigPath) - { - } - - @Override - public String getPermissibleModName() - { - return "all"; - } - - @Override - public float getPermissibleModVersion() - { - return 0.0F; - } - - @Override - public void registerPermissions(PermissionsManagerClient permissionsManager) - { - } - - @Override - public void onPermissionsCleared(PermissionsManager manager) - { - for (Permissible permissible : this.permissibles) - permissible.onPermissionsCleared(manager); - } - - @Override - public void onPermissionsChanged(PermissionsManager manager) - { - for (Permissible permissible : this.permissibles) - permissible.onPermissionsChanged(manager); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/Permission.java b/liteloader/src/main/java/com/mumfrey/liteloader/permissions/Permission.java deleted file mode 100644 index e0f07ac6..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/Permission.java +++ /dev/null @@ -1,219 +0,0 @@ -package com.mumfrey.liteloader.permissions; - -import java.util.Hashtable; -import java.util.Map; - -/** - * Class which represents a permission node - * - * @author Adam Mummery-Smith - */ -public class Permission -{ - /** - * True if this node is the root of the permission tree - */ - private final boolean isRootNode; - - /** - * True if this node is a wildcard node (can match any query) - */ - private final boolean isWildcardNode; - - /** - * Node name - */ - private final String nodeName; - - /** - * Nodes which are children of this node - */ - private final Map childNodes = new Hashtable(); - - /** - * Node value - */ - private boolean value; - - /** - * Create a new root node - */ - public Permission() - { - this.isRootNode = true; - this.isWildcardNode = false; - this.value = true; - this.nodeName = "root"; - } - - /** - * Create a new child node with the specified name and value - * - * @param permissionName Name of the permission node - * @param value Initial value for the permission node - */ - public Permission(String permissionName, boolean value) - { - this.isRootNode = false; - this.isWildcardNode = "*".equals(permissionName); - this.value = value; - this.nodeName = permissionName; - } - - /** - * Create a new child node with the specified name - * - * @param permissionName Name of the permission node - */ - public Permission(String permissionName) - { - this(permissionName, true); - } - - /** - * Get whether this node is a root node (read only) - */ - public boolean isRoot() - { - return this.isRootNode; - } - - /** - * Get whether this node is a wildcard node - */ - public boolean isWildcard() - { - return this.isWildcardNode; - } - - /** - * Get the name of this permission node - */ - public String getName() - { - return this.nodeName; - } - - /** - * Get the value of this permission node - */ - public boolean getValue() - { - return this.value; - } - - /** - * Set the value of this permission node - * - * @param newValue - */ - public void setValue(boolean newValue) - { - this.value = newValue; - } - - /** - * Get the specified node name - * - * @param name - */ - public Permission getPermission(String name) - { - Permission fallback = (this.isWildcardNode) ? this : null; - - if (name.indexOf('.') > -1) - { - String head = name.substring(0, name.indexOf('.')); - String tail = name.substring(name.indexOf('.') + 1); - - Permission child = this.getPermission(head); - - if (child != null) - { - return child.getPermission(tail); - } - } - else if (this.childNodes.containsKey(name)) - { - return this.childNodes.get(name); - } - - for (Permission childPermission : this.childNodes.values()) - { - if (childPermission.isWildcard()) - { - return childPermission; - } - } - - return fallback; - } - - /** - * Set the specified node name - * - * @param name - */ - public Permission setPermission(String name) - { - return this.setPermission(name, true); - } - - /** - * Set the specified permission to the specified value - * - * @param name - * @param value - */ - public Permission setPermission(String name, boolean value) - { - if (name.indexOf('.') > -1) - { - String head = name.substring(0, name.indexOf('.')); - String tail = name.substring(name.indexOf('.') + 1); - - Permission child = this.setPermission(head, false); - return child.setPermission(tail, value); - } - - Permission child = this.getPermission(name); - - if (child == null || child.isWildcard()) - { - child = new Permission(name, value); - this.childNodes.put(child.getName(), child); - } - else - { - child.setValue(value | child.value); - } - - return child; - } - - /** - * Sets a permission and also explicitly sets the permission value, this - * allows negated permissions to be set. - * - * @param name - * @param value - */ - public Permission setPermissionAndValue(String name, boolean value) - { - Permission permission = this.setPermission(name, value); - permission.setValue(value); - return permission; - } - - /** - * Check whether the specified permission is set - * - * @param name - * @param value - */ - public boolean isSet(String name, boolean value) - { - Permission child = this.getPermission(name); - return child == null ? value : child.getValue(); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/Permissions.java b/liteloader/src/main/java/com/mumfrey/liteloader/permissions/Permissions.java deleted file mode 100644 index a70fa531..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/Permissions.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.mumfrey.liteloader.permissions; - -/** - * Represents a set of permissions assigned by an authority - * - * @author Adam Mummery-Smith - */ -public interface Permissions -{ - /** - * Returns true if the specified permission is set in this permission - * container. - * - * @param permission Name of the permission to test for - * @return True if the permission exists in this set - */ - public abstract boolean getPermissionSet(String permission); - - /** - * Returns true if the authority says we have this permission or false if - * the permission is denied or not set. - * - * @param permission Name of the permission to test for - */ - public abstract boolean getHasPermission(String permission); - - /** - * Returns true if the authority says we have this permission or if the - * permission is not specified by the authority returns the default value. - * - * @param permission Name of the permission to test for - * @param defaultValue Value to return if the permission is NOT specified by - * the authority - * @return State of the authority permission or default value if not - * specified - */ - public abstract boolean getHasPermission(String permission, boolean defaultValue); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissionsManager.java b/liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissionsManager.java deleted file mode 100644 index 00376a43..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissionsManager.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.mumfrey.liteloader.permissions; - -import com.mumfrey.liteloader.Permissible; -import com.mumfrey.liteloader.common.GameEngine; - -/** - * Interface for permissions manager implementations - * - * @author Adam Mummery-Smith - */ -public interface PermissionsManager -{ - /** - * Get the underlying permissions node for this manager for the specified - * mod - * - * @param mod Mod to fetch permissions for - */ - public abstract Permissions getPermissions(Permissible mod); - - /** - * Get the time the permissions for the specified mod were last updated - * - * @param mod Mod to check for - * @return Timestamp when the permissions were last updated - */ - public abstract Long getPermissionUpdateTime(Permissible mod); - - /** - * Handler for tick event - * - * @param engine - * @param partialTicks - * @param inGame - */ - public abstract void onTick(GameEngine engine, float partialTicks, boolean inGame); - - /** - * Register a new event listener, the registered object will receive - * callbacks for permissions events - * - * @param permissible - */ - public abstract void registerPermissible(Permissible permissible); - - /** - * Perform any necessary validation to check for a tamper condition, can and - * should be called from as many places as possible - */ - public abstract void tamperCheck(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissionsManagerClient.java b/liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissionsManagerClient.java deleted file mode 100644 index c4b90886..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissionsManagerClient.java +++ /dev/null @@ -1,526 +0,0 @@ -package com.mumfrey.liteloader.permissions; - -import io.netty.buffer.Unpooled; - -import java.io.File; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.TreeSet; - -import net.eq2online.permissions.ReplicatedPermissionsContainer; -import net.minecraft.network.INetHandler; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.play.server.S01PacketJoinGame; - -import com.mumfrey.liteloader.LiteMod; -import com.mumfrey.liteloader.Permissible; -import com.mumfrey.liteloader.PluginChannelListener; -import com.mumfrey.liteloader.common.GameEngine; -import com.mumfrey.liteloader.core.ClientPluginChannels; -import com.mumfrey.liteloader.core.PluginChannels.ChannelPolicy; - -/** - * This class manages permissions on the client, it is a singleton class which - * can manage permissions for multiple client mods. It manages the client/server - * communication used to replicate permissions and serves as a hub for - * permissions objects which keep track of the permissions available on the - * client. - * - * @author Adam Mummery-Smith - */ -public final class PermissionsManagerClient implements PermissionsManager, PluginChannelListener -{ - /** - * Singleton instance of the client permissions manager - */ - private static PermissionsManagerClient instance; - - /** - * Permissions permissible which is a proxy for permissions that are common - * to all mods. - */ - private static Permissible allMods = new PermissibleAllMods(); - - /** - * Minecraft instance - */ - private GameEngine engine; - - /** - * List of registered client mods supporting permissions - */ - private Map registeredClientMods = new HashMap(); - - /** - * List of registered client permissions, grouped by mod - */ - private Map> registeredClientPermissions = new HashMap>(); - - /** - * Objects which listen to events generated by this object - */ - private Set permissibles = new HashSet(); - - /** - * Local permissions, used when server permissions are not available - */ - private LocalPermissions localPermissions = new LocalPermissions(); - - /** - * Server permissions, indexed by mod - */ - private Map serverPermissions = new HashMap(); - - /** - * Last time onTick was called, used to detect tamper condition if no ticks - * are being received. - */ - private long lastTickTime = System.currentTimeMillis(); - - /** - * Delay counter for when joining a server - */ - private int pendingRefreshTicks = 0; - - private int menuTicks = 0; - - /** - * Get a reference to the singleton instance of the client permissions - * manager. - */ - public static PermissionsManagerClient getInstance() - { - if (instance == null) - { - instance = new PermissionsManagerClient(); - } - - return instance; - } - - /** - * Private .ctor, for singleton pattern - */ - private PermissionsManagerClient() - { - this.registerClientMod("all", allMods); - } - - /* (non-Javadoc) - * @see net.eq2online.permissions.PermissionsManager - * #getPermissions(java.lang.String) - */ - @Override - public Permissions getPermissions(Permissible mod) - { - if (mod == null) mod = allMods; - String modName = mod.getPermissibleModName(); - - ServerPermissions modPermissions = this.serverPermissions.get(modName); - return modPermissions != null ? modPermissions : this.localPermissions; - } - - /* (non-Javadoc) - * @see net.eq2online.permissions.PermissionsManager - * #getPermissionUpdateTime(java.lang.String) - */ - @Override - public Long getPermissionUpdateTime(Permissible mod) - { - if (mod == null) mod = allMods; - String modName = mod.getPermissibleModName(); - - ServerPermissions modPermissions = this.serverPermissions.get(modName); - return modPermissions != null ? modPermissions.getReplicationTime() : 0; - } - - /** - * Register a new mod, if permissible - * - * @param mod - */ - public void registerMod(LiteMod mod) - { - if (mod instanceof Permissible) - { - this.registerPermissible((Permissible)mod); - } - } - - /* (non-Javadoc) - * @see net.eq2online.permissions.PermissionsManager - * #registerListener(net.eq2online.permissions.PermissionsListener) - */ - @Override - public void registerPermissible(Permissible permissible) - { - if (!this.permissibles.contains(permissible) && permissible.getPermissibleModName() != null) - { - this.registerClientMod(permissible.getPermissibleModName(), permissible); - permissible.registerPermissions(this); - } - - this.permissibles.add(permissible); - } - - /** - * Register a new client mod with this manager - * - * @param modName Mod name - * @param mod Mod instance - */ - private void registerClientMod(String modName, Permissible mod) - { - if (this.registeredClientMods.containsKey(modName)) - { - throw new IllegalArgumentException("Cannot register mod \"" + modName - + "\"! The mod was already registered with the permissions manager."); - } - - this.registeredClientMods.put(modName, mod); - this.registeredClientPermissions.put(mod, new TreeSet()); - } - - public void onJoinGame(INetHandler netHandler, S01PacketJoinGame joinGamePacket) - { - this.clearServerPermissions(); - this.scheduleRefresh(); - } - - /** - * Schedule a permissions refresh - */ - public void scheduleRefresh() - { - this.pendingRefreshTicks = 2; - } - - /** - * Clears the current replicated server permissions - */ - protected void clearServerPermissions() - { - this.serverPermissions.clear(); - - for (Permissible permissible : this.permissibles) - permissible.onPermissionsCleared(this); - } - - /** - * Send permission query packets to the server for all registered mods - */ - protected void sendPermissionQueries() - { - for (Permissible mod : this.registeredClientMods.values()) - this.sendPermissionQuery(mod); - } - - /** - * Send a permission query packet to the server for the specified mod. You - * do not need to call this method because it is issued automatically by the - * client permissions manager when connecting to a new server. However you - * can call use this method to "force" a refresh of permissions when needed. - * - * @param mod mod to send a query packet for - */ - public void sendPermissionQuery(Permissible mod) - { - String modName = mod.getPermissibleModName(); - - if (this.engine != null && this.engine.isClient() && this.engine.isInGame()) - { - if (!this.registeredClientMods.containsValue(mod)) - { - throw new IllegalArgumentException("The specified mod \"" + modName + "\" was not registered with the permissions system"); - } - - Float modVersion = mod.getPermissibleModVersion(); - Set modPermissions = this.registeredClientPermissions.get(mod); - - if (modPermissions != null) - { - ReplicatedPermissionsContainer query = new ReplicatedPermissionsContainer(modName, modVersion, modPermissions); - - if (!query.modName.equals("all") || query.permissions.size() > 0) - { - byte[] data = query.getBytes(); - PacketBuffer buffer = new PacketBuffer(Unpooled.buffer()); - buffer.writeBytes(data); - ClientPluginChannels.sendMessage(ReplicatedPermissionsContainer.CHANNEL, buffer, ChannelPolicy.DISPATCH_ALWAYS); - } - } - } - else - { - this.serverPermissions.remove(modName); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.permissions.PermissionsManager - * #onTick(net.minecraft.client.Minecraft, float, boolean) - */ - @Override - public void onTick(GameEngine engine, float partialTicks, boolean inGame) - { - this.engine = engine; - this.lastTickTime = System.currentTimeMillis(); - - if (this.pendingRefreshTicks > 0) - { - this.pendingRefreshTicks--; - - if (this.pendingRefreshTicks == 0 && inGame) - { - this.sendPermissionQueries(); - return; - } - } - - for (Map.Entry modPermissions : this.serverPermissions.entrySet()) - { - if (!modPermissions.getValue().isValid()) - { - modPermissions.getValue().notifyRefreshPending(); - this.sendPermissionQuery(this.registeredClientMods.get(modPermissions.getKey())); - } - } - - if (inGame) this.menuTicks = 0; else this.menuTicks++; - - if (this.menuTicks == 200) - { - this.clearServerPermissions(); - } - } - - /* (non-Javadoc) - * @see net.eq2online.permissions.PermissionsManager#tamperCheck() - */ - @Override - public void tamperCheck() - { - if (System.currentTimeMillis() - this.lastTickTime > 60000L) - { - throw new IllegalStateException("Client permissions manager was not ticked for 60 seconds, tamper."); - } - } - - /* (non-Javadoc) - * @see net.eq2online.permissions.PermissionsManager - * #onCustomPayload(java.lang.String, int, byte[]) - */ - @Override - public void onCustomPayload(String channel, PacketBuffer data) - { - if (channel.equals(ReplicatedPermissionsContainer.CHANNEL) && !this.engine.isSinglePlayer()) - { - ServerPermissions modPermissions = null; - try - { - modPermissions = new ServerPermissions(data); - } - catch (Exception ex) {} - - if (modPermissions != null && modPermissions.getModName() != null) - { - this.serverPermissions.put(modPermissions.getModName(), modPermissions); - - Permissible permissible = this.registeredClientMods.get(modPermissions.getModName()); - if (permissible != null) permissible.onPermissionsChanged(this); - } - } - } - - /* (non-Javadoc) - * @see net.eq2online.permissions.PermissionsManager#getChannels() - */ - @Override - public List getChannels() - { - return Arrays.asList(new String[] { ReplicatedPermissionsContainer.CHANNEL }); - } - - /** - * Register a permission for all mods, the permission will be prefixed with - * "mod.all." to provide a common namespace for client mods when - * permissions are replicated to the server. - * - * @param permission - */ - public void registerPermission(String permission) - { - this.registerModPermission(allMods, permission); - } - - /** - * Register a permission for the specified mod, the permission will be - * prefixed with "mod.." to provide a common namespace for - * client mods when permissions are replicated to the server. - * - * @param mod - * @param permission - */ - public void registerModPermission(Permissible mod, String permission) - { - if (mod == null) mod = allMods; - String modName = mod.getPermissibleModName(); - - if (!this.registeredClientMods.containsValue(mod)) - { - throw new IllegalArgumentException("Cannot register a mod permission for mod \"" + modName - + "\"! The mod was not registered with the permissions manager."); - } - - permission = formatModPermission(modName, permission); - - Set modPermissions = this.registeredClientPermissions.get(mod); - if (modPermissions != null && !modPermissions.contains(permission)) - { - modPermissions.add(permission); - } - } - - /** - * Get the value of the specified permission for all mods. - * - * @param permission Permission to check for - */ - public boolean getPermission(String permission) - { - return this.getModPermission(allMods, permission); - } - - /** - * Get the value of the specified permission for all mods and return the - * default value if the permission is not set. - * - * @param permission Permission to check for - * @param defaultValue Value to return if the permission is not set - */ - public boolean getPermission(String permission, boolean defaultValue) - { - return this.getModPermission(allMods, permission, defaultValue); - } - - /** - * Get the value of the specified permission for the specified mod. The - * permission will be prefixed with "mod.." in keeping - * with registerModPermission as a convenience. - * - * @param mod - * @param permission - */ - public boolean getModPermission(Permissible mod, String permission) - { - if (mod == null) mod = PermissionsManagerClient.allMods; - permission = formatModPermission(mod.getPermissibleModName(), permission); - Permissions permissions = this.getPermissions(mod); - - if (permissions != null) - { - return permissions.getHasPermission(permission); - } - - return true; - } - - /** - * Get the value of the specified permission for the specified mod. The - * permission will be prefixed with "mod.." in keeping - * with registerModPermission as a convenience. - * - * @param modName - * @param permission - */ - public boolean getModPermission(String modName, String permission) - { - Permissible mod = this.registeredClientMods.get(modName); - return mod != null ? this.getModPermission(mod, permission) : false; - } - - /** - * Get the value of the specified permission for the specified mod. The - * permission will be prefixed with "mod.." in keeping - * with registerModPermission as a convenience. If the permission does not - * exist, the specified default value will be returned. - * - * @param mod - * @param permission - * @param defaultValue - */ - public boolean getModPermission(Permissible mod, String permission, boolean defaultValue) - { - if (mod == null) mod = allMods; - permission = formatModPermission(mod.getPermissibleModName(), permission); - Permissions permissions = this.getPermissions(mod); - - if (permissions != null && permissions.getPermissionSet(permission)) - { - return permissions.getHasPermission(permission); - } - - return defaultValue; - } - - /** - * Get the value of the specified permission for the specified mod. The - * permission will be prefixed with "mod.." in keeping - * with registerModPermission as a convenience. - * - * @param modName - * @param permission - */ - public boolean getModPermission(String modName, String permission, boolean defaultValue) - { - Permissible mod = this.registeredClientMods.get(modName); - return mod != null ? this.getModPermission(mod, permission, defaultValue) : defaultValue; - } - - /** - * @param modName - * @param permission - */ - protected static String formatModPermission(String modName, String permission) - { - return String.format("mod.%s.%s", modName, permission); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.LiteMod#getName() - */ - @Override - public String getName() - { - // Stub for PluginChannelListener interface - return null; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.LiteMod#getVersion() - */ - @Override - public String getVersion() - { - // Stub for PluginChannelListener interface - return null; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.LiteMod#init() - */ - @Override - public void init(File configPath) - { - // Stub for PluginChannelListener interface - } - - @Override - public void upgradeSettings(String version, File configPath, File oldConfigPath) - { - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissionsManagerServer.java b/liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissionsManagerServer.java deleted file mode 100644 index 6ebe04c9..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/PermissionsManagerServer.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.mumfrey.liteloader.permissions; - -import java.util.List; - -import net.minecraft.entity.player.EntityPlayerMP; -import net.minecraft.network.PacketBuffer; - -import com.mumfrey.liteloader.Permissible; -import com.mumfrey.liteloader.ServerPluginChannelListener; -import com.mumfrey.liteloader.common.GameEngine; - -/** - * TODO implementation - * - * @author Adam Mummery-Smith - */ -public class PermissionsManagerServer implements PermissionsManager, ServerPluginChannelListener -{ - public PermissionsManagerServer() - { - } - - @Override - public String getName() - { - return null; - } - - @Override - public void onCustomPayload(EntityPlayerMP sender, String channel, PacketBuffer data) - { - } - - @Override - public Permissions getPermissions(Permissible mod) - { - return null; - } - - @Override - public Long getPermissionUpdateTime(Permissible mod) - { - return null; - } - - @Override - public void onTick(GameEngine engine, float partialTicks, boolean inGame) - { - } - - @Override - public List getChannels() - { - return null; - } - - @Override - public void registerPermissible(Permissible permissible) - { - } - - @Override - public void tamperCheck() - { - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/ReplicatedPermissions.java b/liteloader/src/main/java/com/mumfrey/liteloader/permissions/ReplicatedPermissions.java deleted file mode 100644 index 8d9a2279..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/ReplicatedPermissions.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.mumfrey.liteloader.permissions; - -/** - * Represents a set of permissions assigned by a remote authority such as a - * server. - * - * @author Adam Mummery-Smith - */ -public interface ReplicatedPermissions extends Permissions -{ - /** - * Get the time that this object was received from the remote authority - */ - public abstract long getReplicationTime(); - - /** - * Return true if this permissions object is valid (within cache period) - */ - public abstract boolean isValid(); - - /** - * Forcibly invalidate this permission container, forces update at the next - * opportunity. - */ - public abstract void invalidate(); - - /** - * Temporarily forces the permissions object to be valid to prevent repeated - * revalidation. - */ - public abstract void notifyRefreshPending(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/ServerPermissions.java b/liteloader/src/main/java/com/mumfrey/liteloader/permissions/ServerPermissions.java deleted file mode 100644 index a94933f1..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/permissions/ServerPermissions.java +++ /dev/null @@ -1,154 +0,0 @@ -package com.mumfrey.liteloader.permissions; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import net.eq2online.permissions.ReplicatedPermissionsContainer; -import net.minecraft.network.PacketBuffer; - - -/** - * Replicated permissions implementation - * - * @author Adam Mummery-Smith - */ -public class ServerPermissions implements ReplicatedPermissions -{ - /** - * Pattern for recognising valid permissions in the server feed - */ - private static final Pattern permissionPattern = Pattern.compile("^([\\+\\-])(([a-z0-9]+\\.)*[a-z0-9\\*]+)$", Pattern.CASE_INSENSITIVE); - - protected String modName; - - /** - * Root permission node - */ - protected Permission permissions = new Permission(); - - /** - * Time the permissions were updated - */ - protected long createdTime = 0L; - - /** - * Expiry time of the current data cache - */ - protected long validUntil = 0L; - - /** - * Time to cache server responses by default - */ - protected long cacheTime = 10L * 60L * 1000L; // 10 minutes - - /** - * Time to wait when refreshing server permissions before trying again - */ - protected long refreshTime = 15L * 1000L; // 15 seconds - - /** - * @param data - */ - public ServerPermissions(PacketBuffer data) - { - this.createdTime = System.currentTimeMillis(); - this.validUntil = this.createdTime + this.cacheTime; - - ReplicatedPermissionsContainer response = ReplicatedPermissionsContainer.fromPacketBuffer(data); - - if (response != null) - { - response.sanitise(); - - this.modName = response.modName; - this.validUntil = System.currentTimeMillis() + response.remoteCacheTimeSeconds * 1000L; - - for (String permissionString : response.permissions) - { - Matcher permissionMatcher = permissionPattern.matcher(permissionString); - - if (permissionMatcher.matches()) - { - String name = permissionMatcher.group(2); - boolean value = permissionMatcher.group(1).equals("+"); - - this.permissions.setPermissionAndValue(name, value); - } - } - } - } - - /** - * Get the permissible mod name - */ - public String getModName() - { - return this.modName; - } - - /* (non-Javadoc) - * @see net.eq2online.permissions.Permissions#getPermissionSet( - * java.lang.String) - */ - @Override - public boolean getPermissionSet(String permission) - { - return this.permissions.getPermission(permission) != null; - } - - /* (non-Javadoc) - * @see net.eq2online.permissions.Permissions#getHasPermission( - * java.lang.String) - */ - @Override - public boolean getHasPermission(String permission) - { - Permission perm = this.permissions.getPermission(permission); - return perm != null && perm.getValue(); - } - - /* (non-Javadoc) - * @see net.eq2online.permissions.Permissions#getHasPermission( - * java.lang.String, boolean) - */ - @Override - public boolean getHasPermission(String permission, boolean defaultValue) - { - Permission perm = this.permissions.getPermission(permission); - - return perm != null ? perm.getValue() : defaultValue; - } - - /* (non-Javadoc) - * @see net.eq2online.permissions.ReplicatedPermissions#getReplicationTime() - */ - @Override - public long getReplicationTime() - { - return this.createdTime; - } - - /* (non-Javadoc) - * @see net.eq2online.permissions.ReplicatedPermissions#isValid() - */ - @Override - public boolean isValid() - { - return System.currentTimeMillis() < this.validUntil; - } - - /* (non-Javadoc) - * @see net.eq2online.permissions.ReplicatedPermissions#invalidate() - */ - @Override - public void invalidate() - { - this.validUntil = 0L; - } - - @Override - public void notifyRefreshPending() - { - this.validUntil = System.currentTimeMillis() + this.refreshTime; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/AppendInsns.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/AppendInsns.java deleted file mode 100644 index 79aca23c..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/AppendInsns.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation which instructs the ClassOverlayTransformer to append instructions - * from the annotated method to the target method. - * - * @author Adam Mummery-Smith - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface AppendInsns -{ - public String value() default(""); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/ByteCodeUtilities.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/ByteCodeUtilities.java deleted file mode 100644 index 3446f509..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/ByteCodeUtilities.java +++ /dev/null @@ -1,864 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -import java.io.IOException; -import java.lang.annotation.Annotation; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import net.minecraft.launchwrapper.IClassTransformer; -import net.minecraft.launchwrapper.Launch; - -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.*; -import org.objectweb.asm.tree.analysis.Analyzer; -import org.objectweb.asm.tree.analysis.AnalyzerException; -import org.objectweb.asm.tree.analysis.BasicValue; -import org.objectweb.asm.tree.analysis.Frame; -import org.objectweb.asm.tree.analysis.SimpleVerifier; - -import com.mumfrey.liteloader.core.runtime.Obf; - -/** - * Utility methods for working with bytecode using ASM - * - * @author Adam Mummery-Smith - */ -public abstract class ByteCodeUtilities -{ - private static Map> calculatedLocalVariables = new HashMap>(); - - private ByteCodeUtilities() {} - - /** - * Replace all constructor invocations for the target class in the supplied - * classNode with invocations of the replacement class. - * - * @param classNode Class to search in - * @param target Target type - * @param replacement Replacement type - */ - public static void replaceConstructors(ClassNode classNode, Obf target, Obf replacement) - { - for (MethodNode method : classNode.methods) - { - ByteCodeUtilities.replaceConstructors(method, target, replacement); - } - } - - /** - * Replace all constructor invocations for the target class in the supplied - * method with invocations of the replacement class. - * - * @param method Method to look in - * @param target Target type - * @param replacement Replacement type - */ - public static void replaceConstructors(MethodNode method, Obf target, Obf replacement) - { - Iterator iter = method.instructions.iterator(); - while (iter.hasNext()) - { - AbstractInsnNode insn = iter.next(); - if (insn.getOpcode() == Opcodes.NEW) - { - TypeInsnNode typeInsn = (TypeInsnNode)insn; - if (target.obf.equals(typeInsn.desc) || target.ref.equals(typeInsn.desc)) - { - typeInsn.desc = replacement.ref; - } - } - else if (insn instanceof MethodInsnNode && insn.getOpcode() == Opcodes.INVOKESPECIAL) - { - MethodInsnNode methodInsn = (MethodInsnNode)insn; - if ((target.obf.equals(methodInsn.owner) || target.ref.equals(methodInsn.owner)) && "".equals(methodInsn.name)) - { - methodInsn.owner = replacement.ref; - } - } - } - } - - /** - * Injects appropriate LOAD opcodes into the supplied InsnList appropriate - * for each entry in the args array starting at pos. - * - * @param args Argument types - * @param insns Instruction List to inject into - * @param pos Start position - */ - public static void loadArgs(Type[] args, InsnList insns, int pos) - { - ByteCodeUtilities.loadArgs(args, insns, pos, -1); - } - - /** - * Injects appropriate LOAD opcodes into the supplied InsnList appropriate - * for each entry in the args array starting at start and ending at end. - * - * @param args Argument types - * @param insns Instruction List to inject into - * @param start Start position - * @param end End position - */ - public static void loadArgs(Type[] args, InsnList insns, int start, int end) - { - int pos = start; - - for (Type type : args) - { - insns.add(new VarInsnNode(type.getOpcode(Opcodes.ILOAD), pos)); - pos += type.getSize(); - if (end >= start && pos >= end) return; - } - } - - /** - * Injects appropriate LOAD opcodes into the supplied InsnList for each - * entry in the supplied locals array starting at pos. - * - * @param locals Local types (can contain nulls for uninitialised, TOP, or - * RETURN values in locals) - * @param insns Instruction List to inject into - * @param pos Start position - */ - public static void loadLocals(Type[] locals, InsnList insns, int pos) - { - for (; pos < locals.length; pos++) - { - if (locals[pos] != null) - { - insns.add(new VarInsnNode(locals[pos].getOpcode(Opcodes.ILOAD), pos)); - } - } - } - - /** - * Get the first variable index in the supplied method which is not an - * argument or "this" reference, this corresponds to the size of the - * arguments passed in to the method plus an extra spot for "this" if the - * method is non-static. - * - * @param method MethodNode to inspect - * @return first available local index which is NOT used by a method - * argument or "this" - */ - public static int getFirstNonArgLocalIndex(MethodNode method) - { - return ByteCodeUtilities.getFirstNonArgLocalIndex(Type.getArgumentTypes(method.desc), (method.access & Opcodes.ACC_STATIC) == 0); - } - - /** - * Get the first non-arg variable index based on the supplied arg array and - * whether to include the "this" reference, this corresponds to the size of - * the arguments passed in to the method plus an extra spot for "this" is - * specified. - * - * @param args Method arguments - * @param includeThis Whether to include a slot for "this" (generally true - * for all non-static methods) - * @return first available local index which is NOT used by a method - * argument or "this" - */ - public static int getFirstNonArgLocalIndex(Type[] args, boolean includeThis) - { - return ByteCodeUtilities.getArgsSize(args) + (includeThis ? 1 : 0); - } - - /** - * Get the size of the specified args array in local variable terms (eg. - * doubles and longs take two spaces). - * - * @param args Method argument types as array - * @return size of the specified arguments array in terms of stack slots - */ - public static int getArgsSize(Type[] args) - { - int size = 0; - - for (Type type : args) - { - size += type.getSize(); - } - - return size; - } - - /** - * Attempts to identify available locals at an arbitrary point in the - * bytecode specified by node. - * - *

This method builds an approximate view of the locals available at an - * arbitrary point in the bytecode by examining the following features in - * the bytecode:

- * - *
    - *
  • Any available stack map frames
  • - *
  • STORE opcodes
  • - *
  • The local variable table
  • - *
- * - *

Inference proceeds by walking the bytecode from the start of the - * method looking for stack frames and STORE opcodes. When either of these - * is encountered, an attempt is made to cross-reference the values in the - * stack map or STORE opcode with the value in the local variable table - * which covers the code range. Stack map frames overwrite the entire - * simulated local variable table with their own value types, STORE opcodes - * overwrite only the local slot to which they pertain. Values in the - * simulated locals array are spaced according to their size (unlike the - * representation in FrameNode) and this TOP, NULL and UNINTITIALIZED_THIS - * opcodes will be represented as null values in the simulated frame.

- * - *

This code does not currently simulate the prescribed JVM behaviour - * where overwriting the second slot of a DOUBLE or LONG actually - * invalidates the DOUBLE or LONG stored in the previous location, so we - * have to hope (for now) that this behaviour isn't emitted by the compiler - * or any upstream transformers. I may have to re-think this strategy if - * this situation is encountered in the wild.

- * - * @param classNode ClassNode containing the method, used to initialise the - * implicit "this" reference in simple methods with no stack frames - * @param method MethodNode to explore - * @param node Node indicating the position at which to determine the locals - * state. The locals will be enumerated UP TO the specified node, so - * bear in mind that if the specified node is itself a STORE opcode, - * then we will be looking at the state of the locals PRIOR to its - * invocation - * @return A sparse array containing a view (hopefully) of the locals at the - * specified location - */ - public static LocalVariableNode[] getLocalsAt(ClassNode classNode, MethodNode method, AbstractInsnNode node) - { - LocalVariableNode[] frame = new LocalVariableNode[method.maxLocals]; - - // Initialise implicit "this" reference in non-static methods - if ((method.access & Opcodes.ACC_STATIC) == 0) - { - frame[0] = new LocalVariableNode("this", classNode.name, null, null, null, 0); - } - - for (Iterator iter = method.instructions.iterator(); iter.hasNext();) - { - AbstractInsnNode insn = iter.next(); - if (insn instanceof FrameNode) - { - FrameNode frameNode = (FrameNode)insn; - - // localPos tracks the location in the frame node's locals list, which doesn't leave space for TOP entries - for (int localPos = 0, framePos = 0; framePos < frame.length; framePos++, localPos++) - { - // Get the local at the current position in the FrameNode's locals list - final Object localType = (localPos < frameNode.local.size()) ? frameNode.local.get(localPos) : null; - - if (localType instanceof String) // String refers to a reference type - { - frame[framePos] = ByteCodeUtilities.getLocalVariableAt(classNode, method, node, framePos); - } - else if (localType instanceof Integer) // Integer refers to a primitive type or other marker - { - boolean isMarkerType = localType == Opcodes.UNINITIALIZED_THIS || localType == Opcodes.TOP || localType == Opcodes.NULL; - boolean is32bitValue = localType == Opcodes.INTEGER || localType == Opcodes.FLOAT; - boolean is64bitValue = localType == Opcodes.DOUBLE || localType == Opcodes.LONG; - if (isMarkerType) - { - frame[framePos] = null; - } - else if (is32bitValue || is64bitValue) - { - frame[framePos] = ByteCodeUtilities.getLocalVariableAt(classNode, method, node, framePos); - - if (is64bitValue) - { - framePos++; - frame[framePos] = null; // TOP - } - } - else - { - throw new RuntimeException("Unrecognised locals opcode " + localType + " in locals array at position " + localPos + " in " - + classNode.name + "." + method.name + method.desc); - } - } - else if (localType == null) - { - frame[framePos] = null; - } - else - { - throw new RuntimeException("Invalid value " + localType + " in locals array at position " + localPos + " in " + classNode.name - + "." + method.name + method.desc); - } - } - } - else if (insn instanceof VarInsnNode) - { - VarInsnNode varNode = (VarInsnNode)insn; - frame[varNode.var] = ByteCodeUtilities.getLocalVariableAt(classNode, method, node, varNode.var); - } - else if (insn == node) - { - break; - } - } - - return frame; - } - - /** - * Attempts to locate the appropriate entry in the local variable table for - * the specified local variable index at the location specified by node. - * - * @param classNode Containing class - * @param method Method - * @param node Instruction defining the location to get the local variable - * table at - * @param var Local variable index - * @return a LocalVariableNode containing information about the local - * variable at the specified location in the specified local slot - */ - public static LocalVariableNode getLocalVariableAt(ClassNode classNode, MethodNode method, AbstractInsnNode node, int var) - { - LocalVariableNode localVariableNode = null; - - int pos = method.instructions.indexOf(node); - - List localVariables = ByteCodeUtilities.getLocalVariableTable(classNode, method); - for (LocalVariableNode local : localVariables) - { - if (local.index != var) continue; - int start = method.instructions.indexOf(local.start); - int end = method.instructions.indexOf(local.end); - if (localVariableNode == null || start < pos && end > pos) - { - localVariableNode = local; - } - } - - return localVariableNode; - } - - /** - * Fetches or generates the local variable table for the specified method. - * Since Mojang strip the local variable table as part of the obfuscation - * process, we need to generate the local variable table when running - * obfuscated. We cache the generated tables so that we only need to do the - * relatively expensive calculation once per method we encounter. - * - * @param classNode Containing class - * @param method Method - */ - public static List getLocalVariableTable(ClassNode classNode, MethodNode method) - { - if (method.localVariables.isEmpty()) - { - String signature = String.format("%s.%s%s", classNode.name, method.name, method.desc); - - List localVars = ByteCodeUtilities.calculatedLocalVariables.get(signature); - if (localVars != null) - { - return localVars; - } - - localVars = ByteCodeUtilities.generateLocalVariableTable(classNode, method); - ByteCodeUtilities.calculatedLocalVariables.put(signature, localVars); - return localVars; - } - - return method.localVariables; - } - - /** - * Use ASM Analyzer to generate the local variable table for the specified - * method. - * - * @param classNode Containing class - * @param method Method - */ - public static List generateLocalVariableTable(ClassNode classNode, MethodNode method) - { - List interfaces = null; - if (classNode.interfaces != null) - { - interfaces = new ArrayList(); - for (String iface : classNode.interfaces) - { - interfaces.add(Type.getObjectType(iface)); - } - } - - Type objectType = null; - if (classNode.superName != null) - { - objectType = Type.getObjectType(classNode.superName); - } - - // Use Analyzer to generate the bytecode frames - Analyzer analyzer = new Analyzer(new SimpleVerifier(Type.getObjectType(classNode.name), - objectType, interfaces, false)); - try - { - analyzer.analyze(classNode.name, method); - } - catch (AnalyzerException ex) - { - ex.printStackTrace(); - } - - // Get frames from the Analyzer - Frame[] frames = analyzer.getFrames(); - - // Record the original size of hte method - int methodSize = method.instructions.size(); - - // List of LocalVariableNodes to return - List localVariables = new ArrayList(); - - LocalVariableNode[] localNodes = new LocalVariableNode[method.maxLocals]; // LocalVariableNodes for current frame - BasicValue[] locals = new BasicValue[method.maxLocals]; // locals in previous frame, used to work out what changes between frames - LabelNode[] labels = new LabelNode[methodSize]; // Labels to add to the method, for the markers - - // Traverse the frames and work out when locals begin and end - for (int i = 0; i < methodSize; i++) - { - Frame f = frames[i]; - if (f == null) continue; - LabelNode label = null; - - for (int j = 0; j < f.getLocals(); j++) - { - BasicValue local = f.getLocal(j); - if (local == null && locals[j] == null) continue; - if (local != null && local.equals(locals[j])) continue; - - if (label == null) - { - label = new LabelNode(); - labels[i] = label; - } - - if (local == null && locals[j] != null) - { - localVariables.add(localNodes[j]); - localNodes[j].end = label; - localNodes[j] = null; - } - else if (local != null) - { - if (locals[j] != null) - { - localVariables.add(localNodes[j]); - localNodes[j].end = label; - localNodes[j] = null; - } - - String desc = (local.getType() != null) ? local.getType().getDescriptor() : null; - localNodes[j] = new LocalVariableNode("var" + j, desc, null, label, null, j); - } - - locals[j] = local; - } - } - - // Reached the end of the method so flush all current locals and mark the end - LabelNode label = null; - for (int k = 0; k < localNodes.length; k++) - { - if (localNodes[k] != null) - { - if (label == null) - { - label = new LabelNode(); - method.instructions.add(label); - } - - localNodes[k].end = label; - localVariables.add(localNodes[k]); - } - } - - // Insert generated labels into the method body - for (int n = methodSize - 1; n >= 0; n--) - { - if (labels[n] != null) - { - method.instructions.insert(method.instructions.get(n), labels[n]); - } - } - - return localVariables; - } - - /** - * Get the source code name for the specified type. - * - * @param type Type to generate a friendly name for - * @return String representation of the specified type, eg "int" for an - * integer primitive or "String" for java.lang.String - */ - public static String getTypeName(Type type) - { - switch (type.getSort()) - { - case Type.BOOLEAN: return "boolean"; - case Type.CHAR: return "char"; - case Type.BYTE: return "byte"; - case Type.SHORT: return "short"; - case Type.INT: return "int"; - case Type.FLOAT: return "float"; - case Type.LONG: return "long"; - case Type.DOUBLE: return "double"; - case Type.ARRAY: return ByteCodeUtilities.getTypeName(type.getElementType()) + "[]"; - case Type.OBJECT: - String typeName = type.getClassName(); - typeName = typeName.substring(typeName.lastIndexOf('.') + 1); - return typeName; - default: - return "Object"; - } - - } - - /** - * Finds a method in the target class, uses names specified in the - * {@link Obfuscated} annotation if present. - * - * @param targetClass Class to search in - * @param searchFor Method to search for - */ - public static MethodNode findTargetMethod(ClassNode targetClass, MethodNode searchFor) - { - for (MethodNode target : targetClass.methods) - { - if (target.name.equals(searchFor.name) && target.desc.equals(searchFor.desc)) - { - return target; - } - } - - AnnotationNode obfuscatedAnnotation = ByteCodeUtilities.getVisibleAnnotation(searchFor, Obfuscated.class); - if (obfuscatedAnnotation != null) - { - for (String obfuscatedName : ByteCodeUtilities.>getAnnotationValue(obfuscatedAnnotation)) - { - for (MethodNode target : targetClass.methods) - { - if (target.name.equals(obfuscatedName) && target.desc.equals(searchFor.desc)) - { - return target; - } - } - } - } - - return null; - } - - /** - * Finds a field in the target class, uses names specified in the - * {@link Obfuscated} annotation if present - * - * @param targetClass Class to search in - * @param searchFor Field to search for - */ - public static FieldNode findTargetField(ClassNode targetClass, FieldNode searchFor) - { - for (FieldNode target : targetClass.fields) - { - if (target.name.equals(searchFor.name)) - { - return target; - } - } - - AnnotationNode obfuscatedAnnotation = ByteCodeUtilities.getVisibleAnnotation(searchFor, Obfuscated.class); - if (obfuscatedAnnotation != null) - { - for (String obfuscatedName : ByteCodeUtilities.>getAnnotationValue(obfuscatedAnnotation)) - { - for (FieldNode target : targetClass.fields) - { - if (target.name.equals(obfuscatedName)) - { - return target; - } - } - } - } - - return null; - } - - /** - * Find a method in the target class which matches the specified method name - * and descriptor - * - * @param classNode - * @param searchFor - * @param desc - */ - public static MethodNode findMethod(ClassNode classNode, Obf searchFor, String desc) - { - int ordinal = 0; - - for (MethodNode method : classNode.methods) - { - if (searchFor.matches(method.name, ordinal++) && method.desc.equals(desc)) - { - return method; - } - } - - return null; - } - - /** - * Find a field in the target class which matches the specified field name - * - * @param classNode - * @param searchFor - */ - public static FieldNode findField(ClassNode classNode, Obf searchFor) - { - int ordinal = 0; - - for (FieldNode field : classNode.fields) - { - if (searchFor.matches(field.name, ordinal++)) - { - return field; - } - } - - return null; - } - - public static ClassNode loadClass(String className) throws IOException - { - return ByteCodeUtilities.loadClass(className, true, null); - } - - public static ClassNode loadClass(String className, boolean runTransformers) throws IOException - { - return ByteCodeUtilities.loadClass(className, runTransformers, null); - } - - public static ClassNode loadClass(String className, IClassTransformer source) throws IOException - { - return ByteCodeUtilities.loadClass(className, source != null, source); - } - - public static ClassNode loadClass(String className, boolean runTransformers, IClassTransformer source) throws IOException - { - byte[] bytes = Launch.classLoader.getClassBytes(className); - - if (runTransformers) - { - bytes = ByteCodeUtilities.applyTransformers(className, bytes, source); - } - - return ByteCodeUtilities.readClass(bytes); - } - - public static ClassNode readClass(byte[] basicClass) - { - ClassReader classReader = new ClassReader(basicClass); - ClassNode classNode = new ClassNode(); - classReader.accept(classNode, ClassReader.EXPAND_FRAMES); - return classNode; - } - - public static byte[] applyTransformers(String className, byte[] basicClass) - { - return ByteCodeUtilities.applyTransformers(className, basicClass, null); - } - - public static byte[] applyTransformers(String className, byte[] basicClass, IClassTransformer source) - { - final List transformers = Launch.classLoader.getTransformers(); - - for (final IClassTransformer transformer : transformers) - { - if (transformer != source) - { - basicClass = transformer.transform(className, className, basicClass); - } - } - - return basicClass; - } - - /** - * Get an annotation of the specified class from the supplied field node - */ - public static AnnotationNode getVisibleAnnotation(FieldNode field, Class annotationClass) - { - return ByteCodeUtilities.getAnnotation(field.visibleAnnotations, Type.getDescriptor(annotationClass)); - } - - /** - * Get an annotation of the specified class from the supplied field node - */ - public static AnnotationNode getInvisibleAnnotation(FieldNode field, Class annotationClass) - { - return ByteCodeUtilities.getAnnotation(field.invisibleAnnotations, Type.getDescriptor(annotationClass)); - } - - /** - * Get an annotation of the specified class from the supplied method node - */ - public static AnnotationNode getVisibleAnnotation(MethodNode method, Class annotationClass) - { - return ByteCodeUtilities.getAnnotation(method.visibleAnnotations, Type.getDescriptor(annotationClass)); - } - - /** - * Get an annotation of the specified class from the supplied method node - */ - public static AnnotationNode getInvisibleAnnotation(MethodNode method, Class annotationClass) - { - return ByteCodeUtilities.getAnnotation(method.invisibleAnnotations, Type.getDescriptor(annotationClass)); - } - - /** - * Get an annotation of the specified class from the supplied class node - */ - public static AnnotationNode getVisibleAnnotation(ClassNode classNode, Class annotationClass) - { - return ByteCodeUtilities.getAnnotation(classNode.visibleAnnotations, Type.getDescriptor(annotationClass)); - } - - /** - * Get an annotation of the specified class from the supplied class node - */ - public static AnnotationNode getInvisibleAnnotation(ClassNode classNode, Class annotationClass) - { - return ByteCodeUtilities.getAnnotation(classNode.invisibleAnnotations, Type.getDescriptor(annotationClass)); - } - - /** - * Get an annotation of the specified class from the supplied list of - * annotations, returns null if no matching annotation was found - */ - public static AnnotationNode getAnnotation(List annotations, String annotationType) - { - if (annotations != null) - { - for (AnnotationNode annotation : annotations) - { - if (annotationType.equals(annotation.desc)) - { - return annotation; - } - } - } - - return null; - } - - /** - * Get the value of an annotation node (the value at key "value") - * - * @param annotation Annotation node to inspect - */ - public static T getAnnotationValue(AnnotationNode annotation) - { - return ByteCodeUtilities.getAnnotationValue(annotation, "value"); - } - - /** - * Get the value of an annotation node - * - * @param annotation - * @param key - */ - @SuppressWarnings("unchecked") - public static T getAnnotationValue(AnnotationNode annotation, String key) - { - if (annotation == null || annotation.values == null) - { - return null; - } - - boolean getNextValue = false; - for (Object value : annotation.values) - { - if (getNextValue) return (T)value; - if (value.equals(key)) getNextValue = true; - } - return null; - } - - /** - * @param returnType - * @param args - */ - public static String generateDescriptor(Type returnType, Object... args) - { - return ByteCodeUtilities.generateDescriptor(Obf.MCP, returnType, args); - } - - /** - * @param returnType - * @param args - */ - public static String generateDescriptor(Obf returnType, Object... args) - { - return ByteCodeUtilities.generateDescriptor(Obf.MCP, returnType, args); - } - - /** - * @param returnType - * @param args - */ - public static String generateDescriptor(String returnType, Object... args) - { - return ByteCodeUtilities.generateDescriptor(Obf.MCP, returnType, args); - } - - /** - * @param obfType - * @param returnType - * @param args - */ - public static String generateDescriptor(int obfType, Object returnType, Object... args) - { - StringBuilder sb = new StringBuilder().append('('); - - for (Object arg : args) - { - sb.append(ByteCodeUtilities.toDescriptor(obfType, arg)); - } - - return sb.append(')').append(returnType != null ? ByteCodeUtilities.toDescriptor(obfType, returnType) : "V").toString(); - } - - /** - * @param obfType - * @param arg - */ - private static String toDescriptor(int obfType, Object arg) - { - if (arg instanceof Obf) - { - return ((Obf)arg).getDescriptor(obfType); - } - else if (arg instanceof String) - { - return (String)arg; - } - else if (arg instanceof Type) - { - return arg.toString(); - } - else if (arg instanceof Class) - { - return Type.getDescriptor((Class)arg).toString(); - } - - return arg == null ? "" : arg.toString(); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/Callback.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/Callback.java deleted file mode 100644 index 51b6d2dc..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/Callback.java +++ /dev/null @@ -1,281 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -import java.util.ArrayList; -import java.util.List; - -import com.mumfrey.liteloader.core.runtime.Obf; - -/** - * Target information for injected callback methods - * - * @author Adam Mummery-Smith - */ -public class Callback -{ - /** - * Type of callback to inject - */ - public enum CallbackType - { - /** - * Redirect callbacks are injected at the start of a method and - * immediately return, thus short-circuiting the method - */ - REDIRECT(true), - - /** - * Event callbacks are injected at the start of a method but do not - * alter the normal method behaviour. - */ - EVENT(false), - - /** - * Return callbacks are injected immediately prior to every RETURN - * opcode in a particular method. Callback handlers must have the SAME - * return type as the method containing the injected callback - */ - RETURN(false), - - /** - * A profiler callback injected at a profiler "startSection" invocation - */ - PROFILER_STARTSECTION(Obf.startSection, true), - - /** - * A profiler callback injected at a profiler "endSection" invocation - */ - PROFILER_ENDSECTION(Obf.endSection, false), - - /** - * A profiler callback injected at a profiler "endStartSection" - * invocation - */ - PROFILER_ENDSTARTSECTION(Obf.endStartSection, true); - - /** - * - */ - private final boolean injectReturn; - - /** - * - */ - private final boolean isProfilerCallback; - - /** - * - */ - private final boolean sectionRequired; - - /** - * - */ - private final Obf profilerMethod; - - private CallbackType(boolean returnFrom) - { - this.injectReturn = returnFrom; - this.isProfilerCallback = false; - this.profilerMethod = null; - this.sectionRequired = false; - } - - private CallbackType(Obf profilerMethod, boolean sectionRequired) - { - this.injectReturn = false; - this.isProfilerCallback = true; - this.profilerMethod = profilerMethod; - this.sectionRequired = sectionRequired; - } - - boolean injectReturn() - { - return this.injectReturn; - } - - boolean isProfilerCallback() - { - return this.isProfilerCallback; - } - - String getProfilerMethod(int obfType) - { - return this.profilerMethod != null ? this.profilerMethod.names[obfType] : ""; - } - - String getProfilerMethodSignature() - { - return this.sectionRequired ? "(Ljava/lang/String;)V" : "()V"; - } - - boolean isSectionRequired() - { - return this.sectionRequired; - } - - public String getSignature() - { - if (this == CallbackType.EVENT || this == CallbackType.REDIRECT) - { - return "head"; - } - - return this.name().toString().toLowerCase(); - } - } - - /** - * - */ - private final CallbackType callbackType; - - /** - * - */ - private final String sectionName; - - /** - * - */ - private final String profilerMethod; - - /** - * Callback class reference - */ - private final String callbackClass; - - /** - * Callback method name - */ - private final String callbackMethod; - - /** - * Return callbacks are injected before every RETURN opcode in the method, - * each RETURN is thus allocated a sequential refNumber which is passed to - * the callback method so that the callback handler can choose which RETURN - * it wishes to handle. - */ - int refNumber; - - /** - * - */ - private final List chainedCallbacks; - - public Callback(CallbackType callbackType, String callbackMethod, String callbackClass) - { - this(callbackType, callbackMethod, callbackClass, null, 0); - } - - /** - * A new callback method in the specified class - * - * @param callbackMethod Method to call, must be public, static and have the - * appropriate signature for the type of injected callback - * @param callbackClass Fully qualified name of the class containing the - * callback method, must also be public or visible from the calling - * package - */ - public Callback(CallbackType callbackType, String callbackMethod, String callbackClass, String section, int obfType) - { - if (section == null && callbackType.isSectionRequired()) - { - throw new RuntimeException(String.format("Callback of type %s requires a section name but no section name was provided", - callbackType.name())); - } - - this.callbackType = callbackType; - this.callbackClass = callbackClass.replace('.', '/'); - this.callbackMethod = callbackMethod; - this.sectionName = section; - this.chainedCallbacks = new ArrayList(); - this.profilerMethod = callbackType.getProfilerMethod(obfType); - } - - private Callback(Callback other, int refNumber) - { - this.callbackType = other.callbackType; - this.callbackClass = other.callbackClass; - this.callbackMethod = other.callbackMethod; - this.sectionName = other.sectionName; - this.chainedCallbacks = other.chainedCallbacks; - this.profilerMethod = other.profilerMethod; - this.refNumber = refNumber; - } - - public CallbackType getType() - { - return this.callbackType; - } - - public String getCallbackClass() - { - return this.callbackClass; - } - - public String getCallbackMethod() - { - return this.callbackMethod; - } - - public boolean injectReturn() - { - return this.callbackType.injectReturn(); - } - - public boolean isProfilerCallback() - { - return this.callbackType.isProfilerCallback(); - } - - public String getSectionName() - { - return this.sectionName; - } - - public String getProfilerMethod() - { - return this.profilerMethod; - } - - public String getProfilerMethodSignature() - { - return this.callbackType.getProfilerMethodSignature(); - } - - public Callback getNextCallback() - { - return new Callback(this, this.refNumber++); - } - - void addChainedCallback(Callback chained) - { - this.chainedCallbacks.add(chained); - } - - public List getChainedCallbacks() - { - return this.chainedCallbacks; - } - - @Override - public String toString() - { - return this.callbackMethod; - } - - @Override - public boolean equals(Object other) - { - if (other == null || !(other instanceof Callback)) return false; - Callback callback = (Callback)other; - return callback.callbackClass.equals(this.callbackClass) && callback.callbackMethod.equals(this.callbackMethod) - && callback.callbackType == this.callbackType; - } - - @Override - public int hashCode() - { - return super.hashCode(); - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/CallbackInjectionTransformer.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/CallbackInjectionTransformer.java deleted file mode 100644 index f20684c3..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/CallbackInjectionTransformer.java +++ /dev/null @@ -1,361 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Map.Entry; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.InsnList; -import org.objectweb.asm.tree.InsnNode; -import org.objectweb.asm.tree.IntInsnNode; -import org.objectweb.asm.tree.LdcInsnNode; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.MethodNode; -import org.objectweb.asm.tree.VarInsnNode; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.Callback.CallbackType; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Transformer which injects callbacks by searching for profiler invocations - * and RETURN opcodes. - * - * @author Adam Mummery-Smith - * @deprecated Use Event Injection instead - */ -@Deprecated -public abstract class CallbackInjectionTransformer extends ClassTransformer -{ - /** - * Mappings for profiler method invocations - */ - private Map> profilerCallbackMappings = new HashMap>(); - - /** - * Mappings for pre-return and method start callbacks - */ - private Map> callbackMappings = new HashMap>(); - - public CallbackInjectionTransformer() - { - this.addCallbacks(); - } - - /** - * Subclasses must override this method and add their mappings - */ - protected abstract void addCallbacks(); - - /** - * @param className - * @param methodName - * @param methodSignature - * @param callback - */ - protected final void addCallback(String className, String methodName, String methodSignature, Callback callback) - { - if (callback.isProfilerCallback()) - { - if (!this.profilerCallbackMappings.containsKey(className)) - { - this.profilerCallbackMappings.put(className, new HashMap()); - } - - String signature = CallbackInjectionTransformer.generateSignature(className, methodName, methodSignature, callback.getProfilerMethod(), - callback.getProfilerMethodSignature(), callback.getSectionName()); - this.addCallbackMapping(this.profilerCallbackMappings.get(className), signature, callback); - } - else - { - if (!this.callbackMappings.containsKey(className)) - { - this.callbackMappings.put(className, new HashMap()); - } - - String signature = CallbackInjectionTransformer.generateSignature(className, methodName, methodSignature, callback.getType()); - this.addCallbackMapping(this.callbackMappings.get(className), signature, callback); - } - } - - /** - * @param callbacks - * @param signature - * @param callback - */ - private void addCallbackMapping(Map callbacks, String signature, Callback callback) - { - if (callbacks.containsKey(signature)) - { - Callback existingCallback = callbacks.get(signature); - if (existingCallback.equals(callback)) return; - - if (callback.injectReturn() || existingCallback.injectReturn()) - { - String errorMessage = String.format("Callback for %s is already defined for %s, cannot add %s", - signature, existingCallback, callback); - LiteLoaderLogger.severe(errorMessage); - throw new InjectedCallbackCollisionError(errorMessage); - } - - existingCallback.addChainedCallback(callback); - } - else - { - callbacks.put(signature, callback); - } - } - - /* (non-Javadoc) - * @see net.minecraft.launchwrapper.IClassTransformer - * #transform(java.lang.String, java.lang.String, byte[]) - */ - @Override - public final byte[] transform(String name, String transformedName, byte[] basicClass) - { - if (basicClass != null && this.profilerCallbackMappings.containsKey(transformedName) || this.callbackMappings.containsKey(transformedName)) - { - return this.injectCallbacks(basicClass, this.profilerCallbackMappings.get(transformedName), this.callbackMappings.get(transformedName)); - } - - return basicClass; - } - - /** - * @param basicClass - * @param profilerMappings - */ - private byte[] injectCallbacks(byte[] basicClass, Map profilerMappings, Map mappings) - { - ClassNode classNode = this.readClass(basicClass, true); - String className = classNode.name.replace('/', '.'); - String classType = Type.getObjectType(classNode.name).toString(); - - for (MethodNode method : classNode.methods) - { - int returnNumber = 0; - String section = null; - int methodReturnOpcode = Type.getReturnType(method.desc).getOpcode(Opcodes.IRETURN); - - if (mappings != null) - { - String headSignature = CallbackInjectionTransformer.generateSignature(classNode.name, method.name, method.desc, - CallbackType.REDIRECT); - if (mappings.containsKey(headSignature)) - { - Callback callback = mappings.get(headSignature); - InsnList callbackInsns = this.genCallbackInsns(classType, method, callback); - if (callbackInsns != null) - { - LiteLoaderLogger.info("Injecting %s callback for %s in class %s", callback.getType().name().toLowerCase(), - callback, className); - method.instructions.insert(callbackInsns); - if (callback.injectReturn()) continue; - } - } - } - - Map profilerCallbackInjectionNodes = new HashMap(); - - Iterator iter = method.instructions.iterator(); - AbstractInsnNode lastInsn = null; - while (iter.hasNext()) - { - AbstractInsnNode insn = iter.next(); - if (profilerMappings != null && insn.getOpcode() == Opcodes.INVOKEVIRTUAL) - { - MethodInsnNode invokeNode = (MethodInsnNode)insn; - if (Obf.Profiler.ref.equals(invokeNode.owner) || Obf.Profiler.obf.equals(invokeNode.owner)) - { - section = ""; - if (lastInsn instanceof LdcInsnNode) - { - section = ((LdcInsnNode)lastInsn).cst.toString(); - } - - String signature = CallbackInjectionTransformer.generateSignature(classNode.name, method.name, method.desc, invokeNode.name, - invokeNode.desc, section); - - if (profilerMappings.containsKey(signature)) - { - profilerCallbackInjectionNodes.put(invokeNode, profilerMappings.get(signature).getNextCallback()); - } - } - } - else if (mappings != null && insn.getOpcode() == methodReturnOpcode) - { - String returnSignature = CallbackInjectionTransformer.generateSignature(classNode.name, method.name, method.desc, - CallbackType.RETURN); - if (mappings.containsKey(returnSignature)) - { - Callback callback = mappings.get(returnSignature); - InsnList callbackInsns = this.genCallbackInsns(classType, method, callback, returnNumber++); - if (callbackInsns != null) - { - LiteLoaderLogger.info("Injecting method return callback for %s in class %s", callback, className); - method.instructions.insertBefore(insn, callbackInsns); - } - else - { - LiteLoaderLogger.severe("Skipping callback mapping %s because the return behaviour does not match the method signature", - returnSignature); - } - } - } - - lastInsn = insn; - } - - for (Entry profilerCallbackNode : profilerCallbackInjectionNodes.entrySet()) - { - Callback callback = profilerCallbackNode.getValue(); - - LiteLoaderLogger.info("Injecting profiler invocation callback for %s in class %s", callback, className); - InsnList injected = this.genProfilerCallbackInsns(new InsnList(), callback, callback.refNumber++); - method.instructions.insert(profilerCallbackNode.getKey(), injected); - } - } - - return this.writeClass(classNode); - } - - /** - * @param injected - * @param callback - * @param refNumber - */ - private InsnList genProfilerCallbackInsns(InsnList injected, Callback callback, int refNumber) - { - injected.add(new LdcInsnNode(refNumber)); - injected.add(new MethodInsnNode(Opcodes.INVOKESTATIC, callback.getCallbackClass(), callback.getCallbackMethod(), "(I)V", false)); - - if (callback.getChainedCallbacks().size() > 0) - { - for (Callback chainedCallback : callback.getChainedCallbacks()) - this.genProfilerCallbackInsns(injected, chainedCallback, refNumber); - } - - return injected; - } - - /** - * Generate bytecode for injecting the specified callback into the specified - * methodNode. - * - * @param classType - * @param methodNode - * @param callback - */ - private InsnList genCallbackInsns(String classType, MethodNode methodNode, Callback callback) - { - return this.genCallbackInsns(classType, methodNode, callback, -1); - } - - /** - * Generate bytecode for injecting the specified callback into the specified - * methodNode. - * - * @param classType - * @param methodNode - * @param callback - * @param returnNumber - */ - private InsnList genCallbackInsns(String classType, MethodNode methodNode, Callback callback, int returnNumber) - { - return this.genCallbackInsns(new InsnList(), classType, methodNode, callback, returnNumber); - } - - /** - * @param injected - * @param classType - * @param methodNode - * @param callback - * @param returnNumber - */ - private InsnList genCallbackInsns(InsnList injected, String classType, MethodNode methodNode, Callback callback, int returnNumber) - { - // First work out some flags which alter the behaviour of this injection - boolean methodReturnsVoid = Type.getReturnType(methodNode.desc).equals(Type.VOID_TYPE); - boolean methodIsStatic = (methodNode.access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC; - boolean hasReturnRef = returnNumber > -1; - - // Generate the parts of the callback signature that we need - Type callbackReturnType = Type.getReturnType(methodNode.desc); - String callbackReturnValueArg = methodReturnsVoid ? "" : callbackReturnType.toString(); - String classInstanceArg = methodIsStatic ? "" : classType; - - // If this is a pre-return injection, push the invocation reference onto the call stack - if (hasReturnRef) injected.insert(new IntInsnNode(Opcodes.BIPUSH, returnNumber)); - - // If the method is non-static, then we pass in the class instance as an argument - if (!methodIsStatic) injected.add(new VarInsnNode(Opcodes.ALOAD, 0)); - - // Push the method arguments onto the stack - int argNumber = methodIsStatic ? 0 : 1; - for (Type type : Type.getArgumentTypes(methodNode.desc)) - { - injected.add(new VarInsnNode(type.getOpcode(Opcodes.ILOAD), argNumber)); - argNumber += type.getSize(); - } - - // Generate the callback method descriptor - String callbackMethodDesc = String.format("(%s%s%s%s)%s", hasReturnRef ? callbackReturnValueArg : "", hasReturnRef ? "I" : "", - classInstanceArg, CallbackInjectionTransformer.getMethodArgs(methodNode), callbackReturnType); - - // Add the callback method insn to the injected instructions list - injected.add(new MethodInsnNode(Opcodes.INVOKESTATIC, callback.getCallbackClass(), callback.getCallbackMethod(), callbackMethodDesc, false)); - - // If the callback RETURNs a value then push the appropriate RETURN opcode into the insns list - if (callback.injectReturn()) - { - injected.add(new InsnNode(callbackReturnType.getOpcode(Opcodes.IRETURN))); - } - else if (callback.getChainedCallbacks().size() > 0) - { - for (Callback chainedCallback : callback.getChainedCallbacks()) - { - this.genCallbackInsns(injected, classType, methodNode, chainedCallback, returnNumber); - } - } - - // return the generated code - return injected; - } - - /** - * @param method - */ - private static String getMethodArgs(MethodNode method) - { - return method.desc.substring(1, method.desc.lastIndexOf(')')); - } - - /** - * @param className - * @param methodName - * @param methodSignature - * @param invokeName - * @param invokeSig - * @param section - */ - private static String generateSignature(String className, String methodName, String methodSignature, - String invokeName, String invokeSig, String section) - { - return String.format("%s::%s%s@%s%s/%s", className.replace('.', '/'), methodName, methodSignature, invokeName, invokeSig, section); - } - - /** - * @param className - * @param methodName - * @param methodSignature - * @param callbackType - */ - private static String generateSignature(String className, String methodName, String methodSignature, Callback.CallbackType callbackType) - { - return String.format("%s::%s%s@%s", className.replace('.', '/'), methodName, methodSignature, callbackType.getSignature()); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/ClassOverlayTransformer.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/ClassOverlayTransformer.java deleted file mode 100644 index 5589965e..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/ClassOverlayTransformer.java +++ /dev/null @@ -1,537 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -import java.io.IOException; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import net.minecraft.launchwrapper.Launch; - -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.commons.RemappingClassAdapter; -import org.objectweb.asm.commons.SimpleRemapper; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.AnnotationNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldInsnNode; -import org.objectweb.asm.tree.FieldNode; -import org.objectweb.asm.tree.LineNumberNode; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.MethodNode; - -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * This transformer applies one class to another as an "overlay". This works by - * merging down and replacing all methods and fields from the "overlay" class - * into the "target" class being transformed. Fields and methods marked with the - * {@link Obfuscated} annotation will search through the list of provided names - * to find a matching member in the target class, this allows methods and fields - * in the target class to be referenced even if they have different names after - * obfuscation. - * - *

The "target" class is identified by a special field which must be named - * __TARGET in the overlay class which must be a private static field - * of the appropriate target type.

- * - *

Notes:

- * - *
    - *
  • Constructors WILL NOT BE overlaid, see below for instruction merging. - * Constructors in the overlay class should throw an InstantiationError. - *
  • - * - *
  • Static method invocations will not be processed by "transformMethod", - * this means that any static methods invoked must be accessible from the - * context of the transformed class (eg. public or package-private in the - * same package).
  • - * - *
  • The overlay class MUST be a sibling of the target class to ensure - * that calls to super.xxx are properly transformed. In other words the - * overlay and the transformed class should have the same parent class - * although they need not be in the same package unless any package-private - * members are accessed.
  • - * - *
  • It is also possible to merge instructions from a "source" method into - * a specific method in the transformed class by annotating the method with - * a {@link AppendInsns} annotation, specifying the name of the target - * method as the annotation value. The target method signature must match - * the source method's signature and both methods must return VOID. The - * instructions from the source method will be inserted immediately before - * the RETURN opcode in the target method.
  • - * - *
  • To create a method stub for private methods you wish to invoke in the - * target class, decorate the stub method with an {@link Stub} annotation, - * this will cause the overlay transformer to NOT merge the method into the - * target, but merely verify that it exists in the target class.
  • - * - *
  • Merge instructions into the constructor by specifying "" as the - * target method name.
  • - *
- * - * @author Adam Mummery-Smith - * @deprecated Use mixins instead! - */ -@Deprecated -public abstract class ClassOverlayTransformer extends ClassTransformer -{ - /** - * Global list of overlaid classes, used to transform references in other - * classes. - */ - private static final Map overlayMap = new HashMap(); - - /** - * Remapper for dynamically renaming references to overlays in other classes - */ - private static SimpleRemapper referenceRemapper; - - /** - * The first ClassOverlayTransformer to be instantiated accepts - * responsibility for performing remapping operations and becomes the - * "remapping agent" transformer. This flag is set to true to indicate that - * this instance is the remapping agent. - */ - private boolean remappingAgent = false; - - /** - * Name of the overlay class - */ - private final String overlayClassName, overlayClassRef; - - /** - * Target class to be transformed - */ - private final String targetClassName; - - /** - * Fields which get a different name from an {@link Obfuscated} annotation - */ - private final Map renamedFields = new HashMap(); - - /** - * Methods which get a different name from an {@link Obfuscated} annotation - */ - private final Map renamedMethods = new HashMap(); - - /** - * True to set the sourceFile property when applying the overlay - */ - protected boolean setSourceFile = true; - - /** - * @param overlayClassName - */ - protected ClassOverlayTransformer(String overlayClassName) - { - this.overlayClassName = overlayClassName; - this.overlayClassRef = overlayClassName.replace('.', '/'); - - String targetClassName = null; - ClassNode overlayClass = this.loadOverlayClass("", true); - for (FieldNode field : overlayClass.fields) - { - if ("__TARGET".equals(field.name) && ((field.access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC)) - { - targetClassName = Type.getType(field.desc).getClassName(); - } - } - - if (targetClassName == null) - { - throw new RuntimeException(String.format("Overlay class %s is missing a __TARGET field, unable to identify target class", - this.overlayClassName)); - } - - this.targetClassName = targetClassName; - ClassOverlayTransformer.overlayMap.put(this.overlayClassRef, this.targetClassName.replace('.', '/')); - - // If this is the first ClassOverlayTransformer, the referenceMapper will be null - if (ClassOverlayTransformer.referenceRemapper == null) - { - // Therefore create the referenceMapper and accept responsibility for class remapping - ClassOverlayTransformer.referenceRemapper = new SimpleRemapper(ClassOverlayTransformer.overlayMap); - this.remappingAgent = true; - } - } - - /* (non-Javadoc) - * @see net.minecraft.launchwrapper.IClassTransformer - * #transform(java.lang.String, java.lang.String, byte[]) - */ - @Override - public byte[] transform(String name, String transformedName, byte[] basicClass) - { - if (this.targetClassName != null && this.targetClassName.equals(transformedName)) - { - try - { - return this.applyOverlay(transformedName, basicClass); - } - catch (InvalidOverlayException th) - { - LiteLoaderLogger.severe(th, "Class overlay failed: %s %s", th.getClass().getName(), th.getMessage()); - th.printStackTrace(); - } - } - else if (this.overlayClassName.equals(transformedName)) - { - throw new RuntimeException(String.format("%s is an overlay class and cannot be referenced directly", this.overlayClassName)); - } - else if (this.remappingAgent && basicClass != null) - { - return this.remapClass(transformedName, basicClass); - } - - return basicClass; - } - - /** - * Remap references to overlay classes in other classes to the overlay class - * - * @param transformedName - * @param basicClass - */ - private byte[] remapClass(String transformedName, byte[] basicClass) - { - ClassReader classReader = new ClassReader(basicClass); - ClassWriter classWriter = new ClassWriter(classReader, 0); - - RemappingClassAdapter remappingAdapter = new RemappingClassAdapter(classWriter, ClassOverlayTransformer.referenceRemapper); - classReader.accept(remappingAdapter, ClassReader.EXPAND_FRAMES); - - return classWriter.toByteArray(); - } - - /** - * Apply the overlay to the class described by basicClass - * - * @param transformedName - * @param classBytes - */ - protected byte[] applyOverlay(String transformedName, byte[] classBytes) - { - ClassNode overlayClass = this.loadOverlayClass(transformedName, true); - ClassNode targetClass = this.readClass(classBytes, true); - - LiteLoaderLogger.info("Applying overlay %s to %s", this.overlayClassName, transformedName); - - try - { - this.verifyClasses(targetClass, overlayClass); - this.overlayInterfaces(targetClass, overlayClass); - this.overlayAttributes(targetClass, overlayClass); - this.overlayFields(targetClass, overlayClass); - this.findRenamedMethods(targetClass, overlayClass); - this.overlayMethods(targetClass, overlayClass); - } - catch (Exception ex) - { - throw new InvalidOverlayException("Unexpecteded error whilst applying the overlay class", ex); - } - - this.postOverlayTransform(transformedName, targetClass, overlayClass); - - return this.writeClass(targetClass); - } - - protected void postOverlayTransform(String transformedName, ClassNode targetClass, ClassNode overlayClass) - { - // Stub - } - - /** - * Perform pre-flight checks on the overlay and target classes - * - * @param targetClass - * @param overlayClass - */ - protected void verifyClasses(ClassNode targetClass, ClassNode overlayClass) - { - if (targetClass.superName == null || overlayClass.superName == null || !targetClass.superName.equals(overlayClass.superName)) - { - throw new InvalidOverlayException("Overlay classes must have the same superclass as their target class"); - } - } - - /** - * Overlay interfaces implemented by the overlay class onto the target class - * - * @param targetClass - * @param overlayClass - */ - private void overlayInterfaces(ClassNode targetClass, ClassNode overlayClass) - { - for (String interfaceName : overlayClass.interfaces) - { - if (!targetClass.interfaces.contains(interfaceName)) - { - targetClass.interfaces.add(interfaceName); - } - } - } - - /** - * Overlay misc attributes from overlay class onto the target class - * - * @param targetClass - * @param overlayClass - */ - private void overlayAttributes(ClassNode targetClass, ClassNode overlayClass) - { - if (this.setSourceFile ) targetClass.sourceFile = overlayClass.sourceFile; - } - - /** - * Overlay fields from overlay class into the target class. It is vital that - * this is done before overlayMethods because we need to compute renamed - * fields so that transformMethod can rename field references in the - * method body. - * - * @param targetClass - * @param overlayClass - */ - private void overlayFields(ClassNode targetClass, ClassNode overlayClass) - { - for (FieldNode field : overlayClass.fields) - { - if ((field.access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC && (field.access & Opcodes.ACC_PRIVATE) != Opcodes.ACC_PRIVATE) - { - throw new InvalidOverlayException(String.format("Overlay classes cannot contain non-private static methods or fields, found %s", - field.name)); - } - - FieldNode target = ByteCodeUtilities.findTargetField(targetClass, field); - if (target == null) - { - targetClass.fields.add(field); - } - else - { - if (!target.desc.equals(field.desc)) - { - throw new InvalidOverlayException(String.format("The field %s in the target class has a conflicting signature", field.name)); - } - - if (!target.name.equals(field.name)) - { - this.renamedFields.put(field.name, target.name); - } - } - } - } - - /** - * Called before merging methods to build the map of original method names - * -> new method names, this is then used by transformMethod to remap. - * - * @param targetClass - * @param overlayClass - */ - private void findRenamedMethods(ClassNode targetClass, ClassNode overlayClass) - { - for (MethodNode overlayMethod : overlayClass.methods) - { - if (ByteCodeUtilities.getVisibleAnnotation(overlayMethod, Stub.class) != null - || (ByteCodeUtilities.getVisibleAnnotation(overlayMethod, AppendInsns.class) == null && !overlayMethod.name.startsWith("<"))) - { - this.checkRenameMethod(targetClass, overlayMethod); - } - } - } - - /** - * Overlay methods from the overlay class into the target class - * - * @param targetClass - * @param overlayClass - */ - private void overlayMethods(ClassNode targetClass, ClassNode overlayClass) - { - for (MethodNode overlayMethod : overlayClass.methods) - { - this.transformMethod(overlayMethod, overlayClass.name, targetClass.name); - - AnnotationNode appendAnnotation = ByteCodeUtilities.getVisibleAnnotation(overlayMethod, AppendInsns.class); - AnnotationNode stubAnnotation = ByteCodeUtilities.getVisibleAnnotation(overlayMethod, Stub.class); - - if (stubAnnotation != null) - { - MethodNode target = ByteCodeUtilities.findTargetMethod(targetClass, overlayMethod); - if (target == null) - { - throw new InvalidOverlayException(String.format("Stub method %s was not located in the target class", overlayMethod.name)); - } - } - else if (appendAnnotation != null) - { - String targetMethodName = ByteCodeUtilities.getAnnotationValue(appendAnnotation); - this.appendInsns(targetClass, targetMethodName, overlayMethod); - } - else if (!overlayMethod.name.startsWith("<")) - { - if ((overlayMethod.access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC - && (overlayMethod.access & Opcodes.ACC_PRIVATE) != Opcodes.ACC_PRIVATE) - { - continue; - } - - MethodNode target = ByteCodeUtilities.findTargetMethod(targetClass, overlayMethod); - if (target != null) targetClass.methods.remove(target); - targetClass.methods.add(overlayMethod); - } - else if ("".equals(overlayMethod.name)) - { - this.appendInsns(targetClass, overlayMethod.name, overlayMethod); - } - } - } - - /** - * Handles "re-parenting" the method supplied, changes all references to the - * overlay class to refer to the target class (for field accesses and method - * invocations) and also renames fields accesses to their obfuscated - * versions. - * - * @param method - * @param fromClass - * @param toClass - */ - private void transformMethod(MethodNode method, String fromClass, String toClass) - { - Iterator iter = method.instructions.iterator(); - while (iter.hasNext()) - { - AbstractInsnNode insn = iter.next(); - - if (insn instanceof MethodInsnNode) - { - MethodInsnNode methodInsn = (MethodInsnNode)insn; - if (methodInsn.owner.equals(fromClass)) - { - methodInsn.owner = toClass; - - String methodDescriptor = methodInsn.name + methodInsn.desc; - if (this.renamedMethods.containsKey(methodDescriptor)) - { - methodInsn.name = this.renamedMethods.get(methodDescriptor); - } - } - } - if (insn instanceof FieldInsnNode) - { - FieldInsnNode fieldInsn = (FieldInsnNode)insn; - if (fieldInsn.owner.equals(fromClass)) fieldInsn.owner = toClass; - - if (this.renamedFields.containsKey(fieldInsn.name)) - { - String newName = this.renamedFields.get(fieldInsn.name); - fieldInsn.name = newName; - } - } - } - } - - /** - * Handles appending instructions from the source method to the target - * method. - * - * @param targetClass - * @param targetMethodName - * @param sourceMethod - */ - private void appendInsns(ClassNode targetClass, String targetMethodName, MethodNode sourceMethod) - { - if (Type.getReturnType(sourceMethod.desc) != Type.VOID_TYPE) - { - throw new IllegalArgumentException("Attempted to merge insns into a method which does not return void"); - } - - if (targetMethodName == null || targetMethodName.length() == 0) targetMethodName = sourceMethod.name; - - Set obfuscatedNames = new HashSet(); - AnnotationNode obfuscatedAnnotation = ByteCodeUtilities.getVisibleAnnotation(sourceMethod, Obfuscated.class); - if (obfuscatedAnnotation != null) - { - obfuscatedNames.addAll(ByteCodeUtilities.>getAnnotationValue(obfuscatedAnnotation)); - } - - for (MethodNode method : targetClass.methods) - { - if ((targetMethodName.equals(method.name) || obfuscatedNames.contains(method.name)) && sourceMethod.desc.equals(method.desc)) - { - AbstractInsnNode returnNode = null; - Iterator findReturnIter = method.instructions.iterator(); - while (findReturnIter.hasNext()) - { - AbstractInsnNode insn = findReturnIter.next(); - if (insn.getOpcode() == Opcodes.RETURN) - { - returnNode = insn; - break; - } - } - - Iterator injectIter = sourceMethod.instructions.iterator(); - while (injectIter.hasNext()) - { - AbstractInsnNode insn = injectIter.next(); - if (!(insn instanceof LineNumberNode) && insn.getOpcode() != Opcodes.RETURN) - { - method.instructions.insertBefore(returnNode, insn); - } - } - } - } - } - - /** - * @param targetClass - * @param searchFor - */ - private void checkRenameMethod(ClassNode targetClass, MethodNode searchFor) - { - MethodNode target = ByteCodeUtilities.findTargetMethod(targetClass, searchFor); - if (target != null && !target.name.equals(searchFor.name)) - { - String methodDescriptor = searchFor.name + searchFor.desc; - this.renamedMethods.put(methodDescriptor, target.name); - searchFor.name = target.name; - } - } - - /** - * @param transformedName - * @throws InvalidOverlayException - */ - private ClassNode loadOverlayClass(String transformedName, boolean runTransformers) - { - byte[] overlayBytes = null; - - try - { - if ((overlayBytes = Launch.classLoader.getClassBytes(this.overlayClassName)) == null) - { - throw new InvalidOverlayException(String.format("The specified overlay '%s' was not found", this.overlayClassName)); - } - - if (runTransformers) - { - overlayBytes = ByteCodeUtilities.applyTransformers(this.overlayClassName, overlayBytes, this); - } - } - catch (IOException ex) - { - LiteLoaderLogger.severe("Failed to load overlay %s for %s, no overlay was applied", this.overlayClassName, transformedName); - throw new InvalidOverlayException("An error was encountered whilst loading the overlay class", ex); - } - - return this.readClass(overlayBytes, false); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/ClassTransformer.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/ClassTransformer.java deleted file mode 100644 index a79a454c..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/ClassTransformer.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -import net.minecraft.launchwrapper.IClassTransformer; - -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.tree.ClassNode; - -/** - * Base class for transformers which work via ClassNode - * - * @author Adam Mummery-Smith - */ -public abstract class ClassTransformer implements IClassTransformer -{ - public static final String HORIZONTAL_RULE = - "----------------------------------------------------------------------------------------------------"; - - private ClassReader classReader; - private ClassNode classNode; - - /** - * @param basicClass - */ - protected final ClassNode readClass(byte[] basicClass, boolean cacheReader) - { - ClassReader classReader = new ClassReader(basicClass); - if (cacheReader) this.classReader = classReader; - - ClassNode classNode = new ClassNode(); - classReader.accept(classNode, ClassReader.EXPAND_FRAMES); - return classNode; - } - - /** - * @param classNode - */ - protected final byte[] writeClass(ClassNode classNode) - { - // Use optimised writer for speed - if (this.classReader != null && this.classNode == classNode) - { - this.classNode = null; - IsolatedClassWriter writer = new IsolatedClassWriter(this.classReader, ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); - this.classReader = null; - classNode.accept(writer); - return writer.toByteArray(); - } - - this.classNode = null; - - IsolatedClassWriter writer = new IsolatedClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); - classNode.accept(writer); - return writer.toByteArray(); - } - - protected static String getSimpleClassName(ClassNode classNode) - { - String className = classNode.name.replace('/', '.'); - int dotPos = className.lastIndexOf('.'); - return dotPos == -1 ? className : className.substring(dotPos + 1); - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/InjectedCallbackCollisionError.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/InjectedCallbackCollisionError.java deleted file mode 100644 index 0fc658b4..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/InjectedCallbackCollisionError.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -public class InjectedCallbackCollisionError extends Error -{ - private static final long serialVersionUID = 1L; - - public InjectedCallbackCollisionError() - { - } - - public InjectedCallbackCollisionError(String message) - { - super(message); - } - - public InjectedCallbackCollisionError(Throwable cause) - { - super(cause); - } - - public InjectedCallbackCollisionError(String message, Throwable cause) - { - super(message, cause); - } - -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/InvalidOverlayException.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/InvalidOverlayException.java deleted file mode 100644 index 0cda72c3..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/InvalidOverlayException.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -/** - * - * @author Adam Mummery-Smith - */ -public class InvalidOverlayException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public InvalidOverlayException(String message) - { - super(message); - } - - public InvalidOverlayException(Throwable cause) - { - super(cause); - } - - public InvalidOverlayException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/IsolatedClassWriter.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/IsolatedClassWriter.java deleted file mode 100644 index 69e30406..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/IsolatedClassWriter.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassWriter; - -/** - * ClassWriter isolated from ASM so that it exists in the LaunchClassLoader - * - * @author Adam Mummery-Smith - */ -public class IsolatedClassWriter extends ClassWriter -{ - public IsolatedClassWriter(int flags) - { - super(flags); - } - - public IsolatedClassWriter(ClassReader classReader, int flags) - { - super(classReader, flags); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/ObfProvider.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/ObfProvider.java deleted file mode 100644 index 448c7258..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/ObfProvider.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -import com.mumfrey.liteloader.core.runtime.Obf; - -/** - * Interface for dynamic (context-specific) obfuscation provider, used - * internally by ModEventInjectionTransformer to provide obf entries for the - * AccessorTransformer from JSON - * - * @author Adam Mummery-Smith - */ -public interface ObfProvider -{ - /** - * Try to locate an obfuscation table entry by name (id), returns null if no - * entry was found - * - * @param name - */ - public abstract Obf getByName(String name); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/Obfuscated.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/Obfuscated.java deleted file mode 100644 index 05f4f83c..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/Obfuscated.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation which provides the obfuscated names for a method or field to the - * ClassOverlayTransformer. - * - * @author Adam Mummery-Smith - */ -@Target({ElementType.METHOD, ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Obfuscated -{ - public String[] value(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/PacketHandlerException.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/PacketHandlerException.java deleted file mode 100644 index 5170f8a6..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/PacketHandlerException.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -import net.minecraft.network.Packet; - -/** - * Exception which a packet handler can throw in order to cancel further - * handling of the event. - * - * @author Adam Mummery-Smith - */ -public class PacketHandlerException extends RuntimeException -{ - private static final long serialVersionUID = -330946238844640302L; - - private Packet packet; - - public PacketHandlerException(Packet packet) - { - } - - public PacketHandlerException(Packet packet, String message) - { - super(message); - } - - public Packet getPacket() - { - return this.packet; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/Stub.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/Stub.java deleted file mode 100644 index 0cf5ab75..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/Stub.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.mumfrey.liteloader.transformers; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Interface which instructs the ClassOverlayTransformer to NOT merge the - * annotated method. - * - * @author Adam Mummery-Smith - */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Stub -{ -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/Accessor.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/Accessor.java deleted file mode 100644 index ceca9223..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/Accessor.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.mumfrey.liteloader.transformers.access; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Defines an accessor method within an accessor injection interface, or an - * accessor interface itself. - * - * @author Adam Mummery-Smith - */ -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.CLASS) -public @interface Accessor -{ - public String[] value(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/AccessorTransformer.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/AccessorTransformer.java deleted file mode 100644 index a5fa5cd2..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/AccessorTransformer.java +++ /dev/null @@ -1,584 +0,0 @@ -package com.mumfrey.liteloader.transformers.access; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import net.minecraft.launchwrapper.Launch; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.AnnotationNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.FieldInsnNode; -import org.objectweb.asm.tree.FieldNode; -import org.objectweb.asm.tree.InsnList; -import org.objectweb.asm.tree.InsnNode; -import org.objectweb.asm.tree.LdcInsnNode; -import org.objectweb.asm.tree.MethodInsnNode; -import org.objectweb.asm.tree.MethodNode; -import org.objectweb.asm.tree.TypeInsnNode; -import org.objectweb.asm.tree.VarInsnNode; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.ByteCodeUtilities; -import com.mumfrey.liteloader.transformers.ClassTransformer; -import com.mumfrey.liteloader.transformers.ObfProvider; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Transformer which can inject accessor methods defined by an annotated - * interface into a target class. - * - * @author Adam Mummery-Smith - */ -public abstract class AccessorTransformer extends ClassTransformer -{ - static final Pattern ordinalRefPattern = Pattern.compile("^#([0-9]{1,5})$"); - - /** - * An injection record - * - * @author Adam Mummery-Smith - */ - class AccessorInjection - { - /** - * Full name of the interface to inject - */ - private final String iface; - - /** - * Obfuscation table class specified by the interface - */ - private final Class table; - - /** - * Obfuscation provider for this context - */ - private final ObfProvider obfProvider; - - /** - * Target class to inject into - */ - private final Obf target; - - /** - * Create a new new accessor using the specified template interface - * - * @param iface Template interface - * @throws IOException Thrown if an problem occurs when loading the - * interface bytecode - */ - protected AccessorInjection(String iface) throws IOException - { - this(iface, null); - } - - /** - * Create a new new accessor using the specified template interface - * - * @param iface Template interface - * @param obfProvider Obfuscation provider for this context - * @throws IOException Thrown if an problem occurs when loading the - * interface bytecode - */ - protected AccessorInjection(String iface, ObfProvider obfProvider) throws IOException - { - ClassNode ifaceNode = ByteCodeUtilities.loadClass(iface, false); - - if (ifaceNode.interfaces.size() > 0) - { - String interfaceList = ifaceNode.interfaces.toString().replace('/', '.'); - throw new RuntimeException("Accessor interface must not extend other interfaces. Found " + interfaceList + " in " + iface); - } - - this.iface = iface; - this.obfProvider = obfProvider; - this.table = this.setupTable(ifaceNode); - this.target = this.setupTarget(ifaceNode); - } - - /** - * Get an obfuscation table mapping by name, first uses any supplied - * context provider, then any obfuscation table class specified by an - * {@link ObfTableClass} annotation on the interface itself, and fails - * over onto the LiteLoader obfuscation table. If the entry is not - * matched in any of the above locations then an exception is thrown. - * - * @param name Obfuscation table entry to fetch - */ - private Obf getObf(List names) - { - String name = names.get(0); - - Matcher ordinalPattern = AccessorTransformer.ordinalRefPattern.matcher(name); - if (ordinalPattern.matches()) - { - int ordinal = Integer.parseInt(ordinalPattern.group(1)); - return new Obf.Ord(ordinal); - } - - if (this.obfProvider != null) - { - Obf obf = this.obfProvider.getByName(name); - if (obf != null) - { - return obf; - } - } - - Obf obf = Obf.getByName(this.table, name); - if (obf != null) - { - return obf; - } - - if (names.size() > 0 && names.size() < 4) - { - String name2 = names.size() > 1 ? names.get(1) : name; - String name3 = names.size() > 2 ? names.get(2) : name; - return new AccessorTransformer.Mapping(name, name2, name3); - } - - throw new RuntimeException("Invalid obfuscation table entry specified: '" + names + "'"); - } - - /** - * Get the target class of this injection - */ - protected Obf getTarget() - { - return this.target; - } - - /** - * Inspects the target class for an {@link ObfTableClass} annotation and - * attempts to get a handle for the class specified. On failure, the - * LiteLoader {@link Obf} is returned. - */ - @SuppressWarnings("unchecked") - private Class setupTable(ClassNode ifaceNode) - { - AnnotationNode annotation = ByteCodeUtilities.getInvisibleAnnotation(ifaceNode, ObfTableClass.class); - if (annotation != null) - { - try - { - Type obfTableType = ByteCodeUtilities.getAnnotationValue(annotation); - return (Class)Class.forName(obfTableType.getClassName(), true, Launch.classLoader); - } - catch (ClassNotFoundException ex) - { - ex.printStackTrace(); - } - } - - return Obf.class; - } - - /** - * Locates the {@link Accessor} annotation on the interface in order to - * determine the target class. - */ - private Obf setupTarget(ClassNode ifaceNode) - { - AnnotationNode annotation = ByteCodeUtilities.getInvisibleAnnotation(ifaceNode, Accessor.class); - if (annotation == null) - { - throw new RuntimeException("Accessor interfaces must be annotated with an @Accessor annotation specifying the target class"); - } - - List targetClass = ByteCodeUtilities.>getAnnotationValue(annotation); - if (targetClass == null || targetClass.isEmpty()) - { - throw new RuntimeException("Invalid @Accessor annotation, the annotation must specify a target class"); - } - - return this.getObf(targetClass); - } - - /** - * Apply this injection to the specified target ClassNode - * - * @param classNode Class tree to apply to - */ - protected void apply(ClassNode classNode) - { - String ifaceRef = this.iface.replace('.', '/'); - - if (classNode.interfaces.contains(ifaceRef)) - { - LiteLoaderLogger.debug("[AccessorTransformer] Skipping %s because %s was already applied", classNode.name, this.iface); - return; - } - - classNode.interfaces.add(ifaceRef); - - try - { - LiteLoaderLogger.debug("[AccessorTransformer] Loading %s", this.iface); - ClassNode ifaceNode = ByteCodeUtilities.loadClass(this.iface, AccessorTransformer.this); - - for (MethodNode method : ifaceNode.methods) - { - this.addMethod(classNode, method); - } - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - /** - * Add a method from the interface to the target class - * - * @param classNode Target class - * @param method Method to add - */ - private void addMethod(ClassNode classNode, MethodNode method) - { - if (!this.addMethodToClass(classNode, method)) - { - LiteLoaderLogger.debug("[AccessorTransformer] Method %s already exists in %s", method.name, classNode.name); - return; - } - - LiteLoaderLogger.debug("[AccessorTransformer] Attempting to add %s to %s", method.name, classNode.name); - - List targetId = null; - AnnotationNode accessor = ByteCodeUtilities.getInvisibleAnnotation(method, Accessor.class); - AnnotationNode invoker = ByteCodeUtilities.getInvisibleAnnotation(method, Invoker.class); - if (accessor != null) - { - targetId = ByteCodeUtilities.>getAnnotationValue(accessor); - Obf target = this.getObf(targetId); - if (this.injectAccessor(classNode, method, target)) return; - } - else if (invoker != null) - { - targetId = ByteCodeUtilities.>getAnnotationValue(invoker); - Obf target = this.getObf(targetId); - if (this.injectInvoker(classNode, method, target)) return; - } - else - { - LiteLoaderLogger.severe("[AccessorTransformer] Method %s for %s has no @Accessor or @Invoker annotation, the method will " - + "be ABSTRACT!", method.name, this.iface); - this.injectException(classNode, method, "No @Accessor or @Invoker annotation on method"); - return; - } - - LiteLoaderLogger.severe("[AccessorTransformer] Method %s for %s could not locate target member, the method will be ABSTRACT!", - method.name, this.iface); - this.injectException(classNode, method, "Could not locate target class member '" + targetId + "'"); - } - - /** - * Inject an accessor method into the target class - * - * @param classNode - * @param method - * @param targetName - */ - private boolean injectAccessor(ClassNode classNode, MethodNode method, Obf target) - { - FieldNode targetField = ByteCodeUtilities.findField(classNode, target); - if (targetField != null) - { - LiteLoaderLogger.debug("[AccessorTransformer] Found field %s for %s", targetField.name, method.name); - if (Type.getReturnType(method.desc) != Type.VOID_TYPE) - { - this.populateGetter(classNode, method, targetField); - } - else - { - this.populateSetter(classNode, method, targetField); - } - - return true; - } - - return false; - } - - /** - * Inject an invoke (proxy) method into the target class - * - * @param classNode - * @param method - * @param targetName - */ - private boolean injectInvoker(ClassNode classNode, MethodNode method, Obf target) - { - MethodNode targetMethod = ByteCodeUtilities.findMethod(classNode, target, method.desc); - if (targetMethod != null) - { - LiteLoaderLogger.debug("[AccessorTransformer] Found method %s for %s", targetMethod.name, method.name); - this.populateInvoker(classNode, method, targetMethod); - return true; - } - - return false; - } - - /** - * Populate the bytecode instructions for a getter accessor - * - * @param classNode - * @param method - * @param field - */ - private void populateGetter(ClassNode classNode, MethodNode method, FieldNode field) - { - Type returnType = Type.getReturnType(method.desc); - Type fieldType = Type.getType(field.desc); - if (!returnType.equals(fieldType)) - { - throw new RuntimeException("Incompatible types! Field type: " + fieldType + " Method type: " + returnType); - } - boolean isStatic = (field.access & Opcodes.ACC_STATIC) != 0; - - method.instructions.clear(); - method.maxLocals = ByteCodeUtilities.getFirstNonArgLocalIndex(method); - method.maxStack = fieldType.getSize(); - - if (isStatic) - { - method.instructions.add(new FieldInsnNode(Opcodes.GETSTATIC, classNode.name, field.name, field.desc)); - } - else - { - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - method.instructions.add(new FieldInsnNode(Opcodes.GETFIELD, classNode.name, field.name, field.desc)); - } - - method.instructions.add(new InsnNode(returnType.getOpcode(Opcodes.IRETURN))); - } - - /** - * Populate the bytecode instructions for a setter - * - * @param classNode - * @param method - * @param field - */ - private void populateSetter(ClassNode classNode, MethodNode method, FieldNode field) - { - Type[] argTypes = Type.getArgumentTypes(method.desc); - if (argTypes.length != 1) - { - throw new RuntimeException("Invalid setter! " + method.name + " must take exactly one argument"); - } - Type argType = argTypes[0]; - Type fieldType = Type.getType(field.desc); - if (!argType.equals(fieldType)) - { - throw new RuntimeException("Incompatible types! Field type: " + fieldType + " Method type: " + argType); - } - boolean isStatic = (field.access & Opcodes.ACC_STATIC) != 0; - - method.instructions.clear(); - method.maxLocals = ByteCodeUtilities.getFirstNonArgLocalIndex(method); - method.maxStack = fieldType.getSize(); - - if (isStatic) - { - method.instructions.add(new VarInsnNode(argType.getOpcode(Opcodes.ILOAD), 0)); - method.instructions.add(new FieldInsnNode(Opcodes.PUTSTATIC, classNode.name, field.name, field.desc)); - } - else - { - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - method.instructions.add(new VarInsnNode(argType.getOpcode(Opcodes.ILOAD), 1)); - method.instructions.add(new FieldInsnNode(Opcodes.PUTFIELD, classNode.name, field.name, field.desc)); - } - - method.instructions.add(new InsnNode(Opcodes.RETURN)); - } - - /** - * Populate the bytecode instructions for an invoker (proxy) method - * - * @param classNode - * @param method - * @param targetMethod - */ - private void populateInvoker(ClassNode classNode, MethodNode method, MethodNode targetMethod) - { - Type[] args = Type.getArgumentTypes(targetMethod.desc); - Type returnType = Type.getReturnType(targetMethod.desc); - boolean isStatic = (targetMethod.access & Opcodes.ACC_STATIC) != 0; - - method.instructions.clear(); - method.maxStack = (method.maxLocals = ByteCodeUtilities.getFirstNonArgLocalIndex(method)) + 1; - - if (isStatic) - { - ByteCodeUtilities.loadArgs(args, method.instructions, 0); - method.instructions.add(new MethodInsnNode(Opcodes.INVOKESTATIC, classNode.name, targetMethod.name, targetMethod.desc, false)); - } - else - { - method.instructions.add(new VarInsnNode(Opcodes.ALOAD, 0)); - ByteCodeUtilities.loadArgs(args, method.instructions, 1); - method.instructions.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, classNode.name, targetMethod.name, targetMethod.desc, false)); - } - - method.instructions.add(new InsnNode(returnType.getOpcode(Opcodes.IRETURN))); - } - - /** - * Populate bytecode instructions for a method which throws an exception - * - * @param classNode - * @param method - * @param message - */ - private void injectException(ClassNode classNode, MethodNode method, String message) - { - InsnList insns = method.instructions; - method.maxStack = 2; - - insns.clear(); - insns.add(new TypeInsnNode(Opcodes.NEW, "java/lang/RuntimeException")); - insns.add(new InsnNode(Opcodes.DUP)); - insns.add(new LdcInsnNode(message)); - insns.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, "java/lang/RuntimeException", "", "(Ljava/lang/String;)V", false)); - insns.add(new InsnNode(Opcodes.ATHROW)); - } - - /** - * Add a method from the template interface to the target class - * - * @param classNode - * @param method - */ - private boolean addMethodToClass(ClassNode classNode, MethodNode method) - { - MethodNode existingMethod = ByteCodeUtilities.findTargetMethod(classNode, method); - if (existingMethod != null) return false; - classNode.methods.add(method); - method.access = method.access & ~Opcodes.ACC_ABSTRACT; - return true; - } - } - - protected static class Mapping extends Obf - { - protected Mapping(String seargeName, String obfName, String mcpName) - { - super(seargeName, obfName, mcpName); - } - } - - /** - * List of accessors to inject - */ - private final List accessors = new ArrayList(); - - /** - * ctor - */ - public AccessorTransformer() - { - this.addAccessors(); - } - - /** - * @param interfaceName - */ - public void addAccessor(String interfaceName) - { - this.addAccessor(interfaceName, null); - } - - /** - * Add an accessor to the accessors list - * - * @param interfaceName - * @param obfProvider - */ - public void addAccessor(String interfaceName, ObfProvider obfProvider) - { - try - { - this.accessors.add(new AccessorInjection(interfaceName, obfProvider)); - } - catch (Exception ex) - { - LiteLoaderLogger.debug(ex); - } - } - - /* (non-Javadoc) - * @see net.minecraft.launchwrapper.IClassTransformer - * #transform(java.lang.String, java.lang.String, byte[]) - */ - @Override - public byte[] transform(String name, String transformedName, byte[] basicClass) - { - ClassNode classNode = null; - - classNode = this.apply(name, transformedName, basicClass, classNode); - - if (classNode != null) - { - this.postTransform(name, transformedName, classNode); - return this.writeClass(classNode); - } - - return basicClass; - } - - /** - * Apply this transformer, used when this transformer is acting as a - * delegate via another transformer (eg. an EventTransformer) and the parent - * transformer already has a ClassNode for the target class. - * - * @param name - * @param transformedName - * @param basicClass - * @param classNode - */ - public ClassNode apply(String name, String transformedName, byte[] basicClass, ClassNode classNode) - { - for (Iterator iter = this.accessors.iterator(); iter.hasNext(); ) - { - AccessorInjection accessor = iter.next(); - Obf target = accessor.getTarget(); - if (target.obf.equals(transformedName) || target.name.equals(transformedName)) - { - LiteLoaderLogger.debug("[AccessorTransformer] Processing access injections in %s", transformedName); - if (classNode == null) classNode = this.readClass(basicClass, true); - accessor.apply(classNode); - iter.remove(); - } - } - - return classNode; - } - - /** - * Subclasses should add their accessors here - */ - protected void addAccessors() - { - } - - /** - * Called after transformation is applied, allows custom transforms to be - * performed by subclasses. - * - * @param name - * @param transformedName - * @param classNode - */ - protected void postTransform(String name, String transformedName, ClassNode classNode) - { - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/Invoker.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/Invoker.java deleted file mode 100644 index 7ee807ff..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/Invoker.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.mumfrey.liteloader.transformers.access; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Defines an invoker method within an accessor injection interface - * - * @author Adam Mummery-Smith - */ -@Target({ElementType.METHOD, ElementType.TYPE}) -@Retention(RetentionPolicy.CLASS) -public @interface Invoker -{ - public String[] value(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/ObfTableClass.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/ObfTableClass.java deleted file mode 100644 index 95a8d5ff..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/access/ObfTableClass.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mumfrey.liteloader.transformers.access; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import com.mumfrey.liteloader.core.runtime.Obf; - -/** - * Defines the obfuscation table class to use for an accessor injection - * interface. - * - * @author Adam Mummery-Smith - */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.CLASS) -public @interface ObfTableClass -{ - public Class value(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/Event.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/Event.java deleted file mode 100644 index 3eaaf97e..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/Event.java +++ /dev/null @@ -1,728 +0,0 @@ -package com.mumfrey.liteloader.transformers.event; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import org.objectweb.asm.Label; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.*; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.ByteCodeUtilities; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * An injectable "event". An event is like a regular callback except that it is - * more intelligent about where it can be injected in the bytecode and also - * supports conditional "cancellation", which is the ability to conditionally - * return from the containing method with a custom return value. - * - * @author Adam Mummery-Smith - */ -public class Event implements Comparable -{ - /** - * Natural ordering of events, for use with sorting events which have the - * same priority. - */ - private static int eventOrder = 0; - - /** - * All the events which exist and their registered listeners - */ - private static final Set events = new HashSet(); - - private static final List>> proxyHandlerMethods = new ArrayList>>(); - - private static int proxyInnerClassIndex = 1; - - static - { - Event.resizeProxyList(); - } - - /** - * The name of this event - */ - protected final String name; - - /** - * Whether this event is cancellable - if it is cancellable then the - * isCancelled() -> RETURN code will be injected. - */ - protected final boolean cancellable; - - /** - * Natural order of this event, for sorting - */ - private final int order; - - /** - * Priority of this event, for sorting - */ - private final int priority; - - private Set listeners = new HashSet(); - - /** - * Method this event is currently "attached" to, we "attach" at the - * beginning of a method injection in order to save recalculating things - * like the return type and descriptor for each invocation, this means we - * need to calculate these things at most once for each method this event is - * injecting into. - */ - protected MethodNode method; - - /** - * Descriptor for this event in the context of the attached method - */ - protected String eventDescriptor; - - /** - * Method's original MAXS, used as a base to work out whether we need to - * increase the MAXS value. - */ - protected int methodMAXS = 0; - - /** - * True if the attached method is static, used so that we know whether to - * push "this" onto the stack when constructing the EventInfo, or "null" - */ - protected boolean methodIsStatic; - - /** - * Return type for the attached method, used to determine which EventInfo - * class to use and which method to invoke. - */ - protected Type methodReturnType; - - protected String eventInfoClass; - - protected Set pendingInjections; - - private int injectionCount = 0; - - protected boolean verbose; - - protected Event(String name, boolean cancellable, int priority) - { - this.name = name.toLowerCase(); - this.priority = priority; - this.order = Event.eventOrder++; - this.cancellable = cancellable; - this.verbose = true; - - if (Event.events.contains(this)) - { - throw new IllegalArgumentException("Event " + name + " is already defined"); - } - - Event.events.add(this); - } - - /** - * Creates a new event with the specified name, if an event with the - * specified name already exists then the existing event is returned - * instead. - * - * @param name Event name (case insensitive) - * @return new Event instance or existing Event instance - */ - public static Event getOrCreate(String name) - { - return Event.getOrCreate(name, false, 1000, false); - } - - /** - * Creates a new event with the specified name, if an event with the - * specified name already exists then the existing event is returned - * instead. - * - * @param name Event name (case insensitive) - * @param cancellable True if the event should be created as cancellable - * @return new Event instance or existing Event instance - */ - public static Event getOrCreate(String name, boolean cancellable) - { - return Event.getOrCreate(name, cancellable, 1000, true); - } - - /** - * Creates a new event with the specified name, if an event with the - * specified name already exists then the existing event is returned - * instead. - * - * @param name Event name (case insensitive) - * @param cancellable True if the event should be created as cancellable - * @param priority Priority for the event, only used when multiple events - * are being injected at the same instruction - * @return new Event instance or existing Event instance - */ - public static Event getOrCreate(String name, boolean cancellable, int priority) - { - return getOrCreate(name, cancellable, priority, true); - } - - protected static Event getOrCreate(String name, boolean cancellable, int priority, boolean defining) - { - Event event = Event.getEvent(name); - if (event != null) - { - if (!event.cancellable && cancellable && defining) - { - throw new IllegalArgumentException("Attempted to define the event " + event.name + " with cancellable '" - + cancellable + "' but the event is already defined with cancellable is '" + event.cancellable + "'"); - } - - return event; - } - - return new Event(name, cancellable, priority); - } - - /** - * Get the name of the event (all lowercase) - */ - public String getName() - { - return this.name; - } - - /** - * Get whether this event is cancellable or not - */ - public boolean isCancellable() - { - return this.cancellable; - } - - /** - * Get the event priority - */ - public int getPriority() - { - return this.priority; - } - - /** - * Set whether to log at INFO or DEBUG - */ - public Event setVerbose(boolean verbose) - { - this.verbose = verbose; - return this; - } - - /** - * Get whether to log at INFO or DEBUG - */ - public boolean isVerbose() - { - return this.verbose; - } - - /** - * Get whether this event is currently attached to a method - */ - public boolean isAttached() - { - return this.method != null; - } - - /** - * Attaches this event to a particular method, this occurs before injection - * in order to allow the event to configure its internal state appropriately - * for the method's signature. Since a single event may be injected into - * multiple target methods, and may also be injected at multiple points in - * the same method, this saves us recalculating this information for every - * injection, and instead just calculate once per method. - * - * @param method Method to attach to - */ - void attach(final MethodNode method) - { - if (this.method != null) - { - throw new IllegalStateException("Attempted to attach the event " + this.name + " to " + method.name - + " but the event was already attached to " + this.method.name + "!"); - } - - this.method = method; - this.methodReturnType = Type.getReturnType(method.desc); - this.methodMAXS = method.maxStack; - this.methodIsStatic = (method.access & Opcodes.ACC_STATIC) == Opcodes.ACC_STATIC; - this.eventInfoClass = this.getEventInfoClassName(); - this.eventDescriptor = String.format("(L%s;%s)V", this.eventInfoClass, method.desc.substring(1, method.desc.indexOf(')'))); - } - - /** - * Detach from the attached method, called once injection is completed for a - * particular method. - */ - void detach() - { - this.method = null; - } - - void addPendingInjection(MethodInfo targetMethod) - { - if (this.pendingInjections == null) - { - this.pendingInjections = new HashSet(); - } - - this.pendingInjections.add(targetMethod); - } - - void notifyInjected(String method, String desc, String className) - { - MethodInfo thisInjection = null; - - if (this.pendingInjections != null) - { - for (MethodInfo pendingInjection : this.pendingInjections) - { - if (pendingInjection.matches(method, desc, className)) - { - thisInjection = pendingInjection; - break; - } - } - } - - if (thisInjection != null) - { - this.pendingInjections.remove(thisInjection); - } - } - - int dumpInjectionState() - { - int uninjectedCount = 0; - int pendingInjectionCount = this.pendingInjections != null ? this.pendingInjections.size() : 0; - - LiteLoaderLogger.debug(" Event: %-40s Injected: %d Pending: %d %s", this.name, this.injectionCount, pendingInjectionCount, - this.injectionCount == 0 ? " <<< NOT INJECTED >>>" : ""); - if (pendingInjectionCount > 0) - { - for (MethodInfo pending : this.pendingInjections) - { - LiteLoaderLogger.debug(" Pending: %s.%s", pending.getOwners(), pending.toString()); - uninjectedCount++; - } - } - - return uninjectedCount; - } - - /** - * Pre-flight check - * - * @param injectionPoint - * @param cancellable - * @param globalEventID - */ - protected void validate(final AbstractInsnNode injectionPoint, boolean cancellable, final int globalEventID) - { - if (this.method == null) - { - throw new IllegalStateException("Attempted to inject the event " + this.name + " but the event is not attached!"); - } - } - - /** - * Inject bytecode for this event into the currently attached method. When - * multiple events want to be injected into the same method at the same - * point only the first event is injected, subsequent events are simply - * added to the same handler delegate in the EventProxy class. - * - * @param injectionPoint Point to inject code, new instructions will be - * injected directly ahead of the specifed insn - * @param cancellable Cancellable flag, if true then the cancellation code - * (conditional return) will be injected as well - * @param globalEventID Global event ID, used to map a callback to the - * relevant event handler delegate method in EventProxy - * - * @return MethodNode for the event handler delegate - */ - final MethodNode inject(final AbstractInsnNode injectionPoint, boolean cancellable, final int globalEventID, final boolean captureLocals, - final Type[] locals) - { - // Pre-flight checks - this.validate(injectionPoint, cancellable, globalEventID); - - Type[] arguments = Type.getArgumentTypes(this.method.desc); - int initialFrameSize = ByteCodeUtilities.getFirstNonArgLocalIndex(arguments, !this.methodIsStatic); - - boolean doCaptureLocals = captureLocals && locals != null && locals.length > initialFrameSize; - String eventDescriptor = this.generateEventDescriptor(doCaptureLocals, locals, arguments, initialFrameSize); - - // Create the handler delegate method - MethodNode handler = new MethodNode(Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC | Opcodes.ACC_SYNTHETIC, Event.getHandlerName(globalEventID), - eventDescriptor, null, null); - Event.addMethodToActiveProxy(handler); - - LiteLoaderLogger.debug("Event %s is spawning handler %s in class %s", this.name, handler.name, Event.getActiveProxyRef()); - - int ctorMAXS = 0, invokeMAXS = arguments.length + (doCaptureLocals ? locals.length - initialFrameSize : 0); - int marshallVar = this.method.maxLocals++; - - InsnList insns = new InsnList(); - - boolean pushReturnValue = false; - - // If this is a ReturnEventInfo AND we are right before a RETURN opcode (so we can expect the *original* return - // value to be on the stack, then we dup the return value into a local var so we can push it later when we invoke - // the ReturnEventInfo ctor - if (injectionPoint instanceof InsnNode && injectionPoint.getOpcode() >= Opcodes.IRETURN && injectionPoint.getOpcode() < Opcodes.RETURN) - { - pushReturnValue = true; - insns.add(new InsnNode(Opcodes.DUP)); - insns.add(new VarInsnNode(this.methodReturnType.getOpcode(Opcodes.ISTORE), marshallVar)); - } - - // Instance the EventInfo for this event - insns.add(new TypeInsnNode(Opcodes.NEW, this.eventInfoClass)); ctorMAXS++; - insns.add(new InsnNode(Opcodes.DUP)); ctorMAXS++; invokeMAXS++; - ctorMAXS += this.invokeEventInfoConstructor(insns, cancellable, pushReturnValue, marshallVar); - insns.add(new VarInsnNode(Opcodes.ASTORE, marshallVar)); - - // Call the event handler method in the proxy - insns.add(new VarInsnNode(Opcodes.ALOAD, marshallVar)); - ByteCodeUtilities.loadArgs(arguments, insns, this.methodIsStatic ? 0 : 1); - if (doCaptureLocals) - { - ByteCodeUtilities.loadLocals(locals, insns, initialFrameSize); - } - insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Event.getActiveProxyRef(), handler.name, handler.desc, false)); - - if (cancellable) - { - // Inject the if (e.isCancelled()) return e.getReturnValue(); - this.injectCancellationCode(insns, injectionPoint, marshallVar); - } - - // Inject our generated code into the method - this.method.instructions.insertBefore(injectionPoint, insns); - this.method.maxStack = Math.max(this.method.maxStack, Math.max(this.methodMAXS + ctorMAXS, this.methodMAXS + invokeMAXS)); - - return handler; - } - - private String generateEventDescriptor(final boolean captureLocals, final Type[] locals, Type[] argumentTypes, int startIndex) - { - if (!captureLocals) return this.eventDescriptor; - - String eventDescriptor = this.eventDescriptor.substring(0, this.eventDescriptor.indexOf(')')); - for (int l = startIndex; l < locals.length; l++) - { - if (locals[l] != null) eventDescriptor += locals[l].getDescriptor(); - } - - return eventDescriptor + ")V"; - } - - protected int invokeEventInfoConstructor(InsnList insns, boolean cancellable, boolean pushReturnValue, int marshallVar) - { - int ctorMAXS = 0; - - insns.add(new LdcInsnNode(this.name)); ctorMAXS++; - insns.add(this.methodIsStatic ? new InsnNode(Opcodes.ACONST_NULL) : new VarInsnNode(Opcodes.ALOAD, 0)); ctorMAXS++; - insns.add(new InsnNode(cancellable ? Opcodes.ICONST_1 : Opcodes.ICONST_0)); ctorMAXS++; - - if (pushReturnValue) - { - insns.add(new VarInsnNode(this.methodReturnType.getOpcode(Opcodes.ILOAD), marshallVar)); - insns.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, this.eventInfoClass, Obf.constructor.name, - EventInfo.getConstructorDescriptor(this.methodReturnType), false)); - } - else - { - insns.add(new MethodInsnNode(Opcodes.INVOKESPECIAL, this.eventInfoClass, Obf.constructor.name, - EventInfo.getConstructorDescriptor(), false)); - } - - return ctorMAXS; - } - - protected String getEventInfoClassName() - { - return EventInfo.getEventInfoClassName(this.methodReturnType).replace('.', '/'); - } - - /** - * if (e.isCancelled()) return e.getReturnValue(); - * - * @param insns - * @param injectionPoint - * @param marshallVar - */ - protected void injectCancellationCode(final InsnList insns, final AbstractInsnNode injectionPoint, int marshallVar) - { - insns.add(new VarInsnNode(Opcodes.ALOAD, marshallVar)); - insns.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, this.eventInfoClass, EventInfo.getIsCancelledMethodName(), - EventInfo.getIsCancelledMethodSig(), false)); - - LabelNode notCancelled = new LabelNode(); - insns.add(new JumpInsnNode(Opcodes.IFEQ, notCancelled)); - - // If this is a void method, just injects a RETURN opcode, otherwise we need to get the return value from the EventInfo - this.injectReturnCode(insns, injectionPoint, marshallVar); - - insns.add(notCancelled); - } - - /** - * Inject the appropriate return code for the method type - * - * @param insns - * @param injectionPoint - * @param eventInfoVar - */ - protected void injectReturnCode(final InsnList insns, final AbstractInsnNode injectionPoint, int eventInfoVar) - { - if (this.methodReturnType.equals(Type.VOID_TYPE)) - { - // Void method, so just return void - insns.add(new InsnNode(Opcodes.RETURN)); - } - else - { - // Non-void method, so work out which accessor to call to get the return value, and return it - insns.add(new VarInsnNode(Opcodes.ALOAD, eventInfoVar)); - String accessor = ReturnEventInfo.getReturnAccessor(this.methodReturnType); - String descriptor = ReturnEventInfo.getReturnDescriptor(this.methodReturnType); - insns.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, this.eventInfoClass, accessor, descriptor, false)); - if (this.methodReturnType.getSort() == Type.OBJECT) - { - insns.add(new TypeInsnNode(Opcodes.CHECKCAST, this.methodReturnType.getInternalName())); - } - insns.add(new InsnNode(this.methodReturnType.getOpcode(Opcodes.IRETURN))); - } - } - - /** - * Add this event to the specified handler - * - * @param handler - */ - void addToHandler(MethodNode handler) - { - LiteLoaderLogger.debug("Adding event %s to handler %s", this.name, handler.name); - - Event.getEventsForHandlerMethod(handler).add(this); - this.injectionCount++; - } - - /** - * Add a listener for this event, the listener - * - * @param listener - * @return fluent interface - */ - public Event addListener(MethodInfo listener) - { - if (listener.hasDesc()) - { - throw new IllegalArgumentException("Descriptor is not allowed for listener methods"); - } - - if (this.pendingInjections != null && this.pendingInjections.size() == 0) - { - throw new EventAlreadyInjectedException("The event " + this.name - + " was already injected and has 0 pending injections, addListener() is not allowed at this point"); - } - - this.listeners.add(listener); - - return this; - } - - /** - * Get currently registered listeners for this event - */ - public Set getListeners() - { - return Collections.unmodifiableSet(this.listeners); - } - - /** - * Get an event by name (case insensitive) - * - * @param eventName - */ - static Event getEvent(String eventName) - { - for (Event event : Event.events) - if (event.name.equalsIgnoreCase(eventName)) - { - return event; - } - - return null; - } - - /** - * Populates the event proxy class with delegating methods for all injected - * events. - * - * @param classNode - * @param proxyIndex - */ - static ClassNode populateProxy(final ClassNode classNode, int proxyIndex) - { - int handlerCount = 0; - int invokeCount = 0; - int lineNumber = proxyIndex < 2 ? 210 : 10; // From EventProxy.java, this really is only to try and make stack traces a bit easier to read - - LiteLoaderLogger.info("Generating new Event Handler Proxy Class %s", classNode.name.replace('/', '.')); - - Map> handlerMethods = Event.proxyHandlerMethods.get(Event.proxyInnerClassIndex); - Event.proxyInnerClassIndex++; - - // Loop through all handlers and inject a method for each one - for (Entry> handler : handlerMethods.entrySet()) - { - MethodNode handlerMethod = handler.getKey(); - List handlerEvents = handler.getValue(); - - // Args is used to inject appropriate LOAD opcodes to put the method arguments on the stack for each handler invocation - Type[] args = Type.getArgumentTypes(handlerMethod.desc); - - // Add our generated method to the the class - classNode.methods.add(handlerMethod); - handlerCount++; - - InsnList insns = handlerMethod.instructions; - for (Event event : handlerEvents) - { - Set listeners = event.listeners; - if (listeners.size() > 0) - { - LabelNode tryCatchStart = new LabelNode(); - LabelNode tryCatchEnd = new LabelNode(); - LabelNode tryCatchHandler1 = new LabelNode(); - LabelNode tryCatchHandler2 = new LabelNode(); - LabelNode tryCatchExit = new LabelNode(); - - handlerMethod.tryCatchBlocks.add(new TryCatchBlockNode(tryCatchStart, tryCatchEnd, - tryCatchHandler1, "java/lang/NoSuchMethodError")); - handlerMethod.tryCatchBlocks.add(new TryCatchBlockNode(tryCatchStart, tryCatchEnd, - tryCatchHandler2, "java/lang/NoClassDefFoundError")); - - insns.add(tryCatchStart); // try { - - for (MethodInfo listener : listeners) - { - invokeCount++; - - LabelNode lineNumberLabel = new LabelNode(new Label()); - insns.add(lineNumberLabel); - insns.add(new LineNumberNode(++lineNumber, lineNumberLabel)); - - ByteCodeUtilities.loadArgs(args, insns, 0); - insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, listener.ownerRef, listener.getOrInflectName(event.name), - handlerMethod.desc, false)); - } - - insns.add(tryCatchEnd); // } - insns.add(new JumpInsnNode(Opcodes.GOTO, tryCatchExit)); - - insns.add(tryCatchHandler1); // catch (NoSuchMethodError err) { - insns.add(new VarInsnNode(Opcodes.ALOAD, 0)); - insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Obf.EventProxy.ref, "onMissingHandler", - "(Ljava/lang/Error;Lcom/mumfrey/liteloader/transformers/event/EventInfo;)V", false)); - insns.add(new JumpInsnNode(Opcodes.GOTO, tryCatchExit)); - - insns.add(tryCatchHandler2); // } catch (NoClassDefFoundError err) { - insns.add(new VarInsnNode(Opcodes.ALOAD, 0)); - insns.add(new MethodInsnNode(Opcodes.INVOKESTATIC, Obf.EventProxy.ref, "onMissingClass", - "(Ljava/lang/Error;Lcom/mumfrey/liteloader/transformers/event/EventInfo;)V", false)); - insns.add(new JumpInsnNode(Opcodes.GOTO, tryCatchExit)); - - insns.add(tryCatchExit); // } - } - } - - insns.add(new InsnNode(Opcodes.RETURN)); - } - - LiteLoaderLogger.info("Successfully generated event handler proxy class with %d handlers(s) and %d total invocations", - handlerCount, invokeCount); - - return classNode; - } - - private static List addMethodToActiveProxy(MethodNode handlerMethod) - { - Event.resizeProxyList(); - - ArrayList events = new ArrayList(); - Event.proxyHandlerMethods.get(Event.proxyInnerClassIndex).put(handlerMethod, events); - return events; - } - - private static void resizeProxyList() - { - while (Event.proxyHandlerMethods.size() < Event.proxyInnerClassIndex + 1) - { - Event.proxyHandlerMethods.add(new LinkedHashMap>()); - } - } - - private static List getEventsForHandlerMethod(MethodNode handlerMethod) - { - for (Map> handlers : Event.proxyHandlerMethods) - { - List events = handlers.get(handlerMethod); - if (events != null) return events; - } - - return Event.addMethodToActiveProxy(handlerMethod); - } - - private static String getHandlerName(int globalEventID) - { - return String.format("$event%05x", globalEventID); - } - - private static String getActiveProxyRef() - { - return Obf.EventProxy.ref + (Event.proxyInnerClassIndex > 1 ? "$" + Event.proxyInnerClassIndex : ""); - } - - @Override - public int compareTo(Event other) - { - if (other == null) return 0; - if (other.priority == this.priority) return this.order - other.order; - return (this.priority - other.priority); - } - - @Override - public int hashCode() - { - return this.name.hashCode(); - } - - @Override - public boolean equals(Object other) - { - if (other == this) return true; - if (other instanceof Event) return ((Event)other).name.equals(this.name); - return false; - } - - @Override - public String toString() - { - return this.name; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventAlreadyInjectedException.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventAlreadyInjectedException.java deleted file mode 100644 index 2d171e51..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventAlreadyInjectedException.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mumfrey.liteloader.transformers.event; - -public class EventAlreadyInjectedException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public EventAlreadyInjectedException(String message) - { - super(message); - } - - public EventAlreadyInjectedException(Throwable cause) - { - super(cause); - } - - public EventAlreadyInjectedException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventInfo.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventInfo.java deleted file mode 100644 index ab2f1596..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventInfo.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.mumfrey.liteloader.transformers.event; - -import org.objectweb.asm.Type; - -import com.mumfrey.liteloader.core.event.Cancellable; -import com.mumfrey.liteloader.core.event.EventCancellationException; - -/** - * Contains information about an injected event, including the source object and - * whether the event is cancellable and/or cancelled. - * - * @author Adam Mummery-Smith - * - * @param Source object type. For non-static methods this will be the - * containing object instance. - */ -public class EventInfo implements Cancellable -{ - protected static final String STRING = "Ljava/lang/String;"; - protected static final String OBJECT = "Ljava/lang/Object;"; - - private final String name; - - private final S source; - - private final boolean cancellable; - - private boolean cancelled; - - public EventInfo(String name, S source, boolean cancellable) - { - this.name = name; - this.source = source; - this.cancellable = cancellable; - } - - public S getSource() - { - return this.source; - } - - public String getName() - { - return this.name; - } - - protected String getSourceClass() - { - return this.source != null ? this.source.getClass().getSimpleName() : null; - } - - @Override - public String toString() - { - return String.format("EventInfo(TYPE=%s,NAME=%s,SOURCE=%s,CANCELLABLE=%s)", this.getClass().getSimpleName(), - this.name, this.getSourceClass(), this.cancellable); - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.core.event.Cancellable#isCancellable() - */ - @Override - public final boolean isCancellable() - { - return this.cancellable; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.transformers.event.Cancellable#isCancelled() - */ - @Override - public final boolean isCancelled() - { - return this.cancelled; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.transformers.event.Cancellable#cancel() - */ - @Override - public void cancel() throws EventCancellationException - { - if (!this.cancellable) - { - throw new EventCancellationException(String.format("The event %s is not cancellable.", this.name)); - } - - this.cancelled = true; - } - - protected static String getEventInfoClassName() - { - return EventInfo.class.getName(); - } - - /** - * @param returnType - */ - protected static String getEventInfoClassName(Type returnType) - { - return returnType.equals(Type.VOID_TYPE) ? EventInfo.class.getName() : ReturnEventInfo.class.getName(); - } - - public static String getConstructorDescriptor(Type returnType) - { - if (returnType.equals(Type.VOID_TYPE)) - { - return EventInfo.getConstructorDescriptor(); - } - - if (returnType.getSort() == Type.OBJECT) - { - return String.format("(%s%sZ%s)V", EventInfo.STRING, EventInfo.OBJECT, EventInfo.OBJECT); - } - - return String.format("(%s%sZ%s)V", EventInfo.STRING, EventInfo.OBJECT, returnType.getDescriptor()); - } - - public static String getConstructorDescriptor() - { - return String.format("(%s%sZ)V", EventInfo.STRING, EventInfo.OBJECT); - } - - public static String getIsCancelledMethodName() - { - return "isCancelled"; - } - - public static String getIsCancelledMethodSig() - { - return "()Z"; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventInjectionTransformer.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventInjectionTransformer.java deleted file mode 100644 index a8d51b07..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventInjectionTransformer.java +++ /dev/null @@ -1,114 +0,0 @@ -package com.mumfrey.liteloader.transformers.event; - -import com.mumfrey.liteloader.transformers.ObfProvider; - -import net.minecraft.launchwrapper.IClassTransformer; - -public abstract class EventInjectionTransformer implements IClassTransformer -{ - public EventInjectionTransformer() - { - try - { - this.addEvents(); - } - catch (Exception ex) - { - ex.printStackTrace(); - } - } - - /* (non-Javadoc) - * @see net.minecraft.launchwrapper.IClassTransformer - * #transform(java.lang.String, java.lang.String, byte[]) - */ - @Override - public byte[] transform(String name, String transformedName, byte[] basicClass) - { - return basicClass; - } - - /** - * Subclasses should register events here - */ - protected abstract void addEvents(); - - /** - * Register a new event to be injected, the event instance will be created - * if it does not already exist. - * - * @param eventName Name of the event to use/create. Beware that - * IllegalArgumentException if the event was already defined with - * incompatible parameters - * @param targetMethod Method descriptor to identify the method to inject - * into - * @param injectionPoint Delegate which finds the location(s) in the target - * method to inject into - * - * @return the event - for fluent interface - */ - protected final Event addEvent(String eventName, MethodInfo targetMethod, InjectionPoint injectionPoint) - { - return this.addEvent(Event.getOrCreate(eventName), targetMethod, injectionPoint); - } - - /** - * Register an event to be injected - * - * @param event Event to inject - * @param targetMethod Method descriptor to identify the method to inject - * into - * @param injectionPoint Delegate which finds the location(s) in the target - * method to inject into - * - * @return the event - for fluent interface - */ - protected final Event addEvent(Event event, MethodInfo targetMethod, InjectionPoint injectionPoint) - { - if (event == null) - { - throw new IllegalArgumentException("Event cannot be null!"); - } - - if (injectionPoint == null) - { - throw new IllegalArgumentException("Injection point cannot be null for event " + event.getName()); - } - - if ("true".equals(System.getProperty("mcpenv"))) - { - EventTransformer.addEvent(event, targetMethod.owner, targetMethod.sig, injectionPoint); - } - else - { - EventTransformer.addEvent(event, targetMethod.owner, targetMethod.sigSrg, injectionPoint); - EventTransformer.addEvent(event, targetMethod.ownerObf, targetMethod.sigObf, injectionPoint); - } - - event.addPendingInjection(targetMethod); - - return event; - } - - /** - * Register an access injection interface - * - * @param interfaceName - */ - protected final void addAccessor(String interfaceName) - { - EventTransformer.addAccessor(interfaceName); - } - - /** - * Register an access injection interface and provide a contextual - * obfuscation provider. - * - * @param interfaceName - * @param obfProvider - */ - protected final void addAccessor(String interfaceName, ObfProvider obfProvider) - { - EventTransformer.addAccessor(interfaceName, obfProvider); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventProxyTransformer.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventProxyTransformer.java deleted file mode 100644 index cc513f37..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventProxyTransformer.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.mumfrey.liteloader.transformers.event; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.InsnNode; -import org.objectweb.asm.tree.MethodNode; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.ClassTransformer; - -/** - * Transformer responsible for transforming/generating the EventProxy inner - * classes, separated from the Event Transformer itself so that we can place it - * higher up the tranformer chain to avoid broken mod transformers screwing - * things up. - * - * @author Adam Mummery-Smith - */ -public class EventProxyTransformer extends ClassTransformer -{ - public EventProxyTransformer() - { - } - - @Override - public byte[] transform(String name, String transformedName, byte[] basicClass) - { - if (transformedName != null && transformedName.startsWith(Obf.EventProxy.name)) - { - int dollarPos = transformedName.indexOf('$'); - int proxyIndex = (dollarPos > -1) ? Integer.parseInt(transformedName.substring(dollarPos + 1)) : 0; - if (proxyIndex != 1) - { - try - { - return this.transformEventProxy(transformedName, basicClass, proxyIndex); - } - catch (Throwable th) - { - th.printStackTrace(); - } - } - } - - return basicClass; - } - - private byte[] transformEventProxy(String transformedName, byte[] basicClass, int proxyIndex) - { - ClassNode classNode = this.getProxyByteCode(transformedName, basicClass, proxyIndex); - return this.writeClass(Event.populateProxy(classNode, proxyIndex == 0 ? 1 : proxyIndex)); - } - - private ClassNode getProxyByteCode(String transformedName, byte[] basicClass, int proxyIndex) - { - if (proxyIndex == 0 || basicClass != null) - { - ClassNode classNode = this.readClass(basicClass, true); - - for (MethodNode method : classNode.methods) - { - // Strip the sanity code out of the EventProxy class initialiser - if ("".equals(method.name)) - { - method.instructions.clear(); - method.instructions.add(new InsnNode(Opcodes.RETURN)); - } - } - - return classNode; - } - - ClassNode classNode = new ClassNode(); - classNode.visit(50, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, transformedName.replace('.', '/'), null, "java/lang/Object", null); - return classNode; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventTransformer.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventTransformer.java deleted file mode 100644 index ba701766..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/EventTransformer.java +++ /dev/null @@ -1,417 +0,0 @@ -package com.mumfrey.liteloader.transformers.event; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.TreeSet; - -import org.apache.commons.io.FileUtils; -import org.apache.logging.log4j.core.helpers.Booleans; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.ClassNode; -import org.objectweb.asm.tree.LocalVariableNode; -import org.objectweb.asm.tree.MethodNode; -import org.objectweb.asm.util.CheckClassAdapter; -import com.google.common.collect.Maps; -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.ByteCodeUtilities; -import com.mumfrey.liteloader.transformers.ClassTransformer; -import com.mumfrey.liteloader.transformers.ObfProvider; -import com.mumfrey.liteloader.transformers.access.AccessorTransformer; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -/** - * EventTransformer is the spiritual successor to the - * CallbackInjectionTransformer and is a more advanced and flexible - * version of the same premise. Like the CallbackInjectionTransformer, it can be - * used to inject callbacks intelligently into a target method, however it has - * the following additional capabilities which make it more flexible and - * scalable: - * - *
    - *
  • Injections are not restricted to RETURN opcodes or profiler - * invocations, each injection is determined by supplying an InjectionPoint - * instance to the {@code addEvent} method which is used to find the - * injection point(s) in the method.
  • - * - *
  • Injected events can optionally be specified as *cancellable* which - * allows method execution to be pre-emptively halted based on the - * cancellation status of the event. For methods with a return value, the - * return value may be specified by the event handler.
  • - * - *
  • Injected events call back against a dynamically-generated proxy - * class, this means that it is no longer necessary to provide your own - * implementation of a static callback proxy, events can call back directly - * against handler methods in your own codebase.
  • - * - *
  • Event injections are more intelligent about injecting at arbitrary - * points in the bytecode without corrupting the local stack, and increase - * MAXS as required.
  • - * - *
  • Event injections do not "collide" like callback injections do - this - * means that if multiple events are injected by multiple sources at the - * same point in the bytecode, then all event handlers will receive and - * handle the event in one go. To provide for this, each event handler is - * defined with an intrinsic "priority" which determines its call order when - * this situation occurs
  • - *
- * - * @author Adam Mummery-Smith - */ -public final class EventTransformer extends ClassTransformer -{ - public static final boolean DUMP = Booleans.parseBoolean(System.getProperty("liteloader.debug.dump"), false); - - public static final boolean VALIDATE = Booleans.parseBoolean(System.getProperty("liteloader.debug.validate"), false); - - /** - * Multidimensional map of class names -> target method signatures -> events - * to inject. - */ - private static Map>> eventMappings = Maps.newHashMap(); - - private static AccessorTransformer accessorTransformer; - - private int globalEventID = 0; - - static class Injection - { - private final AbstractInsnNode node; - - private final boolean captureLocals; - - private final Set events = new TreeSet(); - - private boolean hasLocals = false; - - private LocalVariableNode[] locals; - - public Injection(AbstractInsnNode node, boolean captureLocals) - { - this.node = node; - this.captureLocals = captureLocals; - } - - public AbstractInsnNode getNode() - { - return this.node; - } - - public Set getEvents() - { - return this.events; - } - - public LocalVariableNode[] getLocals() - { - return this.locals; - } - - public Type[] getLocalTypes() - { - if (this.locals == null) return null; - - Type[] localTypes = new Type[this.locals.length]; - for (int l = 0; l < this.locals.length; l++) - { - if (this.locals[l] != null) - { - localTypes[l] = Type.getType(this.locals[l].desc); - } - } - return localTypes; - } - - public boolean hasLocals() - { - return this.hasLocals; - } - - public void setLocals(LocalVariableNode[] locals) - { - this.hasLocals = true; - if (locals == null) return; - this.locals = locals; - } - - public boolean captureLocals() - { - return this.captureLocals; - } - - public void checkCaptureLocals(InjectionPoint injectionPoint) - { - if (injectionPoint.captureLocals != this.captureLocals) - { - throw new RuntimeException("Overlapping injection points defined with incompatible settings. Attempting to handle " - + injectionPoint + " with capture locals [" + injectionPoint.captureLocals + "] but already defined injection point with [" - + this.captureLocals + "]"); - } - } - - public void add(Event event) - { - this.events.add(event); - } - - public int size() - { - return this.events.size(); - } - - public Event getHead() - { - return this.events.iterator().next(); - } - - public void addEventsToHandler(MethodNode handler) - { - for (Event event : this.events) - { - event.addToHandler(handler); - } - } - - public boolean isCancellable() - { - boolean cancellable = false; - for (Event event : this.events) - cancellable |= event.isCancellable(); - return cancellable; - } - } - - static void addEvent(Event event, String className, String signature, InjectionPoint injectionPoint) - { - Map> mappings = EventTransformer.eventMappings.get(className); - if (mappings == null) - { - mappings = new HashMap>(); - EventTransformer.eventMappings.put(className, mappings); - } - - Map events = mappings.get(signature); - if (events == null) - { - events = new LinkedHashMap(); - mappings.put(signature, events); - } - - events.put(event, injectionPoint); - } - - static void addAccessor(String interfaceName) - { - EventTransformer.addAccessor(interfaceName, null); - } - - static void addAccessor(String interfaceName, ObfProvider obfProvider) - { - if (EventTransformer.accessorTransformer == null) - { - EventTransformer.accessorTransformer = new AccessorTransformer() - { - @Override - protected void addAccessors() {} - }; - } - - EventTransformer.accessorTransformer.addAccessor(interfaceName, obfProvider); - } - - @Override - public final byte[] transform(String name, String transformedName, byte[] basicClass) - { - if (basicClass != null && EventTransformer.eventMappings.containsKey(transformedName)) - { - return this.injectEvents(name, transformedName, basicClass, EventTransformer.eventMappings.get(transformedName)); - } - - if (EventTransformer.accessorTransformer != null) - { - return EventTransformer.accessorTransformer.transform(name, transformedName, basicClass); - } - - return basicClass; - } - - private byte[] injectEvents(String name, String transformedName, byte[] basicClass, Map> mappings) - { - if (mappings == null) return basicClass; - - ClassNode classNode = this.readClass(basicClass, true); - - for (MethodNode method : classNode.methods) - { - String signature = MethodInfo.generateSignature(method.name, method.desc); - Map methodInjections = mappings.get(signature); - if (methodInjections != null) - { - this.injectIntoMethod(classNode, signature, method, methodInjections); - } - } - - if (EventTransformer.accessorTransformer != null) - { - EventTransformer.accessorTransformer.apply(name, transformedName, basicClass, classNode); - } - - if (EventTransformer.VALIDATE) - { - ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES); - classNode.accept(new CheckClassAdapter(writer)); - } - - byte[] bytes = this.writeClass(classNode); - - if (EventTransformer.DUMP) - { - try - { - FileUtils.writeByteArrayToFile(new File(".classes/" + Obf.lookupMCPName(transformedName).replace('.', '/') + ".class"), bytes); - } - catch (IOException ex) {} - } - - return bytes; - } - - /** - * @param classNode - * @param signature - * @param method - * @param methodInjections - */ - void injectIntoMethod(ClassNode classNode, String signature, MethodNode method, Map methodInjections) - { - Map injectionPoints = this.findInjectionPoints(classNode, method, methodInjections); - - for (Entry injectionPoint : injectionPoints.entrySet()) - { - this.injectEventsAt(classNode, method, injectionPoint.getKey(), injectionPoint.getValue()); - } - - for (Event event : methodInjections.keySet()) - { - event.notifyInjected(method.name, method.desc, classNode.name); - event.detach(); - } - } - - /** - * @param classNode - * @param method - * @param methodInjections - */ - private Map findInjectionPoints(ClassNode classNode, MethodNode method, Map methodInjections) - { - ReadOnlyInsnList insns = new ReadOnlyInsnList(method.instructions); - Collection nodes = new ArrayList(32); - Map injectionPoints = new LinkedHashMap(); - for (Entry eventEntry : methodInjections.entrySet()) - { - Event event = eventEntry.getKey(); - event.attach(method); - InjectionPoint injectionPoint = eventEntry.getValue(); - nodes.clear(); - if (injectionPoint.find(method.desc, insns, nodes, event)) - { - for (AbstractInsnNode node : nodes) - { - Injection injection = injectionPoints.get(node); - if (injection == null) - { - injection = new Injection(node, injectionPoint.captureLocals()); - injectionPoints.put(node, injection); - } - else - { - injection.checkCaptureLocals(injectionPoint); - } - - if (injectionPoint.captureLocals() && !injection.hasLocals()) - { - LocalVariableNode[] locals = ByteCodeUtilities.getLocalsAt(classNode, method, node); - injection.setLocals(locals); - if (injectionPoint.logLocals()) - { - int startPos = ByteCodeUtilities.getFirstNonArgLocalIndex(method); - - LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); - LiteLoaderLogger.debug("Logging local variables for " + injectionPoint); - for (int i = startPos; i < locals.length; i++) - { - LocalVariableNode local = locals[i]; - if (local != null) - { - LiteLoaderLogger.debug(" Local[%d] %s %s", i, ByteCodeUtilities.getTypeName(Type.getType(local.desc)), - local.name); - } - } - LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); - } - } - - injection.add(event); - } - } - } - - return injectionPoints; - } - - /** - * @param classNode - * @param method - * @param injectionPoint - * @param injection - */ - private void injectEventsAt(ClassNode classNode, MethodNode method, AbstractInsnNode injectionPoint, Injection injection) - { - Event head = injection.getHead(); - - Verbosity verbosity = head.isVerbose() ? Verbosity.NORMAL : Verbosity.VERBOSE; - LiteLoaderLogger.info(verbosity, "Injecting %s[x%d] in %s in %s", head.getName(), injection.size(), method.name, - ClassTransformer.getSimpleClassName(classNode)); - - MethodNode handler = head.inject(injectionPoint, injection.isCancellable(), this.globalEventID, injection.captureLocals(), - injection.getLocalTypes()); - injection.addEventsToHandler(handler); - - this.globalEventID++; - } - - public static void dumpInjectionState() - { - int uninjectedCount = 0; - int eventCount = 0; - - LiteLoaderLogger.debug("EventInjectionTransformer: Injection State"); - LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); - for (Entry>> mapping : EventTransformer.eventMappings.entrySet()) - { - LiteLoaderLogger.debug("Class: %s", mapping.getKey()); - for (Entry> classMapping : mapping.getValue().entrySet()) - { - LiteLoaderLogger.debug(" Method: %s", classMapping.getKey()); - for (Event event : classMapping.getValue().keySet()) - { - uninjectedCount += event.dumpInjectionState(); - eventCount++; - } - } - } - LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); - LiteLoaderLogger.debug("Listed %d injection candidates with %d uninjected", eventCount, uninjectedCount); - LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/InjectionPoint.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/InjectionPoint.java deleted file mode 100644 index 63f148de..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/InjectionPoint.java +++ /dev/null @@ -1,331 +0,0 @@ -package com.mumfrey.liteloader.transformers.event; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashSet; -import java.util.List; - -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.InsnList; - -import com.google.common.base.Joiner; - -/** - * Base class for injection point discovery classes. Each subclass describes a - * strategy for locating code injection points within a method, with the - * {@link #find} method populating a collection with insn nodes from the method - * which satisfy its strategy. - * - *

This base class also contains composite strategy factory methods such as - * {@code and} and {@code or} which allow strategies to be combined using - * intersection (and) or union (or) relationships to allow multiple strategies - * to be easily combined.

- * - *

You are free to create your own injection point subclasses, but take note - * that it is allowed for a single InjectionPoint instance to be used for - * multiple injections and thus implementing classes MUST NOT cache the insn - * list, event, or nodes instance passed to the {@code find} method, as each - * call to {@code find} must be considered a separate functional contract and - * the InjectionPoint's lifespan is not linked to the discovery lifespan, - * therefore it is important that the InjectionPoint implementation is fully - * STATELESS.

- * - * @author Adam Mummery-Smith - */ -public abstract class InjectionPoint -{ - /** - * Capture locals as well as args - */ - protected boolean captureLocals; - - protected boolean logLocals; - - /** - * Find injection points in the supplied insn list - * - * @param desc Method descriptor, supplied to allow return types and - * arguments etc. to be determined - * @param insns Insn list to search in, the strategy MUST ONLY add nodes - * from this list to the {@code nodes} collection - * @param nodes Collection of nodes to populate. Injectors should NOT make - * any assumptions about the state of this collection and should only - * call add() - * @param event Event being injected here, supplied to allow alteration of - * behaviour for specific event configurations (eg. cancellable) - * @return true if one or more injection points were found - */ - public abstract boolean find(String desc, InsnList insns, Collection nodes, Event event); - - /** - * Set whether this injection point should capture local variables as well - * as method arguments. - * - * @param captureLocals - * @return this, for fluent interface - */ - public InjectionPoint setCaptureLocals(boolean captureLocals) - { - this.captureLocals = captureLocals; - return this; - } - - /** - * Get whether capture locals is enabled - */ - public boolean captureLocals() - { - return this.captureLocals; - } - - /** - * Since it's virtually impossible to know what locals are available at a - * given injection point by reading the source, this method causes the - * injection point to dump the locals to the debug log at injection time. - * - * @param logLocals - * @return this, for fluent interface - */ - public InjectionPoint setLogLocals(boolean logLocals) - { - this.logLocals = logLocals; - return this; - } - - /** - * Get whether log locals is enabled - */ - public boolean logLocals() - { - return this.logLocals; - } - - @Override - public String toString() - { - return "InjectionPoint(" + this.getClass().getSimpleName() + ")"; - } - - /** - * Composite injection point - * - * @author Adam Mummery-Smith - */ - abstract static class CompositeInjectionPoint extends InjectionPoint - { - protected final InjectionPoint[] components; - - protected CompositeInjectionPoint(InjectionPoint... components) - { - if (components == null || components.length < 2) - { - throw new IllegalArgumentException("Must supply two or more component injection points for composite point!"); - } - - this.components = components; - - for (InjectionPoint component : this.components) - { - this.captureLocals |= component.captureLocals; - this.logLocals |= component.logLocals; - } - } - - @Override - public String toString() - { - return "CompositeInjectionPoint(" + this.getClass().getSimpleName() + ")[" + Joiner.on(',').join(this.components) + "]"; - } - } - - static final class Intersection extends InjectionPoint.CompositeInjectionPoint - { - public Intersection(InjectionPoint... points) - { - super(points); - } - - @Override - public boolean find(String desc, InsnList insns, Collection nodes, Event event) - { - boolean found = false; - - @SuppressWarnings("unchecked") - ArrayList[] allNodes = new ArrayList[this.components.length]; - - for (int i = 0; i < this.components.length; i++) - { - allNodes[i] = new ArrayList(); - this.components[i].find(desc, insns, allNodes[i], event); - } - - ArrayList alpha = allNodes[0]; - for (int nodeIndex = 0; nodeIndex < alpha.size(); nodeIndex++) - { - AbstractInsnNode node = alpha.get(nodeIndex); - boolean in = true; - - for (int b = 1; b < allNodes.length; b++) - { - if (!allNodes[b].contains(node)) - { - break; - } - } - - if (!in) continue; - - nodes.add(node); - found = true; - } - - return found; - } - } - - static final class Union extends InjectionPoint.CompositeInjectionPoint - { - public Union(InjectionPoint... points) - { - super(points); - } - - @Override - public boolean find(String desc, InsnList insns, Collection nodes, Event event) - { - LinkedHashSet allNodes = new LinkedHashSet(); - - for (int i = 0; i < this.components.length; i++) - { - this.components[i].find(desc, insns, allNodes, event); - } - - nodes.addAll(allNodes); - - return allNodes.size() > 0; - } - } - - static final class Shift extends InjectionPoint - { - private final InjectionPoint input; - private final int shift; - - public Shift(InjectionPoint input, int shift) - { - if (input == null) - { - throw new IllegalArgumentException("Must supply an input injection point for SHIFT"); - } - - this.input = input; - this.shift = shift; - } - - @Override - public InjectionPoint setCaptureLocals(boolean captureLocals) - { - return this.input.setCaptureLocals(captureLocals); - } - - @Override - public boolean captureLocals() - { - return this.input.captureLocals(); - } - - @Override - public InjectionPoint setLogLocals(boolean logLocals) - { - return this.input.setLogLocals(logLocals); - } - - @Override - public boolean logLocals() - { - return this.input.logLocals(); - } - - @Override - public String toString() - { - return "InjectionPoint(" + this.getClass().getSimpleName() + ")[" + this.input + "]"; - } - - @Override - public boolean find(String desc, InsnList insns, Collection nodes, Event event) - { - List list = (nodes instanceof List) ? (List)nodes : new ArrayList(nodes); - - this.input.find(desc, insns, nodes, event); - - for (int i = 0; i < list.size(); i++) - { - list.set(i, insns.get(insns.indexOf(list.get(i)) + this.shift)); - } - - if (nodes != list) - { - nodes.clear(); - nodes.addAll(list); - } - - return nodes.size() > 0; - } - } - - /** - * Returns a composite injection point which returns the intersection of - * nodes from all component injection points - * - * @param operands - */ - public static InjectionPoint and(InjectionPoint... operands) - { - return new InjectionPoint.Intersection(operands); - } - - /** - * Returns a composite injection point which returns the union of nodes from - * all component injection points. - * - * @param operands - */ - public static InjectionPoint or(InjectionPoint... operands) - { - return new InjectionPoint.Union(operands); - } - - /** - * Returns an injection point which returns all insns immediately following - * insns from the supplied injection point. - * - * @param point - */ - public static InjectionPoint after(InjectionPoint point) - { - return new InjectionPoint.Shift(point, 1); - } - - /** - * Returns an injection point which returns all insns immediately prior to - * insns from the supplied injection point. - * - * @param point - */ - public static InjectionPoint before(InjectionPoint point) - { - return new InjectionPoint.Shift(point, -1); - } - - /** - * Returns an injection point which returns all insns offset by the - * specified "count" from insns from the supplied injection point. - * - * @param point - */ - public static InjectionPoint shift(InjectionPoint point, int count) - { - return new InjectionPoint.Shift(point, count); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/Jump.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/Jump.java deleted file mode 100644 index 723c2415..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/Jump.java +++ /dev/null @@ -1,54 +0,0 @@ -//package com.mumfrey.liteloader.transformers.event; -// -//import org.objectweb.asm.Opcodes; -//import org.objectweb.asm.tree.AbstractInsnNode; -//import org.objectweb.asm.tree.InsnList; -//import org.objectweb.asm.tree.InsnNode; -//import org.objectweb.asm.tree.JumpInsnNode; -//import org.objectweb.asm.tree.MethodInsnNode; -//import org.objectweb.asm.tree.VarInsnNode; -// -//public class Jump extends Event -//{ -// Jump(String name, boolean cancellable, int priority) -// { -// super(name, cancellable, priority); -// } -// -// @Override -// protected void validate(AbstractInsnNode injectionPoint, boolean cancellable, int globalEventID) -// { -// if (!(injectionPoint instanceof JumpInsnNode)) -// { -// throw new IllegalArgumentException("Attempted to inject a JUMP event where no JUMP is present"); -// } -// -// super.validate(injectionPoint, cancellable, globalEventID); -// } -// -// @Override -// protected void injectCancellationCode(InsnList insns, AbstractInsnNode injectionPoint, int eventInfoVar) throws IllegalArgumentException -// { -// int opcode = injectionPoint.getOpcode(); -// -// if (opcode == Opcodes.JSR) throw new IllegalArgumentException("Can't jump on finally clause"); -// -// if (opcode == Opcodes.IFEQ || opcode == Opcodes.IFNE || opcode == Opcodes.IFLT || opcode == Opcodes.IFGE -// || opcode == Opcodes.IFGT || opcode == Opcodes.IFLE || opcode == Opcodes.IFNULL || opcode == Opcodes.IFNONNULL) -// { -// insns.add(new InsnNode(Opcodes.POP)); -// } -// -// if (opcode == Opcodes.IF_ICMPEQ || opcode == Opcodes.IF_ICMPNE || opcode == Opcodes.IF_ICMPLT || opcode == Opcodes.IF_ICMPGE -// || opcode == Opcodes.IF_ICMPGT || opcode == Opcodes.IF_ICMPLE || opcode == Opcodes.IF_ACMPEQ || opcode == Opcodes.IF_ACMPNE) -// { -// insns.add(new InsnNode(Opcodes.POP)); -// insns.add(new InsnNode(Opcodes.POP)); -// } -// -// insns.add(new VarInsnNode(Opcodes.ALOAD, eventInfoVar)); -// insns.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, this.eventInfoClass, "isCancelled", "()Z")); -// -// ((JumpInsnNode)injectionPoint).setOpcode(Opcodes.IFEQ); -// } -//} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/MethodInfo.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/MethodInfo.java deleted file mode 100644 index 364b58dc..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/MethodInfo.java +++ /dev/null @@ -1,375 +0,0 @@ -package com.mumfrey.liteloader.transformers.event; - -import joptsimple.internal.Strings; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.ByteCodeUtilities; - -/** - * Encapsulates a method descriptor with varying degrees of accuracy from a - * simpler owner/method mapping up to and including a multi-faceted - * notch/srg/mcp method descriptor which works in all obfuscation environments. - * - * @author Adam Mummery-Smith - */ -public class MethodInfo -{ - public static final String INFLECT = Strings.EMPTY; - - // Owning class - final String owner; - final String ownerRef; - final String ownerObf; - - // Method name - final String name; - final String nameSrg; - final String nameObf; - - // Descriptor - final String desc; - final String descObf; - - // "Signature" - method name plus descriptor - final String sig; - final String sigSrg; - final String sigObf; - - /** - * Create a MethodInfo for the specified class with a method name inflected - * by context - * - * @param owner Literal owner class name - */ - public MethodInfo(String owner) - { - this(owner, owner, MethodInfo.INFLECT, MethodInfo.INFLECT, MethodInfo.INFLECT, null, null); - } - - /** - * Create a MethodInfo for the specified class with a method name inflected - * by context - * - * @param owner Owner name descriptor - */ - public MethodInfo(Obf owner) - { - this(owner.name, owner.obf, MethodInfo.INFLECT, MethodInfo.INFLECT, MethodInfo.INFLECT, null, null); - } - - /** - * Create a MethodInfo for the specified class and method names (literal) - * - * @param owner Literal owner class name - * @param method Literal method name - */ - public MethodInfo(String owner, String method) - { - this(owner, owner, method, method, method, null, null); - } - - /** - * Create a MethodInfo for the specified class and literal method name - * - * @param owner Owner name descriptor - * @param method Literal method name - */ - public MethodInfo(Obf owner, String method) - { - this(owner.name, owner.obf, method, method, method, null, null); - } - - /** - * Create a MethodInfo for the specified class and method name - * - * @param owner Owner name descriptor - * @param method Literal method name - */ - public MethodInfo(Obf owner, Obf method) - { - this(owner.name, owner.obf, method.name, method.srg, method.obf, null, null); - } - - /** - * Create a MethodInfo for the specified class, literal method name and - * literal descriptor - * - * @param owner Owner name descriptor - * @param method Literal method name - * @param descriptor Literal descriptor (useful for methods which only - * accept primitive types and therefore have a fixed descriptor) - */ - public MethodInfo(Obf owner, String method, String descriptor) - { - this(owner.name, owner.obf, method, method, method, descriptor, descriptor); - } - - /** - * Create a MethodInfo for the specified literal class, literal method and - * literal descriptor - * - * @param owner Literal class name - * @param method Literal method name - * @param descriptor Literal descriptor (useful for methods which only - * accept primitive types and therefore have a fixed descriptor) - */ - public MethodInfo(String owner, String method, String descriptor) - { - this(owner, owner, method, method, method, descriptor, descriptor); - } - - /** - * Create a MethodInfo for the specified class and method, with a literal - * descriptor - * - * @param owner Owner class name descriptor - * @param method Method name descriptor - * @param descriptor Literal descriptor (useful for methods which only - * accept primitive types and therefore have a fixed descriptor) - */ - public MethodInfo(Obf owner, Obf method, String descriptor) - { - this(owner.name, owner.obf, method.name, method.srg, method.obf, descriptor, descriptor); - } - - /** - *

Create a MethodInfo for the specified class and literal method and - * compute the descriptor using the supplied arguments, both the returnType - * and args values can be one of four types:

- * - *
    - *
  • Obf instances - are converted to the appropriate class - * name for the obf type internally
  • - *
  • Strings - are added directly to the descriptor
  • - *
  • Type instances - are expanded to their bytecode literal - *
  • - *
  • Class instances - are expanded to their bytecode - * descriptor via Type.getDescriptor
  • - *
- * - * @param owner Owner name descriptor - * @param method Literal method name - * @param returnType Return type for the method (use Void.TYPE for void - * methods) - * @param args (optional) list of method arguments as Obf/String/Type/Class - * instances - */ - public MethodInfo(Obf owner, String method, Object returnType, Object... args) - { - this(owner.name, owner.obf, method, method, method, - ByteCodeUtilities.generateDescriptor(Obf.MCP, returnType, args), - ByteCodeUtilities.generateDescriptor(Obf.OBF, returnType, args)); - } - - /** - *

Create a MethodInfo for the specified class and method names and - * compute the descriptor using the supplied arguments, both the returnType - * and args values can be one of four types:

- * - *
    - *
  • Obf instances - are converted to the appropriate class - * name for the obf type internally
  • - *
  • Strings - are added directly to the descriptor
  • - *
  • Type instances - are expanded to their bytecode literal - *
  • - *
  • Class instances - are expanded to their bytecode - * descriptor via Type.getDescriptor
  • - *
- * - * @param owner Owner name descriptor - * @param method Method name descriptor - * @param returnType Return type for the method (use Void.TYPE for void - * methods) - * @param args (optional) list of method arguments as Obf/String/Type/Class - * instances - */ - public MethodInfo(Obf owner, Obf method, Object returnType, Object... args) - { - this(owner.name, owner.obf, method.name, method.srg, method.obf, - ByteCodeUtilities.generateDescriptor(Obf.MCP, returnType, args), - ByteCodeUtilities.generateDescriptor(Obf.OBF, returnType, args)); - } - - /** - * @param owner - * @param ownerObf - * @param name - * @param nameSrg - * @param nameObf - * @param desc - * @param descObf - */ - MethodInfo(String owner, String ownerObf, String name, String nameSrg, String nameObf, String desc, String descObf) - { - this.owner = owner.replace('/', '.'); - this.ownerRef = owner.replace('.', '/'); - this.ownerObf = ownerObf; - this.name = name; - this.nameSrg = nameSrg; - this.nameObf = nameObf; - this.desc = desc; - this.descObf = descObf; - this.sig = MethodInfo.generateSignature(this.name, this.desc); - this.sigSrg = MethodInfo.generateSignature(this.nameSrg, this.desc); - this.sigObf = MethodInfo.generateSignature(this.nameObf, this.descObf); - } - - /** - * Get the method's owning class - */ - public String getOwner() - { - return this.owner; - } - - /** - * Get the method's owning class's obfuscated name (if it has one, otherwise - * returns the same as getOwner()) - */ - public String getOwnerObf() - { - return this.ownerObf; - } - - /** - * Get all owner variants in an array - */ - public String[] getOwners() - { - return new String[] { this.ownerObf, this.owner, this.owner }; - } - - /** - * Get the method's name - */ - public String getName() - { - return this.name; - } - - /** - * Get the method name or inflects it using the supplied context if this - * MethodInfo was created with inflection enabled - */ - public String getOrInflectName(String context) - { - return this.name == MethodInfo.INFLECT ? context : this.name; - } - - /** - * Get the Searge name of the method (if it has one, otherwise returns the - * base name) - */ - public String getNameSrg() - { - return this.nameSrg; - } - - /** - * Get the obfuscated name of the method (if it has one, otherwise returns - * the base name) - */ - public String getNameObf() - { - return this.nameObf; - } - - /** - * Get all name variants in an array - */ - public String[] getNames() - { - return new String[] { this.nameObf, this.nameSrg, this.name }; - } - - /** - * Get the method descriptor - */ - public String getDesc() - { - return this.desc; - } - - /** - * Get the method descriptor with obfuscated parameter types (if available, - * otherwise returns the same as getDesc()) - */ - public String getDescObf() - { - return this.descObf; - } - - /** - * Get all descriptors in an array - */ - public String[] getDescriptors() - { - return this.desc == null ? null : new String[] { this.descObf, this.desc, this.desc }; - } - - /** - * Returns true if this MethodInfo has a descriptor - */ - public boolean hasDesc() - { - return this.desc != null; - } - - /** - * Get the signature (combined method name and descriptor) for the method - * represented by this methodInfo - * - * @param type Obfuscation type to use - */ - public String getSignature(int type) - { - if (type == Obf.OBF) return this.sigObf; - if (type == Obf.SRG) return this.sigSrg; - return this.sig; - } - - public boolean matches(String method, String desc) - { - return this.matches(method, desc, null); - } - - public boolean matches(String method, String desc, String className) - { - if ((className == null || this.ownerRef.equals(className)) && (this.name.equals(method) || this.nameSrg.equals(method))) - { - return this.desc == null || this.desc.equals(desc); - } - else if ((className == null || this.ownerObf.equals(className)) && this.nameObf.equals(method)) - { - return this.descObf == null || this.descObf.equals(desc); - } - - return false; - } - - static String generateSignature(String methodName, String methodSignature) - { - return String.format("%s%s", methodName, methodSignature == null ? "" : methodSignature); - } - - @Override - public boolean equals(Object other) - { - if (other == this) return true; - if (other instanceof MethodInfo) return this.sig.equals(((MethodInfo)other).sig); - if (other instanceof String) return this.sig.equals(other); - return false; - } - - @Override - public String toString() - { - return this.sig; - } - - @Override - public int hashCode() - { - return this.sig.hashCode(); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/ReadOnlyInsnList.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/ReadOnlyInsnList.java deleted file mode 100644 index b8f4ec8f..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/ReadOnlyInsnList.java +++ /dev/null @@ -1,147 +0,0 @@ -package com.mumfrey.liteloader.transformers.event; - -import java.util.ListIterator; - -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.InsnList; - -/** - * Read-only wrapper for InsnList - * - * @author Adam Mummery-Smith - */ -public class ReadOnlyInsnList extends InsnList -{ - private InsnList insnList; - - public ReadOnlyInsnList(InsnList insns) - { - this.insnList = insns; - } - - void dispose() - { - this.insnList = null; - } - - @Override - public void set(AbstractInsnNode location, AbstractInsnNode insn) - { - throw new UnsupportedOperationException(); - } - - @Override - public void add(AbstractInsnNode insn) - { - throw new UnsupportedOperationException(); - } - - @Override - public void add(InsnList insns) - { - throw new UnsupportedOperationException(); - } - - @Override - public void insert(AbstractInsnNode insn) - { - throw new UnsupportedOperationException(); - } - - @Override - public void insert(InsnList insns) - { - throw new UnsupportedOperationException(); - } - - @Override - public void insert(AbstractInsnNode location, AbstractInsnNode insn) - { - throw new UnsupportedOperationException(); - } - - @Override - public void insert(AbstractInsnNode location, InsnList insns) - { - throw new UnsupportedOperationException(); - } - - @Override - public void insertBefore(AbstractInsnNode location, AbstractInsnNode insn) - { - throw new UnsupportedOperationException(); - } - - @Override - public void insertBefore(AbstractInsnNode location, InsnList insns) - { - throw new UnsupportedOperationException(); - } - - @Override - public void remove(AbstractInsnNode insn) - { - throw new UnsupportedOperationException(); - } - - @Override - public AbstractInsnNode[] toArray() - { -// throw new UnsupportedOperationException(); - return this.insnList.toArray(); - } - - @Override - public int size() - { - return this.insnList.size(); - } - - @Override - public AbstractInsnNode getFirst() - { - return this.insnList.getFirst(); - } - - @Override - public AbstractInsnNode getLast() - { - return this.insnList.getLast(); - } - - @Override - public AbstractInsnNode get(int index) - { - return this.insnList.get(index); - } - - @Override - public boolean contains(AbstractInsnNode insn) - { - return this.insnList.contains(insn); - } - - @Override - public int indexOf(AbstractInsnNode insn) - { - return this.insnList.indexOf(insn); - } - - @Override - public ListIterator iterator() - { - return this.insnList.iterator(); - } - - @Override - public ListIterator iterator(int index) - { - return this.insnList.iterator(index); - } - - @Override - public void resetLabels() - { - this.insnList.resetLabels(); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/ReturnEventInfo.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/ReturnEventInfo.java deleted file mode 100644 index 81d69c92..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/ReturnEventInfo.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.mumfrey.liteloader.transformers.event; - -import org.objectweb.asm.Type; - -import com.mumfrey.liteloader.core.event.EventCancellationException; - -/** - * EventInfo for events which have a return type - * - * @author Adam Mummery-Smith - * - * @param Source object type. For non-static methods this will be the - * containing object instance. - * @param Return type - */ -public class ReturnEventInfo extends EventInfo -{ - private R returnValue; - - public ReturnEventInfo(String name, S source, boolean cancellable) - { - super(name, source, cancellable); - this.returnValue = null; - } - - public ReturnEventInfo(String name, S source, boolean cancellable, R returnValue) - { - super(name, source, cancellable); - this.returnValue = returnValue; - } - - @SuppressWarnings("unchecked") - public ReturnEventInfo(String name, S source, boolean cancellable, byte returnValue) - { - super(name, source, cancellable); - this.returnValue = (R)Byte.valueOf(returnValue); - } - - @SuppressWarnings("unchecked") - public ReturnEventInfo(String name, S source, boolean cancellable, char returnValue) - { - super(name, source, cancellable); - this.returnValue = (R)Character.valueOf(returnValue); - } - - @SuppressWarnings("unchecked") - public ReturnEventInfo(String name, S source, boolean cancellable, double returnValue) - { - super(name, source, cancellable); - this.returnValue = (R)Double.valueOf(returnValue); - } - - @SuppressWarnings("unchecked") - public ReturnEventInfo(String name, S source, boolean cancellable, float returnValue) - { - super(name, source, cancellable); - this.returnValue = (R)Float.valueOf(returnValue); - } - - @SuppressWarnings("unchecked") - public ReturnEventInfo(String name, S source, boolean cancellable, int returnValue) - { - super(name, source, cancellable); - this.returnValue = (R)Integer.valueOf(returnValue); - } - - @SuppressWarnings("unchecked") - public ReturnEventInfo(String name, S source, boolean cancellable, long returnValue) - { - super(name, source, cancellable); - this.returnValue = (R)Long.valueOf(returnValue); - } - - @SuppressWarnings("unchecked") - public ReturnEventInfo(String name, S source, boolean cancellable, short returnValue) - { - super(name, source, cancellable); - this.returnValue = (R)Short.valueOf(returnValue); - } - - @SuppressWarnings("unchecked") - public ReturnEventInfo(String name, S source, boolean cancellable, boolean returnValue) - { - super(name, source, cancellable); - this.returnValue = (R)Boolean.valueOf(returnValue); - } - - /** - * Sets a return value for this event and cancels the event (required in - * order to return the new value). - * - * @param returnValue - */ - public void setReturnValue(R returnValue) throws EventCancellationException - { - super.cancel(); - - this.returnValue = returnValue; - } - - public R getReturnValue() - { - return this.returnValue; - } - - // CHECKSTYLE:OFF - - // All of the accessors below are to avoid having to generate unboxing conversions in bytecode - public byte getReturnValueB() { if (this.returnValue == null) return 0; return (Byte) this.returnValue; } - public char getReturnValueC() { if (this.returnValue == null) return 0; return (Character)this.returnValue; } - public double getReturnValueD() { if (this.returnValue == null) return 0.0; return (Double) this.returnValue; } - public float getReturnValueF() { if (this.returnValue == null) return 0.0F; return (Float) this.returnValue; } - public int getReturnValueI() { if (this.returnValue == null) return 0; return (Integer) this.returnValue; } - public long getReturnValueJ() { if (this.returnValue == null) return 0; return (Long) this.returnValue; } - public short getReturnValueS() { if (this.returnValue == null) return 0; return (Short) this.returnValue; } - public boolean getReturnValueZ() { if (this.returnValue == null) return false; return (Boolean) this.returnValue; } - - // CHECKSTYLE:ON - - - public static String getReturnAccessor(Type returnType) - { - if (returnType.getSort() == Type.OBJECT) - { - return "getReturnValue"; - } - - return String.format("getReturnValue%s", returnType.getDescriptor()); - } - - public static String getReturnDescriptor(Type returnType) - { - if (returnType.getSort() == Type.OBJECT) - { - return String.format("()%s", EventInfo.OBJECT); - } - - return String.format("()%s", returnType.getDescriptor()); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeFieldAccess.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeFieldAccess.java deleted file mode 100644 index 6afe5fb4..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeFieldAccess.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.inject; - -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.FieldInsnNode; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.event.MethodInfo; - -/** - * An injection point which searches for GETFIELD and SETFIELD opcodes matching - * its arguments and returns a list of insns immediately prior to matching - * instructions. Only the field name is required, owners and signatures are - * optional and can be used to disambiguate between fields of the same name but - * with different types, or belonging to different classes. - * - * @author Adam Mummery-Smith - */ -public class BeforeFieldAccess extends BeforeInvoke -{ - private final int opcode; - - public BeforeFieldAccess(int opcode, String... fieldNames) - { - super(fieldNames); - this.opcode = opcode; - } - - public BeforeFieldAccess(int opcode, String fieldName, int ordinal) - { - super(fieldName, ordinal); - this.opcode = opcode; - } - - public BeforeFieldAccess(int opcode, String[] fieldNames, int ordinal) - { - super(fieldNames, ordinal); - this.opcode = opcode; - } - - public BeforeFieldAccess(int opcode, String[] fieldNames, String[] fieldOwners) - { - super(fieldNames, fieldOwners); - this.opcode = opcode; - } - - public BeforeFieldAccess(int opcode, String[] fieldNames, String[] fieldOwners, int ordinal) - { - super(fieldNames, fieldOwners, ordinal); - this.opcode = opcode; - } - - public BeforeFieldAccess(int opcode, String[] fieldNames, String[] fieldOwners, String[] fieldSignatures) - { - super(fieldNames, fieldOwners, fieldSignatures); - this.opcode = opcode; - } - - public BeforeFieldAccess(int opcode, String[] fieldNames, String[] fieldOwners, String[] fieldSignatures, int ordinal) - { - super(fieldNames, fieldOwners, fieldSignatures, ordinal); - this.opcode = opcode; - } - - public BeforeFieldAccess(int opcode, Obf fieldNames, int ordinal) - { - super(fieldNames.names, ordinal); - this.opcode = opcode; - } - - public BeforeFieldAccess(int opcode, Obf fieldNames, Obf fieldOwners) - { - super(fieldNames.names, fieldOwners.names); - this.opcode = opcode; - } - - public BeforeFieldAccess(int opcode, Obf fieldNames, Obf fieldOwners, int ordinal) - { - super(fieldNames.names, fieldOwners.names, ordinal); - this.opcode = opcode; - } - - public BeforeFieldAccess(int opcode, MethodInfo fieldInfo) - { - super(fieldInfo); - this.opcode = opcode; - } - - public BeforeFieldAccess(int opcode, MethodInfo fieldInfo, int ordinal) - { - super(fieldInfo, ordinal); - this.opcode = opcode; - } - - @Override - protected boolean matchesInsn(AbstractInsnNode insn) - { - return insn instanceof FieldInsnNode && ((FieldInsnNode)insn).getOpcode() == this.opcode; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeInvoke.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeInvoke.java deleted file mode 100644 index e37002f1..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeInvoke.java +++ /dev/null @@ -1,387 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.inject; - -import java.util.Collection; -import java.util.ListIterator; - -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.FieldInsnNode; -import org.objectweb.asm.tree.InsnList; -import org.objectweb.asm.tree.MethodInsnNode; - -import com.mumfrey.liteloader.transformers.ClassTransformer; -import com.mumfrey.liteloader.transformers.event.Event; -import com.mumfrey.liteloader.transformers.event.InjectionPoint; -import com.mumfrey.liteloader.transformers.event.MethodInfo; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * An injection point which searches for method invocations matching its - * arguments and returns a list of insns immediately prior to matching - * invocations. Only the method name is required, owners and signatures are - * optional and can be used to disambiguate between methods of the same name but - * with different args, or belonging to different classes. - * - * @author Adam Mummery-Smith - */ -public class BeforeInvoke extends InjectionPoint -{ - protected class InsnInfo - { - public final String owner; - public final String name; - public final String desc; - - public InsnInfo(AbstractInsnNode insn) - { - if (insn instanceof MethodInsnNode) - { - MethodInsnNode methodNode = (MethodInsnNode)insn; - this.owner = methodNode.owner; - this.name = methodNode.name; - this.desc = methodNode.desc; - } - else if (insn instanceof FieldInsnNode) - { - FieldInsnNode fieldNode = (FieldInsnNode)insn; - this.owner = fieldNode.owner; - this.name = fieldNode.name; - this.desc = fieldNode.desc; - } - else - { - throw new IllegalArgumentException("insn must be an instance of MethodInsnNode or FieldInsnNode"); - } - } - } - - /** - * Method name(s) to search for, usually this will contain the different - * names of the method for different obfuscations (mcp, srg, notch) - */ - protected final String[] methodNames; - - /** - * Method owner(s) to search for, the values in this array MUST much the - * equivalent indices in methodNames, if the array is NULL then all owners - * are valid. - */ - protected final String[] methodOwners; - - /** - * Method signature(s) to search for, the values in this array MUST much the - * equivalent indices in methodNames, if the array is NULL then all - * signatures are valid. - */ - protected final String[] methodSignatures; - - /** - * This strategy can be used to identify a particular invocation if the same - * method is invoked at multiple points, if this value is -1 then the - * strategy returns ALL invocations of the method. - */ - protected final int ordinal; - - /** - * True to turn on strategy debugging to the console - */ - protected boolean logging = false; - - protected final String className; - - /** - * Match all occurrences of the specified method or methods - * - * @param methodNames Method name(s) to search for - */ - public BeforeInvoke(String... methodNames) - { - this(methodNames, null, -1); - } - - /** - * Match the specified invocation of the specified method - * - * @param methodName Method name to search for - * @param ordinal ID of the invocation to hook, or -1 to hook all - * invocations - */ - public BeforeInvoke(String methodName, int ordinal) - { - this(new String[] { methodName }, null, null, ordinal); - } - - /** - * Match the specified invocation of the specified method(s) - * - * @param methodNames Method names to search for - * @param ordinal ID of the invocation to hook, or -1 to hook all - * invocations - */ - public BeforeInvoke(String[] methodNames, int ordinal) - { - this(methodNames, null, null, ordinal); - } - - /** - * Match all occurrences of the specified method or methods with the - * specified owners. - * - * @param methodNames Method names to search for - * @param methodOwners Owners to search for, indices in this array MUST - * match the indices in methodNames, eg. if methodNames contains - * { "mcpName", "func_12345_a", "a" } then methodOwners should contain - * { "net/minecraft/pkg/ClsName", "net/minecraft/pkg/ClsName", "abc" } - * in order that the appropriate owner name obfuscation matches the - * corresponding index in the methodNames array - */ - public BeforeInvoke(String[] methodNames, String[] methodOwners) - { - this(methodNames, methodOwners, null, -1); - } - - /** - * Match the specified invocation of the specified method or methods with - * the specified owners. - * - * @param methodNames Method names to search for - * @param methodOwners Owners to search for, indices in this array MUST - * match the indices in methodNames, eg. if methodNames contains - * { "mcpName", "func_12345_a", "a" } then methodOwners should contain - * { "net/minecraft/pkg/ClsName", "net/minecraft/pkg/ClsName", "abc" } - * in order that the appropriate owner name obfuscation matches the - * corresponding index in the methodNames array - * @param ordinal ID of the invocation to hook or -1 to hook all invocations - */ - public BeforeInvoke(String[] methodNames, String[] methodOwners, int ordinal) - { - this(methodNames, methodOwners, null, ordinal); - } - - /** - * Match all occurrences of the specified method or methods with the - * specified owners or signatures, pass null to the owners array if you only - * want to match signatures. - * - * @param methodNames Method names to search for - * @param methodOwners Owners to search for, indices in this array MUST - * match the indices in methodNames, eg. if methodNames contains - * { "mcpName", "func_12345_a", "a" } then methodOwners should contain - * { "net/minecraft/pkg/ClsName", "net/minecraft/pkg/ClsName", "abc" } - * in order that the appropriate owner name obfuscation matches the - * corresponding index in the methodNames array - * @param methodSignatures Signatures to search for, indices in this array - * MUST match the indices in methodNames, eg. if methodNames contains - * { "mcpName", "func_12345_a", "a" } then methodSignatures should - * contain - * { "(Lnet/minecraft/pkg/ClsName;)V", - * "(Lnet/minecraft/pkg/ClsName;)V", "(Labc;)V" } - * in order that the appropriate signature obfuscation matches the - * corresponding index in the methodNames array (and ownerNames array - * if present) - */ - public BeforeInvoke(String[] methodNames, String[] methodOwners, String[] methodSignatures) - { - this(methodNames, methodOwners, methodSignatures, -1); - } - - /** - * Match the specified invocation of the specified method or methods with - * the specified owners or signatures, pass null to the owners array if you - * only want to match signatures. - * - * @param methodNames Method names to search for - * @param methodOwners Owners to search for, indices in this array MUST - * match the indices in methodNames, eg. if methodNames contains - * { "mcpName", "func_12345_a", "a" } then methodOwners should contain - * { "net/minecraft/pkg/ClsName", "net/minecraft/pkg/ClsName", "abc" } - * in order that the appropriate owner name obfuscation matches the - * corresponding index in the methodNames array - * @param methodSignatures Signatures to search for, indices in this array - * MUST match the indices in methodNames, eg. if methodNames contains - * { "mcpName", "func_12345_a", "a" } then methodSignatures should - * contain { "(Lnet/minecraft/pkg/ClassName;)V", - * "(Lnet/minecraft/pkg/ClassName;)V", "(Labc;)V" } - * in order that the appropriate signature obfuscation matches the - * corresponding index in the methodNames array (and ownerNames array - * if present) - * @param ordinal ID of the invocation to hook or -1 to hook all invocations - */ - public BeforeInvoke(String[] methodNames, String[] methodOwners, String[] methodSignatures, int ordinal) - { - if (methodNames == null || methodNames.length == 0) - { - throw new IllegalArgumentException("Method name selector must not be null"); - } - - if (methodSignatures != null && methodSignatures.length == 0) methodSignatures = null; - if (methodOwners != null && methodOwners.length == 0) methodOwners = null; - if (ordinal < 0) ordinal = -1; - - this.methodNames = methodNames; - this.methodOwners = methodOwners; - this.methodSignatures = methodSignatures; - this.ordinal = ordinal; - this.className = this.getClass().getSimpleName(); - - this.convertClassRefs(); - } - - /** - * Match the invocation described by the supplied MethodInfo - * - * @param method - */ - public BeforeInvoke(MethodInfo method) - { - this(method, -1); - } - - /** - * Match the invocation described by the supplied MethodInfo at the - * specified ordinal. - * - * @param method - * @param ordinal - */ - public BeforeInvoke(MethodInfo method, int ordinal) - { - this.methodNames = method.getNames(); - this.methodOwners = method.getOwners(); - this.methodSignatures = method.getDescriptors(); - this.ordinal = ordinal; - this.className = this.getClass().getSimpleName(); - - this.convertClassRefs(); - } - - private void convertClassRefs() - { - for (int i = 0; i < this.methodOwners.length; i++) - { - if (this.methodOwners[i] != null) this.methodOwners[i] = this.methodOwners[i].replace('.', '/'); - } - - if (this.methodSignatures != null) - { - for (int i = 0; i < this.methodSignatures.length; i++) - { - if (this.methodSignatures[i] != null) this.methodSignatures[i] = this.methodSignatures[i].replace('.', '/'); - } - } - } - - public BeforeInvoke setLogging(boolean logging) - { - this.logging = logging; - return this; - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.transformers.event.InjectionStrategy - * #findInjectionPoint(java.lang.String, - * org.objectweb.asm.tree.InsnList, - * com.mumfrey.liteloader.transformers.event.Event, - * java.util.Collection) - */ - @Override - public boolean find(String desc, InsnList insns, Collection nodes, Event event) - { - int ordinal = 0; - boolean found = false; - - if (this.logging) - { - LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); - LiteLoaderLogger.debug(this.className + " is searching for an injection point in method with descriptor %s", desc); - } - - ListIterator iter = insns.iterator(); - while (iter.hasNext()) - { - AbstractInsnNode insn = iter.next(); - - if (this.matchesInsn(insn)) - { - InsnInfo nodeInfo = new InsnInfo(insn); - - if (this.logging) - { - LiteLoaderLogger.debug(this.className + " is considering insn NAME=%s DESC=%s OWNER=%s", - nodeInfo.name, nodeInfo.desc, nodeInfo.owner); - } - - int index = BeforeInvoke.arrayIndexOf(this.methodNames, nodeInfo.name, -1); - if (index > -1 && this.logging) LiteLoaderLogger.debug(this.className + " found a matching insn, checking owner/signature..."); - - int ownerIndex = BeforeInvoke.arrayIndexOf(this.methodOwners, nodeInfo.owner, index); - int descIndex = BeforeInvoke.arrayIndexOf(this.methodSignatures, nodeInfo.desc, index); - if (index > -1 && ownerIndex == index && descIndex == index) - { - if (this.logging) LiteLoaderLogger.debug(this.className + " found a matching insn, checking preconditions..."); - if (this.matchesInsn(nodeInfo, ordinal)) - { - if (this.logging) LiteLoaderLogger.debug(this.className + " found a matching insn at ordinal %d", ordinal); - nodes.add(insn); - found = true; - - if (this.ordinal == ordinal) - { - break; - } - } - - ordinal++; - } - } - - this.inspectInsn(desc, insns, insn); - } - - if (this.logging) LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); - - return found; - } - - protected boolean matchesInsn(AbstractInsnNode insn) - { - return insn instanceof MethodInsnNode; - } - - protected void inspectInsn(String desc, InsnList insns, AbstractInsnNode insn) - { - // stub for subclasses - } - - protected boolean matchesInsn(InsnInfo nodeInfo, int ordinal) - { - if (this.logging) - { - LiteLoaderLogger.debug(this.className + " comparing target ordinal %d with current ordinal %d", this.ordinal, ordinal); - } - return this.ordinal == -1 || this.ordinal == ordinal; - } - - /** - * Special version of contains which returns TRUE if the haystack array is - * null, which is an odd behaviour we actually want here because null - * indicates that the value is not important. - * - * @param haystack - * @param needle - */ - private static int arrayIndexOf(String[] haystack, String needle, int pos) - { - if (haystack == null) return pos; - if (pos > -1 && pos < haystack.length && needle.equals(haystack[pos])) return pos; - - for (int index = 0; index < haystack.length; index++) - { - if (needle.equals(haystack[index])) - { - return index; - } - } - - return -1; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeNew.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeNew.java deleted file mode 100644 index 9c218157..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeNew.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.inject; - -import java.util.Collection; -import java.util.ListIterator; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.InsnList; -import org.objectweb.asm.tree.TypeInsnNode; - -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.event.Event; -import com.mumfrey.liteloader.transformers.event.InjectionPoint; - -public class BeforeNew extends InjectionPoint -{ - private final String[] classNames; - - private final int ordinal; - - public BeforeNew(Obf className) - { - this(-1, className.names); - } - - public BeforeNew(String... classNames) - { - this(-1, classNames); - } - - public BeforeNew(int ordinal, Obf className) - { - this(ordinal, className.names); - } - - public BeforeNew(int ordinal, String... classNames) - { - this.ordinal = Math.max(-1, ordinal); - this.classNames = classNames; - - for (int i = 0; i < this.classNames.length; i++) - { - this.classNames[i] = this.classNames[i].replace('.', '/'); - } - } - - @Override - public boolean find(String desc, InsnList insns, Collection nodes, Event event) - { - boolean found = false; - int ordinal = 0; - - ListIterator iter = insns.iterator(); - while (iter.hasNext()) - { - AbstractInsnNode insn = iter.next(); - - if (insn instanceof TypeInsnNode && insn.getOpcode() == Opcodes.NEW && this.matchesOwner((TypeInsnNode)insn)) - { - if (this.ordinal == -1 || this.ordinal == ordinal) - { - nodes.add(insn); - found = true; - } - - ordinal++; - } - } - - return found; - } - - private boolean matchesOwner(TypeInsnNode insn) - { - for (String className : this.classNames) - { - if (className.equals(insn.desc)) return true; - } - - return false; - } - -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeReturn.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeReturn.java deleted file mode 100644 index d35ac9d5..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeReturn.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.inject; - -import java.util.Collection; -import java.util.ListIterator; - -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.InsnList; -import org.objectweb.asm.tree.InsnNode; - -import com.mumfrey.liteloader.transformers.event.Event; -import com.mumfrey.liteloader.transformers.event.InjectionPoint; - -/** - * An injection point which searches for RETURN opcodes in the supplied method - * and either finds all insns or the insn at the specified ordinal. - * - * @author Adam Mummery-Smith - */ -public class BeforeReturn extends InjectionPoint -{ - private final int ordinal; - - public BeforeReturn() - { - this(-1); - } - - public BeforeReturn(int ordinal) - { - this.ordinal = Math.max(-1, ordinal); - } - - @Override - public boolean find(String desc, InsnList insns, Collection nodes, Event event) - { - boolean found = false; - int returnOpcode = Type.getReturnType(desc).getOpcode(Opcodes.IRETURN); - int ordinal = 0; - - ListIterator iter = insns.iterator(); - while (iter.hasNext()) - { - AbstractInsnNode insn = iter.next(); - - if (insn instanceof InsnNode && insn.getOpcode() == returnOpcode) - { - if (this.ordinal == -1 || this.ordinal == ordinal) - { - nodes.add(insn); - found = true; - } - - ordinal++; - } - } - - return found; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeStringInvoke.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeStringInvoke.java deleted file mode 100644 index 91e24815..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/BeforeStringInvoke.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.inject; - -import java.util.Collection; - -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.InsnList; -import org.objectweb.asm.tree.LdcInsnNode; - -import com.mumfrey.liteloader.transformers.event.Event; -import com.mumfrey.liteloader.transformers.event.MethodInfo; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * An injection point which searches for a matching String LDC insn immediately - * prior to a qualifying invoke. - * - * @author Adam Mummery-Smith - */ -public class BeforeStringInvoke extends BeforeInvoke -{ - private static final String STRING_VOID_SIG = "(Ljava/lang/String;)V"; - - private final String ldcValue; - - private boolean foundLdc; - - public BeforeStringInvoke(String ldcValue, MethodInfo method) - { - this(ldcValue, method, -1); - } - - public BeforeStringInvoke(String ldcValue, MethodInfo method, int ordinal) - { - super(method, ordinal); - this.ldcValue = ldcValue; - - for (int i = 0; i < this.methodSignatures.length; i++) - { - if (!STRING_VOID_SIG.equals(this.methodSignatures[i])) - { - throw new IllegalArgumentException("BeforeStringInvoke requires method with with signature " + STRING_VOID_SIG); - } - } - } - - @Override - public boolean find(String desc, InsnList insns, Collection nodes, Event event) - { - this.foundLdc = false; - - return super.find(desc, insns, nodes, event); - } - - @Override - protected void inspectInsn(String desc, InsnList insns, AbstractInsnNode insn) - { - if (insn instanceof LdcInsnNode) - { - LdcInsnNode node = (LdcInsnNode)insn; - if (node.cst instanceof String && this.ldcValue.equals(node.cst)) - { - if (this.logging) LiteLoaderLogger.info("BeforeInvoke found a matching LDC with value %s", node.cst); - this.foundLdc = true; - return; - } - } - - this.foundLdc = false; - } - - @Override - protected boolean matchesInsn(InsnInfo nodeInfo, int ordinal) - { - if (this.logging) LiteLoaderLogger.debug("BeforeInvoke foundLdc \"%s\" = %s", this.ldcValue, this.foundLdc); - return this.foundLdc && super.matchesInsn(nodeInfo, ordinal); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/JumpInsnPoint.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/JumpInsnPoint.java deleted file mode 100644 index 9469b423..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/JumpInsnPoint.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.inject; - -import java.util.Collection; -import java.util.ListIterator; - -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.InsnList; -import org.objectweb.asm.tree.JumpInsnNode; - -import com.mumfrey.liteloader.transformers.event.Event; -import com.mumfrey.liteloader.transformers.event.InjectionPoint; - -/** - * An injection point which searches for JUMP opcodes (if, try/catch, continue, - * break, conditional assignment, etc.) with either a particular opcode or at a - * particular ordinal in the method body (eg. "the Nth JUMP insn" where N is the - * ordinal of the instruction). By default it returns all JUMP instructions in a - * method body. - * - * @author Adam Mummery-Smith - */ -public class JumpInsnPoint extends InjectionPoint -{ - private final int opCode; - - private final int ordinal; - - public JumpInsnPoint() - { - this(0, -1); - } - - public JumpInsnPoint(int ordinal) - { - this(0, ordinal); - } - - public JumpInsnPoint(int opCode, int ordinal) - { - this.opCode = opCode; - this.ordinal = ordinal; - } - - @Override - public boolean find(String desc, InsnList insns, Collection nodes, Event event) - { - boolean found = false; - int ordinal = 0; - - ListIterator iter = insns.iterator(); - while (iter.hasNext()) - { - AbstractInsnNode insn = iter.next(); - - if (insn instanceof JumpInsnNode && (this.opCode == -1 || insn.getOpcode() == this.opCode)) - { - if (this.ordinal == -1 || this.ordinal == ordinal) - { - nodes.add(insn); - found = true; - } - - ordinal++; - } - } - - return found; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/MethodHead.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/MethodHead.java deleted file mode 100644 index 0b62586d..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/inject/MethodHead.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.inject; - -import java.util.Collection; - -import org.objectweb.asm.tree.AbstractInsnNode; -import org.objectweb.asm.tree.InsnList; - -import com.mumfrey.liteloader.transformers.event.Event; -import com.mumfrey.liteloader.transformers.event.InjectionPoint; - -/** - * An injection point which locates the first instruction in a method body - * - * @author Adam Mummery-Smith - */ -public class MethodHead extends InjectionPoint -{ - public MethodHead() - { - } - - @Override - public boolean find(String desc, InsnList insns, Collection nodes, Event event) - { - nodes.add(insns.getFirst()); - return true; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/InvalidEventJsonException.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/InvalidEventJsonException.java deleted file mode 100644 index 320730d7..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/InvalidEventJsonException.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.json; - -public class InvalidEventJsonException extends RuntimeException -{ - private static final long serialVersionUID = 1L; - - public InvalidEventJsonException() - { - } - - public InvalidEventJsonException(String message) - { - super(message); - } - - public InvalidEventJsonException(Throwable cause) - { - super(cause); - } - - public InvalidEventJsonException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonDescriptor.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonDescriptor.java deleted file mode 100644 index e8c0e265..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonDescriptor.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.json; - -import java.io.Serializable; -import java.util.UUID; - -import com.google.gson.annotations.SerializedName; -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.event.MethodInfo; - -/** - * A JSON method descriptor, - * - * @author Adam Mummery-Smith - */ -public class JsonDescriptor implements Serializable -{ - private static final long serialVersionUID = 1L; - - /** - * Key used to refer to this method descriptor elsewhere - */ - @SerializedName("id") - private String key; - - /** - * Name of the class which owns this method - */ - @SerializedName("owner") - private String owner; - - /** - * Method name - */ - @SerializedName("name") - private String name; - - /** - * Method return type, assumes VOID if none specified - */ - @SerializedName("return") - private String returnType; - - /** - * Argument types for the method - */ - @SerializedName("args") - private String[] argumentTypes; - - /** - * Get the key used to refer to this method descriptor - */ - public String getKey() - { - if (this.key == null) - { - this.key = "UserDescriptor" + UUID.randomUUID().toString(); - } - - return this.key; - } - - /** - * @param obfTable - * @return MethodInfo for this descriptor - */ - public MethodInfo parse(JsonObfuscationTable obfTable) - { - if (this.owner == null || this.name == null) - { - throw new InvalidEventJsonException("Method descriptor was invalid, must specify owner and name!"); - } - - Obf owner = obfTable.parseClass(this.owner); - Obf name = obfTable.parseMethod(this.name); - - if (this.argumentTypes == null && this.returnType == null) - { - return new MethodInfo(owner, name); - } - - Object returnType = obfTable.parseType(this.returnType == null ? "VOID" : this.returnType); - Object[] args = (this.argumentTypes != null ? new Object[this.argumentTypes.length] : new Object[0]); - if (this.argumentTypes != null) - { - for (int arg = 0; arg < this.argumentTypes.length; arg++) - { - args[arg] = obfTable.parseType(this.argumentTypes[arg]); - } - } - - return new MethodInfo(owner, name, returnType, args); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonEvent.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonEvent.java deleted file mode 100644 index 4871ae39..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonEvent.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.json; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; -import com.mumfrey.liteloader.transformers.event.Event; -import com.mumfrey.liteloader.transformers.event.InjectionPoint; -import com.mumfrey.liteloader.transformers.event.MethodInfo; - -/** - * An event definition in JSON, serialisable class read by Gson - * - * @author Adam Mummery-Smith - */ -public class JsonEvent implements Serializable -{ - private static final long serialVersionUID = 1L; - - private static int nextEventID = 0; - - /** - * Event name - */ - @SerializedName("name") - private String name; - - /** - * Whether the event is cancellable - */ - @SerializedName("cancellable") - private boolean cancellable; - - /** - * Event priority (relative to other events at the same injection point) - */ - @SerializedName("priority") - private int priority = 1000; - - /** - * Injection points specified in the JSON file - */ - @SerializedName("injections") - private List jsonInjections; - - /** - * Listeners defined in the JSON file - */ - @SerializedName("listeners") - private List jsonListeners; - - /** - * Listener methods parsed from the JSON - */ - private transient List listeners = new ArrayList(); - - /** - * Get the name of this event - */ - public String getName() - { - if (this.name == null) - { - this.name = "onUserEvent" + (JsonEvent.nextEventID++); - } - - return this.name; - } - - /** - * Get whether this event is cancellable or not - */ - public boolean isCancellable() - { - return this.cancellable; - } - - /** - * Get the event priority - */ - public int getPriority() - { - return this.priority; - } - - /** - * Get the list of listeners parsed from the JSON - */ - public List getListeners() - { - return this.listeners; - } - - /** - * Parse the JSON to initialise this object - */ - public void parse(JsonMethods methods) - { - this.parseInjectionPoints(methods); - this.parseListeners(methods); - } - - /** - * @param methods - */ - private void parseInjectionPoints(JsonMethods methods) - { - if (this.jsonInjections == null || this.jsonInjections.isEmpty()) - { - throw new InvalidEventJsonException("Event " + this.getName() + " does not have any defined injections"); - } - - for (JsonInjection injection : this.jsonInjections) - { - injection.parse(methods); - } - } - - /** - * @param methods - */ - private void parseListeners(JsonMethods methods) - { - if (this.jsonListeners == null || this.jsonListeners.isEmpty()) - { - throw new InvalidEventJsonException("Event " + this.getName() + " does not have any defined listeners"); - } - - for (String listener : this.jsonListeners) - { - this.listeners.add(methods.get(listener)); - } - } - - /** - * @param transformer Transformer to register events with - * @return Event which was registered - */ - public Event register(ModEventInjectionTransformer transformer) - { - Event event = Event.getOrCreate(this.getName(), this.isCancellable(), this.getPriority()); - - for (JsonInjection injection : this.jsonInjections) - { - MethodInfo targetMethod = injection.getMethod(); - InjectionPoint injectionPoint = injection.getInjectionPoint(); - - transformer.registerEvent(event, targetMethod, injectionPoint); - } - - for (MethodInfo listener : this.listeners) - { - event.addListener(listener); - } - - return event; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonEvents.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonEvents.java deleted file mode 100644 index 0eb81491..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonEvents.java +++ /dev/null @@ -1,205 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.json; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.annotations.SerializedName; -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.transformers.ObfProvider; - -/** - * Serialisable class which represents a set of event injection definitions. - * Instances of this class are created by deserialising with JSON. The JSON - * string should be passed to the static {@link #parse} method which returns an - * instance of the class. - * - *

After parsing, the events defined here can be injected into an event - * transformer instance by calling the {@link #register} method.

- * - * @author Adam Mummery-Smith - */ -public class JsonEvents implements Serializable, ObfProvider -{ - private static final long serialVersionUID = 1L; - - private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); - - /** - * Tokens are an instruction to the parser to look up a value rather than - * using a literal. - */ - private static final Pattern tokenPattern = Pattern.compile("^\\$\\{([a-zA-Z0-9_\\-\\.\\$]+)\\}$"); - - /** - * Serialised obfusctation entries - */ - @SerializedName("obfuscation") - private JsonObfuscationTable obfuscation; - - /** - * Serialised method descriptors - */ - @SerializedName("descriptors") - private List descriptors; - - /** - * Serialised events - */ - @SerializedName("events") - private List events; - - /** - * List of accessor interfaces - */ - @SerializedName("accessors") - private List accessors; - - /** - * Parsed method descriptors - */ - private transient JsonMethods methods; - - /** - * Parsed accessors - */ - private transient List accessorInterfaces = new ArrayList(); - - /** - * Attempts to parse the information in this object - */ - private void parse() - { - if (this.obfuscation == null) - { - this.obfuscation = new JsonObfuscationTable(); - } - - try - { - // Parse the obfuscation table - this.obfuscation.parse(); - - // Parse the descriptor list - this.methods = new JsonMethods(this.obfuscation, this.descriptors); - - if (this.events != null) - { - // Parse the events - for (JsonEvent event : this.events) - { - event.parse(this.methods); - } - } - - if (this.accessors != null) - { - for (String accessor : this.accessors) - { - if (accessor != null) - { - Obf accessorName = this.obfuscation.parseClass(accessor); - this.accessorInterfaces.add(accessorName.name); - } - } - } - } - catch (InvalidEventJsonException ex) - { - throw ex; - } - catch (Exception ex) - { - throw new InvalidEventJsonException("An error occurred whilst parsing the event definition: " + ex.getClass().getSimpleName() - + ": " + ex.getMessage(), ex); - } - } - - public boolean hasAccessors() - { - return this.accessorInterfaces.size() > 0; - } - - /** - * Parse a token name, returns the token name as a string if the token is - * valid, or null if the token is not valid - * - * @param token - */ - static String parseToken(String token) - { - token = token.replace(" ", "").trim(); - - Matcher tokenPatternMatcher = JsonEvents.tokenPattern.matcher(token); - if (tokenPatternMatcher.matches()) - { - return tokenPatternMatcher.group(1); - } - - return null; - } - - /** - * Called to register all events defined in this object into the specified - * transformer. - * - * @param transformer - */ - public void register(ModEventInjectionTransformer transformer) - { - for (JsonEvent event : this.events) - { - event.register(transformer); - } - - for (String interfaceName : this.accessorInterfaces) - { - transformer.registerAccessor(interfaceName, this); - } - } - - /* (non-Javadoc) - * @see com.mumfrey.liteloader.transformers.ObfProvider - * #getByName(java.lang.String) - */ - @Override - public Obf getByName(String name) - { - return this.obfuscation.getByName(name); - } - -// public String toJson() -// { -// return JsonEvents.gson.toJson(this); -// } - - /** - * Parse a new JsonEvents object from the supplied JSON string - * - * @param json - * @return new JsonEvents instance - * @throws InvalidEventJsonException if the JSON ins invalid - */ - public static JsonEvents parse(String json) throws InvalidEventJsonException - { - try - { - JsonEvents newJsonEvents = JsonEvents.gson.fromJson(json, JsonEvents.class); - newJsonEvents.parse(); - return newJsonEvents; - } - catch (InvalidEventJsonException ex) - { - throw ex; - } - catch (Throwable th) - { - throw new InvalidEventJsonException("An error occurred whilst parsing the event definition: " + th.getClass().getSimpleName() - + ": " + th.getMessage(), th); - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonInjection.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonInjection.java deleted file mode 100644 index c010329d..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonInjection.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.json; - -import java.io.Serializable; -import java.lang.reflect.Constructor; - -import com.google.gson.annotations.SerializedName; -import com.mumfrey.liteloader.transformers.event.InjectionPoint; -import com.mumfrey.liteloader.transformers.event.MethodInfo; -import com.mumfrey.liteloader.transformers.event.inject.BeforeInvoke; -import com.mumfrey.liteloader.transformers.event.inject.BeforeReturn; -import com.mumfrey.liteloader.transformers.event.inject.BeforeStringInvoke; -import com.mumfrey.liteloader.transformers.event.inject.MethodHead; - -/** - * A JSON injection point definition - * - * @author Adam Mummery-Smith - */ -public class JsonInjection implements Serializable -{ - private static final long serialVersionUID = 1L; - - /** - * Method to inject into - */ - @SerializedName("method") - private String methodName; - - /** - * Type of injection point - */ - @SerializedName("type") - private JsonInjectionType type; - - /** - * Shift type (optional) - */ - @SerializedName("shift") - private JsonInjectionShiftType shift; - - /** - * Target method to search for when using INVOKE and INVOKESTRING - */ - @SerializedName("target") - private String target; - - /** - * Ordinal to use when using INVOKE and INVOKESTRING - */ - @SerializedName("ordinal") - private int ordinal = -1; - - /** - * InjectionPoint class to use for CUSTOM - */ - @SerializedName("class") - private String className; - - /** - * Constructor arguments to pass wehn using CUSTOM - */ - @SerializedName("args") - private Object[] args; - - private transient MethodInfo method; - - private transient InjectionPoint injectionPoint; - - public MethodInfo getMethod() - { - return this.method; - } - - public InjectionPoint getInjectionPoint() - { - return this.injectionPoint; - } - - public void parse(JsonMethods methods) - { - this.method = this.parseMethod(methods); - this.injectionPoint = this.parseInjectionPoint(methods); - } - - private MethodInfo parseMethod(JsonMethods methods) - { - try - { - return methods.get(this.methodName); - } - catch (NullPointerException ex) - { - throw new InvalidEventJsonException("'method' must not be null for injection"); - } - } - - public InjectionPoint parseInjectionPoint(JsonMethods methods) - { - switch (this.type) - { - case INVOKE: - return this.applyShift(new BeforeInvoke(methods.get(this.getTarget()), this.ordinal)); - - case INVOKESTRING: - return this.applyShift(new BeforeStringInvoke(this.getArg(0).toString(), methods.get(this.getTarget()), this.ordinal)); - - case RETURN: - return this.applyShift(new BeforeReturn(this.ordinal)); - - case HEAD: - return new MethodHead(); - - case CUSTOM: - try - { - @SuppressWarnings("unchecked") - Class injectionPointClass = (Class)Class.forName(this.className); - if (this.args != null) - { - Constructor ctor = injectionPointClass.getDeclaredConstructor(Object[].class); - return ctor.newInstance(this.args); - } - return injectionPointClass.newInstance(); - } - catch (Exception ex) - { - throw new RuntimeException(ex); - } - - default: - throw new InvalidEventJsonException("Could not parse injection type"); - } - } - - private Object getArg(int arg) - { - if (this.args == null || this.args.length >= this.args.length || arg < 0) - { - return ""; - } - - return this.args[arg]; - } - - private String getTarget() - { - if (this.target != null && this.shift == null) - { - if (this.target.startsWith("before(") && this.target.endsWith(")")) - { - this.target = this.target.substring(7, this.target.length() - 1); - this.shift = JsonInjectionShiftType.BEFORE; - } - else if (this.target.startsWith("after(") && this.target.endsWith(")")) - { - this.target = this.target.substring(6, this.target.length() - 1); - this.shift = JsonInjectionShiftType.AFTER; - } - } - - if (this.target == null) - { - throw new InvalidEventJsonException("'target' is required for injection type " + this.type.name()); - } - - return this.target; - } - - private InjectionPoint applyShift(InjectionPoint injectionPoint) - { - if (this.shift != null) - { - switch (this.shift) - { - case AFTER: - return InjectionPoint.after(injectionPoint); - - case BEFORE: - return InjectionPoint.before(injectionPoint); - - default: - return injectionPoint; - } - } - - return injectionPoint; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonInjectionShiftType.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonInjectionShiftType.java deleted file mode 100644 index c10ebbb2..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonInjectionShiftType.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.json; - -public enum JsonInjectionShiftType -{ - BEFORE, - AFTER -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonInjectionType.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonInjectionType.java deleted file mode 100644 index ec50a18b..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonInjectionType.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.json; - -public enum JsonInjectionType -{ - INVOKE, - INVOKESTRING, - FIELD, - RETURN, - HEAD, - CUSTOM; -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonMethods.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonMethods.java deleted file mode 100644 index af0315c4..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonMethods.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.json; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.mumfrey.liteloader.core.runtime.Methods; -import com.mumfrey.liteloader.transformers.event.MethodInfo; - -/** - * A simple registry of MethodInfo objects parsed from the JSON, objects which - * consume the specified MethodInfo objects will be passed an instance of this - * object at parse time. - * - * @author Adam Mummery-Smith - */ -public class JsonMethods -{ - /** - * Serialised obfusctation entries - */ - private final JsonObfuscationTable obfuscation; - - /** - * Method descriptors - */ - private final List descriptors; - - /** - * Method descriptors which have been parsed from the descriptors collection - */ - private Map methods = new HashMap(); - - /** - * @param obfuscation - * @param descriptors - */ - public JsonMethods(JsonObfuscationTable obfuscation, List descriptors) - { - this.obfuscation = obfuscation; - this.descriptors = descriptors; - - this.parse(); - } - - /** - * - */ - private void parse() - { - if (this.descriptors != null) - { - for (JsonDescriptor descriptor : this.descriptors) - { - this.methods.put(descriptor.getKey(), descriptor.parse(this.obfuscation)); - } - } - } - - /** - * Fetches a method descriptor by token - * - * @param token - */ - public MethodInfo get(String token) - { - String key = JsonEvents.parseToken(token); - if (key == null) - { - throw new InvalidEventJsonException("\"" + token + "\" is not a valid token"); - } - - MethodInfo method = this.methods.get(key); - if (method != null) - { - return method; - } - - MethodInfo builtinMethod = Methods.getByName(key); - if (builtinMethod != null) - { - return builtinMethod; - } - - throw new InvalidEventJsonException("Could not locate method descriptor with token " + token); - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonObf.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonObf.java deleted file mode 100644 index 54b7c94f..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonObf.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.json; - -import java.io.Serializable; -import java.util.UUID; - -import com.google.gson.annotations.SerializedName; -import com.mumfrey.liteloader.core.runtime.Obf; - -public class JsonObf implements Serializable -{ - private static final long serialVersionUID = 1L; - - @SerializedName("id") - private String key; - - @SerializedName("mcp") - private String mcp; - - @SerializedName("srg") - private String srg; - - @SerializedName("obf") - private String obf; - - public String getKey() - { - if (this.key == null) - { - this.key = "UserObfuscationMapping" + UUID.randomUUID().toString(); - } - - return this.key; - } - - public Obf parse() - { - String seargeName = this.getFirstValidEntry(this.srg, this.mcp, this.obf, this.getKey()); - String obfName = this.getFirstValidEntry(this.obf, this.srg, this.mcp, this.getKey()); - String mcpName = this.getFirstValidEntry(this.mcp, this.srg, this.obf, this.getKey()); - - return new Mapping(seargeName, obfName, mcpName); - } - - private String getFirstValidEntry(String... entries) - { - for (String entry : entries) - { - if (entry != null) return entry; - } - - throw new InvalidEventJsonException("No valid entry found in list!"); - } - - public static class Mapping extends Obf - { - protected Mapping(String seargeName, String obfName, String mcpName) - { - super(seargeName, obfName, mcpName); - } - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonObfuscationTable.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonObfuscationTable.java deleted file mode 100644 index 1cd594e2..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/JsonObfuscationTable.java +++ /dev/null @@ -1,182 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.json; - -import java.io.Serializable; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import com.google.gson.annotations.SerializedName; -import com.mumfrey.liteloader.core.runtime.Obf; -import com.mumfrey.liteloader.core.runtime.Packets; - -/** - * JSON-defined obfuscation table entries used like a registry by the other JSON - * components to look up obfuscation mappings for methods and fields. - * - * @author Adam Mummery-Smith - */ -public class JsonObfuscationTable implements Serializable -{ - private static final long serialVersionUID = 1L; - - @SerializedName("classes") - private List jsonClasses; - - @SerializedName("methods") - private List jsonMethods; - - @SerializedName("fields") - private List jsonFields; - - // Parsed values - private transient Map classObfs = new HashMap(); - private transient Map methodObfs = new HashMap(); - private transient Map fieldObfs = new HashMap(); - - /** - * Parse the entries in each collection to actual Obf objects - */ - public void parse() - { - if (this.jsonClasses != null) - { - for (JsonObf jsonClass : this.jsonClasses) - { - this.classObfs.put(jsonClass.getKey(), jsonClass.parse()); - } - } - - if (this.jsonMethods != null) - { - for (JsonObf jsonMethod : this.jsonMethods) - { - this.methodObfs.put(jsonMethod.getKey(), jsonMethod.parse()); - } - } - - if (this.jsonFields != null) - { - for (JsonObf jsonField : this.jsonFields) - { - this.fieldObfs.put(jsonField.getKey(), jsonField.parse()); - } - } - } - - /** - * Look up a type (a class or primitive type) by token - */ - public Object parseType(String token) - { - token = token.replace(" ", "").trim(); - - if ("I".equals(token) || "INT".equals(token)) return Integer.TYPE; - if ("J".equals(token) || "LONG".equals(token)) return Long.TYPE; - if ("V".equals(token) || "VOID".equals(token)) return Void.TYPE; - if ("Z".equals(token) || "BOOLEAN".equals(token) || "BOOL".equals(token)) return Boolean.TYPE; - if ("B".equals(token) || "BYTE".equals(token)) return Byte.TYPE; - if ("C".equals(token) || "CHAR".equals(token)) return Character.TYPE; - if ("S".equals(token) || "SHORT".equals(token)) return Short.TYPE; - if ("D".equals(token) || "DOUBLE".equals(token)) return Double.TYPE; - if ("F".equals(token) || "FLOAT".equals(token)) return Float.TYPE; - if ("STRING".equals(token)) return String.class; - - if (token.startsWith("L") && token.endsWith(";")) - { - token = token.substring(1, token.length() - 1).replace('/', '.'); - } - - return this.parseClass(token); - } - - /** - * Find an obf entry of any type by name - * - * @param name - */ - public Obf getByName(String name) - { - Obf classObf = this.classObfs.get(name); - if (classObf != null) - { - return classObf; - } - - Obf methodObf = this.methodObfs.get(name); - if (methodObf != null) - { - return methodObf; - } - - Obf fieldObf = this.fieldObfs.get(name); - if (fieldObf != null) - { - return fieldObf; - } - - return null; - } - - /** - * @param token - */ - public Obf parseClass(String token) - { - return this.parseObf(token, this.classObfs, false); - } - - /** - * @param token - */ - public Obf parseMethod(String token) - { - return this.parseObf(token, this.methodObfs, false); - } - - /** - * @param token - */ - public Obf parseField(String token) - { - return this.parseObf(token, this.fieldObfs, false); - } - - /** - * @param token - * @param obfs - * @param returnNullOnFailure return null instead of throwing an exception - */ - private Obf parseObf(String token, Map obfs, boolean returnNullOnFailure) - { - String key = JsonEvents.parseToken(token); - - if (key != null) - { - if (obfs.containsKey(key)) - { - return obfs.get(key); - } - - Obf obf = Obf.getByName(key); - if (obf != null) - { - return obf; - } - - Packets packet = Packets.getByName(key); - if (packet != null) - { - return packet; - } - - if (returnNullOnFailure) - { - return null; - } - - throw new InvalidEventJsonException("The token " + token + " could not be resolved to a type"); - } - - return new JsonObf.Mapping(token, token, token); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/ModEventInjectionTransformer.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/ModEventInjectionTransformer.java deleted file mode 100644 index 7cd71644..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/ModEventInjectionTransformer.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.json; - -import com.mumfrey.liteloader.transformers.ClassTransformer; -import com.mumfrey.liteloader.transformers.ObfProvider; -import com.mumfrey.liteloader.transformers.event.Event; -import com.mumfrey.liteloader.transformers.event.EventInjectionTransformer; -import com.mumfrey.liteloader.transformers.event.InjectionPoint; -import com.mumfrey.liteloader.transformers.event.MethodInfo; -import com.mumfrey.liteloader.transformers.event.json.ModEvents.ModEventDefinition; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger.Verbosity; - -/** - * Event transformer which manages injections of mod events specified via - * events.json in the mod container. - * - * @author Adam Mummery-Smith - */ -public class ModEventInjectionTransformer extends EventInjectionTransformer -{ - @Override - protected void addEvents() - { - for (ModEventDefinition eventsDefinition : ModEvents.getEvents().values()) - { - this.addEvents(eventsDefinition); - } - } - - /** - * @param identifier - * @param json - */ - private void addEvents(ModEventDefinition def) - { - JsonEvents events = null; - - try - { - LiteLoaderLogger.info("Parsing events for mod with id %s", def.getIdentifier()); - events = JsonEvents.parse(def.getJson()); - } - catch (InvalidEventJsonException ex) - { - LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); - LiteLoaderLogger.debug(ex.getMessage()); - LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); - LiteLoaderLogger.debug(def.getJson()); - LiteLoaderLogger.debug(ClassTransformer.HORIZONTAL_RULE); - LiteLoaderLogger.severe(ex, "Invalid JSON event declarations for mod with id %s", def.getIdentifier()); - } - catch (Throwable ex) - { - LiteLoaderLogger.severe(ex, "Error whilst parsing event declarations for mod with id %s", def.getIdentifier()); - } - - try - { - if (events != null) - { - if (events.hasAccessors()) - { - LiteLoaderLogger.info("%s contains Accessor definitions, injecting into classpath...", def.getIdentifier()); - def.injectIntoClassPath(); - } - - LiteLoaderLogger.info(Verbosity.REDUCED, "Registering events for mod with id %s", def.getIdentifier()); - events.register(this); - def.onEventsInjected(); - } - } - catch (Throwable ex) - { - LiteLoaderLogger.severe(ex, "Error whilst parsing event declarations for mod with id %s", def.getIdentifier()); - } - } - - protected Event registerEvent(Event event, MethodInfo targetMethod, InjectionPoint injectionPoint) - { - return super.addEvent(event, targetMethod, injectionPoint); - } - - protected void registerAccessor(String interfaceName, ObfProvider obfProvider) - { - super.addAccessor(interfaceName, obfProvider); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/ModEvents.java b/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/ModEvents.java deleted file mode 100644 index 4e2e876e..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/transformers/event/json/ModEvents.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.mumfrey.liteloader.transformers.event.json; - -import java.io.File; -import java.net.MalformedURLException; -import java.util.HashMap; -import java.util.Map; - -import net.minecraft.launchwrapper.Launch; - -import com.google.common.base.Charsets; -import com.mumfrey.liteloader.api.ContainerRegistry.DisabledReason; -import com.mumfrey.liteloader.api.EnumerationObserver; -import com.mumfrey.liteloader.core.ModInfo; -import com.mumfrey.liteloader.core.api.LoadableModFile; -import com.mumfrey.liteloader.interfaces.LoadableMod; -import com.mumfrey.liteloader.interfaces.LoaderEnumerator; -import com.mumfrey.liteloader.interfaces.TweakContainer; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -public class ModEvents implements EnumerationObserver -{ - public static class ModEventDefinition - { - private final LoadableModFile file; - - private final String identifier; - - private final String json; - - public ModEventDefinition(LoadableModFile file, String json) - { - this.file = file; - this.identifier = file.getIdentifier(); - this.json = json; - } - - public String getIdentifier() - { - return this.identifier; - } - - public String getJson() - { - return this.json; - } - - public void onEventsInjected() - { - this.file.onEventsInjected(); - } - - public void injectIntoClassPath() - { - try - { - this.file.injectIntoClassPath(Launch.classLoader, true); - } - catch (MalformedURLException ex) - { - ex.printStackTrace(); - } - } - } - - private static final String DEFINITION_FILENAME = "events.json"; - - private static Map events = new HashMap(); - - @Override - public void onRegisterEnabledContainer(LoaderEnumerator enumerator, LoadableMod container) - { - if (container instanceof LoadableModFile) - { - LoadableModFile file = (LoadableModFile)container; - if (!file.exists()) return; - - String json = file.getFileContents(ModEvents.DEFINITION_FILENAME, Charsets.UTF_8); - if (json == null) return; - - LiteLoaderLogger.info("Registering %s for mod with id %s", ModEvents.DEFINITION_FILENAME, file.getIdentifier()); - ModEvents.events.put(file.getIdentifier(), new ModEventDefinition(file, json)); - } - } - - @Override - public void onRegisterDisabledContainer(LoaderEnumerator enumerator, LoadableMod container, DisabledReason reason) - { - } - - @Override - public void onRegisterTweakContainer(LoaderEnumerator enumerator, TweakContainer container) - { - } - - @Override - public void onModAdded(LoaderEnumerator enumerator, ModInfo> mod) - { - } - - static Map getEvents() - { - return events; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/update/UpdateSite.java b/liteloader/src/main/java/com/mumfrey/liteloader/update/UpdateSite.java deleted file mode 100644 index 7b3f5c0a..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/update/UpdateSite.java +++ /dev/null @@ -1,421 +0,0 @@ -package com.mumfrey.liteloader.update; - -import java.text.DateFormat; -import java.util.Comparator; -import java.util.Date; -import java.util.Map; -import java.util.Map.Entry; - -import com.google.gson.Gson; -import com.google.gson.JsonSyntaxException; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; -import com.mumfrey.liteloader.util.net.HttpStringRetriever; - -/** - * An update site, used by liteloader to check for new versions but is also - * available to mods who may want to use a similar system. - * - * @author Adam Mummery-Smith - */ -public class UpdateSite implements Comparator -{ - /** - * Gson instance for deserializing remote version data - */ - private static Gson gson = new Gson(); - - /** - * Base URL of the remote update site - */ - private final String updateSiteUrl; - - /** - * Name of the json file containing the remote versions data, eg. - * versions.json - */ - private final String updateSiteJsonFileName; - - /** - * The version of minecraft being targetted - */ - private final String targetVersion; - - /** - * Artefact name in the form "com.somedomain.pkg:artefactname" - */ - private final String artefact; - - /** - * Local artefact timestamp - */ - private final long currentTimeStamp; - - /** - * Comparator for the timestamps - */ - private final Comparator timeStampComparator; - - /** - * Threading lock object - */ - private final Object lock = new Object(); - - /** - * StringRetriever which will fetch the remote json file, null when not - * performing a fetch operation. - */ - private HttpStringRetriever stringRetriever; - - /** - * True if the check is complete (even if it failed) - */ - private volatile boolean checkComplete = false; - - /** - * True if the check succeeded - */ - private volatile boolean checkSuccess = false; - - /** - * True if an updated version is available - */ - private volatile boolean updateAvailable = false; - - /** - * The version which is available - */ - private String availableVersion = null; - - /** - * The version which is available - */ - private String availableVersionDate = null; - - /** - * The URL to the available artefact - */ - private String availableVersionURL = null; - - /** - * Create a new UpdateSite with the specified information - * - * @param updateSiteUrl Base URL of the update site, should include the - * trailing slash - * @param jsonFileName Name of the json file on the remote site containing - * the version data, eg. versions.json - * @param targetVersion The target minecraft version - * @param artefact Artefact name in the form - * "com.somedomain.pkg:artefactname" - * @param currentTimeStamp Timestamp of the current artefact - * @param timeStampComparator Comparator to use for comparing timestamps, if - * null uses built in comparator - */ - public UpdateSite(String updateSiteUrl, String jsonFileName, String targetVersion, String artefact, long currentTimeStamp, - Comparator timeStampComparator) - { - this.updateSiteUrl = updateSiteUrl + (updateSiteUrl.endsWith("/") ? "" : "/"); - this.updateSiteJsonFileName = jsonFileName; - - this.targetVersion = targetVersion; - this.artefact = artefact; - this.currentTimeStamp = currentTimeStamp; - - this.timeStampComparator = timeStampComparator != null ? timeStampComparator : this; - } - - /** - * Create a new UpdateSite with the specified information - * - * @param updateSiteUrl Base URL of the update site, should include the - * trailing slash - * @param jsonFileName Name of the json file on the remote site containing - * the version data, eg. versions.json - * @param targetVersion The target minecraft version - * @param artefact Artefact name in the form - * "com.somedomain.pkg:artefactname" - * @param currentTimeStamp Timestamp of the current artefact - */ - public UpdateSite(String updateSiteUrl, String jsonFileName, String targetVersion, String artefact, long currentTimeStamp) - { - this(updateSiteUrl, jsonFileName, targetVersion, artefact, currentTimeStamp, null); - } - - /** - * If an update check is not already in progress, starts an update check - */ - public void beginUpdateCheck() - { - synchronized (this.lock) - { - if (this.stringRetriever == null) - { - LiteLoaderLogger.debug("Update site for %s is starting the update check", this.artefact); - this.stringRetriever = new HttpStringRetriever(String.format("%s%s", this.updateSiteUrl, this.updateSiteJsonFileName)); - this.stringRetriever.start(); - } - } - } - - /** - * Gets whether a check is in progress - */ - public boolean isCheckInProgress() - { - this.update(); - boolean checkInProgress = false; - - synchronized (this.lock) - { - checkInProgress = this.stringRetriever != null; - } - - return checkInProgress; - } - - /** - * Gets whether a check has been completed - */ - public boolean isCheckComplete() - { - this.update(); - return this.checkComplete; - } - - /** - * Gets whether the last check was a success - */ - public boolean isCheckSucceess() - { - this.update(); - return this.checkComplete && this.checkSuccess; - } - - /** - * Gets whether an update is available at the remote site - */ - public boolean isUpdateAvailable() - { - this.update(); - return this.updateAvailable; - } - - /** - * Gets the latest version available at the remote site - */ - public String getAvailableVersion() - { - this.update(); - return this.availableVersion; - } - - /** - * Gets the latest version available at the remote site - */ - public String getAvailableVersionDate() - { - this.update(); - return this.availableVersionDate; - } - - /** - * Gets the URL to the available version - */ - public String getAvailableVersionURL() - { - this.update(); - return this.availableVersionURL; - } - - /** - * Check whether an in-progress check has completed and if it has parse the - * retrieved data. - */ - private void update() - { - synchronized (this.lock) - { - if (this.stringRetriever != null && this.stringRetriever.isDone()) - { - this.checkComplete = true; - this.checkSuccess = this.stringRetriever.getSuccess(); - - if (this.checkSuccess) - { - try - { - LiteLoaderLogger.debug("Update site for %s is parsing the update response", this.artefact); - this.parseData(this.stringRetriever.getString()); - LiteLoaderLogger.debug("Update site for %s successfully parsed the update response", this.artefact); - } - catch (Exception ex) - { - LiteLoaderLogger.debug("Update site for %s failed parsing the update response: %s:%s", this.artefact, - ex.getClass().getSimpleName(), ex.getMessage()); - this.checkSuccess = false; - ex.printStackTrace(); - } - } - - this.stringRetriever = null; - } - } - } - - /** - * Parse data receieved from a query - * - * @param json - */ - private void parseData(String json) - { - this.updateAvailable = false; - - try - { - Map data = UpdateSite.gson.fromJson(json, Map.class); - - if (data.containsKey("versions")) - { - this.handleVersionsData((Map)data.get("versions")); - } - else - { - LiteLoaderLogger.warning("No key 'versions' in update site JSON"); - } - } - catch (JsonSyntaxException ex) - { - ex.printStackTrace(); - LiteLoaderLogger.warning("Error parsing update site JSON: %s: %s", ex.getClass().getSimpleName(), ex.getMessage()); - } - } - - /** - * @param versions - */ - private void handleVersionsData(Map versions) - { - if (versions.containsKey(this.targetVersion)) - { - for (Entry versionDataEntry : ((Map)versions.get(this.targetVersion)).entrySet()) - { - this.handleVersionData(versionDataEntry.getKey(), (Map)versionDataEntry.getValue()); - } - } - else - { - LiteLoaderLogger.warning("No version entry for current version '%s' in update site JSON", this.targetVersion); - } - } - - /** - * @param key - * @param value - */ - private void handleVersionData(Object key, Map value) - { - if ("artefacts".equals(key)) - { - if (value.containsKey(this.artefact)) - { - this.handleArtefactData((Map)value.get(this.artefact)); - } - else - { - LiteLoaderLogger.warning("No artefacts entry for specified artefact '%s' in update site JSON", this.artefact); - } - } - } - - /** - * @param availableArtefacts - */ - @SuppressWarnings("unchecked") - private void handleArtefactData(Map availableArtefacts) - { - if (availableArtefacts.containsKey("latest")) - { - Map latestArtefact = (Map)availableArtefacts.get("latest"); - this.checkAndUseRemoteArtefact(latestArtefact, this.currentTimeStamp, false); - } - else - { - LiteLoaderLogger.warning("No key 'latest' in update site JSON"); - - long bestTimeStamp = this.currentTimeStamp; - Map bestRemoteArtefact = null; - - for (Map remoteArtefact : ((Map>)availableArtefacts).values()) - { - if (this.checkAndUseRemoteArtefact(remoteArtefact, bestTimeStamp, true)) - { - bestTimeStamp = Long.parseLong(remoteArtefact.get("timestamp").toString()); - bestRemoteArtefact = remoteArtefact; - } - } - - if (bestRemoteArtefact != null) - { - this.availableVersion = bestRemoteArtefact.get("version").toString(); - this.availableVersionURL = this.createArtefactURL(bestRemoteArtefact.get("file").toString()); - this.updateAvailable = this.compareTimeStamps(this.currentTimeStamp, bestTimeStamp); - } - } - } - - /** - * @param artefact - * @param bestTimeStamp - * @param checkOnly - */ - private boolean checkAndUseRemoteArtefact(Map artefact, long bestTimeStamp, boolean checkOnly) - { - if (artefact.containsKey("file") && artefact.containsKey("version") && artefact.containsKey("timestamp")) - { - Long remoteTimeStamp = Long.parseLong(artefact.get("timestamp").toString()); - - if (checkOnly) - { - return this.compareTimeStamps(bestTimeStamp, remoteTimeStamp); - } - - this.availableVersion = artefact.get("version").toString(); - this.availableVersionDate = DateFormat.getDateTimeInstance().format(new Date(remoteTimeStamp * 1000L)); - this.availableVersionURL = this.createArtefactURL(artefact.get("file").toString()); - this.updateAvailable = this.compareTimeStamps(bestTimeStamp, remoteTimeStamp); - - return true; - } - - return false; - } - - /** - * @param bestTimeStamp - * @param remoteTimeStamp - */ - private boolean compareTimeStamps(long bestTimeStamp, Long remoteTimeStamp) - { - return this.timeStampComparator.compare(bestTimeStamp, remoteTimeStamp) < 0; - } - - /** - * @param file - */ - private String createArtefactURL(String file) - { - return String.format("%s%s/%s/%s", this.updateSiteUrl, this.artefact.replace('.', '/').replace(':', '/'), this.targetVersion, file); - } - - /* (non-Javadoc) - * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) - */ - @Override - public int compare(Long localTimestamp, Long remoteTimestamp) - { - if (localTimestamp == null && remoteTimestamp == null) return 0; - if (localTimestamp == null) return -1; - if (remoteTimestamp == null) return 1; - return (int)(localTimestamp.longValue() - remoteTimestamp.longValue()); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/ChatUtilities.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/ChatUtilities.java deleted file mode 100644 index 983f8a24..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/ChatUtilities.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.mumfrey.liteloader.util; - -import java.util.List; - -import net.minecraft.util.ChatComponentText; -import net.minecraft.util.ChatStyle; -import net.minecraft.util.EnumChatFormatting; -import net.minecraft.util.IChatComponent; - -/** - * Utility functions for chat - * - * @author Adam Mummery-Smith - */ -public abstract class ChatUtilities -{ - private static String formattingCodeLookup; - - static - { - StringBuilder formattingCodes = new StringBuilder(); - - for (EnumChatFormatting chatFormat : EnumChatFormatting.values()) - { - formattingCodes.append(chatFormat.toString().charAt(1)); - } - - ChatUtilities.formattingCodeLookup = formattingCodes.toString(); - } - - private ChatUtilities() {} - - /** - * Get a chat style from a legacy formatting code - * - * @param code Code - * @return chat style - */ - public static ChatStyle getChatStyleFromCode(char code) - { - int pos = ChatUtilities.formattingCodeLookup.indexOf(code); - if (pos < 0) return null; - EnumChatFormatting format = EnumChatFormatting.values()[pos]; - - ChatStyle style = new ChatStyle(); - if (format.isColor()) - { - style.setColor(format); - } - else if (format.isFancyStyling()) - { - switch (format) - { - case BOLD: style.setBold(true); break; - case ITALIC: style.setItalic(true); break; - case STRIKETHROUGH: style.setStrikethrough(true); break; - case UNDERLINE: style.setUnderlined(true); break; - case OBFUSCATED: style.setObfuscated(true); break; - default: return style; - } - } - - return style; - } - - /** - * Convert a component containing text formatted with legacy codes to a - * native ChatComponent structure. - */ - public static IChatComponent convertLegacyCodes(IChatComponent chat) - { - return ChatUtilities.covertCodesInPlace(chat); - } - - private static List covertCodesInPlace(List siblings) - { - for (int index = 0; index < siblings.size(); index++) - { - siblings.set(index, ChatUtilities.covertCodesInPlace(siblings.get(index))); - } - - return siblings; - } - - @SuppressWarnings("unchecked") - private static IChatComponent covertCodesInPlace(IChatComponent component) - { - IChatComponent newComponent = null; - if (component instanceof ChatComponentText) - { - ChatComponentText textComponent = (ChatComponentText)component; - ChatStyle style = textComponent.getChatStyle(); - String text = textComponent.getChatComponentText_TextValue(); - - int pos = text.indexOf('\247'); - while (pos > -1 && text != null) - { - if (pos < text.length() - 1) - { - IChatComponent head = new ChatComponentText(pos > 0 ? text.substring(0, pos) : "").setChatStyle(style); - style = ChatUtilities.getChatStyleFromCode(text.charAt(pos + 1)); - text = text.substring(pos + 2); - newComponent = (newComponent == null) ? head : newComponent.appendSibling(head); - pos = text.indexOf('\247'); - } - else - { - text = null; - } - } - - if (text != null) - { - IChatComponent tail = new ChatComponentText(text).setChatStyle(style); - newComponent = (newComponent == null) ? tail : newComponent.appendSibling(tail); - } - } - - if (newComponent == null) - { - ChatUtilities.covertCodesInPlace(component.getSiblings()); - return component; - } - - for (IChatComponent oldSibling : ChatUtilities.covertCodesInPlace((List)component.getSiblings())) - { - newComponent.appendSibling(oldSibling); - } - - return newComponent; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/EntityUtilities.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/EntityUtilities.java deleted file mode 100644 index 7feb857f..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/EntityUtilities.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.mumfrey.liteloader.util; - -import net.minecraft.entity.Entity; -import net.minecraft.util.MovingObjectPosition; -import net.minecraft.util.Vec3; - -public abstract class EntityUtilities -{ - public static MovingObjectPosition rayTraceFromEntity(Entity entity, double traceDistance, float partialTicks) - { - Vec3 var4 = EntityUtilities.getPositionEyes(entity, partialTicks); - Vec3 var5 = entity.getLook(partialTicks); - Vec3 var6 = var4.addVector(var5.xCoord * traceDistance, var5.yCoord * traceDistance, var5.zCoord * traceDistance); - return entity.worldObj.rayTraceBlocks(var4, var6, false, false, true); - } - - public static Vec3 getPositionEyes(Entity entity, float partialTicks) - { - if (partialTicks == 1.0F) - { - return new Vec3(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ); - } - - double interpX = entity.prevPosX + (entity.posX - entity.prevPosX) * partialTicks; - double interpY = entity.prevPosY + (entity.posY - entity.prevPosY) * partialTicks + entity.getEyeHeight(); - double interpZ = entity.prevPosZ + (entity.posZ - entity.prevPosZ) * partialTicks; - return new Vec3(interpX, interpY, interpZ); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/Input.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/Input.java deleted file mode 100644 index f72df8c4..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/Input.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.mumfrey.liteloader.util; - -import net.minecraft.client.settings.KeyBinding; -import net.minecraft.network.INetHandler; -import net.minecraft.network.play.server.S01PacketJoinGame; -import net.minecraft.world.World; - -import com.mumfrey.liteloader.api.CoreProvider; -import com.mumfrey.liteloader.core.LiteLoaderMods; -import com.mumfrey.liteloader.util.jinput.ComponentRegistry; - -public abstract class Input implements CoreProvider -{ - /** - * Register a key for a mod - * - * @param binding - */ - public abstract void registerKeyBinding(KeyBinding binding); - - /** - * Unregisters a registered keybind with the game settings class, thus - * removing it from the "controls" screen. - * - * @param binding - */ - public abstract void unRegisterKeyBinding(KeyBinding binding); - - /** - * Writes mod bindings to disk - */ - public abstract void storeBindings(); - - /** - * Gets the underlying JInput component registry - */ - public abstract ComponentRegistry getComponentRegistry(); - - /** - * Returns a handle to the event described by descriptor (or null if no - * component is found matching the descriptor. Retrieving an event via this - * method adds the controller (if found) to the polling list and causes it - * to raise events against the specified handler. - * - *

This method returns an {@link InputEvent} which is passed as an - * argument to the relevant callback on the supplied handler in order to - * identify the event. For example:

- * - * this.joystickButton = input.getEvent(descriptor, this); - * - *

then in onAxisEvent

- * - * if (source == this.joystickButton) // do something with button - * - * - * @param descriptor - * @param handler - */ - public abstract InputEvent getEvent(String descriptor, InputHandler handler); - - /** - * Get events for all components which match the supplied descriptor - * - * @param descriptor - * @param handler - */ - public abstract InputEvent[] getEvents(String descriptor, InputHandler handler); - - @Override - public void onPostInitComplete(LiteLoaderMods mods) - { - } - - @Override - public void onStartupComplete() - { - } - - @Override - public void onJoinGame(INetHandler netHandler, S01PacketJoinGame loginPacket) - { - } - - @Override - public void onWorldChanged(World world) - { - } - - @Override - public void onPostRender(int mouseX, int mouseY, float partialTicks) - { - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/InputEvent.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/InputEvent.java deleted file mode 100644 index 6e383789..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/InputEvent.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.mumfrey.liteloader.util; - -import net.java.games.input.Component; -import net.java.games.input.Controller; -import net.java.games.input.Event; - -/** - * A handle to an input event, this handle will be used to call back the handler - * for the specified component's events. This class represents a singly-linked - * list of delegates with each delegate's next field pointing to the next - * delegate in the chain. - * - * @author Adam Mummery-Smith - */ -public class InputEvent -{ - /** - * Controller this event is delegating events for - */ - private final Controller controller; - - /** - * Component this event is delegating events for - */ - private final Component component; - - /** - * Event handler - */ - private final InputHandler handler; - - /** - * Next event handler in the chain - */ - private InputEvent next; - - /** - * @param controller - * @param component - * @param handler - */ - InputEvent(Controller controller, Component component, InputHandler handler) - { - this.controller = controller; - this.component = component; - this.handler = handler; - } - - /** - * Link this delegate to the specified delegate and return the start of the - * delegate chain. - * - * @param chain delegate to link to (will be null if the chain is empty) - */ - InputEvent link(InputEvent chain) - { - if (chain == null) return this; // Chain is empty, return self - return chain.append(this); // Append self to the start of the chain - } - - /** - * Append specified delegate to the end of the delegate chain - * - * @param delegate - */ - private InputEvent append(InputEvent delegate) - { - InputEvent tail = this; // Start here - - while (tail.next != null) // Find the end of the chain - { - tail = tail.next; - } - - tail.next = delegate; // Append the new delegate - return this; // Return the start of the delegate chain (eg. this node) - } - - /** - * @param event - */ - void onEvent(Event event) - { - if (this.component.isAnalog()) - { - this.onAxisEvent(event.getValue(), event.getNanos()); - } - else if (this.component.getIdentifier() == Component.Identifier.Axis.POV) - { - this.onPovEvent(event.getValue(), event.getNanos()); - } - else - { - this.onButtonEvent(event.getValue() == 1.0F); - } - } - - /** - * @param value - * @param nanos - */ - private void onAxisEvent(float value, long nanos) - { - this.handler.onAxisEvent(this, value, nanos); - if (this.next != null) this.next.onAxisEvent(value, nanos); - } - - /** - * @param value - * @param nanos - */ - private void onPovEvent(float value, long nanos) - { - this.handler.onPovEvent(this, value, nanos); - if (this.next != null) this.next.onPovEvent(value, nanos); - } - - /** - * @param pressed - */ - private void onButtonEvent(boolean pressed) - { - this.handler.onButtonEvent(this, pressed); - if (this.next != null) this.next.onButtonEvent(pressed); - } - - public Controller getController() - { - return this.controller; - } - - public Component getComponent() - { - return this.component; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/InputHandler.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/InputHandler.java deleted file mode 100644 index fb2e0049..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/InputHandler.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.mumfrey.liteloader.util; - -/** - * Interface for objects which handle JInput events - * - * @author Adam Mummery-Smith - */ -public interface InputHandler -{ - /** - * Called when an analogue (axis) event is raised on the specified component - * - * @param source - * @param nanos - * @param value - */ - void onAxisEvent(InputEvent source, float value, long nanos); - - /** - * Called when a POV (Point-Of-View) event is raised on the specified - * component. - * - * @param source - * @param value - * @param nanos - */ - void onPovEvent(InputEvent source, float value, long nanos); - - /** - * Called when a button event is raised on the specified component - * - * @param source - * @param value - */ - void onButtonEvent(InputEvent source, boolean value); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/ObfuscationUtilities.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/ObfuscationUtilities.java deleted file mode 100644 index db74c709..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/ObfuscationUtilities.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.mumfrey.liteloader.util; - -import net.minecraft.launchwrapper.IClassTransformer; -import net.minecraft.launchwrapper.Launch; -import net.minecraft.server.MinecraftServer; -import net.minecraft.util.BlockPos; - -import com.mumfrey.liteloader.core.runtime.Obf; - -public class ObfuscationUtilities -{ - /** - * True if FML is being used, in which case we use searge names instead of - * raw field/method names. - */ - private static boolean fmlDetected = false; - - private static boolean checkedObfEnv = false; - private static boolean seargeNames = false; - - static - { - // Check for FML - ObfuscationUtilities.fmlDetected = ObfuscationUtilities.fmlIsPresent(); - } - - public static boolean fmlIsPresent() - { - for (IClassTransformer transformer : Launch.classLoader.getTransformers()) - { - if (transformer.getClass().getName().contains("fml")) - { - return true; - } - } - - return false; - } - - public static boolean useSeargeNames() - { - if (!ObfuscationUtilities.checkedObfEnv) - { - ObfuscationUtilities.checkedObfEnv = true; - - try - { - MinecraftServer.class.getDeclaredField("serverRunning"); - } - catch (SecurityException ex) - { - } - catch (NoSuchFieldException ex) - { - ObfuscationUtilities.seargeNames = true; - } - } - - return ObfuscationUtilities.seargeNames; - } - - /** - * Abstraction helper function - * - * @param fieldName Name of field to get, returned unmodified if in debug - * mode - * @return Obfuscated field name if present - */ - public static String getObfuscatedFieldName(String fieldName, String obfuscatedFieldName, String seargeFieldName) - { - boolean deobfuscated = BlockPos.class.getSimpleName().equals("BlockPos"); - return deobfuscated ? (ObfuscationUtilities.useSeargeNames() ? seargeFieldName : fieldName) - : (ObfuscationUtilities.fmlDetected ? seargeFieldName : obfuscatedFieldName); - } - - /** - * Abstraction helper function - * - * @param obf Field to get, returned unmodified if in debug mode - * @return Obfuscated field name if present - */ - public static String getObfuscatedFieldName(Obf obf) - { - boolean deobfuscated = BlockPos.class.getSimpleName().equals("BlockPos"); - return deobfuscated ? (ObfuscationUtilities.useSeargeNames() ? obf.srg : obf.name) : (ObfuscationUtilities.fmlDetected ? obf.srg : obf.obf); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/Position.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/Position.java deleted file mode 100644 index 24f4c26c..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/Position.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.mumfrey.liteloader.util; - -import net.minecraft.entity.Entity; -import net.minecraft.util.Vec3; - -/** - * A 3D vector position with rotation as well - * - * @author Adam Mummery-Smith - */ -public class Position extends Vec3 -{ - public final float yaw; - - public final float pitch; - - public Position(double x, double y, double z) - { - this(x, y, z, 0.0F, 0.0F); - } - - public Position(double x, double y, double z, float yaw, float pitch) - { - super(x, y, z); - - this.yaw = yaw; - this.pitch = pitch; - } - - public Position(Entity entity) - { - this(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch); - } - - public Position(Entity entity, boolean usePrevious) - { - this(usePrevious ? entity.prevPosX : entity.posX, - usePrevious ? entity.prevPosY : entity.posY, - usePrevious ? entity.prevPosZ : entity.posZ, - usePrevious ? entity.prevRotationYaw : entity.rotationYaw, - usePrevious ? entity.prevRotationPitch : entity.rotationPitch); - } - - public void applyTo(Entity entity) - { - entity.posX = this.xCoord; - entity.posY = this.yCoord; - entity.posZ = this.zCoord; - entity.rotationYaw = this.yaw; - entity.rotationPitch = this.pitch; - } - - @Override - public String toString() - { - return "(" + this.xCoord + ", " + this.yCoord + ", " + this.zCoord + ", " + this.yaw + ", " + this.pitch + ")"; - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/PrivateFields.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/PrivateFields.java deleted file mode 100644 index c3108766..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/PrivateFields.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.mumfrey.liteloader.util; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; - -import com.mumfrey.liteloader.core.runtime.Obf; - -/** - * Wrapper for obf/mcp reflection-accessed private fields, mainly added to - * centralise the locations I have to update the obfuscated field names. - * - * @author Adam Mummery-Smith - * - * @param

Parent class type, the type of the class that owns the field - * @param Field type, the type of the field value - */ -public class PrivateFields -{ - /** - * Class to which this field belongs - */ - public final Class

parentClass; - - /** - * Name used to access the field, determined at init - */ - private final String fieldName; - - private boolean errorReported = false; - - /** - * Creates a new private field entry - * - * @param obf - */ - protected PrivateFields(Class

owner, Obf obf) - { - this.parentClass = owner; - this.fieldName = ObfuscationUtilities.getObfuscatedFieldName(obf); - } - - /** - * Get the current value of this field on the instance class supplied - * - * @param instance Class to get the value of - * @return field value or null if errors occur - */ - @SuppressWarnings("unchecked") - public T get(P instance) - { - try - { - Field field = this.parentClass.getDeclaredField(this.fieldName); - field.setAccessible(true); - return (T)field.get(instance); - } - catch (Exception ex) - { - if (!this.errorReported) - { - this.errorReported = true; - ex.printStackTrace(); - } - return null; - } - } - - /** - * Set the value of this field on the instance class supplied - * - * @param instance Object to set the value of the field on - * @param value value to set - * @return value - */ - public T set(P instance, T value) - { - try - { - Field field = this.parentClass.getDeclaredField(this.fieldName); - field.setAccessible(true); - field.set(instance, value); - } - catch (Exception ex) - { - if (!this.errorReported) - { - this.errorReported = true; - ex.printStackTrace(); - } - } - - return value; - } - - /** - * Set the value of this FINAL field on the instance class supplied - * - * @param instance Object to set the value of the field on - * @param value value to set - * @return value - */ - public T setFinal(P instance, T value) - { - try - { - Field modifiers = Field.class.getDeclaredField("modifiers"); - modifiers.setAccessible(true); - - Field field = this.parentClass.getDeclaredField(this.fieldName); - modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL); - field.setAccessible(true); - field.set(instance, value); - } - catch (Exception ex) - { - if (!this.errorReported) - { - this.errorReported = true; - ex.printStackTrace(); - } - } - - return value; - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/SortableValue.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/SortableValue.java deleted file mode 100644 index 00e2b1a9..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/SortableValue.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.mumfrey.liteloader.util; - -/** - * Struct which contains a mapping of a priority value to another object, used - * for sorting items using the native functionality in TreeMap and TreeSet. - * - * @author Adam Mummery-Smith - */ -public class SortableValue implements Comparable> -{ - private final int priority; - - private final int order; - - private final T value; - - public SortableValue(int priority, int order, T value) - { - this.priority = priority; - this.order = order; - this.value = value; - } - - public int getPriority() - { - return this.priority; - } - - public int getOrder() - { - return this.order; - } - - public T getValue() - { - return this.value; - } - - @Override - public int compareTo(SortableValue other) - { - if (other == null) return 0; - if (other.priority == this.priority) return this.order - other.order; - return (this.priority - other.priority); - } -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/jinput/ComponentRegistry.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/jinput/ComponentRegistry.java deleted file mode 100644 index bc31bd93..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/jinput/ComponentRegistry.java +++ /dev/null @@ -1,285 +0,0 @@ -package com.mumfrey.liteloader.util.jinput; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map.Entry; - -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -import net.java.games.input.Component; -import net.java.games.input.Controller; -import net.java.games.input.ControllerEnvironment; - -/** - * Registry which keeps track of mappings of JInput descriptors to the - * controller and component references. - * - * @author Adam Mummery-Smith - */ -public class ComponentRegistry -{ - /** - * List of components - */ - private static HashMap components = new HashMap(); - - /** - * List of controllers - */ - private static HashMap controllers = new HashMap(); - - /** - * Constructor - */ - public ComponentRegistry() - { - } - - public void enumerate() - { - try - { - LiteLoaderLogger.info("JInput Component Registry is initialising..."); - this.enumerate(ControllerEnvironment.getDefaultEnvironment()); - LiteLoaderLogger.info("JInput Component Registry initialised, found %d controller(s) %d component(s)", - ControllerEnvironment.getDefaultEnvironment().getControllers().length, components.size()); - } - catch (Throwable th) - { - } - } - - public void enumerate(ControllerEnvironment environment) - { - components.clear(); - controllers.clear(); - - for (Controller controller : environment.getControllers()) - { - LiteLoaderLogger.info("Inspecting %s controller %s on %s...", controller.getType(), controller.getName(), controller.getPortType()); - for (Component component : controller.getComponents()) - { - this.addComponent(controller, component); - } - } - } - - private String addComponent(Controller controller, Component component) - { - String descriptor = ComponentRegistry.getDescriptor(controller, component); - components.put(descriptor, component); - controllers.put(descriptor, controller); - return descriptor; - } - - public ArrayList getComponents(String descriptor) - { - ArrayList components = new ArrayList(); - - int offset = 0; - Component component = null; - - do - { - component = this.getComponent(descriptor, offset++); - - if (components.contains(component)) - { - component = null; - } - - if (component != null) - { - components.add(component); - } - - } while (component != null && components.size() < 32); - - return components; - } - - public Component getComponent(String descriptor) - { - return this.getComponent(descriptor, 0); - } - - protected Component getComponent(String descriptor, int offset) - { - if (components.containsKey(descriptor)) - { - return components.get(descriptor); - } - - for (Entry entry : components.entrySet()) - { - if (matches(entry.getKey(), descriptor)) - { - if (--offset < 0) - { - return entry.getValue(); - } - } - } - - return null; - } - - public ArrayList getControllers(String descriptor) - { - ArrayList controllers = new ArrayList(); - - int offset = 0; - Controller controller = null; - - do - { - controller = this.getController(descriptor, offset++); - - if (controllers.contains(controller)) - { - controller = null; - } - - if (controller != null) - { - controllers.add(controller); - } - - } while (controller != null && controllers.size() < 32); - - return controllers; - } - - public Controller getController(String descriptor) - { - return this.getController(descriptor, 0); - } - - protected Controller getController(String descriptor, int offset) - { - if (controllers.containsKey(descriptor)) - { - return controllers.get(descriptor); - } - - for (Entry entry : controllers.entrySet()) - { - if (matches(entry.getKey(), descriptor)) - { - if (--offset < 0) - { - return entry.getValue(); - } - } - } - - return null; - } - - public static String getDescriptor(Controller controller, Component component) - { - int index = 0; - String controllerPath = ComponentRegistry.getControllerPath(controller); - String componentId = component.getIdentifier().getName(); - - String descriptor = ComponentRegistry.getDescriptor(controllerPath, componentId, index); - - while (components.containsKey(descriptor) && components.get(descriptor) != component) - { - descriptor = ComponentRegistry.getDescriptor(controllerPath, componentId, ++index); - } - - return descriptor; - } - - /** - * @param type - * @param name - * @param portType - * @param portNumber - * @param component - * @param index - */ - public static String getDescriptor(String type, String name, String portType, int portNumber, String component, int index) - { - String controllerPath = ComponentRegistry.getControllerPath(type, name, portType, portNumber); - return ComponentRegistry.getDescriptor(controllerPath, component, index); - } - - /** - * @param controller - * @param component - * @param index - */ - private static String getDescriptor(String controller, String component, int index) - { - String descriptor = String.format("jinput:%s/%s/%d", controller, ComponentRegistry.format(component), index); - return descriptor; - } - - /** - * @param controller - */ - private static String getControllerPath(Controller controller) - { - return ComponentRegistry.getControllerPath( - controller.getType().toString().toLowerCase(), - controller.getName(), - controller.getPortType().toString(), - controller.getPortNumber() - ); - } - - /** - * @param type - * @param name - * @param portType - * @param portNumber - */ - public static String getControllerPath(String type, String name, String portType, int portNumber) - { - return String.format("%s/%s/%s/%d", - ComponentRegistry.format(type), - ComponentRegistry.format(name), - ComponentRegistry.format(portType), - portNumber - ); - } - - public static boolean matches(String descriptor, String wildDescriptor) - { - String[] descriptorParts = ComponentRegistry.splitDescriptor(descriptor.trim()); - String[] wildDescriptorParts = ComponentRegistry.splitDescriptor(wildDescriptor.trim()); - - if (descriptorParts.length != wildDescriptorParts.length) return false; - - for (int i = 0; i < descriptorParts.length; i++) - { - if (wildDescriptorParts[i].length() > 0 && descriptorParts[i].length() > 0 - && !wildDescriptorParts[i].equals(descriptorParts[i]) - && !wildDescriptorParts[i].equals("*")) - { - return false; - } - } - - return true; - } - - public static String[] splitDescriptor(String descriptor) - { - if (descriptor.startsWith("jinput:")) - { - String[] path = descriptor.split("(? logTail = new LinkedList(); - - private static long logIndex = 0; - - private static Throwable lastThrowable; - - /** - * Provides some wiggle-room within log4j's Level so we can have different - * levels of logging on the same, um.. Level - */ - public static enum Verbosity - { - VERBOSE(3), - NORMAL(2), - REDUCED(1), - SILENT(0); - - protected final int level; - - private Verbosity(int level) - { - this.level = level; - } - - public int getLevel() - { - return this.level; - } - } - - public static Verbosity verbosity = LiteLoaderLogger.DEBUG ? Verbosity.VERBOSE : Verbosity.NORMAL; - - static - { - LiteLoaderLogger.logger.addAppender(new LiteLoaderLogger()); - } - - protected LiteLoaderLogger() - { - super("Internal Log Appender", null, null); - this.start(); - } - - @Override - public void append(LogEvent event) - { - synchronized (LiteLoaderLogger.logTail) - { - LiteLoaderLogger.logIndex++; - this.append(event.getMillis(), event.getMessage().getFormattedMessage()); - Throwable thrown = event.getThrown(); - if (thrown != null) - { - this.append(event.getMillis(), String.format("\2474%s: \2476%s", thrown.getClass().getSimpleName(), thrown.getMessage())); - } - } - } - - /** - * @param message - */ - private void append(long timestamp, String message) - { - String date = new java.text.SimpleDateFormat("[HH:mm:ss] ").format(new Date(timestamp)); - - while (message.indexOf('\n') > -1) - { - int lineFeedPos = message.indexOf('\n'); - this.appendLine(date + message.substring(0, lineFeedPos)); - message = message.substring(lineFeedPos + 1); - } - - this.appendLine(date + message); - } - - /** - * @param line - */ - private void appendLine(String line) - { - LiteLoaderLogger.logTail.add(line); - - if (LiteLoaderLogger.logTail.size() > LiteLoaderLogger.LOG_TAIL_SIZE) - { - LiteLoaderLogger.logTail.remove(); - } - } - - public static long getLogIndex() - { - return LiteLoaderLogger.logIndex; - } - - public static List getLogTail() - { - List log = new ArrayList(); - - synchronized (LiteLoaderLogger.logTail) - { - log.addAll(LiteLoaderLogger.logTail); - } - - return log; - } - - public static Logger getLogger() - { - return LiteLoaderLogger.logger; - } - - public static void clearLastThrowable() - { - LiteLoaderLogger.lastThrowable = null; - } - - public static Throwable getLastThrowable() - { - Throwable lastThrowableWrapped = null; - - // Wrap the throwable to avoid loader constraint violations during PREINIT and INIT - if (LiteLoaderLogger.lastThrowable != null) - { - StringWriter sw = new StringWriter(); - LiteLoaderLogger.lastThrowable.printStackTrace(new PrintWriter(sw)); - lastThrowableWrapped = new Throwable(sw.toString()); - try - { - sw.close(); - } - catch (IOException ex) - { - // oh well - } - } - - return lastThrowableWrapped; - } - - private static void log(Level level, Verbosity verbosity, String format, Object... data) - { - if (verbosity.level > LiteLoaderLogger.verbosity.level) - { - return; - } - - try - { - LiteLoaderLogger.logger.log(level, String.format(format, data)); - } - catch (MissingFormatArgumentException ex) - { - LiteLoaderLogger.logger.log(level, format.replace('%', '@')); - } - } - - private static void log(Level level, Verbosity verbosity, Throwable th, String format, Object... data) - { - if (verbosity.level > LiteLoaderLogger.verbosity.level) - { - return; - } - - LiteLoaderLogger.lastThrowable = th; - - try - { - LiteLoaderLogger.logger.log(level, String.format(format, data), th); - } - catch (LinkageError ex) // This happens because of ClassLoader scope derpiness during the PREINIT and INIT phases - { - th.printStackTrace(); - } - catch (Throwable th2) - { - th2.initCause(th); - th2.printStackTrace(); - } - } - - public static void severe(String format, Object... data) - { - LiteLoaderLogger.severe(Verbosity.REDUCED, format, data); - } - - public static void severe(Verbosity verbosity, String format, Object... data) - { - LiteLoaderLogger.log(Level.ERROR, verbosity, format, data); - } - - public static void severe(Throwable th, String format, Object... data) - { - LiteLoaderLogger.severe(Verbosity.REDUCED, th, format, data); - } - - public static void severe(Verbosity verbosity, Throwable th, String format, Object... data) - { - LiteLoaderLogger.lastThrowable = th; - - try - { - LiteLoaderLogger.log(Level.ERROR, verbosity, th, format, data); - } - catch (LinkageError ex) // This happens because of ClassLoader scope derpiness during the PREINIT and INIT phases - { - th.printStackTrace(); - } - catch (Throwable th2) - { - th2.initCause(th); - th2.printStackTrace(); - } - } - - public static void warning(String format, Object... data) - { - LiteLoaderLogger.warning(Verbosity.REDUCED, format, data); - } - - public static void warning(Verbosity verbosity, String format, Object... data) - { - LiteLoaderLogger.log(Level.WARN, verbosity, format, data); - } - - public static void warning(Throwable th, String format, Object... data) - { - LiteLoaderLogger.warning(Verbosity.REDUCED, th, format, data); - } - - public static void warning(Verbosity verbosity, Throwable th, String format, Object... data) - { - LiteLoaderLogger.lastThrowable = th; - - try - { - LiteLoaderLogger.log(Level.WARN, verbosity, th, format, data); - } - catch (LinkageError ex) // This happens because of ClassLoader scope derpiness during the PREINIT and INIT phases - { - th.printStackTrace(); - } - catch (Throwable th2) - { - th2.initCause(th); - th2.printStackTrace(); - } - } - - public static void info(String format, Object... data) - { - LiteLoaderLogger.info(Verbosity.NORMAL, format, data); - } - - public static void info(Verbosity verbosity, String format, Object... data) - { - LiteLoaderLogger.log(Level.INFO, verbosity, format, data); - } - - public static void debug(String format, Object... data) - { - if (LiteLoaderLogger.DEBUG) - { - System.err.print("[DEBUG] "); - System.err.println(String.format(format, data)); - } - } - - public static void debug(Throwable th, String format, Object... data) - { - if (LiteLoaderLogger.DEBUG) - { - th.printStackTrace(); - LiteLoaderLogger.debug(format, data); - } - } - - public static void debug(Throwable th) - { - if (LiteLoaderLogger.DEBUG) - { - th.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/net/HttpStringRetriever.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/net/HttpStringRetriever.java deleted file mode 100644 index beeffb5a..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/net/HttpStringRetriever.java +++ /dev/null @@ -1,232 +0,0 @@ -package com.mumfrey.liteloader.util.net; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.commons.io.IOUtils; - -/** - * Utility class to fetch the contents of a URL into a string - * - * @author Adam Mummery-Smith - */ -public class HttpStringRetriever extends Thread -{ - public static final String LINE_ENDING_LF = "\n"; - public static final String LINE_ENDING_CR = "\r"; - public static final String LINE_ENDING_CRLF = "\r\n"; - - /** - * URL to connect to - */ - private final String url; - - /** - * Additional headers to pass, if required - */ - private final Map headers; - - private final String lineEnding; - - /** - * Response code returned from the remote server (if any) - */ - private int httpResponseCode = 0; - - private final Object resultLock = new Object(); - - /** - * String retrieved from the remote server - */ - private String string; - - /** - * True when this retriever is complete, even if retrieval failed - */ - private volatile boolean done = false; - - /** - * True if the fetch operation was a success - */ - private volatile boolean success = false; - - /** - * Create a new string retriever for the specified URL, with the supplied - * headers and line end characters. - * - * @param url URL to download from - * @param headers Additional headers to add to the request - * @param lineEnding Line ending to use - */ - public HttpStringRetriever(String url, Map headers, String lineEnding) - { - this.url = url; - this.headers = headers; - this.lineEnding = lineEnding; - } - - /** - * Create a new string retriever for the specified URL, with the supplied - * headers. - * - * @param url URL to download from - * @param headers Additional headers to add to the request - */ - public HttpStringRetriever(String url, Map headers) - { - this(url, headers, HttpStringRetriever.LINE_ENDING_LF); - } - - /** - * Create a new string retriever for the specified URL - * - * @param url URL to download from - */ - public HttpStringRetriever(String url) - { - this(url, null); - } - - /** - * Create a new string retriever to be used synchronously - */ - public HttpStringRetriever() - { - this(null, null); - } - - /** - * Get the string which was retrieved - */ - public String getString() - { - synchronized (this.resultLock) - { - return this.string; - } - } - - /** - * True if the download is complete, even if it failed - */ - public boolean isDone() - { - return this.done; - } - - /** - * True if the download completed successfully - */ - public boolean getSuccess() - { - return this.success; - } - - /** - * Get the response code from the HTTP request, -1 if a connection error - * occurred. - */ - public int getHttpResponseCode() - { - return this.httpResponseCode; - } - - /* (non-Javadoc) - * @see java.lang.Thread#run() - */ - @Override - public void run() - { - try - { - String result = this.fetch(new URL(this.url)); - - synchronized (this.resultLock) - { - this.string = result; - } - } - catch (MalformedURLException ex) - { - ex.printStackTrace(); - } - - this.done = true; - } - - /** - * Fetch a String in the current thread, normally this method is called by - * the run() method to fetch the resource in a new thread but can be called - * directly to fetch the result in the current thread. - * - * @param url URL to fetch - * @return retrieved string or empty string on failure - */ - public String fetch(URL url) - { - StringBuilder readString = new StringBuilder(); - HttpURLConnection httpClient = null; - - try - { - // Open a HTTP connection to the URL - httpClient = (HttpURLConnection)url.openConnection(); - httpClient.setDoInput(true); - httpClient.setUseCaches(false); - - httpClient.setRequestMethod("GET"); - httpClient.setRequestProperty("Connection", "Close"); - httpClient.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/21.0"); // For CloudFlare - - if (this.headers != null) - { - for (Entry header : this.headers.entrySet()) - httpClient.addRequestProperty(header.getKey(), header.getValue()); - } - - this.httpResponseCode = httpClient.getResponseCode(); - if (this.httpResponseCode >= 200 && this.httpResponseCode < 300) - { - InputStream httpStream = httpClient.getInputStream(); - BufferedReader reader = null; - try - { - reader = new BufferedReader(new InputStreamReader(httpStream)); - - String readLine; - while ((readLine = reader.readLine()) != null) - { - readString.append(readLine).append(this.lineEnding); - } - - this.success = true; - } - catch (IOException ex) - { - } - finally - { - IOUtils.closeQuietly(reader); - IOUtils.closeQuietly(httpStream); - } - } - } - catch (IOException ex) - { - this.httpResponseCode = -1; - } - finally - { - if (httpClient != null) httpClient.disconnect(); - } - - return readString.toString(); - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/net/LiteLoaderLogUpload.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/net/LiteLoaderLogUpload.java deleted file mode 100644 index 187eea3e..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/net/LiteLoaderLogUpload.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.mumfrey.liteloader.util.net; - -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLEncoder; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import com.mumfrey.liteloader.core.LiteLoader; -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Upload manager for posting logs to liteloader.com - * - * @author Adam Mummery-Smith - */ -public class LiteLoaderLogUpload extends Thread -{ - private static final String POST_URL = "http://logs.liteloader.com/post"; - - private static final String LITELOADER_KEY = "liteloader0cea4593b6a51e7c"; - - private final String encodedData; - - private volatile boolean completed; - - private String response = "Unknown Error"; - - public LiteLoaderLogUpload(String nick, String uuid, String content) - { - Map data = new HashMap(); - - data.put("nick", nick); - data.put("uuid", uuid); - data.put("token", LITELOADER_KEY); - data.put("version", LiteLoader.getVersion()); - data.put("brand", "" + LiteLoader.getBranding()); - data.put("log", content); - - StringBuilder sb = new StringBuilder(); - - try - { - String separator = ""; - for (Entry postValue : data.entrySet()) - { - sb.append(separator).append(postValue.getKey()).append("=").append(URLEncoder.encode(postValue.getValue(), "UTF-8")); - separator = "&"; - } - } - catch (UnsupportedEncodingException ex) - { - ex.printStackTrace(); - } - - this.encodedData = sb.toString(); - } - - public boolean isCompleted() - { - return this.completed; - } - - public String getLogUrl() - { - return this.response; - } - - @Override - public void run() - { - try - { - URL url = new URL(POST_URL); - HttpURLConnection httpClient = (HttpURLConnection)url.openConnection(); - httpClient.setConnectTimeout(5000); - httpClient.setReadTimeout(10000); - httpClient.addRequestProperty("Content-type", "application/x-www-form-urlencoded"); - httpClient.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); // For not fail++ - httpClient.setRequestMethod("POST"); - httpClient.setDoOutput(true); - - DataOutputStream outputStream = new DataOutputStream(httpClient.getOutputStream()); - outputStream.writeBytes(this.encodedData); - outputStream.flush(); - - InputStream httpStream = httpClient.getInputStream(); - - try - { - StringBuilder readString = new StringBuilder(); - BufferedReader reader = new BufferedReader(new InputStreamReader(httpStream)); - - String readLine; - while ((readLine = reader.readLine()) != null) - { - readString.append(readLine).append("\n"); - } - - reader.close(); - this.response = readString.toString(); - } - catch (IOException ex) - { - ex.printStackTrace(); - } - - httpStream.close(); - outputStream.close(); - } - catch (Exception ex) - { - this.response = ex.getMessage(); - LiteLoaderLogger.warning("Error posting log to liteloader.com: %s: %s", ex.getClass(), ex.getMessage()); - } - - this.completed = true; - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/net/PastebinUpload.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/net/PastebinUpload.java deleted file mode 100644 index ccf099db..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/net/PastebinUpload.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.mumfrey.liteloader.util.net; - -import java.io.BufferedReader; -import java.io.DataOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLEncoder; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import com.mumfrey.liteloader.util.log.LiteLoaderLogger; - -/** - * Thing for doing the whole pastebin malarkey - * - * @author Adam Mummery-Smith - */ -public class PastebinUpload extends Thread -{ - public static int PUBLIC = 0; - public static int UNLISTED = 1; - public static int PRIVATE = 2; - - private static final String PASTEBIN_API_URL = "http://pastebin.com/api/api_post.php"; - - private static final String PASTEBIN_API_KEY = "2eda2d0840d2ab7e1ed036e3e810bfda"; - - private final String encodedData; - - private volatile boolean completed; - - private String pasteUrl = null; - - public PastebinUpload(String author, String pasteName, String content, int privacy) - { - Map data = new HashMap(); - - data.put("api_option", "paste"); - data.put("api_user_key", ""); - data.put("api_paste_private", String.valueOf(privacy)); - data.put("api_paste_name", pasteName); - data.put("api_paste_expire_date", "N"); - data.put("api_paste_format", "text"); - data.put("api_dev_key", PASTEBIN_API_KEY); - data.put("api_paste_code", content); - - StringBuilder sb = new StringBuilder(); - - try - { - String separator = ""; - for (Entry postValue : data.entrySet()) - { - sb.append(separator).append(postValue.getKey()).append("=").append(URLEncoder.encode(postValue.getValue(), "UTF-8")); - separator = "&"; - } - } - catch (UnsupportedEncodingException ex) - { - ex.printStackTrace(); - } - - this.encodedData = sb.toString(); - } - - public boolean isCompleted() - { - return this.completed; - } - - public String getPasteUrl() - { - return this.pasteUrl; - } - - @Override - public void run() - { - try - { - URL url = new URL(PASTEBIN_API_URL); - HttpURLConnection httpClient = (HttpURLConnection)url.openConnection(); - httpClient.setConnectTimeout(5000); - httpClient.setReadTimeout(10000); - httpClient.addRequestProperty("Content-type", "application/x-www-form-urlencoded"); - httpClient.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"); // For not fail++ - httpClient.setRequestMethod("POST"); - httpClient.setDoOutput(true); - - DataOutputStream outputStream = new DataOutputStream(httpClient.getOutputStream()); - outputStream.writeBytes(this.encodedData); - outputStream.flush(); - - int responseCode = httpClient.getResponseCode(); - if (responseCode / 100 == 2) - { - InputStream httpStream = httpClient.getInputStream(); - - try - { - StringBuilder readString = new StringBuilder(); - BufferedReader reader = new BufferedReader(new InputStreamReader(httpStream)); - - String readLine; - while ((readLine = reader.readLine()) != null) - { - readString.append(readLine).append("\n"); - } - - reader.close(); - this.pasteUrl = readString.toString(); - } - catch (IOException ex) - { - ex.printStackTrace(); - } - - httpStream.close(); - } - - outputStream.close(); - } - catch (Exception ex) - { - LiteLoaderLogger.warning("Error posting log to pastebin: %s: %s", ex.getClass(), ex.getMessage()); - } - - this.completed = true; - } -} \ No newline at end of file diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/render/Icon.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/render/Icon.java deleted file mode 100644 index 38fa57ec..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/render/Icon.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.mumfrey.liteloader.util.render; - -public interface Icon -{ - public abstract int getIconWidth(); - public abstract int getIconHeight(); - public abstract float getMinU(); - public abstract float getMaxU(); - public abstract float getInterpolatedU(double slice); - public abstract float getMinV(); - public abstract float getMaxV(); - public abstract float getInterpolatedV(double slice); - public abstract String getIconName(); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/render/IconClickable.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/render/IconClickable.java deleted file mode 100644 index 3a2609b5..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/render/IconClickable.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.mumfrey.liteloader.util.render; - -/** - * Icon with an onClicked handler - * - * @author Adam Mummery-Smith - */ -public interface IconClickable extends IconTextured -{ - /** - * @param source Source of the event, usually the outermost gui screen - * @param container Container of this icon, the actual component hosting the - * icon - */ - public void onClicked(Object source, Object container); -} diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/util/render/IconTextured.java b/liteloader/src/main/java/com/mumfrey/liteloader/util/render/IconTextured.java deleted file mode 100644 index e7fb57c2..00000000 --- a/liteloader/src/main/java/com/mumfrey/liteloader/util/render/IconTextured.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.mumfrey.liteloader.util.render; - -import net.minecraft.util.ResourceLocation; - -/** - * Icon with a texture and tooltip allocated to it - * - * @author Adam Mummery-Smith - */ -public interface IconTextured extends Icon -{ - /** - * Get tooltip text, return null for no tooltip - */ - public abstract String getDisplayText(); - - /** - * Get the texture resource for this icon - */ - public abstract ResourceLocation getTextureResource(); - - /** - * Get the U coordinate on the texture for this icon - */ - public abstract int getUPos(); - - /** - * Get the V coordinate on the texture for this icon - */ - public abstract int getVPos(); -} diff --git a/liteloader/src/main/java/net/eq2online/permissions/ReplicatedPermissionsContainer.java b/liteloader/src/main/java/net/eq2online/permissions/ReplicatedPermissionsContainer.java deleted file mode 100644 index b86beb04..00000000 --- a/liteloader/src/main/java/net/eq2online/permissions/ReplicatedPermissionsContainer.java +++ /dev/null @@ -1,129 +0,0 @@ -package net.eq2online.permissions; - -import java.io.*; -import java.util.Collection; -import java.util.Set; -import java.util.TreeSet; - -import net.minecraft.network.PacketBuffer; - -/** - * Serializable container object - * - * @author Adam Mummery-Smith - */ -public class ReplicatedPermissionsContainer implements Serializable -{ - /** - * Serial version UID to suppoer Serializable interface - */ - private static final long serialVersionUID = -764940324881984960L; - - /** - * Mod name - */ - public String modName = "all"; - - /** - * Mod version - */ - public Float modVersion = 0.0F; - - /** - * List of permissions to replicate, prepend "-" for a negated permission - * and "+" for a granted permission. - */ - public Set permissions = new TreeSet(); - - /** - * Amount of time in seconds that the client will trust these permissions - * for before requesting an update. - */ - public long remoteCacheTimeSeconds = 600L; // 10 minutes - - public static final String CHANNEL = "PERMISSIONSREPL"; - - public ReplicatedPermissionsContainer() - { - } - - public ReplicatedPermissionsContainer(String modName, Float modVersion, Collection permissions) - { - this.modName = modName; - this.modVersion = modVersion; - this.permissions.addAll(permissions); - } - - /** - * Add all of the listed permissions to this container - * - * @param permissions - */ - public void addAll(Collection permissions) - { - this.permissions.addAll(permissions); - } - - /** - * Check and correct - */ - public void sanitise() - { - if (this.modName == null || this.modName.length() < 1) this.modName = "all"; - if (this.modVersion == null || this.modVersion < 0.0F) this.modVersion = 0.0F; - if (this.remoteCacheTimeSeconds < 0) this.remoteCacheTimeSeconds = 600L; - } - - /** - * Serialise this container to a byte array for transmission to a remote - * host. - */ - public byte[] getBytes() - { - try - { - ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); - new ObjectOutputStream(byteStream).writeObject(this); - return byteStream.toByteArray(); - } - catch (IOException e) {} - - return new byte[0]; - } - - /** - * Deserialises a replicated permissions container from a byte array - * - * @param data Byte array containing the serialised data - * @return new container or null if deserialisation failed - */ - public static ReplicatedPermissionsContainer fromPacketBuffer(PacketBuffer data) - { - try - { - int readableBytes = data.readableBytes(); - if (readableBytes == 0) return null; - - byte[] payload = new byte[readableBytes]; - data.readBytes(payload); - - ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(payload)); - ReplicatedPermissionsContainer object = (ReplicatedPermissionsContainer)inputStream.readObject(); - return object; - } - catch (IOException e) - { - // Don't care - } - catch (ClassNotFoundException e) - { - // Don't care - } - catch (ClassCastException e) - { - // Don't care - } - - return null; - } -} diff --git a/liteloader/src/main/resources/assets/liteloader/lang/en_US.lang b/liteloader/src/main/resources/assets/liteloader/lang/en_US.lang deleted file mode 100644 index 4d1e45c5..00000000 --- a/liteloader/src/main/resources/assets/liteloader/lang/en_US.lang +++ /dev/null @@ -1,89 +0,0 @@ -# This file MUST be saved as UTF-8 - -key.categories.litemods=§eMod Keys - -gui.about.modsloaded=%d mod(s) loaded -gui.about.versiontext=Version %s -gui.about.poweredbyversion=v%s§r powered by LiteLoader v%s - -gui.about.checkupdates=§nCheck for updates - -gui.settings.showtab.label=Show LiteLoader Panel Tab -gui.settings.showtab.help1=If you disable this option, use CTRL+SHIFT+TAB -gui.settings.showtab.help2=to open the LiteLoader panel -gui.settings.notabhide.label=LiteLoader Tab Always Expanded -gui.settings.notabhide.help1=Only applies if the above option is also checked -gui.settings.forceupdate.label=Periodically Check For Updates -gui.settings.forceupdate.help1=This option is §cexperimental§r and may not work properly -gui.settings.forceupdate.help2=yet, it also enables the "force update" capability. - -gui.about.taboptions=§nLiteLoader Panel Options - -gui.about.authors=Authors - -gui.disablemod=Disable mod -gui.enablemod=Enable mod -gui.modsettings=Settings... - -gui.unknown=Unknown - -gui.status.loaded=Loaded -gui.status.active=Active -gui.status.disabled=Disabled -gui.status.pending.enabled=Enabled on next startup -gui.status.pending.disabled=Disabled on next startup -gui.status.missingdeps=Missing dependencies -gui.status.missingapis=Missing required APIs -gui.status.startuperror=Startup errors detected -gui.description.missingdeps=Missing dependencies: %s -gui.description.missingapis=Missing APIs: %s - -gui.mod.providestweak=Tweak -gui.mod.providestransformer=Transformer -gui.mod.providesevents=Injector -gui.mod.providesmixins=Mixins -gui.mod.usingapi=Uses additional API -gui.mod.startuperror=%d startup error(s) - -gui.mod.help.tweak=A tweaker is a special type of mod. Tweakers have almost unlimited control of the game and are usually mods which alter the game engine fundamentally, for example APIs or performance-enhancement mods like Optifine. Because they have the greatest amount of control, they are also the most likely to cause instability when not compatible with each other, if you are experiencing crashes or serious problems, you should always try disabling tweak mods first. -gui.mod.help.transformer=A transformer mod uses bytecode injection to hook extra functionality within the game which LiteLoader does not normally provide. Because transformers access functionality outside of LiteLoader's core, it is possible for them to have unforseen side-effects when combined with other mods. If you are experiencing crashes or other unexpected behaviour, you should disable transformer mods before regular mods to determine whether they are the source of the issue. Forge refers to this type of mod as a §lCoreMod -gui.mod.help.events=An injector mod uses a restricted form of bytecode injection which makes it somewhat safer than a full transformer mod, but can still cause instability under some circumstances. If you are experiencing crashes or other issues, then you should disable injector mods before regular mods to determine whether they are the source of the issue. -gui.mod.help.mixins=A mod with mixins uses a safe form of bytecode injection to hook into Minecraft - -gui.settings.title=%s Settings -gui.saveandclose=Save & Close - -gui.updates.title=Check for updates for %s -gui.updates.status.idle=§7No update check in progress -gui.updates.status.checking=Contacting update site... %s -gui.updates.status.success=§asuccess! -gui.updates.status.failed=§cfailed! - -gui.updates.available.title=§nAvailable Update Info -gui.updates.available.nonewversion=§7No newer version available -gui.updates.available.newversion=§aNew version available -gui.updates.available.version=Version: §a%s -gui.updates.available.date=Release date: §a%s - -gui.updates.forced=Update forced, restart the game to apply update - -gui.checknow=Check now -gui.installupdate=Install now -gui.downloadupdate=Download now -gui.forceupdate=Force update -gui.exitgame=Exit Game - -gui.log.button=LiteLoader Log -gui.log.title=LiteLoader Log Viewer -gui.log.scalecheckbox=Use native resolution -gui.log.postlog=Upload Log -gui.log.uploading=Uploading log please wait... -gui.log.uploadfailed=Upload failed -gui.log.uploadsuccess=Upload succeeded, log available at -gui.log.closedialog=Close - -gui.error.title=Startup errors for %s - -gui.error.tooltip=%d mod startup error(s) detected (%d critical) - -gui.notifications.updateavailable=LiteLoader Update Available! \ No newline at end of file diff --git a/liteloader/src/main/resources/assets/liteloader/lang/pt_BR.lang b/liteloader/src/main/resources/assets/liteloader/lang/pt_BR.lang deleted file mode 100644 index ddb90a75..00000000 --- a/liteloader/src/main/resources/assets/liteloader/lang/pt_BR.lang +++ /dev/null @@ -1,67 +0,0 @@ -# This file MUST be saved as UTF-8 - -key.categories.litemods=§eTecla de Mods - -gui.about.modsloaded=%d mod(s) carregados -gui.about.versiontext=Versão %s -gui.about.poweredbyversion=v%s§r powered by LiteLoader v%s - -gui.about.checkupdates=§nVerificar atualizações - -gui.settings.showtab.label=Mostrar aba do Painel do Liteloader -gui.settings.showtab.help1=Se você desabilitar essa opção, use CTRL + SHIFT + TAB -gui.settings.showtab.help2=para abrir o painel LiteLoader -gui.settings.notabhide.label=Aba de LiteLoader Sempre Expandida -gui.settings.notabhide.help1=Só se aplica se a opção acima também é verificada - -gui.about.taboptions=§nPainel de Opções do LiteLoader - -gui.about.authors=Autores - -gui.disablemod=Desativar Mod -gui.enablemod=Ativar Mod -gui.modsettings=Configurações... - -gui.unknown=Desconhecido - -gui.status.loaded=Carregado -gui.status.active=Ativo -gui.status.disabled=Desativado -gui.status.pending.enabled=Ativado na próxima inicialização -gui.status.pending.disabled=Desativado na próxima inicialização -gui.status.missingdeps=dependências não existentes -gui.status.missingapis=Faltando APIs necessárias -gui.description.missingdeps=dependências não existentes: %s -gui.description.missingapis=APIs que faltam: %s - -gui.mod.providestweak=oferece o Tweak -gui.mod.providestransformer=oferece do transformador -gui.mod.usingapi=Utilizar API adicional - -gui.settings.title=%s Configurações -gui.saveandclose=Salvar & Fechar - -gui.updates.title=Verificar se há atualizações para %s -gui.updates.status.idle=§7Nenhuma verificação de atualização em andamento -gui.updates.status.checking=Contacting update site... %s -gui.updates.status.success=§asucesso! -gui.updates.status.failed=§cfalhou! - -gui.updates.available.title=§nAtualização de informações disponível -gui.updates.available.nonewversion=§7Nenhuma versão recente disponível -gui.updates.available.newversion=§aNova versão disponível -gui.updates.available.version=Versão: §a%s -gui.updates.available.date=Data de lançamento: §a%s - -gui.checknow=Verificar agora -gui.installupdate=Instalar agora -gui.downloadupdate=Baixar agora - -gui.log.button=LiteLoader Log -gui.log.title=Visualizador de Logs do LiteLoader -gui.log.scalecheckbox=Usar resolução nativa -gui.log.postlog=Enviar Log -gui.log.uploading=Enviando log para o Pastebin... -gui.log.uploadfailed=Falha ao enviar -gui.log.uploadsuccess=Enviado com sucesso, log disponível em -gui.log.closedialog=Fechar \ No newline at end of file diff --git a/liteloader/src/main/resources/assets/liteloader/textures/gui/about.png b/liteloader/src/main/resources/assets/liteloader/textures/gui/about.png deleted file mode 100644 index eee2a893a87dc078e750f78f0423b0a4e6e27ab6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 43567 zcmbTdWmH_jvoE>_cMlMBa1vYt6WrY`KyZRP!DVpQKyZfu!QFy8!9BQ3@ZkRDf9^T= zy$^TY4{z39Ys-{$cUAZ9s`~8+6(wm*G!irb05D}`B-8)^1iJ(QC`hoAzH`YJ*y*jS zq>ih)!xvX~V`pRY+^kx?tz1sQAAH+q?YtK*5HL&BNG{jf0h)&Cc#W z{rWFz7gsg&|F;?cM`{-hPe*e$HFFn-ug<10dwik!A7jq@Z!4CXiqYJV6KWXRqz$5Oy&Hn$4 z7#plHZ2xhM|BtKu&m)-s{pa$3J3j2@e@`8Ad)Rz&hE0qgmi^oS@WWVELR7G(4; zbar-LX!z<++DVAr6_&hadN|tqa1&`s$@My>MhoeycZ^$ALOH7zlFZ?`iy+aYA8_y6 z+1i-(7T4S#6#lKdFrL+!R zW@T?L6tvCvy)JR;_hUxvNv#>fI-4t%?z+W8?DZ5ut`h%$2%@qtBxAyZ!zB;u@#YsN71d3`6;X ze-P~O{G@ihwL}jNwp<|%V&3u%LJWU6dw4T%EX}6Vh(zNac>&guRvkZF*2i`YJ_*< zxS%cu5N+vX4#5jPCSc&dt$5+`zHI6SE_7_4uPWo#$zH4A0un8EDX{=a%G&p#&ShLP9%s8-6wQ z@}cX<87P=bII43TtoYE-bd!=U52E^6S@~mJ@F~B(zTWI$GOuWp7>WQi`##>p&`1wHq{P_0}rmbdO1HTD)ZM8OHNgRaB5m1p8rw zKI&Op|4qEQx;k?r=QJDQ&6#LwC@eHfG}=F+z3~HpaPWHI{_Vlkc2wo(Hb2j0yQbac zlbeNgpUW|V&Bd;VDQU_goVrc_ohFk0^|ySE8*a`oZq8ZgyMrIeVh7JV!Ua1Oh9^YE z`Gb7cCA1L8>`YC!X?9$SJp9|et{*a=VD`7JolmfMO9Nl;xZ&Zg83qGEUV&3dNy_#)nYghTr+==B2}@KbO&Q9?(N;VH0w3X3{g zvHrrfRduIrB{MU#>h>Whw_$P@R92{5p*oa~-;JXS_|VBs3TrnA<=0Xe{>ri z8XternGUrrR?6z2g=>fFJe$nxed94+{;5t41!vm=Y`fL1S|D|jtoG2{+>ETMw|!e6 z9oHdwr^H|kd5`H9I71T5hhJES zR?3E+yUEMrg6=+V2VLCAfAhH=ueJRvdKEBa_zGFQn>b3l-5cLlX5ZAlLJWudWw+d@ zTG*~5_AHGvmd1o%4GuGqmzU>a^tdJ^A@O5?^Tz_k`rQf1=*8i69{s7?mqX3M_ShNb zXHrvFf5c-art)Ls1mM>4QNh<+b@{z&&i>IOTqESsj)^xpUBKk*3W`D8a&AK(BC7BS z9dkxv!gpS$+3-z#*<$$oib*Ymim71oD%`-{PYfo=s1dLDio)rW`^(|a0z#vn`Opha zOmrMFwV=erM8O>|=nF`Ije`R>0JucreZTncO27nSOAA2vuae=Rj-RJ8*p|-9qp5=V zZp{E(dwx^|20XwrqJ82VLNi4#0^#8!!?K18Hxl6{#rZ3zZG2JB*A6~3%M3=GoL~U( zRpbB@8ylM{StTVu&B=Pjv9U4X#2bi2qe0eW}m0VXGd^#M#r7XpF* z%&M&tO)2c~Vrq(y5Z20#XN_Trl?nKP-l3?($S&<#1&sT@92CUGD$2;DirU_O@V+{@ z80!u~z73hFHXe=4Ju?p+ElH)MVwMB}fogu{T|E*wci(hh&U%27ZMiae8ClsMOBC8p zROy(=H3)dlI^QK3QcfRA7laBIj{Ku8>*}dst`K_!W-kd=*jkPP3M2tAdJ4WIE}OINV-_w7apnAZ-Cr&Q zhu|Y673Qx%?0+hmoSdvE9*V(A`Qh|o=S!;Dp3GBFaz#a1t>0LZ;XI86B6fj>Ncu6vFUBy47C!IC}HC&H?=IdaKR z=B!9(vdz7!5SJ#@oy6tg0M{ap)cfVFMJ9(DPGoK-$P6@CbIDd+uHWJucGvRj*Hey~ zF;$?~X0B+^7ugIfv)HNA)i&(p?8_mVI2}?_Qj3DFL|%Kp-DGXTZTHvv34fA|^z@QR z_midT1oPkDuM^Q|aUU!~RA`t#)$YJMy~5r&yy1X~ii%^zT^rYz(Qt%$+~Rx8K$8Nivg@JOhC*rXMVp75Gx}AQ{ zegw-AQ1K_&k|u$xgbev=6ROlBNL)zs)3D zQlTLnV2ln8bxFMGa?~_2p%%mv6^$mqk=@ig<|VqZF`g4WAa-v)*&~f5;?3nAiDlq^ zsQLc=yE}q9BXUTLZAI#4ljr501?~PLEz{?}fB)`L8Ex=4=d0v**)7!{l2AVh%OIZo zvB;^&;dj~N*=g#?6(XT-o_4u`y&On!UnKEzi}r;sN4c6J0h;U}Fm%viz2n&mF?35_ zS=qlOFVDF0P9Zg!@d474Cd!b49}E)U+`iBtY^JR2JZ+^id0%aLY03@s28kw$cF+){ za>C7ydyqXK5`V8)>M$LQ`{;hc>H;BK*0pVXZgV?keDayw^XZNc=3P_ZBSReiUaJ?IQu~zs`uwaAdKv@>k z%Veo@QK!85u_(3U%3I02Gx7YA!>mvKv8*Ob3vt}| zPtk#&7}JC0j+|!bb>o(QTl^@V)_0y=%713VM1Ic!v|J+l!vB*jo^m7Q13Qev_J>WK z9Ub-=%lj<$R@N)_?CE5g6AMEZ`cYbC3<}*wWtElAMdq%KPSuj|8c$>k zjy_x;fd=7?-m}M|f^P(9X=xcb0oA)AfNBgKh3q$Hd}8M8_N+S6ZS^19eI8z(DI61d z`KaFgZ4v>4GyB@P#O;6h9*cfQV;?&H4J@A_3izoi%{tW^3c-);Htk-;#dOgUqp+Z% z;RX|GDB$oIiZGAAE4o06hBGzoxs%*k#_tv#Vyq8wO^%z0C-N5ju`D5v;3?wdgvxB# zk!kIO0L=b_g(@LTmCb>Bzz`8P(Ikcl4o)57+$f?xvlbIAExnl5QMefXJYVv$397y@(Bs|tVq{F@Bh zz^7znWN^H*2*%S(Y{azsO%^gvL&VM--Gw}d7QXR81s){1Dg4}RZmMwcc71D2L{WxL z>!7y1+IhajqUePjRebZ6I&U{lMHmGYH7=*U;obD`pixE%AIPqewp~fNp>t7{V;H&D zM^2YKgi;zKKLQ+!-^IdOvMPBg%1zZ5%N9qb!jLy5qph!|K7+ynCFnLLK3Mti3Jd6d z`#c^5imD)YZPw>U(E73#@zRwAkoCToR3#wHil+Z5iRkgiDc6MLoWrB!o?Qt0`!8-@ zltoSAxBHh{Tt~h7dM8cPA$SF8CyXomI+evgu6fYh{QHVx?C@ChqUh8JD1g65f4v3= z^*CIjIe{r;=!HKwJc07R6kK!^Hj1!*vG+_&hwjahaIw*FRV)vv67$fUB7ajF|NHxV zLd%LQ%KSg}_xsmZkgE0@h<{SBu!ujuC~;v6b|hQ&HX{J-47cR&49N=q++eMFmXt&g z*|Q^{n_9;s9k^Q)%?DZx6%9hNOSZyqVGBStosj;x6lX1veQ5= zkzSO-QwiTNigG(e;HhJy#bt&h*e&q#t7)ct!s5K3Im^i@ z+zd&n_***8G}VAf4es&E5I3#A-YLUx=*x3s)1s|r3}#G!Rp-SL6`YEYCqw7uxYg*< zNsc%U0-V_D6ZnAw3m|ry)o=xJ-wOHM;Ulnzg?x;!KXNd0iP%~5F}9?`2LVYvsiNv( zPMO;H$&K4S`Hku%s3Rqo%=FRXsu9n@oJr?(JfZ{(*b4^JjqzT0*Bp(glzEEOAgHch zNkeh^x@?VNy~O!PjieM&F)`}7oqR26q{$+AqE>94x9KPc1RBm5kxC*7gz`L;XiWrw z3L`AhxO(RPM#ln2)UvXws;c%Q8Qt^4HB(t>nV#E1{W4Ma6zP|8jbL&7T@Noa9!74Y zPenP7=)8e!>D#i8wbX5Z|Duv^V}^FkVXxxLJM4Qz{uU2IS3o2!(2#57EGYR;Cr-Bw ztFi=I3i&(tAx<12DyC_(a=CE>&t_#J7GP*eBKysIMjQiskL!?UH9UYaR4_LD}vjhLo2I|nd|CFqlEg(D!6kOTb#kK>na zcfp0m&4A*LP$4GTL+dJMg^}}3Rj%RP=&UnlVHVfqVM_@JivO|A^%pcr?D9P>k_xU* zPEY#<+H7VFCpAq@Bnz3*$o8}DTi_s8B;%Z;UbYZ|x%s0k2<13(1~2dI#E~xoX#sC@ zHynoqZt3m2R+$;q)TwdlFOwB|P0*~k^}HMD&3>_DY9PE(&>okpZ@VC`e+b91{{ry` zU)jag%wQirU>Pq!W=A~C2faanTWZNS2NGMKI#2+doj0)oAYv-l@9SVizw?dm%dPG0 zM||FexOz`$EpG0*WLLWx%$&bjf1URP;iRuqnq4No;Lt^F7EO!}lUY9HmR9Z3@9t#{ zT7Ts)*IJKL;+D(_v-#(l*(MOXmlf9ddMCdb`N|9ZM~vVZhRwGpwNhgQ<>$AcE}Pop zEa&}z65U?;IdkE&bs5Y3^=(ttGAlfhfh>;n`t7r25Ko%E@&e`Aw|(C+3h9}%`?7ss z7t80t@e*Gk><_(x#qZdL*R*DZB9^2@cv8%xkIw-`G%@qDOuiHgtvT5g&ozzGaTJu; zg1bpVWD^`;8yY^BmHn(;VQn&)eaK&pg?qR2h>R8-uJj%ORX|I?K<=a_-O<$4bc1Y4 zzstD)A7fCWi(=Kxm#=42g5P}V<+-!TR^zUsd8i0QQRNVquzawiNa6On@9pX` zs^h?B^;Wn{U+o2xRynck(w{omj&Li(p`%5HAoWw-mwx38-jmS6!a~x%bPyUwR45&T zV)_+=r$yV%@gFWOHnuaOH-x!wEN!`$l#Y)LWGyVD74-N<)7P#kriZ0VvdX63j?ZP_ z=MJX5LRkwc?|wo2pQD!dUXOAWT%2of^Z73mlC_UmhHtqrG76Rqdd^6ghaFF6GUT%q z=h!MdPgg?F7D7((DP)d0|Nd-|IF}v?;wH(u$b2DM@z=hcDfVmJyT72UuTdlhRfm4! zYF#H+%!u~)lK(bn{`l)W<^GlB;qcmv9~}F5TZL_n>4Y785@&E5`bIg^OLM>OwEBkc zD72|>f7>UUQ*I4)&QGmuj*jO~`d6uTDi$uLj~61{FUBn`kwHgVhGvkm9u@M#l*x6xCay6r?!vlCVtelxSg#%vtWd8ly(0U-Ou(u z72xUCj@Y?6S?_$cfJOC&Py52JY1cd7lzE5hljwB;Kv*5;9p_w$#hA`>{92~RX9cQv z?f3si{Y=@EJ&X=}Z4CL&xZaZH-p-$_JmR&*c04?*h{o*XesNJiean{l-1mU$?eDdp zm)LMN7xf&9A}zKs^Me_Tk?)XtS@EL}>qFN4kaCNiExz0FcIW8yTb7hQ$C-xW3?2T%fLB83eTB~?Khn~B^pCC&Y}Cj^mytr5Yuiv z2?Z(Tw`U?ST4&i$WV*lH?)~iPfr}fJvQ-9$BLT!H6+NVfcd0~h1B)%uIsPx6w=U!S z`*zbx^Nsq0CN=uJz7JP^2mouMwL<_%!W{10uaz_v?PT;&xZvDyb$)=C!TgyrZ|k^~ zXyR2L4age*#gez2TDl%K^N>Iov*zkn<5KCt*}`NUuzru)DFiYbHWJ^0I}x^(Hmmwn;7(2_TKO32uIadTsvlC z%BLl#q^xJ8rQNp{p46*80=n`EM@XM<2XMq%s)SZoKR#qy-Y7ju}%Deih7q7aT_l2+}ZiXJ7V5TaV-RqdliLP23-#(H*d5JeH-ffX2=`xRoJ~t*1<)Wx#4eg!$0eW*c5K#)jcZU=TrR1 z`_SmH!rQ6LpmDjU7@bsbqpX-)4r!c3#)j_=zxxtR zAk89iOvDe`Cp@HF&7T@U*Y4@%sHn&+7Z()N!S--~LC(Svjo46>CkPGeJoyeVQUQ*ap163g62Sp1tWO8QBPoQtj{i{1*rTVX7y6{5bN9Ir7GP7x zrK?cpUaIbMPFl>nLAK{@E2!*M3JX5?J$1n|W%FI%$n;1YJWO_^j7drV98O$1%#>MR zS#Es#lamcOS#Ln*Z6{RavUVjuZ-uY&^pxOMUey0oeNbF1J;A(Mdlf>wBr$W;Gw6-G z@s|R%xmvLLGqu#v=!FFe0L8zxUS3mv9=EOtl+Idiepz5?{QjK@9}jN^34n}O zA?5=?(=rbgD{EyKpR3OMq^Z8AU3vh5TqG8=pdc?_P&5QrM}R&q%|RQnkee1HaNzBB zl<7Q0mjWT@&B!`-`Iw1i;rqGWdm?*v&CLx<%4gP+2X-UqG+>0#{Wh5H8r9uaU42H> zdGy=H1PGjZ+)g)r4NFF820rgC82Ufg*(_8N1%LbwaJjK^9HN=P>y z>FwY#NNJa`sJ%gV_i-)`ut-qE%{y$T{_MSDCutWw4aD97Jg4QKq@sy@kC zYvQ+NsA!Gov8Lh{?a|g#4^k3!gfRWoda5QkiNUjWP->k#ar3rkVq&VxC6ulbw07sl z-D!X?I2W6_+?_Qnt%do`t{sQ@NKy_;9ixMNjV7)mBNexK+sy8o$NotZOUNWfz3Epz z>+;y&A|VtpQurL&dKmJ~svgm@dRR!ZSmNBnveVw24CZc8YFua=WN&HTY6T@=3L3+& z7BpjfbryAwmmRvl_^R^#jldjpRBaH%7Qo+b%LhbKrF_gj?G&M^o#OSCFuoTQ(ZIZive5&?&OF*!L51Ln1jN$NSe!Es6jZMsJn>yW#xQ8EK3vfip zjN|l3;wOEV{YG!TbaJCmJi{NKibJHKsqH}3mJ;<$DTe%;3^Tyqz0R~d5K%P*3(p;PQFHjGU&ys~3^o{!`Q3aQ->iO4_``G4|f&1!O<^_r~X&>ZlfjmnIq}-`A&ZSb8hLb5?)KBe?gNzb2sYx{wL9_IJn)=c6^)K~` z`Qx)1{uC7w>T+e@8DT-Y0ZlLXau$IR!U;v`HMM#HAkT#)6j_0mXX>OfoDh|Fc_^J_ zB_+B0+n%W@xqn^Fh=13&oeg_DC#RHw`9A2TOMWfnLS86LPt)dm#)AWcKj8ulE8}{tvN$Y#qH*bc94KML> zg~lZh_aS(ZZJ8xy3I0Hnex_gh$T1T1Hhg-b`|gZq-daetA!03a();PSg0fx@dE4iv z$B;;%!~f8w4UzW@N2`hiU=MtYV;g7H;1;&pt*NP1i$v|XMGWem*YM+`p51B&HFyQ$ zZWKMhj)=W2h%!NfTt%1sN%g^ElUSSYiOlf+?{YJ)h7rkDMBfO9*(7abRCscSLw zI$G)WCw9{fIvhwMr{&YjyANaJr0aQupAx9i(dgB1}=rX{?$+FQq!xyho^qJ z4^(KQE7N8wNZ#u86g6I{*DBtQLPO83FORl1;>f_(F1$ZLkr3@ai~ms|B}Mf{@I@^z z?kl8pC&}z*A__`C05mexmjByM5m6-p-o zaIn5qyeBXyEcBe`_)QYw##Ddk&=t4)HgL>-kQ|gj!GJFrAZ-_oDxB{&kk?Bi6`kuJ z#SD5Iz_(nTeh4=7x;oZe{NS*mmA$P-hUG0Vcv%|!J&ly~@3(6&GZ5CnQpIC;db)13 zDJj)c>OteLQ8z>=u_Cm9>PbLy#T3!ZjArw}@ZQHjx5=33a2rpWV$Y8K1O+(RGl|?4 za`O}Njgq(%oYp+LeApN+-kXdPyuWju`b4kgjQT>Az5n;G^aw)n&;! z6AzyDo&7icDO7b5Ruoq57FA#%#P>-Wg>v?=uKB0DGqc_OhwjQ`r7Eg(ZV` z&i#1yUF_nk)6ReotgKr~qJ^K6RuJdXwt|Q*oMlJ_0vfPrtFqjGC6~t{vYY5uziiaZ zQFPP8qxprc6|d({WwgE^-cGT8nNnpZpQ8`GurA`{yFBE7!jD4?5Q%U9mXyhP`y@-` zFlo)5dXcQFr}ypX#)DHXDyj`QkDGD38!ayT z<1L$^q;4XXvOJ!rVPaFLdph}Tqi?ZaJ>ocoShl*zVbj`L-6V`FHX`LsNZMxOhtqq{ zo7CbrN%neVadJ^h(W-d`5j{|#&avBvpx*8R6?JbmY1Sh~>)Vf+Lv`s`62a2uk`3M2 ze5YX~%wzhlU z4nG+GnYKVV!XZ^+-tI%yV?)q(yB5WWU>tlDgK9$>Qt^PHkQ^JPIlH5-AB>C;myt2b zO!AoX4@sw)O`Bt7DX}^2*U^j)4?5K|$#PH-z>4e@3EI-S-@1vn1!ZySFNZDvit`nhy_ zl(_vu-k@w<`>WZqYZfKLBmxZ8gG0zfOS}u`_N;lII7kPCau=Dm;`)&EKg9cZH2T93jh~SR!TiZz<*3j3yU{TV

    W8kA#-ikCzT) z3X?^yFxuD(?GS^Bs#!ouRz6w5GvDI_{IV zlR=zd=#g}C;8EiTGFxpRTx+`#4wtm|tEttu#ei@JE+$j~7Y!hH3mYYv@aFW-XYu(M zu*Q2_t>Ipg6}*cM*x^`wen+Z+03pUM9vE*`8w+SD&`5O;2!If9Ir?=DM%5~4tl$3&tCE*f zQzJoGz|=?&Vr|}j;M!U0O~Y^a#`^AE=^3mtIeWk6ea6z&3Bzi*$2XFao@Q?LhQ(23 zVE!i+cP{fL_-9#}e=^{MLB-rj)OORgcM`$BIk;(wxu>)`{;X|bq5f6Ad0Kl*t^Vbb ze9C%Nso2070)k5RI^+m*v@U<~XsV!kul~MZ-wNLi{`kOm+|EMk5B=<`MvM2@&1_|{ zg#EV*Y}e9vi#l&pGVwW9J~i64sJy#BmyU1jM`i55$cdcCc)}UHq)1sV>KE|MbS^I{ zN`u@

    P6(f}Wl(Cz24s$;CmQ%!KTz+pZTE7rH%U2jLQJtD$iHe{6XPqvFBg;dxRB zAt%dCGbI6had|qn2t)~=!#AMBMiDL+A~v=00ygZ^JCRdxX7y3T1#Hm-1%tb=JeOxc z`PF6gTQ2)-7=%g(kWp3^POiW1v9#ZLJnJ;Xm@cg&{vM?iYiV(NYIyVX!b($B61h`z z<~Jam9kJIMJ1~-yfi};(^?bJy3s2JijyWjeZ1TDGqOQq+uzk13F@)*G8?c~@tOv(1 zEEwSQHq=mh$oprxmnd^Wd7>=W{na4J{U14OV8 ze%7b$H~%dx-0{iM%29lo^!Cj(DA>#mu(Zu|431rA2xOZl5;2xUf^I&SA0P9<0eq^c z%3ZyZ^(jq7MUrtw0b*>m0KrXuK6R>)FGP^i=8cIfn1LbeCB~GXuUq!Og`N0Hgc0-y&I}QtClx$)elq*=$TWl|jZ2$qs!NtWTdiKpmnnm`z&ilQL&eN5aOUW>s zAQ-BXx#RFh#!Y~k94q}&YCQlfDq$A2?J>AhxSkm=OJq*CZ7d*Ob_+v8Zu#`ks6is6 zqh7xp;uh@KrvHv*#T^%Y$}ysFLH5(TQ$2IBryQ?Nu;G)k{ubCk*-j1|9=IUwq-EDg zgT9Qt2*0dzQG5Y&XZ}FIsz;5C#5z`zlk*W0q$yy+{Wlx=FS5M8UZb6V!i13(!rrre zLA2{=#*BERKoQqkef567k8>aTy*p%MoADQk0*Q7F5)@N^Y zw0pn*P;U6Tzr<74Y4Flp8`osF{BL?BS-9isWWn%xfh0$TMG2msg=1j*+=N2M1TOp< zttChj8O!x#&2D%|wSX6cgwxd}$M5;Z_3v~MGY3aYnu@QNGUI{FBS&yJQ!K5-N!%q) zcmV+}qsq_A+mn;D`1n-n7#$HCa#5{r;V!HAR*9PUZN`7-3gGk*tSS9wN8{CBo|mWM z()t)x!B~gCE(S=?q%qgND`{$L-~O&>TJvf;UY*J-U@p7vM**&$>X=xzegTOf7hoz zF*F9vjR)7qek4SXgovo=5OmT69@tox6gLV(K&o6(A)+jVv-2eKDV3|W{p%&Am6e7~ zU&i3z=qHE>34cw_F5Ve7EnogErIG5856+k;Bq~FY{T(A~=?R!c_pLB8v7Am9>D_9a zPhij>16EX1U0jKemy)Q!R#e<~P&nJHB7!HwCk7bW`jMx{tr3S%9T(A~nUGmWMV|YP zDOggWw7mR@iUfzM-1;b;$A*FdxF3Q=p!!Vh*iLUCPCMhLXW;?v`fa9GV?Qkh$A7NW z-PpsDMV~du=8j71=f3;g?OSkFF1;N3l7gFE-?ZQS^P9911( zG*#aT=-1~|zI4{@FIqoI z7U!P&j|I3su-JgepVh+^4HTb4Yp0;S`BLyD4F|#lVdu)p#xF`6OjMeYLEbWwbrdjU zq=mzQ0MeNRs%+&*f2>DI*^MffcSj^KSy;{_i?NjD2EsCKhX*NNF#fvq�)`7st8? zvbs}iAr4pu>R3u#y)eZ{+1i$e)$C_}IDtVnJC(+DX));_2>tu0D{W||Mg(N6{}>|# zlHOMgkZ~&uGHP>c$sJ-?V_#&WW*q#1L4C6$A|leJZ<}F}5=#^z%hK&ILk_pt0kPA) z?XPK6)`rCW z{2K5DkVi$oMt2jp9Ce+FH8~Bg8J+A-yX7bECPtJFwdLRI;v(9Gd!LO?1fFWCegwNh zcGH*FG+O+}ei>T3v)UwNG@~VuDFwW7sdZ=S&{kZ6%A$UPA3w2EJcCH2OCUBt#d!k+ zYvLeKGREPixUoxZezpelg|fjseK09*NF%)!lR!ZhR?t1KeN=6wC?kkaL%n?8jx04F z8a?tD#J;en@lbX}Ze=!ss}ymk0YFn4BFIvU&i*i|I!;H5j9ddIpR?011zzv2kc&$2 z-(;t5Z;^$K$VF^i8r?qlf>?{uIqPc4=kM;SzQ0!2>w^?`!+*-k$S~5;i!x-44dg0| z5;!N^MEwavLCJp$6>%#$RzVic1&N`X-Vum-8Kix};dF`=8;Vy&P56hVD~<}xTK_Hs zLGc`icz9(XYD0I9A>LCmv8qQUqBNr#1cCM2TxdP`b`}*GiT<-j~oYTB@k-94$-k@FPD80-`uUuwg~-@W;YT(UPwi zN|MX(Rkf;mE`LrLs<6ZByr~OK2`Sy#o=b+bNo}^4%aKY(hLp84Ng*QKp*XpD>N&nY z`>ttZRW8=%jCLl)YRJrJu`PEd97hcV2@1#%z(Zp2Ih`l@^_gp$$zaYyIcO(64eN=nm*49|sGHlz_01$FW*7dJV ziv@tWxPDKyTb$ja3qPAt){h76YdQk8wM0YjEdA->fD%-PX5-(^qFN*Y1JVaw9qPd1M-5m;ff@W^+CWHfDG)fd94;`7&Hp!@u2?d)p)SxU@ zQ=7vnl{kd5r@oz}BJL|mi(?0(P^g8G1~ggSNmqie5lgU@pkvVBCRaTq zYdDfF>+V^lteUQ&2FcM%6_`CRqL!t*3+a!AS^})P0F?cNsPtrR?JF&pxL;>Y^)DGa zyvm%Cb_)aaleTlT*m@bZkZ+TcEzfLl0rjm_D1Z98#m%?Y9AFFAM6Z-|0_=kdz z`3O)MC}k<-&(Fo5K~U{;flCfJD5DQW2u`SgR>k*h<|5JZ(Id+77QBchio?dpS=8l` zo*s}0H{56wC>)Hz*xwUL%|XLA>K*k4#iX5ra=Xo#T0od`+gHkG|6~kE3jR2~^(~l3 zWB`Cwkr9C$xVc2Mj+O4g(qO5i)Brq`^OF@V>AxRRi6IP>n|>y~3kn2#Dtf13sPL(S zCTUHM5wdn5l8%@OUx`q7N-T7hf0_SO0f2!ER49gy=g^Kfmk_G918k_be4)LBzM@0M zESJG(8z!$Hvja$7jH+$r$tv zJA}{Cr=9O~j>MKcd>q4t&x?1OyEp^{13LmOi2<$gLkX=KE%I@+6=qz5?a91P-z>Dt zy%h|U*kDwKCS@Ac=sWfA$Wr>SpCPszP{yTvZPmY4R8$OejKpl~?O)W@{d;q~T9+m2 z+ASAOHo@}w-)iGo=W7QiE31lw_> zf6ngu{pqs?C#i%{JgeTv+a3Rl=G?Gu6uz*V$jbJ+02amOoR0MX$ww1A8fE6%sORzB z8|dmLLftS5i58>4%mCR`Za!jS3%mG6U zmnHhX;Hg*HG*L{h5JdO)9FJVJkuUpW|G1SK{N^t7kcZv9X&cZm!v<<@Vm<#XS6m4o z%NvEaiA4P7sG|Ua)zCD)DTZoIIdcBH(KEi-fX^@^UD6e-=-KZFHQo*{kC1{=rm67?8ASyB z-Up_mR1C<^G~Zucjh;IMB$L*k$l*yo=k^}B(g$_N&ziUg3?AiV((tgfzgiUxPU;;_ z*R7vXj%PGEpZs_dyLj=*G<=JFkPI(1E&7QbDSy}SKyYcup>^1Sn)&Z=d$J~P*I(h= zDXG@4|57_EE(bSVgMFk3aSlD^(*X97EhUgq{>VT|8VNp^5CJH$Q|(g6tH>hsd+GoDmYh>rGQh4~ z2-htZvFwv{urB@<^!$NO?svP}_!%Q^S29)lr?M%W4e*As(IKX{kIL0&aKT^^@B~CCt zc|?b624U^Nj~_scp#E@0fz+g_;d_*mm9xWaP@&A`P?cxz$`0a0^>5*zWt4)@z3u_! zj!>q`Rx}ud4wHw6CjgR^a15GzSK`r96^H#5K$7=AfBuK__e$Lu@y-_quw67jAj;-v zw;M@%XQAA>@s#maN*o~@y)_=xz`^8VhVmh-5qJLXax-Zyky7HMqRBF1tPtCez4kS3 zwZH2gG4liIwUG;61?_RbdkGbP;ZrFox>SB3X7FB~$^b44bL9}uEUWFLRkztJNX<@=pGeybO)7tkhnWs_81c?^;aHI}Qd>q{cervG2AYfs4$`J1kn9+PUG zSvY3}HPvOX9eZ8tlY{)M&F3qL*_(H$POeP<4*=*u7r$OcF3h4p z>j(hoVtDvfzwafsr3VZ=ouGudZqi7|PWPAg_ISJ}#rQA{y_yho<{z}Iu6aG0`n7Y11Z-r@Te&hYgmP2rU%R$&}%7FJ88sK%w zId@IJk*}$0pdf(TRPz3Di_6XTUc$dR=RHQw8ee>4DZh5TA7o}c^9@Xxa2fA*dzr&- zIhE=MXa;vkO@ZP4dl6f}8+4A=Y=+J$@o?b40hl&z8mw8p2GEy{Rjz~F08*{4V%rDr z=7qnRh<Ai+Vwf$s!kUy1UoYJUZwkOKg(VZcl0 z>4Sg~1Px90pr5IwQ>wS_(aTOX_jcFOsWGplb5;jsPdqZRXF)>&iW^F<3mXVrzc{N*$sB%lLwW}xQ%SMd!*Mj?CJW(;IRqYZagAs&A>AT~YInL>AJ3-r?A>=_&t82d-f`#ME%mjv zd;k1n!%yU8e1#SS5)raC*EY0p$FktZBAkD>1*d^)Ngc)9bakR(>C&ZFty{Nld|6pp z%9JTnYOc8Aif=1Ti3_U=3ZPrJZb9c^`md4*ll^VC{Z$+R*#D8?rX<9xq>S;PGn>Ew z9Msg-LUv{cm@r{HeEro|w111txK+!y@&I1UE|k)9StejBZAUZOf38yaPgVHk$wPeb z2RQ&VIBd<^EGfC&@OSXuwXA;tgBM?x-4RH|JzSS7HU{P$=(NEOMQm&np;}&zk2+uQ zHZ5k8B_*-T&|W>e4Iv%lu8N9^?WD7;nloq4?Oy{e$T{C@^kLb|WqJ#Pp8QsDUl#Uwo&M^;@fb2I zFE8)$;DZm&-@JMADQ2^oPUpUO@nR?}EWDc7(>IMAIr3To@Q=gfS;4=hVw4Pd@eB2@{*EDy#Aj79ZUC_>AdG60LFD1;0TP zxxV|a5dLFX;}b#8A#dRS8o-rCx>!E>+=1Nq2gJ%Pir40d5aGnT$cRx^kPM4a15t1o6?N;sZ(fBE zMCT8X0|5K`Z)=0%LqC1<5&iMJQ4`?O^WLW{!2cllU>vxJ7H0&(^=AUQ15AegZFka# z#2Ydi9R%1=?kU6A7X6BHk z%U4cuI&7u+d-tq*|NZxWAxvex=tQh*v>lb0;;~Nmb)XqcI8_OuN$8)Sqygp-`I~?y zpFvs~N7MW%KPMpk3X2E=!A|iBs>h2UATBSz{PKM${9U_th3l@n4o*Amv_E}5-|TO{ z{r0)$=H~83qY?i2wUw`ur0kvG{(4hmJy1oNp2MJay5p@6HAxv_!wb-DdvJy&)i=niv3<$dg zm)k`Yqltn6AJFQ&DtLu80U|g9waQ+RP#2?y@jE3@Gm96|5hM%F?juMTZ>FCyDX6l+ z4v$TL0BS2M$afrMX6Hg~ZZ7DJCg_qknlKBN0D)I%T>n4|x7+LYPLc-3^kJl4=rokJ zJzg94A;6%|0BtR!L9b1UkLye**gwXM8FTfkufAHoZQHh0GiN^aV{$^=Zh=PD?>$gq zKi)n4ZC!}4-%N!58`7l^r3*<@>I}eElKq`YSDvB-0PVS~UcLI#w6rw1>Z+??`0(K# zLY?m*e{Uqh;+i*a-gm?#U`k3#!ZEoQiSXY?wiI~Jd2&6hcyh#HL4eZ09qjK;ak@&v z1nL@^ps~dcT{>o?7Nk@-jsQS$W2=7}+05;?-U>I~bR%Un(JYPR{5^a2z>h!v2+NnR zfcpA6uvjcXW_MU8ATRHfe8|v*NG5=4e@2?p>J*egj>B!KCd9VlHI`FOg@h!pXVQKK&r2=&+OH!7j^R4?e>bq#KbLRAGYO& zjvYHT5i=kG|CVU|KgedN^cwoOWMlvrUHkSSUZXc7fSuB&_orkB2#Gjox;8Z10(Af| z)V*l=DtO?ADb!Df9X-yV2d<%2w`8Pez<_~yRQLn(5+-2>e+Nwm0)%wE_S$P<{`~or zML6wt9EB@ED*xDEK7v0W8Wzy*CBd{heaJp@oP`QBvWe7q3nVA`GY#V{CaTp@_|X(V zXP`zQ^;iTUX>EWI53`p>6EIIhqt_df`}XZOao~Ww^UgSD(!cJ%_s;3JP9F0yL^~Gz z@E7B`=Z??*^2;y#5YS>;T5P_?W*hHtI5?lj?Q3kTcek{(_y`5`)YjGe_Uzha|MuH& z8f$B7%Z~7UAix;NKhubzwUu;(TOq?wL1pWyk_)khfKrjV{w$%X;Ecd~2dsI-h4T5$jpHnl_X}|pWw?AOq znWHERUuojXBp$J`)=8U8j}kHh|q;Y1u?Fmd8}@WKl(!sacTA>L{YB zV_X&OAR;qV*b#}5C7|B{1OU*ZIiT?;B1!KL!38rI5eV>{%GzewvA>KdudGUJtgp5~ zbh8v4iA9r?l$8A8#~=6ha=`M0F%hKK#uKzh^93D5EW?_yL-9gBcV$fz?A>3q_qTOF zYmX!oAaws9F5qTf#!u|Ai1{7|0GP>V`rTq?=?kg`ajTm0+x}6rqJZvJ{C>oU5gT{! z-hDwsLjw@7OJ2Kn?cKzDn@K)D=yJIX%a<=l&$?6tT=wxTS!9znlW6=Wj|?kf!bJgv zq#S}g0?g*^rTu0dK$a z4p^<0kjgm;fCgh%a+U$?aXo<58h|1DG=jF)vRax$pf{SSFjIc2rO`dZDSz}2*Jx})cM1n#N=sc zvccBfMKJcPG3Mbz2lSXbcP=_F-OxIFQJa?uLY)61{yZu`m+}*D1-}`fD*Wi>R}*%5 z1iN@F61f&tb@{v9XceyLWFMVE{CyP6UX1_0?DJlbkYE z*57C1KMViW|F9TAn0g=qpf0VdhT_U<=-s_D&HpD415+=W2%r4028Isk1LZY!(5c5@ z*iMB1qYpoXYo|`7HvOM}{s}KU|2$lM%{9=!fB%?4K#Yu`Ox<<&U0}1@;gk9Ei8)}A z0j(dfP~g#|!cb#oW)>tSC6TtQ#gHr6@1W<2pem07bpO98T_$EH>rV9%G-J^5?sEX^ zwgJ(t(2d9rSGSU&iN8J{jdz0IJI@lqc5AHQCX7LgaeM*-&H9d@i|YdaI6WEivpWD- zJEEfpN{aHqVaNmq0fU^2G+nB-5kL^F48jm$x!ED+3GlS22uBAa;X~`Rny4BR{Q`gN zEHc(Rn8D=F%=QKV6nMSC2s{y%W`_re-S1~OvS-3ouhT$nBWZ5}1W!EsY$pVa+0Q)N zb^G@1wr{@vvYLQF9cjZRXr0aIaAv)YI5{OI`CyzsAm|!>i15=yAdx=muVygLFABOw z6Ds_841hlohz_#p*6n$s*$xt$|DkWb`KE7kb2I*kW6+>Mn=ilo@>v&LaKVp~Tl!OG z=YN5>aK(S?z7W4Zyg*LyczuxtpujXVHN%!Y`=NKQZs=gbG)5TQqciMpbioS3*jgGJ z;Eu_I;KdhSfCnCYkZNmOI(P02qeqX1=bw8Xrd~G{s}LU+2t54oLp0-X`42x3W)K(n z9@`T8R#IXTj2kx&CY*O3G&Q%tmfzPy+JGL=mB?UiZ9Tm6};b_~J8qb?Pwr z;*mMe49#V%ULOiM16@;jNHj5!nZVH;e_pkwCORfDAAloUe-;BHl-D<#EeN5Q!b6jQ zd_MHV^1xF$bs1gNWj3#sDW!Kz1*lbPI=HzsOyg`F#vm-s@d4F;g zj=jKf`N#$;YU*L%fin2_ZIcAE$6s7UOTfWyxA}hm{ZHFB-+o)WVE!ky<>lp#5@x`w z(8!D7g`aPI7SGeQ5b^hsy=yh7X0;AH6$}!G~3XUj1SjTsQ4s#Jn^>9bqjC z7JLTxKX8ALkfY$1l$5|5ufGA)ADvE1hqbj34PFZ!qt{=5Jw{Qed5bj&FbQh>_z5s| z>a`G`kO-fD_9-~4N@3ENVUUxPL(XyOUegKXc;HdYLM*$ZbjMfJ9j|8-Pc+mJf1VG&WQG=vm zHti?@T@DC71^+eCQHQZsv{$f*2nw`P_7$=NGtrP9!GXpF%8~i)9W*VdbC8^GH2O8x zo}vo)b#npKG_=s#257=?TG|3^JNGZ%>9D&$dG}@dM~9ql@a12+nXj?VO|6tW29kFAf3#t89riU{IFpo;-7i?sZRO(_uCgNSXjGg z;exvS{QMfkxsxJ&IGzCIu>gK{rX$R8FYGQn2z`+Skbb5yn;8qCeg5U z#MVzz)ZUo?GV%P0@X<#f(YgU`1pvGjCKcUs%PsKuzyD48gb^;f=pwlN_S+#lI~%ra z-41WP{32X@+8`Km_Qih3C1&rEKELl^DU?;!1Tqmt6QI+?Q#xH}F=>Z-h>*wmNAZHo z$3n+=fGY=cROozSae{yoL72#gVWD+ogP%5;bUdus$HIn#D9Ai?Oe7S;ih#fpJH!Qr zRd&#J*7`mD$yQp)|9}36hAb+E4sf{mn1kt*JdLrQ9&yw={3%oRZ$n)YTDu$W{ zr4@Cse)|E)FRr5d(B>As?Y5={bO73pM(1K#4S8`se+>okIT-(73nS4SK9382{pnk} zzt6C<;f6a$5~0^pQ_Jhakf@e6vuNrFRhihnefwIbKl-TUmfP;^_}IT6FZp=x+dBnD zptw{n>Kd-sX~f7##^l1kkKhMU{?JgMXk%l)Yao<*{?eb}>F!Vf53q{ziq|w8c5)pAl0m)0*fX? zYJ!D!YHG_1sg-z1jX>wofvEPQumRGA?hu{SGiSCGhZ#Q~dWY6@FqSl$Mmk=RdBa%sMzS zL{l3$w?*p#M&tG?b)6HkjKs!qF|cL_76R4yr`o}ggh>MyqYgMi2{bweIwWEpe$0mC zz-rb)vQ-Da5Ubkh)__^B@i!=s;6OS$y zNPE@e%gUyK&EcX|hV~UzLbKgTs}9ppn_wzv7(B)aE|-U4HCppgFahE&7?ztgX>hzT z-jE1gQ@!BaaR<2<0)31Qe401{bOuP%Ccwvcc85j+Rx2B=Ao?@?;MN-9z-K{_^yf!t z==Xk2!$7k~kKR;V+f*+>#txXj7Yhi^Uuhk?FD=^P*XYPLpPRQ3QWE1~)X)LI##^9Q zb{Z6y6hjsf_QrUpwrm--R0KK3!6nC?ri)zIRF zx~A5!(7{Sapim()13l5)HWv>=Qy8#&4U|Y>5^;;qNT@zJkMn|7@6V0SOpAw%WUCOf z^bah;260noAr}}G7|Ah+zrCN({MCQvLuFkPEm?+WElwRL2ySWj0xhuw_3RrkcGw^|gRDixCD0PL8G25h3|brmQ&|a_nVHbDS1(wz^%94c33O`GYxm`+zF{%3tV^gr8s#*=;$Cq_gAd`4ZiyM7oi^oXA5dU zbberNF{3<#iB$eDrmm4W=fr}=NaO7;BH*mQs*s6om9JFtxt{R>=HU4_4ZVrH9yzo@ z=u}HikA&J20Py&2d!)G-64VObefd&F1b)q*`yu~er9Zn6D-Z|F211qeddQ47gC))Y zWmWZ}C&j&O)9+YDw%tbwo|00*dN~%1~*vh|m%L%(mb-SI?$xPeSr-;^PBKQeTY$HIi zI7lc6V6?{LaltpMet|_ltb!o}^Wesz{t?SvyL5p~e{O>FFYxC}UUSVg@XE`tz_O)F zX=sl2iBnF2CEtBdBLnChYzqqz?`hc3Auz6gZm8z>Q%EQ*I0!F%_&NOztwt*w5XAdu z&?N$^VOS~Thnru72YKQlBm9RK(c-K@gzlrm4{1NHKAxp3kkw0Wq^ZS8^Zrli+ey%D zTI!%P3T4F6OK&mhsTQY^1g9ICZBD=$ip0!84CVc@c|YJ}BBhme6d=T009L5uW^=e9 zInfO9R--@4Kx__{VUKFZLa;Py{Z63TW)D=;l~Yo!0zxsdWsd23A<@&YUZK=0D;=` zBE^?%sqo|W?we@w-yN|yD@>yfY!p4mo0|JU+y2~eD4sZSM zEh6;a2`0G~F1+|6Sn%nB!@mE-)Ksve@FTU?YJ;eIbyY1q^2&QqQc)E!7sclkO#uJI zoKCJ0lWJ%PA4xma@}jm6onlwaKaQ4XGJ*#VH#R2+%|s9f_w7jRC`-VGrRlyn3lQn- zDA-Ha?SMnojbJwF=zdnX1`7UWqW!*IwH3DRE2ZHw%nrn_eFDY8$O0BJ<>+iK#MUOq z;Bz7P;MVPI!q|W9(db}@8k|r~1i#VYB_@u4=rXn`no33i>@Z58(;yS#XjA}w0az{_ z^A_IyVlDi+>mZbr*Td3ZcEF0?cF}NVLY#@TrOWRSB+ndY()gkQ08zt7+WxInzf7|# zeGW;u6^GLjp({UB4zp*^rs>R>0EG1oFi}UGBcPz503Lk!VVWTH{(J8QSOEI16w;kz zT6|tF>_1ovYu9arExY#l6aSkBJMs&O3>gA9O`l0-0@Q3Qu>ILLOFIrb zA<}rHrzX87fMOP-HXzX0aT(U{*ptWUrR~M>!N}@&A`;DQ=OKyE^1TNtpxN$)(*|{g zwB&gDTYCyCpron}w(cnNkLO5r!}Eg=Hppx}fyjaXd>nE_@M zV(h<;2nd1!nhs)tQ&gbHD3TM*V6V5g91Z$U1**;!06)AJy0ZQ{bM#$d-2*LQ2|5<) z?Ht$%V7&3!Dj1g6g`U5W2>*s1MKC(dy?QmwoH-MofBt!xJb5xqnQ|3m=j71zU$@Im z9e%xf^`tofnD+e0^yxHR__^nvhncfx(m_6LF$H$++6_OiSPm1%42K&hUr1?xd1*O3 zN;Loa?YpV+l-vE%T7w7xyqie9+sjkUiGuBLaZoR&oijqrT39d)NGA!QW1zLPrXSK% z9I$`YJ=Dcu-2=iV-e}CIr0KL0(fUeo8P*1crol}5x zbWCt?xV*4#b3XjKbw4o|xUUMHbDdP&-^SfijrYCI&x#}QiW_ER(o)#n7{L#LyT z*g>9Vt^O!Exp)uHcy+v6iy-AS>C=eAic8m=J)@an&lD{>Y#F!YxiUkF%*rJG)A_#=udp*ig?>MgC?cVL} z?au%Ae)E1azn$CN+r!hC-0$%jw#{#5c5hyP@B8#5NXqKMG`nv0J7B6bmX}3qygvfn zp=@S3RkPnACo_fDOkm)t;KT_}V`Biw^mbRExe9`MRj47d0ril4g_2B4g1K|Q;KewI zaWHY>Rh;>ex--UKFn>P0Ib$YoC_;K>@(#jaLO`Uv z?No5G5RT;ThL;|>8-@-W%YDW_V#m#(-?jzbz4COJ!vC&k{OcjGkfC~ux0)9esMc==wx`w+LNwIPK*tvUl ztOR4;z>iJt*=wtJ+;rRTI`$oLQQEQ4U1Vr>7e{Ee0krE7q>=vJ)CGhgJY0$S%U-;yck15{lhfbY3F$NvReEtt%=+I#> zaL@qA%F2X)KJzS$7(EJl_Ui}FO`Qr?UU?;S>)yTIbs;_?;td`?as&?S-_Pe1wr9s& zx8mRM)ZI5ihaO!)FROr$7cPSrX3v4jDwk#U1B3(mqC_u+xkg zpIi;qR@a%Qtf=Di%W%QkSZ^FY|-O5mly z{KxnEc!N~ObSI3t;4G-Fi-S%3^0^zv0aS&b=Q99Qu|Oz;2|*M9(NVEb>8gebR}G{k z#=`c^8_IsDTO+i8^AZAq8PA|C!NFVukWhqV;lbV-I&=u15-hYiJ`Nf*2->&r0AGCZ z1$_I>*PIVJw8(~4GiQLCY5ulDhQf<4y$rp2_JsBw+OzdBP+3t4h?P)XW8A7KDXEZ@ zoD8`K4#K>-pTb}6V$9#A6YODHfBI+N!ot-Xji56QFaf=u_BR8ay4?bxbf9iZJ0EwN zHAl3GWo`fn1e*1M{Y1JM?5h_Bq^CIVFQsKSh;^ocztYd$0!=cbaK~!K)Kyh(UOKCB z$Z(CrE@80D09G&s??+e<`Sgx^kNm$q8bk}8u0+$9~~7P{S)T7 zJ)eE__KETuZ|te6=)|aKhxuFinLD7z#Dd3}4ABYMz$+sB$Dq#Z;cgISHqz2kd2dFm z>@>(sOXNYsa>n#ncvZ`Xr|Piys}GK?Shna`Bmy8*l)w3!{^50A*!Y0BcO|O<1A5(q zXmJz*X=!ONdekT=D((d>y=KWzO5T2fm7m;dKK;1`T9F01<`Sb3jpS zrN;ncc}Woz79N9hySIkNuX%#k_5b7LS@7ku)lgDi!7S}Ks{4r$Er%Z! zY9Kx#)lt!oeTU@en0T$W+6DePjGnQZHo*x|)CTO(DQ61C01@##yqwjrbQ-!1x(Hl) z0`u=HAj<3DLI9ZKamB%75L^2>yE`|w99DIV?<(1OdR`OJ}V7_ zZc|h|Y}j>}XFN*FtHAH8<7v=JS1q?>P@v)bMO=f{5vEbo*zdssM%a(PZuN3>XMRv4 zP_sAv?b!U9rRqchPvHIlGLVQ+h!_t;W(}GWj?$oOx2}-Ng!;5sUWLx+Dzlq7jVXfP zVr;Fl0>1BY22A|*ubD5u1)l!L)13Kz?0%_ox#8@Aec-AK&gJ#|54|`8R&Cu01;wRY zIm#w~L#DqR3qS!-vhqOf_O*w+yPS#9i8)R!e#-q%-_@i4Sp)av9)c?7W4j7ZLi~yk zAjVO|gn$OFD0V?HKBFDT!G4?=w-J8Qz_bxiNI2?rZYJ?S9b;x^S~^6x83tv{6{w}@ zzdG|=b23txR;%V_u0yk|3>^b!1R#PpzAwQriyfLK1M%|*%=x2$KxP4Iv&Gl}nnal5 ztYF9Iwv6BBD=RHII&;nn{ie&${;BRUEjuH_k;*iHUpM@o8g~`HanduhAT2c&PT){X zjGwTZAu-12fhetTF@KMl`>9bp*oQ6@#s`v|M*g|7qC#Ij@8e^K_V4{EA{G;5-AEJb5w~8gfvN1M9N=-k3feo_O-Fu;yQ%!rB*}h5o)+ zcJFG?%@GABd-Q-~$Bsi!<_ZiNJP6jVTgL<98BAzw&CP?&duN(KZFFlBiSdn?MFXXv zL57L)ECAz=Z_)4clvik_<Ru=Y7f1fleQrpPJIJ*iUYN(_g^ZyS0b-nt`76yJT^;$iI%#!lT#{x= zVJwE>14Rg`QT*U&4x^us1wvRxEM^Jd2_0t8(#tyylM~~4kdnC&9%fOr`iTo&b>`D) z8R@A|%zj|}t&!1r_9WKHvmF|BR;DH=@zh`i6L^>vDPxbxOsG}4JzSt+%p)f&1Vlm3zl*>QnnWST*+V-CWb2-yfd+m zW6hd1Fr6_u&N`4G!O@?eHf*FRjK|Mr^m9bQij#3dQhPp{F8E`B9qFi}Untv2r*=I4|JPl5jx-5xm zk2~smhzqs^t%0GZ@iZ9v%H_-?wih08tIkl7h(YF4?VTtkD2>kug+Z_ypjA&8#oa0h%Lg*2p0W__y%GKcxyfSx~1O~ zKKGA5?_zIZwA8Cuw+a0{OUHZ$1t?;dp?>MMbb{*G}HShe$nnd3hWy=%OpGgg@^;0GC{TISlC5 z&2}9QXe?|%gE#|0(tsvqWn~*~DLUT7n3#5Q2;fi35^y&6>j5!7krr`iQKY>c;7!kl zgp@3(bEZLdi-C}>iJ*%X^5U>s57Qi|9eG+3Gz#?5Xfd`=T1tWm>`}=yBM@S-14JOv z%T0a^0&1ERrmS-pZ&+;?$L74$O-M^vWFzc$0xzb zq7o+5jnt;M)^K$&_=nMcLomRCiyVtxmcjbSAc`!#`b>!gQLu@PP)U9XB^Dm#$N!OiDgqF(6OlLlR zHDEy&$32XRg2IwY{`;jSCqVx0Z~ad__Vmueq6!>$=24v6v`Ij`AG0#jp;Nmyyyl{o zxwyGUkHML}y1O_QR6Ng)nV|2shHhBlezYyglbYz{g+N%tj|D&}$xcXOzAqNJpx{7rI3p#AKNpfxm|OT|TyCS}76WAF`xIAT ze_Va%#x?U9^DlqP3&+%yg5Xf@?jx^1{l~Iyy#}-$H0q+3@j01sQH~@iC@kiM zA7vHQ{ATl2m-~<9&CrStFZb8fxML-QOIPgMbOAt}eENYsyTZy%J7DXc{m{ExXXdV! zK}A&+w>A;0qG#7m92aoQzJoC9i-j=bPxml4ts=1Wo$5{8)z#3iZ$G&Ao_qNFI54zl z&t8z5yO%ctbz@rpcX!?ig@uK1|GoFYop;>@8JQV4Bn4hzf&$x$6L>Wr0hVckp(#wR zS?AIt{GMSgfLO}4f4Xqv$t%wrT*b7}1ooq7yd;$(m;n+*`0+uS863=u@Ie&&0W0~v zis?Em^F`Oei`9B$mekhP@Zem0e6-o=XHNcM*Mb2U4B%y_CG#ISAgT%mmLR6ZFu#wj zzvc{fY}@216a*@*t6Q;T0q_4WDR=!G?m4Un#^_K~?yfDR`*&~g^y)J({p|4*Q+>Xq zSQG%Y%*Q;jf2(Wu^uHC}Gcl#3*B|fq)cR2XUM`0?OL{k*B-tL*6rL24?O!ibnnoX@4M?j9i=47x3#Cx!6L*LoP+ zCY-X6wt2nt>49T*D_Z zCPsf2(|<+fl_oS%KpI7_{}ud{0r1;KC*gaQ>^h4pTxOmYtrRhn5F@7OGI%{c%ur~t zv2px_c1Z6300|~WKPHuVGtP`;Xi~Xx~-5E!@?IgDwuGSc7}V^&lm8L4UT_utD+!*EUw@efo>&2^{GO`Sdg8iTf`ic4cYD6R`KO9a2s^wFG5GwKKmVE6_6y(M!z>6a zXv0pxl#~=W|AGr(>y|Chx@{Yd4)i$N|M};hgWGSv!vKGEID$_2jllD7RCXZ1c5mIX z1>aib@N57iGQT{XeNn7y#;88iM39)A3W-T+kebl~lG8Goq)LL=ghYsQCbQ4dd0|U- z%hrHnpLr?+#B4MJpo7=6rz9JKgiA(pJup{RTL)#8Zl1g65M?BY(vqD9GBJA-Yx}YO zUEt}9#-C(oJO{?msFr{SAH6l6-Rr-9?(qk1yOsIR-%NdH;eXn1jv?mfu>f|Tc(As| zl*Uoy*ZDn39a=!gR425Fa_H>m!4hWO2la<}#KDh`YuKy^@5yv_e|Bus3O4T8%WLu< zx#fCZMf${R?|?%$`ZR|1>&aY%Hn3>TCKId$Z#+c3zUjs(aQ*eyG56F92M-+J(}A$` zmj}byd!x@ihx_^%Anc7DgN)g?ZrcXuoO2F5_SmD`EXL};(+g_qCg6v>1rrta$v_;D zCm=w;m=w!uacBkB=%Z#uKV41)p#P767Ch+3%=*Nn6a&ZJvH6eCdKnwdBgnjaO=YBD#@Ms!c%|S zx@q0_jPZ~DTr5n+-BKy26qCLdY*Hg1_B;Gjwd71GoR}1wMI)Po-ji!K=<24JV6AVg1g% z=6#AyI|By}fCnCUz;vOJ=|7k~8?L_Q8fKx!Knzo+!-o!oL}w!ZeAw{eyu)wqoH-E7 z`0d(juZ7CWN_ghksSqFU2&`}U0g+!(9|96DJFC)oSdmKUUJdk$2<&fMbUj3j8yezr8bAXjYLblCu8(ldMafVEq9!z~jp zf?i$P!ylfX&g=V;(ea+^+O92(9Mlh%Z{7~4O3Ey(O6otUtFvme5dZ%#fBh>gU9uD& zedJMC^8NR4_;8+q48;UM%bb=xJ-C1W0meISjv|DvL+e(pxU~?Ofge5_XQ2SqcPFB4 z`^v-=I&xN&#x<*M6yf;m>Y!Gy<|e#gY(6?%^Z+;v6THS#$9vj&sU)J=qFVFoX2L?4 zCOl23TfK#HIz<%mc)2T~1u#Df2MktX?KMZrVgJ0<<%geo`0j^x@7%Ux#+>Cxt6Uzw z_UGhY(k41LYT5l#>hT+WB>094i!c))S)igDE|Q^8*uCel-4Bfh0Z|mr_pgKQojUO7 z{|y(9gEKm{hx?v+4GM~ic!mk@SM<*>9rFtwr2A^w8j~&Y{)>-`gYDb4!|(366CV51 zV>tJaT+2?eK$sK4G25bayHg3HH^gzbBBVbkth3v81j z@d!z`m}&Xqk`nmUuP%Z%ty@Dph3hxKfdl)Y=fR$E)`+v< zo3Foyg$oz*NxtvA^EOWd^7(yoX}lgj>=y~+2WtijU|K;BO#N5gv-eN@`1wEoe)WiR z&Yv)R%&%^Yg1EkP^O~i%PDJx%&MTV!Zb~0o$I%Qc0kZ?_$E)KiOapIB4B`D-!3Z89 zWAC+Tna;;zVGVq7nGxW|4nLj_)P-9DRw=T#;?$fEKKRGS@4x*ydzJU@m#cJ-x9;bB zp9uy|q@bWI-TYo3l%FW(E&%?{e9BKz1)QSiHKg(J(FF}-04i!sgf==Fju)PS$6uZW zUoTn3bNPb#xw%&7gI_b>Kf85HnD*gZUek}LOm-_8dE=aO&w)!Xy^NdtSm-n9h8wsw zj1_)KiAgYi!UR4Ga^r>#*wx9wME~!>hrrF0DFzamb%mpF761wXFHX;$ z`oL9hu3EZa-iUK2T++VB!0Q~zIsNN&2Uqw;@s7@edZ^_~%PM&JVsy0a(3;W7hqLZ5 z$Y+cIkKuvGXbx``$IE>&2-qScg*W=(h%bcv#-SI^gjk*-u<~Gjz4S!xyyu^Kc)F{q za>bWRwv_N@pUVG=tQZOblv45J4hVn}O>z@tswQUl(%M>O`u`XLAPQD(+|C&l?@bv> z8-4$FEnC1uCICtc3Sr6mEj&0K%r@5vK&M5EY`%pf91?3eB5nO z32hPeFiH&N1YYCsWgBJ-VvR52Hv~k08Bfz~Fh-D&oeHfoQ#mY=(Z_H2S?K>{q$EQ7 zRvBC{c&WI8;||uc-)-Ee!2v#e+@q(A9S2nKX{BT|#loXd3DfK2GD|l%4`t`_NfKYVpA71e=X5Ihcvv zX4(8N$6a{EWrNNhf3K!FTj|uAEBf}4ffEzrc?)G#l?!y)o-rkwPWb*h2k$`4Kg|0> zvVrb{%wNcU9MAqYV9(a&oA&I^-!%1|h55SvKgS!2;eU?)8oMVi9x?#Bckc`Z#|vP? z&ON;1RK9;PFwOBZ*uCAob9?YH3m}sFQ&`4x=FWv`wkFBx4CG*)tczebi;PMnF}fCM zQ1EmGfS{Wmn^m2jp0fYh`>vd^=$p?LU4H#-Hzj3vn&^*7ZlTkcegU-7+VvAi(wO*RA7d!H7i=w2fB}-|ZKq-Yz0tqwCra696;+dLvK$lOLNm z=l$ugv&TiFFSz`wcHPgsK#xyL2i=PDW8e?XeNVL;qGRK*(!fCPsWVD^5y-;~7_uW* zR#y4lhriJ(a^Ke+(Q$wiz3Y4~9Eje6{Ac$crku|MYF{qd@?RqeZoBQa)U2#5p4~4h zD)LUBKD|7W&mMW?ku33i$BrFtcGIXnfSLf^XXt>_wyLOua5n= z9&o$kcyymv`ANTxtN7T_)&HKoZCJs%PyRwYpEqyb9wq?xDi-|-0)v#X(xPMF z9A*ieGvZ9%5X4Q}fN4U;O9bUHJvk%zz-M9-UjvYL5 z{3u6!N*c!wkbW~h`PTGZu&Afbe{|oLEzdvo@LR+CXP+6#yU3K!vZ5vjYqA^P&HM0Wf69nXr7t3Jx3+Ps3t_pfICk zl;#r|K}|&c#q{U^A3%z&>3T%|K%)h~M^o>LCQXk_pTV{iVn|WcBG@~PS^GVb;-KI9 zWphgwee@-@U7B9Y z8B>J@+7ur>S5#8Q@%piN2wh#Q;;Uhdjp)GG_m43z1Oh#A>=;aa{&{8r`(V~vZ^7cl zi}+wr1R2FjL`->O!5oh*V3xs_=98-e^~NUtf2aU>^NGoV`H}H6NeCe0$z5(}$hS(0 zhk+TXFqW};7oXQ#%NCxoX6aXJ`)6%Aaz^{%o%8*DpwyQNnQ6%ot@-@>c5K-Cw@2@L zhpok`H!S7NZj+Og74W67E5SlO(CGSwD-sJeQ0qGBL6Jr#zf z_@K|y^#xJ=$`(P-uA87`+!?x7b4AJGuNJI$cjl|#u=NGfu@YOih-)poHFoPr5;!sB zj>s91@_QzY^FH(Tf}bQNz$DWp?Bc$NWZ#=_zWK=Md^Tai1m*KLJz;-EM9}IE-umvS zCowPu*tuOB7|$5EQ|lbqzW)#`T)7?!nN@%{?7RgF;nv?=2lIMOEEes9y(A_mP*@N}+^aPX(U?E}|rM+VMCQa886N@F| z-HnYre?uJimHT|X&Mpwy)l z3o|9Qioojk1Sx|}U<4!uCEbvUri_7--mCt)S+1WNe+4pO7m*fQiq!94r1ce24A8sU%e@PRB0G! z%&<3JsV*B!-{w}$V^{PDyFK$Q?gNjj9z~$9lLb3A-)td{9(8b=u6exRM)~v;Q!*SQ z#>WG^;_X%P@V|4A$C7LRnz2xSOrm$LlK)D?Rk$jO^atyl`n;vI-9%ShROZv5;hQ(N z4tQa8^pv0>2VmgpzEWJLr>iQET4VZfM_U?U!foU?Oo6K8nBpJA79M)P#TN)}ol$l~YBA-BY;AHoaDtjR+ZY%G(2 zMRrG&gk08!i!(KyXuo6RR#q@bLWSLlp0U6`zavufv4j1y4#~xnt@Y!h*p73iq6iW0?qH6U|kg@ zc};*!+$GCB1B=nh+@*j$xfZ=d(wN8D`T{5@hc@xB0pQbW*;I}D+`x7g%0zIw?hzI^ ziZ|Ef!R9(&AMcj?IedT^lp|7)_&0%92|eui^#J)rnTva89D9*losRY#3|AHqD_2{F zj;GF?&dgwDB8=kf8E+Cx0_mAQDM`r|mtpZ&Xid6~==*PWhsG7*z)^>8_BxImP$C8U ztBb;oAD$BT^uA8kBpSrGLEHdNrEa$eh##deu;PPz2o-@AEN?kqdlp39lyoVXlS&G7 zN5v8K_V-~tJlaWlmqb4+u#<5ygA(eUCO8A{zHP5fe^w?WWOeda?DakumPXZg#{F^0 zTqq!l$)Y`Sc~6k=+o&JIOQ}rx$`E_o1S}@vQ@|!AeTndO#6Pi}=^Fp<)nHX+4C$Zt z4F@F$G3~X)O5+Rs}Pso-aVM>jl$dN9aa{Vy1JQDjeOz@ zcQRwq0^FoDQ1AKAB0d3o(z6Msxl3mn5Ko?otyQ_A9Hpv=I6SXCJYp@~+j)wP*9}rF zvun$x3Co_D)VRL~xR`2qLx=W(Ws{`CjKrVbU~r1M|Tzoy`{M_k9-ADpBWuoa&CA<^_67X{oS=E&fbku zYDDtz@Px4MY!0Q{9dC^s{KGW~=e(XL$+h=9ZXDcaBGn-C!Y5FV$zTyZORJvx*iuiz z*kKCwbSY_xA|x!nH?vAtaYr3PaQw$?)BOcbno+H|SdIxs?p=!IAB2p(_4i-9#V!)C z*E#Gn#4QA7rinD+|2#pfVK5VZv}^%b8A(^rRQ>bj7SKNq;<{$oWk~%PE_0X7+`|?d zwj8`yb#uvff1zRa)j?oIg!eJQe1prtneH}AG|l_>p6jX##wI4V(NG<<=*KZK1kR(b zAY|PV1%WO-lx8D;W@UxtqcHc8=z0Yyk@o$@fvlg`PH(-nm7o2DVSht`oaP$9g9V=b zqQ;Bk4ZHV^0^D`9TfFEBd?`dieMm$>_^XcY#$f18ov%2%3N1hnCRmLc8(yl-6e0;j z?^UvE7kpE8buL)#zrud--g-dOpmx^R(ay7(smFomTC2~VsQiA z#o(8WY2%%rb$p9{+t%aNp{;S%7p#vL+e>ks`K7nfUtE5HmpLuY$cK z74T7-jWwq;9S4|kp?cFku`LlEtoe%bkFI~W0k2w-mQ`(KH+~%IiPaMV+3ZvqbQ%el zD3RxX%$YO6cH++Gwn|!UjYf?$0)N?zVf-AhhyC2nVc(=6HorFO6XPz^#+3uFcEdcU z^N)^*72r@JiZG*W08&dUA|Zj8>Y|vV+i?BOb;rppwQWnx%Yy6|pc%C2$h`R!9x%wy z$(RHoC8*Y;`@mn4BGgF zfT^=mtQ1J6g$MQu@ahNApvZ2XxM|@7s*TL(uhet?{DYD^wz@-~xho3tsEdUZ-V zd}C!c9c+8sa_V{9pUcszCgr=kh;Ol3k7}Niab#=_Bv{*-cpehNjzjVNeeYcB`cn*j zxJB~M9&GyNXGJs!68(MNX6N;X8KU-^RSOqjTSIV( z=BFO?cbA1yx5zTrw513aKOL%%azT{DP-3Nj<5a?g=yjLb4*3xbCe zkcSXD$x#>1Fh*B>8kHP}t6X{1*9L7~Jzo`GPkO~Zjd`1k6%*TV-y%sEgjOd@?nn#j z^Zd6R`Wa#FEBiNeX2lK4c3=sWc zx=m10TH-wirObCsUI>!-tt^xMDQ5f9_WDDVKN@rye`uXao^DVV51J|dmH70({hgFTyj zMlmsxPPWJZ!Kc+xI0Q@2=b|S!AHQR<4vxWW^a`%@_3l$G6Wc2dE_ALd9e79jdA4o4 z+u_|fLW7dx7LL|#0PBwJJnYY{eSPkJbWEx;TYk`hW=XMgBp95S-Sz48yz#P-rccr3 z0XXz1`;w_g{!nJtPC0_&^INp@vZrZO|z(Vl5i6GnD zTy*zJ(~1cKof*Q38F1FWW22+)2W3Y>^upauRG2F7*H>Qb}B6S6&Xv) z%9PZCqRn3k>f8eHAYDrVE2OvA=j1_^xO^B|$B{gufG@Yfr@#AzA&)}ivOy$_51+Ns z(}p(DKYM*^;ywf6VrCY5Im&#o(~}Zp2Rr}80O{rH71u5%{j-ukY;%qAkR-J`&4+;; z2@ul4c&V@OdPSFa*bbXcwZDKoVD~mqsy}!JkzzEr)NsU5z6OKmo^X?Len+S$F%`3n zXO}M&2ThHM8^KPqk#%-%p9A5b~o-<=M17F4!j>67nGjZwkJuVjsDPR8#&&( zk2!N&Kp@_(nS6p*IIQsP*d$}x^k~VuF!iMs)S=<#?IQjX4w)!dk_-F_F>JlvpttiXL}@Pt)Bl& zVF{~q9EqSAeoD`nHy)bQK(;g408J6dlRt9x8NozC)~d2S;A>wAxGTx-m~&&^h+j&} z&G8ea+|CuJ0E4a^CRGq$Qg)BicRj!m;ipQyc(`3t0!D#9-46Dobm8bbCLW5ahd~=j z(yN}!cAwp5k$CHgodW4)U?;yncyp}*B4fwJo9hy_ux4<62L? z3`_a2J5b>Hhk%0SW-x;BjG<5GMj-KUqP2%>QV5V-h!r0LekE7g+; z@V}KtpmI()ttO$j`+_xXlredaz@_?OEO+f8-^|S-@2j4*=ir4F!02WDT~R+D5)Q|} z8*BZBO|=i4)CJZNj!HV;yogVBCb&2;eH`64v>+HlUPmTG^F^QS}XI z95(*-g?95{DN|(5^;$Flsp)H|Tdr-5Y60KwLZIzt(&4&)S7>E#?(|ZSPrv>R5hV@= z`$ThDoy$7knmtyRYdu~tX^;fpHzg%0tpXqwtp7!35R0ak}&UuERR?xU*gvL+4J`jl4siiWzTV8ju_b9hx)tx-twYJ zWxgu;XBPSHQ=59uw@tl&9!+k`q&jdeD118A8~ScAjTHtk1a!h_5nZHtAIZq&4ghk} zr;m0f>L7N33(84}6cl=YVwiX_P!TzDT$IPXUFKU_l5<^h0BT%EfZZ#dd6wO=Ia}gf z;;3ogVS&ZflAnkyWmBSN z-1`#W81K6)KG@rtKC^2G#@IsE+}7HEA1)1To7&fDCYgtSf}98aVN4Z zcPc1sj{UPzBm}b;X%ow{BC=N6p0+IRx(~;>`EaRyIF3&lkq}+&e^)o0zxN?7PW0e3 zvPq_v=zkl${h;_mHUOS=nFJCgJjzRQa7gv|DzX=KKJn82_Q7sYaO$aG7lNhV&t>kc z&Fz-=E2pF8tas<%~k8Onz zv|JvTG&i$D^pMOZ?9cw1C&XoV|(<<;ijR6P1 zXT0<R_k*)b%o3pyhy4|Ei$DYRL=GjkVvhkl^ zC~+A?M2*!9*UCBog-W|VjF*OXqx*N2uzL;E^>_*71vSrL_U+6!RP`U~Tg_Iau$Pfl zipXuMJ@E*u;sOunbZa`b?_{ewJp(Tvjfr8vNdf!)*<2h%FepNdjadSVBCiw4%98^RMW-;sy0l`K(E(agqKO|G|$ zDBa1z`N@~8lpyx(-~4g}krb+`Zp&HdJu}o3`@d`&`|(Ari;A&AX`tN;{KmjYOAC=s zS}&BYZ>Sfn&7EU9SZxG-Tg9XktFL&QQ4AnwlqipvkR;u&y#(O&dQ=2eI9|0yqdR_; zC1jm=oqMe+w+UV2^{i|1lQw2-dE2pFCEW^u_h(9^7+B~j4gg?k7z|e5#B)Uh%=9b; zoX;m*Ut5X|oToX`_9;NzECR*d>_eZ5HB1fFC?a$c%7ls5hxfVG)=MQn#AR=ACkcyJ zg@%T2`p0qRN3hc>m!Br&)WKkezFVOG&D&(c37F1@ZM+FZ!Iu|>dM&!U-M5{cbfz^H zG`@Z2TKqp5LWG)sX;$vNK}j>D5 z>+ZSsY94&MTl_vSNBmyKIko%)t?&(*FQZEJb!ZIC7VD;{uufHJ(@Iu^E+{{q4FEa_ z2Sro@YqM7djiV_-w$qIaV6J;y91hr!-J5ZwPrHPw=NQW-Iw42)-lc_zs8rkUWU$`J zz4K;rID{Uu4t)0dZ$p_K;DRVWMdyX;`HPdm=P63(tl^)!pmah}e5|2~Dv^Z%m~cy7tt?{X_SZ_Nh>c)k0m>gNGD8!c=C zNto8vjV)ecTz=L2GlBQ(0GQJ1i10U%X%z3lam-AtY%CL_JFn4nBC-OaQlXvFAN%XY zueSbsT$?KTm!PS{JpO@p_#@1;|CYw@xi4H{y+bN>FT-Gm=JSm%(6Eb6#ct9kyc!|a zAU!#=(H;SLdlPH6h1aBMZ8c7mkC#r@mft$G6B0-{wih{W0TH!>LGpi#kHgu|mtKq9 z{7aU##gW5FSrLd*u;cnj8b95xYuSxw)nE^Nx&s36~LSn%U!DvC60lJ zYT9Sy&Pl1+fBfmXw+J})OPdMc1ac}cLDpIiqR2&N&I@!yW~3ud#d=;Muiv^nu|_2* zzfy&3KCKHawS0|fIb~XHYFZ+wX+L9xoVX&0(Saed0e{N*0OKK9nju@~(H~zQmuav@ zzvZ(6?{}U*>$)Z)A`_2dLRZI6~zwz1};T_{o zqgp+w*|bY8CEY=Q;0XV)AGOf!kCAHra=|VJi-8-u z%=pbMEiDSgUX=>NpJY_Ki=Oal$I{Y#AT|>O14{3^4JUAQ(r@jl-$bd^OD*dB$BFxE zsrAK9(?M^e5Q4b=pafk+kS+8ta9+BnG)V1q+1tKeCLXwfERVa0XlJu|mLh-&ZyZkI z+RE48qw1*?DID8ubh1j(Rj(*H77RcbqSUF~JDo}6ERmy>JK?M<4GVo5u`AxgRR_2q zEqu{B7`;6e2$4L>hVvOFvp#y|tWQbC`E><$D1b@2`D*Wg_5@PKKPpQL>O?kEbCY;p zD+ZHaZ;S9gwax5BRw4J^idiMDzx8ExM>F<%e2W=9B=;7fjJ)_g_cI_NIey(ughenv zioALt^B0knI_;j?dmB0VB1Bg(fvf3*)Wy8I4446R*DY{Cg)u%VrePF$&OC0=QsOmb4NAM-H z#pY$wA_$2g4z3c1Du(Cc!3b|H;+vy38}CjVUhJs`{h?@7Mlbu^SPCJcGivZS$gj#2dzhMP79=y7Cz$=2yJpEx#Ec-!dapI6gPD)Zp>`70);dG6Ipa# zAM*T@8gy>0eFz`|QUlK3Tp5&ly|lk@v$Z=L>M9_u8lcCa5#J!g+imxrb4VD|5&uVF z>&N^($66t*{8W$lrYhnpNjV`Why(!$$f2rN8@CacXs(9n)l0(zbl!h5Bu*>+N8rS= zK{K;GtRPE!S837NxJ+{@vyoW)G|>-$5dwc$#T0dSG46gf`)UH}PZJz(2a?V|^#(>{ z&trr@4$D&YwBp3l`TbYE#O!y`5#g}@FuE>wvEu^_L%3Lfi>SIcc-5b>7A zNTT6MVEKxEip8-}Mv?AOBrjh}nF(AHha&m0i&>B%;^y>@eL*ck{;ybj?YGcW-HLo0uB}PX z1AM;`#txo-w@cl2kz_Sq->kt{qto35I`8v;(AJa`dYcls-^6%{B=VsJ+*$ILGdw$U36(HcDS^0sYzqaJ4)wbzu?Zdz;^Ff=ZK?4N+=PixkO^{%9oNFDTqX^ z2E$!9_3YnV2dh1xv`t>hjMb+0m|J*&$1nW?2qw! zZ0c;3?|^aqApUB7@?{ck7azjzk~EZ4%=|V{FxI{Iih3v^Fe2*Jf~ZU1%kwF(&HRlZ zO3wcnkcI|C1w+3&TbS`{C93(0em(z|Bs~~t@;^f@8N7*@|{JFs#uYl8Zk*I&7kVkRPRF0x0G!9=}L;leza1B6gr?tZ6K;1 z+m0j5t}&`gdb0w>S_Zb?i&5D|MDeN)#8^GG-UHUuj8cP=*|B_z{hDtS#f$|BR}fq^ zvymaRvvH>wg()Vp6wHt_Y>t%wE+O77xe94mP$i=BH=(59C!>zpbxSnWYL@R;oDl81 zRA_oO{X>~$s%@~|{`kvS+r`I~z~0%TZTtMkVYlapW`R1^TH3@}_+H?}21x_Urvvrv zD~kt`VqwBmj58VR?H{24STKo90!{DYn8)fil(v`3Jj&LoJuT11V|9Mh=aXUEY9YJ3 zj>;a5z&mDF&5E~8JMl=UMPL~7EqSF}gw1yXC#$`LjDpgkoT0gey<XR4>72+-krFV!^ zf)?BG9WROCC5^w%gWpOlPwD@~qx^`%w9%&-Ad>AH*8!#r_kdti&R`L)4-nB#H`8#j}GxqngWIU-)scyFeE4! z>?v1fpP}2Ncb_{7u8q) z^`1z-<5?y4zVVH}Tzcmh?%26gkLaSn*16VI&365kHo(@D|4f%Bq_56@7Kir0Fj8!h zd{wYg45M-00Wm$dw*n4_tQ5_ng;tMqPlmYpdQZ zFR0GK67$}nzK#hRmz4iB^d;<6WaiNtgAV2Er_VGd*vkLQQmsaCnxRA4;od5T*{YNP zP2W3XO#lMj93$Ufj5Mrk1UNjQ&pvl=Y$rV3JN3$6bLd`}3Mo1Q?9qh{H(p0LnTGFm zlK+N4)&2mUgXaWfxO#&VX_zC&G3q2__9MUeIA#_iV;_(eAo~Duz%P>L=AuQr_LQ|t zzWt5!+g*%o4^!q_vTqI~2=fTIq4W+1uQg$Drx8F8K=E@=RoK0i+`wK7tnwS)QLrn^ zM=j+C(^snAb`}q|o|X)H0`p3|4C!q>$#We=lVXy@WeP}&cW(zD2hxzpwY$W}E0k^A zWP=CFTyyc%Mad46x3m)%NJ&-=tzzBu(H7LO&GU$8$>z8yiWbmH+UMm6^qo&j^0My| zCuzJqXwEs#1cg>_%d;YeZ`N1U-^0BvRV|(n0o6t<0PJ`->27MhF#F)KtP;00;1@W9 zk_>FxN7$@6JR-;u){`}P<Zt{mza!VM+c!1 zwBYKormA~Yv1{2WNjc4Vg)}fG+V<1KCIKiSjdK{^OdBh5wQG1i?9_U#nR`!BDc8pG zpe;k8HC>|0R*ae*-+`e3HUw}@g6T_7&N`QTq<6ZC8K75c^JEDN(RLoFkM(y;q(^xomV&Gmvn6oO-v81~#|Cmf)YR z#xcXErA+Vz+^xh~U{aeEg+DhM4dTH#KH@i;uKZl+Z=1Ga11_5#mCd8~KXtC&=Y!wx zR?=a*@e1a{X#^6G0DhyA^6WkUwSW;$q32Xf_@97{OryjJ=K@9`-1^kC{&xwI2%v^L q11vzMapKxy|8Fmr47dsd5&&B0YhHFE{<8t#4ox*Z)oNwii2nnA_GPdD diff --git a/liteloader/src/main/resources/liteloader.properties b/liteloader/src/main/resources/liteloader.properties deleted file mode 100644 index 6b8768a7..00000000 --- a/liteloader/src/main/resources/liteloader.properties +++ /dev/null @@ -1,5 +0,0 @@ -search.mods=true -search.jar=false -search.classpath=true -log=stderr -brand= \ No newline at end of file diff --git a/liteloader/src/main/resources/mixins.liteloader.core.json b/liteloader/src/main/resources/mixins.liteloader.core.json deleted file mode 100644 index 51b3a199..00000000 --- a/liteloader/src/main/resources/mixins.liteloader.core.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "required": true, - "minVersion": "0.4.10", - "package": "com.mumfrey.liteloader.common.mixin", - "refmap": "mixins.liteloader.core.refmap.json", - "mixins": [ - "MixinMinecraftServer", - "MixinServerConfigurationManager", - "MixinNetHandlerPlayServer", - "MixinItemInWorldManager", - "MixinC15PacketClientSettings", - "MixinS02PacketChat" - ] -} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle index 29a68890..66cf9de3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1 @@ rootProject.name = 'MineLittlePony' - -include 'LiteLoader' diff --git a/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinNetHandlerPlayServer.java b/src/api/java/com/mumfrey/liteloader/common/mixin/MixinNetHandlerPlayServer.java similarity index 99% rename from liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinNetHandlerPlayServer.java rename to src/api/java/com/mumfrey/liteloader/common/mixin/MixinNetHandlerPlayServer.java index 054ef435..4e18e214 100644 --- a/liteloader/src/main/java/com/mumfrey/liteloader/common/mixin/MixinNetHandlerPlayServer.java +++ b/src/api/java/com/mumfrey/liteloader/common/mixin/MixinNetHandlerPlayServer.java @@ -1,5 +1,6 @@ package com.mumfrey.liteloader.common.mixin; + import org.objectweb.asm.Opcodes; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -73,6 +74,7 @@ public abstract class MixinNetHandlerPlayServer at = @At( value = "FIELD", opcode = Opcodes.GETFIELD, + // XXX fix target = "Lnet/minecraft/entity/Entity;posY:D", ordinal = 4 ) diff --git a/liteloader/src/debug/java/com/mumfrey/liteloader/debug/Start.java b/src/api/java/com/mumfrey/liteloader/debug/Start.java similarity index 89% rename from liteloader/src/debug/java/com/mumfrey/liteloader/debug/Start.java rename to src/api/java/com/mumfrey/liteloader/debug/Start.java index 4d7d94a3..402ca372 100644 --- a/liteloader/src/debug/java/com/mumfrey/liteloader/debug/Start.java +++ b/src/api/java/com/mumfrey/liteloader/debug/Start.java @@ -9,14 +9,14 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; -import net.minecraft.launchwrapper.Launch; - import com.google.common.base.Strings; import com.google.common.collect.ImmutableSet; import com.mumfrey.liteloader.launch.LiteLoaderTweaker; import com.mumfrey.liteloader.launch.LiteLoaderTweakerServer; import com.mumfrey.liteloader.util.log.LiteLoaderLogger; +import net.minecraft.launchwrapper.Launch; + /** * Wrapper class for LaunchWrapper Main class, which logs in using Yggdrasil * first so that online shizzle can be tested. @@ -70,7 +70,6 @@ public abstract class Start } args = Start.combineArgs(args, unqualifiedArgs, qualifiedArgs); - return args; } @@ -120,29 +119,19 @@ public abstract class Start private static void addRequiredArgsClient(String[] args, List unqualifiedArgs, Map> qualifiedArgs) { LoginManager loginManager = Start.doLogin(qualifiedArgs); - - File gameDir = new File(System.getProperty("user.dir")); - File assetsDir = new File(gameDir, "assets"); - + // XXX gradle Fix Start.addArg(qualifiedArgs, "--tweakClass", LiteLoaderTweaker.class.getName()); Start.addArg(qualifiedArgs, "--username", loginManager.getProfileName()); Start.addArg(qualifiedArgs, "--uuid", loginManager.getUUID()); Start.addArg(qualifiedArgs, "--accessToken", loginManager.getAuthenticatedToken()); Start.addArg(qualifiedArgs, "--userType", loginManager.getUserType()); Start.addArg(qualifiedArgs, "--userProperties", loginManager.getUserProperties()); - Start.addArg(qualifiedArgs, "--version", "mcp"); - Start.addArg(qualifiedArgs, "--gameDir", gameDir.getAbsolutePath()); - Start.addArg(qualifiedArgs, "--assetIndex", LiteLoaderTweaker.VERSION); - Start.addArg(qualifiedArgs, "--assetsDir", assetsDir.getAbsolutePath()); } private static void addRequiredArgsServer(String[] args, List unqualifiedArgs, Map> qualifiedArgs) { - File gameDir = new File(System.getProperty("user.dir")); - Start.addArg(qualifiedArgs, "--tweakClass", LiteLoaderTweakerServer.class.getName()); Start.addArg(qualifiedArgs, "--version", "mcp"); - Start.addArg(qualifiedArgs, "--gameDir", gameDir.getAbsolutePath()); } private static LoginManager doLogin(Map> qualifiedArgs) @@ -164,16 +153,16 @@ public abstract class Start { Set args = qualifiedArgs.get(qualifier); - if (args != null && !Start.MULTI_VALUE_ARGS.contains(qualifier)) - { - return; - } - if (args == null) { args = new HashSet(); qualifiedArgs.put(qualifier, args); } + + if (!Start.MULTI_VALUE_ARGS.contains(qualifier)) + { + args.clear(); + } args.add(arg); }