-
-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to intercept serialized input packets on CraftBukkit.
Spigot will be added later.
- Loading branch information
Showing
10 changed files
with
201 additions
and
20 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
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
64 changes: 64 additions & 0 deletions
64
ProtocolLib/src/main/java/com/comphenix/protocol/injector/packet/CaptureInputStream.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,64 @@ | ||
package com.comphenix.protocol.injector.packet; | ||
|
||
import java.io.FilterInputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
|
||
/** | ||
* Represents an input stream that stores every read block of bytes in another output stream. | ||
* | ||
* @author Kristian | ||
*/ | ||
class CaptureInputStream extends FilterInputStream { | ||
protected OutputStream out; | ||
|
||
public CaptureInputStream(InputStream in, OutputStream out) { | ||
super(in); | ||
this.out = out; | ||
} | ||
|
||
@Override | ||
public int read() throws IOException { | ||
int value = super.read(); | ||
|
||
// Write the byte | ||
if (value >= 0) | ||
out.write(value); | ||
return value; | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
super.close(); | ||
out.close(); | ||
} | ||
|
||
@Override | ||
public int read(byte[] b) throws IOException { | ||
int count = super.read(b); | ||
|
||
if (count > 0 ) { | ||
out.write(b, 0, count); | ||
} | ||
return count; | ||
} | ||
|
||
@Override | ||
public int read(byte[] b, int off, int len) throws IOException { | ||
int count = super.read(b, off, len); | ||
|
||
if (count > 0 ) { | ||
out.write(b, off, count); | ||
} | ||
return count; | ||
} | ||
|
||
/** | ||
* Retrieve the output stream that recieves all the read information. | ||
* @return The output stream everything is copied to. | ||
*/ | ||
public OutputStream getOutputStream() { | ||
return out; | ||
} | ||
} |
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
Oops, something went wrong.