Skip to content
This repository was archived by the owner on Feb 19, 2019. It is now read-only.

Commit 5b02eaf

Browse files
committed
Updated Alpine, added method to disable EventManager
1 parent 64b5312 commit 5b02eaf

6 files changed

Lines changed: 38 additions & 9 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ repositories {
5454

5555
dependencies {
5656
testCompile group: 'junit', name: 'junit', version: '4.12'
57-
compile 'com.github.ZeroMemes:Alpine:1.3'
57+
compile 'com.github.ZeroMemes:Alpine:1.4'
5858
compile("org.spongepowered:mixin:0.6.10-SNAPSHOT") {
5959
exclude module: "launchwrapper"
6060
}

src/main/java/me/zero/client/api/Client.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package me.zero.client.api;
1818

19+
import me.zero.client.api.event.handle.ClientHandler;
20+
1921
/**
2022
* The base for all Clients
2123
*
@@ -30,7 +32,7 @@ public abstract class Client extends ClientBase {
3032
* @see me.zero.client.api.module.Module
3133
* @see me.zero.client.api.module.plugin.Plugin
3234
*
33-
* @param info The ClientInfo object from the client.json
35+
* @param handler The handler that's being used to handle Client API events
3436
*/
35-
public abstract void onInit(ClientInfo info);
37+
public abstract void onInit(ClientHandler handler);
3638
}

src/main/java/me/zero/client/api/ClientAPI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package me.zero.client.api;
1818

1919
import me.zero.alpine.EventBus;
20-
import me.zero.alpine.EventManager;
20+
import me.zero.client.api.event.CAPIEventManager;
2121

2222
/**
2323
* Contains some constants that are used throughout the API.
@@ -36,5 +36,5 @@ private ClientAPI() {}
3636
* Instance of the API event bus. All default game event are
3737
* passed through this event bus.
3838
*/
39-
public static final EventBus EVENT_BUS = new EventManager();
39+
public static final EventBus EVENT_BUS = new CAPIEventManager();
4040
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package me.zero.client.api.event;
2+
3+
import me.zero.alpine.EventManager;
4+
5+
/**
6+
* Gives more control to EventManager
7+
*
8+
* @author Brady
9+
* @since 6/9/2017 2:53 PM
10+
*/
11+
public final class CAPIEventManager extends EventManager {
12+
13+
private boolean enabled = true;
14+
15+
@Override
16+
public final void post(Object event) {
17+
if (!enabled)
18+
super.post(event);
19+
}
20+
21+
public final void setEnabled(boolean enabled) {
22+
this.enabled = enabled;
23+
}
24+
25+
public final boolean isEnabled() {
26+
return this.enabled;
27+
}
28+
}

src/main/java/me/zero/client/api/event/handle/ClientHandler.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ public final class ClientHandler implements Helper {
5252
*/
5353
@EventHandler
5454
private final Listener<RenderHudEvent> render2DListener = new Listener<>(event ->
55-
CameraManager.getInstance().getData().stream().filter(Camera::isVisible).forEach(camera -> camera.updateFramebuffer(event.getPartialTicks())),
56-
EventPriority.LOWEST);
55+
CameraManager.getInstance().getData().forEach(camera -> camera.updateFramebuffer(event.getPartialTicks())), EventPriority.LOWEST);
5756

5857
/**
5958
* Handles keybinds

src/main/java/me/zero/client/api/module/Module.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
* for values, properties, type, keybind, name
3535
* and description.
3636
*
37+
* @see IModule
3738
* @see Category
3839
*
3940
* @author Brady
@@ -75,8 +76,7 @@ public Module() {
7576
this.description = data.description();
7677

7778
this.bind = new Keybind(Keybind.Type.TOGGLE, data.bind(), type -> {
78-
if (type == CLICK)
79-
Module.this.toggle();
79+
if (type == CLICK) Module.this.toggle();
8080
});
8181
}
8282

0 commit comments

Comments
 (0)