This repository has been archived by the owner on Jul 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from 3arthqu4ke/0.3.0
[0.3.0] Cleaned up Session subscribers a bit, some convenience methods
- Loading branch information
Showing
18 changed files
with
213 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
pb-api/src/main/java/me/earth/pingbypass/api/event/impl/DelegatingEventBus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package me.earth.pingbypass.api.event.impl; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.experimental.Delegate; | ||
import me.earth.pingbypass.api.event.api.EventBus; | ||
|
||
@RequiredArgsConstructor | ||
public class DelegatingEventBus implements EventBus { | ||
@Delegate | ||
private final EventBus eventBus; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
pb-api/src/main/java/me/earth/pingbypass/api/plugin/impl/UnloadableEventBus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package me.earth.pingbypass.api.plugin.impl; | ||
|
||
import me.earth.pingbypass.api.event.impl.DelegatingEventBus; | ||
|
||
class UnloadableEventBus extends DelegatingEventBus { | ||
private final PluginUnloadingService unloadingService; | ||
|
||
public UnloadableEventBus(PluginUnloadingService unloadingService) { | ||
super(unloadingService.pingBypass.getEventBus()); | ||
this.unloadingService = unloadingService; | ||
} | ||
|
||
@Override | ||
public void subscribe(Object subscriber) { | ||
unloadingService.subscribe(subscriber); | ||
} | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
pb-api/src/main/java/me/earth/pingbypass/api/setting/PreAndPostObservable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
package me.earth.pingbypass.api.setting; | ||
|
||
import java.util.Collection; | ||
|
||
public interface PreAndPostObservable<O> { | ||
void addPreObserver(O observer); | ||
|
||
void addPostObserver(O observer); | ||
|
||
void removeObserver(O observer); | ||
|
||
Collection<O> getPreObservers(); | ||
|
||
Collection<O> getPostObservers(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
pb-server/src/main/java/me/earth/pingbypass/server/handlers/play/PlayerUpdateHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package me.earth.pingbypass.server.handlers.play; | ||
|
||
import me.earth.pingbypass.api.event.SubscriberImpl; | ||
import me.earth.pingbypass.api.event.listeners.generic.Listener; | ||
import me.earth.pingbypass.api.event.loop.LocalPlayerUpdateEvent; | ||
import net.minecraft.client.player.LocalPlayer; | ||
|
||
public class PlayerUpdateHandler extends SubscriberImpl { | ||
private final ThreadLocal<Boolean> inUpdate = ThreadLocal.withInitial(() -> false); | ||
|
||
public PlayerUpdateHandler() { | ||
listen(new Listener<LocalPlayerUpdateEvent>() { | ||
@Override | ||
public void onEvent(LocalPlayerUpdateEvent event) { | ||
if (!inUpdate.get()) { | ||
event.setCancelled(true); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
public void update(LocalPlayer player) { | ||
try { | ||
inUpdate.set(true); | ||
player.tick(); | ||
} finally { | ||
inUpdate.set(false); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.