Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

Commit

Permalink
Slab block data fix (#172) + reformat project
Browse files Browse the repository at this point in the history
  • Loading branch information
ApocalypsjeNL authored and HoverEpic committed Jan 2, 2018
1 parent 08efc82 commit 057a326
Show file tree
Hide file tree
Showing 64 changed files with 399 additions and 369 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/dragonet/proxy/DesktopServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.dragonet.proxy;

import java.util.Map;

import org.dragonet.proxy.configuration.RemoteServer;

public class DesktopServer extends RemoteServer {
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/org/dragonet/proxy/DragonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.dragonet.proxy;

import com.github.steveice10.mc.protocol.MinecraftConstants;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
Expand Down Expand Up @@ -151,7 +152,7 @@ public DragonProxy(String[] args) {

// set logger mode
logger.debug = config.log_debug;

// Put at the top instead
if (!IS_RELEASE)
logger.warning("This is a development build. It may contain bugs. Do not use on production.\n");
Expand All @@ -177,7 +178,7 @@ public DragonProxy(String[] args) {
authMode = config.mode.toLowerCase();
if (!authMode.equals("cls") && !authMode.equals("online") && !authMode.equals("offline"))
logger.severe("Invalid login 'mode' option detected, must be cls/online/offline. You set it to '" + authMode
+ "'! ");
+ "'! ");

// Init session and command stuff
sessionRegister = new SessionRegister(this);
Expand All @@ -191,7 +192,7 @@ public DragonProxy(String[] args) {
logger.info(lang.get(Lang.INIT_BINDING, config.udp_bind_ip, config.udp_bind_port));
// RakNet.enableLogging();
network = new RaknetInterface(this, config.udp_bind_ip, // IP
config.udp_bind_port); // Port
config.udp_bind_port); // Port

// MOTD
motd = config.motd;
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/dragonet/proxy/PocketServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.dragonet.proxy;

import java.util.Map;

import org.dragonet.proxy.configuration.RemoteServer;

public class PocketServer extends RemoteServer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import org.dragonet.proxy.DragonProxy;
import org.dragonet.proxy.configuration.Lang;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void execute(DragonProxy proxy, String[] args) {

for (Command command1 : commands.values()) {
proxy.getLogger()
.info(MCColor.DARK_GREEN + command1.getName() + ": " + MCColor.WHITE + command1.getDescription());
.info(MCColor.DARK_GREEN + command1.getName() + ": " + MCColor.WHITE + command1.getDescription());
}
}
}
40 changes: 20 additions & 20 deletions src/main/java/org/dragonet/proxy/commands/defaults/TestCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public TestCommand(String name) {
}

public void execute(DragonProxy proxy, String[] args) {
if(args.length == 0) {
System.out.println("This is a developer's command! ");
return;
}
if (args.length == 0) {
System.out.println("This is a developer's command! ");
return;
}
UpstreamSession player = proxy.getSessionRegister().getAll().values().toArray(new UpstreamSession[1])[0];
if (args[0].equalsIgnoreCase("status")) {
PlayStatusPacket s = new PlayStatusPacket();
Expand All @@ -38,11 +38,11 @@ public void execute(DragonProxy proxy, String[] args) {
player.sendPacket(new ResourcePacksInfoPacket());
} else if (args[0].equalsIgnoreCase("pos")) {
player.sendChat("pos at: " + player.getEntityCache().getClientEntity().x + ", "
+ player.getEntityCache().getClientEntity().y + ", " + player.getEntityCache().getClientEntity().z);
+ player.getEntityCache().getClientEntity().y + ", " + player.getEntityCache().getClientEntity().z);
} else if (args[0].equalsIgnoreCase("respawn")) {
RespawnPacket resp = new RespawnPacket();
resp.position = new Vector3F(Float.parseFloat(args[1]), Float.parseFloat(args[2]),
Float.parseFloat(args[3]));
Float.parseFloat(args[3]));
player.sendPacket(resp);
} else if (args[0].equalsIgnoreCase("chunkradius")) {
player.sendPacket(new ChunkRadiusUpdatedPacket(8));
Expand All @@ -59,7 +59,7 @@ public void execute(DragonProxy proxy, String[] args) {
player.sendPacket(new SetHealthPacket(0));
} else if (args[0].equalsIgnoreCase("tp")) {
Vector3F dest = new Vector3F(Float.parseFloat(args[1]), Float.parseFloat(args[2]),
Float.parseFloat(args[3]));
Float.parseFloat(args[3]));
MovePlayerPacket m = new MovePlayerPacket();
m.rtid = 1L;
m.mode = (byte) (Integer.parseInt(args[4]) & 0xFF);
Expand All @@ -68,7 +68,7 @@ public void execute(DragonProxy proxy, String[] args) {
player.sendChat("\u00a7bTeleported to: " + dest.toString());
} else if (args[0].equalsIgnoreCase("moveentity")) {
Vector3F dest = new Vector3F(Float.parseFloat(args[1]), Float.parseFloat(args[2]),
Float.parseFloat(args[3]));
Float.parseFloat(args[3]));
MoveEntityPacket m = new MoveEntityPacket();
m.rtid = 1L;
m.teleported = args[4].equalsIgnoreCase("true");
Expand All @@ -77,7 +77,7 @@ public void execute(DragonProxy proxy, String[] args) {
player.sendChat("\u00a7bTeleported to: " + dest.toString());
} else if (args[0].equalsIgnoreCase("chunk")) {
/*
* FullChunkData chunk = new FullChunkData(Integer.parseInt(args[1]),
* FullChunkData chunk = new FullChunkData(Integer.parseInt(args[1]),
* Integer.parseInt(args[2])); Arrays.fill(chunk.ids, (byte)1);
*/
ChunkData data = new ChunkData();
Expand All @@ -93,7 +93,7 @@ public void execute(DragonProxy proxy, String[] args) {
chunk.payload = data.getBuffer();
player.sendPacket(chunk);
} else if (args[0].equalsIgnoreCase("form")) {
testForm(player);
testForm(player);
} else if (args[0].equalsIgnoreCase("sound")) {

int id = Integer.parseInt(args[1]);
Expand All @@ -112,14 +112,14 @@ public void execute(DragonProxy proxy, String[] args) {
}

public static void testForm(UpstreamSession player) {
ModalFormRequestPacket p = new ModalFormRequestPacket();
CustomFormComponent form = new CustomFormComponent("\u00a7dTest Form");
form.addComponent(new LabelComponent("\u00a71Text \u00a7ki"));
form.addComponent(new LabelComponent("LABEL 2"));
form.addComponent(new DropDownComponent("DROP DOWN", Arrays.asList("option 1", "option 2")));
System.out.println(form.serializeToJson().toString());
p.formId = 1;
p.formData = form.serializeToJson().toString();
player.sendPacket(p);
}
ModalFormRequestPacket p = new ModalFormRequestPacket();
CustomFormComponent form = new CustomFormComponent("\u00a7dTest Form");
form.addComponent(new LabelComponent("\u00a71Text \u00a7ki"));
form.addComponent(new LabelComponent("LABEL 2"));
form.addComponent(new DropDownComponent("DROP DOWN", Arrays.asList("option 1", "option 2")));
System.out.println(form.serializeToJson().toString());
p.formId = 1;
p.formData = form.serializeToJson().toString();
player.sendPacket(p);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,8 @@ public PEEntityAttribute(int id, String name, float min, float max, float defaul
this.defaultValue = defaultValue;
this.currentValue = currentValue;
}

public PEEntityAttribute setValue(float currentValue)
{

public PEEntityAttribute setValue(float currentValue) {
this.currentValue = currentValue;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.util.HashMap;
import java.util.Map;

import org.dragonet.proxy.data.entity.meta.type.ByteArrayMeta;
import org.dragonet.proxy.data.entity.meta.type.FloatMeta;
import org.dragonet.proxy.data.entity.meta.type.LongMeta;
Expand Down Expand Up @@ -58,7 +59,7 @@ public static class Constants {
public static final int DATA_ENDERMAN_HELD_ITEM_DAMAGE = 24; // short
public static final int DATA_ENTITY_AGE = 25; // short
/*
* 27 (byte) player-specific flags 28 (int) player "index"? 29 (block coords)
* 27 (byte) player-specific flags 28 (int) player "index"? 29 (block coords)
* bed position
*/
public static final int DATA_BED_POSITION = 29;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.dragonet.proxy.data.entity.meta.type;

import java.nio.charset.StandardCharsets;

import org.dragonet.proxy.data.entity.meta.EntityMetaData;
import org.dragonet.proxy.data.entity.meta.IEntityMetaDataObject;
import org.dragonet.proxy.utilities.BinaryStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.dragonet.proxy.network.translator.itemsblocks.IItemDataTranslator;

/**
*
* @author vincent
*/
public class ItemEntry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ public static void closeOpened(UpstreamSession session, boolean byServer) {
if (session.getDataCache().containsKey(CacheKey.WINDOW_BLOCK_POSITION)) {
// Already a block was replaced to Chest, reset it
session.sendFakeBlock(((Position) session.getDataCache().get(CacheKey.WINDOW_BLOCK_POSITION)).getX(),
((Position) session.getDataCache().get(CacheKey.WINDOW_BLOCK_POSITION)).getY(),
((Position) session.getDataCache().remove(CacheKey.WINDOW_BLOCK_POSITION)).getZ(), 1,
// Set to stone since we don't know what it was, server will correct it once client interacts it
0);
((Position) session.getDataCache().get(CacheKey.WINDOW_BLOCK_POSITION)).getY(),
((Position) session.getDataCache().remove(CacheKey.WINDOW_BLOCK_POSITION)).getZ(), 1,
// Set to stone since we don't know what it was, server will correct it once client interacts it
0);
}
}
}
Expand All @@ -110,7 +110,7 @@ public static void updateContent(UpstreamSession session, ServerWindowItemsPacke
return; // We don't process player inventory updates here.
}
if (!session.getDataCache().containsKey(CacheKey.WINDOW_OPENED_ID)
|| !session.getWindowCache().hasWindow(packet.getWindowId())) {
|| !session.getWindowCache().hasWindow(packet.getWindowId())) {
session.getDownstream().send(new ClientCloseWindowPacket(packet.getWindowId()));
return;
}
Expand All @@ -136,7 +136,7 @@ public static void updateSlot(UpstreamSession session, ServerSetSlotPacket packe
return; // We don't process player inventory updates here.
}
if (!session.getDataCache().containsKey(CacheKey.WINDOW_OPENED_ID)
|| !session.getWindowCache().hasWindow(packet.getWindowId())) {
|| !session.getWindowCache().hasWindow(packet.getWindowId())) {
session.getDownstream().send(new ClientCloseWindowPacket(packet.getWindowId()));
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public void connect(String addr, int port) {
remoteClient.getSession().addListener(new SessionAdapter() {
public void connected(ConnectedEvent event) {
proxy.getLogger().info(proxy.getLang().get(Lang.MESSAGE_REMOTE_CONNECTED, upstream.getUsername(),
upstream.getRemoteAddress()));
upstream.getRemoteAddress()));
upstream.onConnected();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public static Packet[] translateToPC(UpstreamSession session, PEPacket packet) {
if (packet == null)
return null;
IPEPacketTranslator<PEPacket> target = (IPEPacketTranslator<PEPacket>) PE_TO_PC_TRANSLATOR
.get(packet.getClass());
.get(packet.getClass());
if (target == null)
return null;
try {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/dragonet/proxy/network/RaknetInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public RakNetServer getRakServer() {
}

/*
* public void onTick() { }
* public void onTick() { }
*/
public void handlePing(ServerPing ping) {
DragonProxy.getInstance().getLogger().debug("PING " + ping.getSender().toString());
Expand Down Expand Up @@ -103,8 +103,8 @@ public void onSessionException(RakNetClientSession session, Throwable throwable)

public void setBroadcastName(String serverName, int players, int maxPlayers) {
rakServer.setIdentifier(
new MinecraftIdentifier(serverName, ProtocolInfo.CURRENT_PROTOCOL, ProtocolInfo.MINECRAFT_VERSION_NETWORK,
players, maxPlayers, new Random().nextLong(), "DragonProxy", "Survival"));
new MinecraftIdentifier(serverName, ProtocolInfo.CURRENT_PROTOCOL, ProtocolInfo.MINECRAFT_VERSION_NETWORK,
players, maxPlayers, new Random().nextLong(), "DragonProxy", "Survival"));
if (!rakServer.isBroadcastingEnabled())
rakServer.setBroadcastingEnabled(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.dragonet.proxy.DragonProxy;

public class SessionRegister {

private final DragonProxy proxy;
private final Map<String, UpstreamSession> clients = Collections
.synchronizedMap(new HashMap<String, UpstreamSession>());
.synchronizedMap(new HashMap<String, UpstreamSession>());

public SessionRegister(DragonProxy proxy) {
this.proxy = proxy;
Expand Down
Loading

0 comments on commit 057a326

Please sign in to comment.