Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.deftware.aristois.event;
- import com.google.gson.JsonArray;
- import com.google.gson.JsonElement;
- import com.google.gson.JsonPrimitive;
- import me.deftware.aristois.events.EventUpdateFast;
- import me.deftware.aristois.gui.modgui.ModGui;
- import me.deftware.aristois.mod.mods.movement.Blink;
- import me.deftware.aristois.util.MacroManager;
- import me.deftware.client.framework.event.EventListener;
- import me.deftware.client.framework.event.events.*;
- import me.deftware.client.framework.maps.SettingsMap;
- import me.deftware.client.framework.utils.ChatColor;
- import java.awt.*;
- import lombok.Setter;
- import me.deftware.aristois.main.Client;
- import me.deftware.aristois.gui.IGuiClientOptions;
- import me.deftware.aristois.gui.IGuiMainMenu;
- import me.deftware.aristois.main.Main;
- import me.deftware.aristois.mod.mods.render.Waypoints;
- import me.deftware.aristois.util.ChatUtils;
- import me.deftware.aristois.util.WaypointsManager;
- import me.deftware.aristois.util.WaypointsManager.Waypoint;
- import me.deftware.client.framework.event.Event;
- import me.deftware.client.framework.event.events.EventGuiScreenDisplay.ScreenTypes;
- import me.deftware.client.framework.event.events.EventGuiScreenDraw.CommonScreenTypes;
- import me.deftware.client.framework.utils.RenderUtils;
- import me.deftware.client.framework.wrappers.IChat;
- import me.deftware.client.framework.wrappers.IMinecraft;
- import me.deftware.client.framework.wrappers.entity.IEntity;
- import me.deftware.client.framework.wrappers.entity.IEntity.EntityType;
- import me.deftware.client.framework.wrappers.entity.IEntityPlayer;
- import me.deftware.client.framework.wrappers.gui.IGuiButton;
- import me.deftware.client.framework.wrappers.gui.IGuiInventory;
- import me.deftware.client.framework.wrappers.gui.IGuiScreen;
- import me.deftware.client.framework.wrappers.gui.IScreens.Screen;
- import me.deftware.client.framework.wrappers.world.IWorld;
- import org.lwjgl.glfw.GLFW;
- public class EventBus extends EventListener {
- private static IGuiScreen iScreen = null;
- private static Screen screenType = null;
- @Setter
- private static String invsee = "";
- public static void onEvent(Event event) {
- if (Client.getInstance().getModloader().isLoaded()) {
- Client.getInstance().getModloader().getMods().forEach((key, mod) -> {
- if (mod.isEnabled()) {
- mod.onEvent(event);
- } else if (mod.getName().equals("Blink") && event instanceof EventUpdate && ((Blink) mod).flag) {
- mod.onEvent(event);
- }
- });
- }
- if (event instanceof EventRender2D || event instanceof EventRender3D) {
- RenderUtils.fixDarkLight();
- }
- if (event instanceof EventUpdateFast && IMinecraft.getIScreen() != null && IMinecraft.getIScreen() instanceof ModGui) {
- ((ModGui) IMinecraft.getIScreen()).onTick();
- }
- if (event instanceof EventChatSend) {
- EventChatSend e = (EventChatSend) event;
- if (e.getMessage().contains(" && ")) {
- event.setCanceled(true);
- for (String cmd : e.getMessage().split(" && ")) {
- IChat.sendChatMessage(cmd);
- }
- }
- } else if (event instanceof EventChatReceive) {
- JsonArray usernames = Main.getConfig().getArray("user_ignore_list");
- String msg = ((EventChatReceive) event).getMessage().toLowerCase();
- if (msg.contains(" ")) {
- for (JsonElement username : usernames) {
- if (msg.contains(username.getAsString().toLowerCase())) {
- event.setCanceled(true);
- break;
- }
- }
- } else {
- // This shouldn't happen but oh well
- event.setCanceled(usernames.contains(new JsonPrimitive(msg)));
- }
- } else if (event instanceof EventKeyAction) {
- Client.getInstance().getModloader().getMods().forEach((key, mod) -> {
- if (mod.getKeybind() == ((EventKeyAction) event).getKeyCode() && mod.getKeybind() != GLFW.GLFW_KEY_UNKNOWN) {
- mod.toggle();
- }
- });
- MacroManager.getInstance().processMacro((EventKeyAction) event);
- } else if (event instanceof EventRender2D) {
- checkForScreens();
- if (!invsee.equals("")) {
- IEntity e = null;
- for (IEntity entity : IWorld.getILoadedEntityList()) {
- if (!entity.isPlayer()) { continue; }
- if (entity.getName().toLowerCase().equals(invsee.toLowerCase())) {
- if (entity.instanceOf(EntityType.EntityOtherPlayerMP)) {
- e = entity;
- }
- break;
- }
- }
- if (e == null) {
- ChatUtils.sendClientMessage("Could not find the specified player");
- } else {
- ChatUtils.sendClientMessage("Opening inventory for player " + invsee);
- IMinecraft.openInventory(new IGuiInventory(e));
- }
- invsee = "";
- }
- } else if (event instanceof EventGuiScreenDisplay) {
- EventGuiScreenDisplay gEvent = (EventGuiScreenDisplay) event;
- if (gEvent.getType().equals(ScreenTypes.MainMenu)) {
- gEvent.setScreen(new IGuiMainMenu());
- }
- } else if (event instanceof EventIRCMessage) {
- String message = ((EventIRCMessage) event).getMessage();
- if (Client.getInstance().getIrc() == null) {
- ChatUtils.sendClientMessage("You are not connected to the IRC");
- return;
- } else if (!Client.getInstance().getIrc().isConnected()) {
- ChatUtils.sendClientMessage("You are not connected to the IRC");
- return;
- }
- if (message.equals("quit")) {
- Client.getInstance().getIrc().disconnect();
- return;
- }
- Client.getInstance().getIrc().onInput(message);
- return;
- } else if (event instanceof EventGameOver) {
- if (Client.getInstance().getModloader().getMod(Waypoints.class).isDeathpoints()) {
- Waypoint p = new Waypoint("Death", (int) IEntityPlayer.getPosX(), (int) IEntityPlayer.getPosY(),
- (int) IEntityPlayer.getPosZ(), WaypointsManager.getInstance().getServerSave(), Color.pink.getRGB(), true);
- WaypointsManager.getInstance().addWaypoint(p);
- ChatUtils.sendClientMessage("Created death waypoint");
- }
- } else if (event instanceof EventGuiScreenDraw) {
- drawMenuButton((EventGuiScreenDraw) event);
- } else if (event instanceof EventServerPinged) {
- String version = ((EventServerPinged) event).getGameVersion();
- ((EventServerPinged) event)
- .setPopulationInfo(ChatColor.AQUA + "" + version + " " + ChatColor.GRAY + "| " + ((EventServerPinged) event).getPopulationInfo());
- } else if (event instanceof EventChatboxType) {
- if (!Main.getConfig().getBool("chat-overlay", true)) {
- return;
- }
- EventChatboxType e = (EventChatboxType) event;
- if (e.getText().equals("")) {
- e.setOverlay("# <Message> - Sends an IRC message | " + (String) SettingsMap.getValue(SettingsMap.MapKeys.EMC_SETTINGS, "COMMAND_TRIGGER", ".") + "help - View all " + Main.getName() + " commands");
- } else {
- e.setOverlay("");
- }
- }
- }
- public static void checkForScreens() {
- if (iScreen != null) {
- IMinecraft.setGuiScreen(iScreen);
- iScreen = null;
- }
- if (screenType != null) {
- IMinecraft.setGuiScreenType(screenType);
- screenType = null;
- }
- }
- public static void setScreen(IGuiScreen screen) {
- EventBus.iScreen = screen;
- }
- public static void setScreenType(Screen screen) {
- EventBus.screenType = screen;
- }
- private static void drawMenuButton(EventGuiScreenDraw event) {
- if (event.instanceOf(CommonScreenTypes.GuiIngameMenu)) {
- if (event.getIButtonList().isEmpty()) {
- event.addButton(new IGuiButton(30, event.getWidth() / 2 - 100, event.getHeight() / 4 + 56,
- Main.getName() + " Options") {
- @Override
- public void onButtonClick(double mouseX, double mouseY) {
- IMinecraft.setGuiScreen(new IGuiClientOptions());
- }
- });
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement