Skip to content

Commit a78adb5

Browse files
Merge pull request #5 from NeonAngelThreads/proxy-support
Proxy support
2 parents f6f5f3d + 26d2153 commit a78adb5

File tree

8 files changed

+234
-205
lines changed

8 files changed

+234
-205
lines changed

README.md

Lines changed: 197 additions & 195 deletions
Large diffs are not rendered by default.

src/main/java/org/angellock/impl/AbstractRobot.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,11 @@ public void scheduleReconnect() {
228228
} catch (InterruptedException e) {
229229
throw new RuntimeException(e);
230230
}
231-
this.scheduleConnect(0);
231+
this.scheduleConnect();
232232
}
233233

234-
public void scheduleConnect(int wait) {
235-
this.reconnectScheduler.schedule(() -> this.connect(), wait, TimeUnit.SECONDS);
234+
public void scheduleConnect() {
235+
this.reconnectScheduler.schedule(this::connect, 0, TimeUnit.SECONDS);
236236
}
237237

238238
public void setBypassed(boolean bypassed) {

src/main/java/org/angellock/impl/RobotPlayer.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,20 @@
2323
import org.angellock.impl.plugin.PluginManager;
2424
import org.angellock.impl.util.ConsoleTokens;
2525
import org.angellock.impl.util.math.Position;
26+
import org.cloudburstmc.math.immutable.vector.ImmutableVector3d;
27+
import org.cloudburstmc.math.vector.Vector3d;
28+
import org.cloudburstmc.math.vector.Vector3i;
29+
import org.geysermc.mcprotocollib.protocol.data.game.entity.object.Direction;
30+
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand;
31+
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.InteractAction;
32+
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.PlayerAction;
33+
import org.geysermc.mcprotocollib.protocol.data.game.level.particle.positionsource.BlockPositionSource;
34+
import org.geysermc.mcprotocollib.protocol.data.game.level.particle.positionsource.PositionSource;
35+
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.inventory.ServerboundPlaceRecipePacket;
36+
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.*;
2637

2738
import java.util.Optional;
39+
import java.util.Vector;
2840

2941
public class RobotPlayer extends AbstractRobot {
3042
private long connectTime;
@@ -76,7 +88,7 @@ public void onKicked() {
7688
@Override
7789
public void onPreLogin() {
7890
this.connectTime = System.currentTimeMillis();
79-
log.info(ConsoleTokens.colorizeText("&l&bAttempt to join to the server &3"+ this.infoHelper.getServer()+':'+this.infoHelper.getPort() +". &bWaiting for server establishing the connection..."));
91+
log.info(ConsoleTokens.colorizeText("&l&bAttempt to join to the server &3{}:{}. &bWaiting for server establishing the connection..."), this.infoHelper.getServer(), this.infoHelper.getPort());
8092
}
8193

8294
@Override
@@ -88,4 +100,11 @@ public double getDistanceFromOthers(IPlayer player) {
88100
public Position getPosition() {
89101
return this.loginPos;
90102
}
103+
104+
@Override
105+
public void interactBlock(double x, double y, double z, int s) {
106+
this.sendPacket(new ServerboundSwingPacket(Hand.MAIN_HAND));
107+
this.sendPacket(new ServerboundUseItemOnPacket(Vector3i.from(x, y, z), Direction.SOUTH, Hand.MAIN_HAND, 0f,0f,0f,false, (int)(System.currentTimeMillis())));
108+
109+
}
91110
}

src/main/java/org/angellock/impl/ingame/IPlayer.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ public interface IPlayer extends IWalkable {
77
double getDistanceFromOthers(IPlayer player);
88

99
Position getPosition();
10+
void interactBlock(double x, double y, double z, int s);
1011
}

src/main/java/org/angellock/impl/ingame/Player.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public Position getPosition() {
3333
return position;
3434
}
3535

36+
@Override
37+
public void interactBlock(double x, double y, double z, int s) {
38+
39+
}
40+
3641
public void setPosition(Position position) {
3742
this.position = position;
3843
}
@@ -54,4 +59,6 @@ public void pushVelocity(double x, double y, double z) {
5459
public double getDistanceFromOthers(IPlayer player) {
5560
return position.getDistance(player.getPosition());
5661
}
62+
63+
5764
}

src/main/java/org/angellock/impl/managers/BotManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ public static Map<String, RobotPlayer> bots() {
193193

194194
public void startAll(){
195195
for (RobotPlayer bot: bots.values()){
196-
bot.scheduleConnect(0);
196+
bot.scheduleConnect();
197197
while (bot.getServerGamemode() == GameMode.ADVENTURE){
198198
try {
199199
Thread.sleep(5000L);

src/main/java/org/angellock/impl/managers/ResourceHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private void autoCopy(File outFile) throws IOException {
3939
InputStream in = Start.class.getClassLoader().getResourceAsStream(getFullFileName());
4040
if (in != null) {
4141
OutputStream out = new FileOutputStream(outFile);
42-
byte[] buf = new byte[512];
42+
byte[] buf = new byte[1024];
4343
int len;
4444
while((len = in.read(buf)) > 0) {
4545
out.write(buf, 0, len);

src/main/resources/bot.profiles.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"profiles": {
33
"bot#1": {
4-
"name": "爱丽丝的DolphinBot1",
4+
"name": "DolphinBot1",
55
"password": "default_password",
66
"owner": [
77
"Melibertan"
@@ -14,7 +14,7 @@
1414
"proxy": {
1515
"enabled": true,
1616
"info": {
17-
"address": "45.78.199.53",
17+
"address": "",
1818
"port": 7777,
1919
"type": "SOCKS4",
2020
"username": "",
@@ -23,7 +23,7 @@
2323
}
2424
},
2525
"bot#2": {
26-
"name": "爱丽丝的DolphinBot2",
26+
"name": "DolphinBot2",
2727
"password": "default_password",
2828
"owner": [
2929
"Melibertan"
@@ -35,7 +35,7 @@
3535
"proxy": {
3636
"enabled": true,
3737
"info": {
38-
"address": "47.91.89.3",
38+
"address": "",
3939
"port": 40000,
4040
"type": "SOCKS4",
4141
"username": "",

0 commit comments

Comments
 (0)