diff --git a/.gitignore b/.gitignore index baf69fc7..7c3ec6a8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ /target/ *.prefs *.sw? -dependency-reduced-pom.xml /bin /docs -/javadoc-gen.xml +/.idea/ +*.iml diff --git a/README.md b/README.md index d25820c5..79f4fc9b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ CanaryLib ========= -[Last Build](http://build.canarymod.net/job/CanaryLib/lastBuild/net.canarymod$CanaryLib/) ![Build Status](http://build.canarymod.net/job/CanaryLib/badge/icon) -[Last Successful Build](http://build.canarymod.net/job/CanaryLib/lastSuccessfulBuild/net.canarymod$CanaryLib/) +[Last Build](http://build.canarymod.net/job/CanaryLib/lastBuild/net.canarymod$CanaryLib/) +[Last Successful Build](http://build.canarymod.net/job/CanaryLib/lastSuccessfulBuild/net.canarymod$CanaryLib/) [ChangeLog](http://build.canarymod.net/job/CanaryLib/changes) CanaryMod is a Minecraft Server wrapper and library with built-in data @@ -33,7 +33,7 @@ Maven -*Unoffical repository (until the official one is setup):* +*Repository:* vi-repo @@ -45,7 +45,7 @@ Maven Non-Maven ------------- - Add CanaryLib and VIUtils 1.0.4 to the build path of your Plugin project. + Add CanaryLib (unshaded or shaded) and VIUtils 1.1.1 (if using unshaded) to the build path of your Plugin project. VIUtils downloads can be found at [http://wiki.visualillusionsent.net/VIUtils](http://wiki.visualillusionsent.net/VIUtils) or [http://repo.visualillusionsent.net/net/visualillusionsent/viutils/](http://repo.visualillusionsent.net/net/visualillusionsent/viutils/) Java Docs @@ -65,7 +65,7 @@ http://docs.visualillusionsent.net/VIUtils/ Pull Requests ============= -It helps us when others take the time to submit fixes rather than just pointing out bugs/inconsistancies. +It helps us when others take the time to submit fixes rather than just pointing out bugs/inconsistencies. However, We have standards for the sources we have. Things like formatting and generally following the [Sun/Oracle coding standards](http://www.oracle.com/technetwork/java/javase/documentation/codeconvtoc-136057.html) @@ -80,5 +80,18 @@ Source Formatting and requirements If you’re on a Windows machine, set it to true — this converts LF endings into CRLF when you check out code. (git config --global core.autocrlf true) * Eclipse: http://stackoverflow.com/a/11596227/532590 * NetBeans: http://stackoverflow.com/a/1866385/532590 + * IntelliJ: http://stackoverflow.com/a/9872584 * JavaDocs well written (as necessary) -* Matching how we format statements \ No newline at end of file +* Matching how we format statements + + public class MyClass { //note the whitespace + public void function() { + if (something) { + // do stuff + } else if (somethingElse) { + // do other stuff + } else { + // do else stuff + } + } + } diff --git a/pom.xml b/pom.xml index 8826de65..771dcd5a 100644 --- a/pom.xml +++ b/pom.xml @@ -89,7 +89,7 @@ org.xerial sqlite-jdbc - + net.visualillusionsent viutils diff --git a/src/main/java/net/canarymod/api/ConfigurationManager.java b/src/main/java/net/canarymod/api/ConfigurationManager.java index 7af59ba7..b71a2a63 100644 --- a/src/main/java/net/canarymod/api/ConfigurationManager.java +++ b/src/main/java/net/canarymod/api/ConfigurationManager.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import net.canarymod.api.entity.living.humanoid.Player; +import net.canarymod.api.packet.Packet; import net.canarymod.api.world.DimensionType; import net.canarymod.api.world.World; import net.canarymod.api.world.blocks.Block; @@ -20,7 +21,7 @@ public interface ConfigurationManager { * @param world * the {@link World} name * @param packet - * the {@link Packet} to be sent + * the {@link net.canarymod.api.packet.Packet} to be sent */ public void sendPacketToAllInWorld(String world, Packet packet); diff --git a/src/main/java/net/canarymod/api/EntityTracker.java b/src/main/java/net/canarymod/api/EntityTracker.java index 3256a694..44a2bf6f 100644 --- a/src/main/java/net/canarymod/api/EntityTracker.java +++ b/src/main/java/net/canarymod/api/EntityTracker.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import net.canarymod.api.entity.Entity; import net.canarymod.api.entity.living.humanoid.Player; +import net.canarymod.api.packet.Packet; import net.canarymod.api.world.World; /** @@ -50,12 +51,12 @@ public interface EntityTracker { public World getAttachedDimension(); /** - * Send a {@link Packet} to a tracked {@link Player} + * Send a {@link net.canarymod.api.packet.Packet} to a tracked {@link Player} * * @param player - * the {@link Player} to send the {@link Packet} + * the {@link Player} to send the {@link net.canarymod.api.packet.Packet} * @param packet - * the {@link Packet} to be sent + * the {@link net.canarymod.api.packet.Packet} to be sent */ public void sendPacketToTrackedPlayer(Player player, Packet packet); diff --git a/src/main/java/net/canarymod/api/NetServerHandler.java b/src/main/java/net/canarymod/api/NetServerHandler.java index c5524a1c..379873d7 100644 --- a/src/main/java/net/canarymod/api/NetServerHandler.java +++ b/src/main/java/net/canarymod/api/NetServerHandler.java @@ -1,6 +1,7 @@ package net.canarymod.api; import net.canarymod.api.entity.living.humanoid.Player; +import net.canarymod.api.packet.Packet; /** * NetServerHandler wrapper @@ -14,7 +15,7 @@ public interface NetServerHandler { * It will be sent when it's polled form the queue * * @param packet - * the {@link Packet} to be sent + * the {@link net.canarymod.api.packet.Packet} to be sent */ public void sendPacket(Packet packet); diff --git a/src/main/java/net/canarymod/api/entity/living/humanoid/Player.java b/src/main/java/net/canarymod/api/entity/living/humanoid/Player.java index 9915732a..4ff93a05 100755 --- a/src/main/java/net/canarymod/api/entity/living/humanoid/Player.java +++ b/src/main/java/net/canarymod/api/entity/living/humanoid/Player.java @@ -2,7 +2,7 @@ import net.canarymod.api.GameMode; import net.canarymod.api.NetServerHandler; -import net.canarymod.api.Packet; +import net.canarymod.api.packet.Packet; import net.canarymod.api.PlayerListEntry; import net.canarymod.api.inventory.Inventory; import net.canarymod.api.world.blocks.Sign; diff --git a/src/main/java/net/canarymod/api/factory/Factory.java b/src/main/java/net/canarymod/api/factory/Factory.java index 4bf7419f..b0ec1e61 100644 --- a/src/main/java/net/canarymod/api/factory/Factory.java +++ b/src/main/java/net/canarymod/api/factory/Factory.java @@ -44,4 +44,11 @@ public interface Factory { */ public NBTFactory getNBTFactory(); + /** + * Gets the {@link PacketFactory} instance + * + * @return {@link PacketFactory} + */ + public PacketFactory getPacketFactory(); + } diff --git a/src/main/java/net/canarymod/api/factory/PacketFactory.java b/src/main/java/net/canarymod/api/factory/PacketFactory.java new file mode 100644 index 00000000..e0dc6e25 --- /dev/null +++ b/src/main/java/net/canarymod/api/factory/PacketFactory.java @@ -0,0 +1,13 @@ +package net.canarymod.api.factory; + +/** + * Packet Factory + * + * @author Jason (darkdiplomat) + */ +public interface PacketFactory { + + // IMPLEMENTATIONS PENDING + + +} diff --git a/src/main/java/net/canarymod/api/packet/BlockChangePacket.java b/src/main/java/net/canarymod/api/packet/BlockChangePacket.java new file mode 100644 index 00000000..b2d9e83d --- /dev/null +++ b/src/main/java/net/canarymod/api/packet/BlockChangePacket.java @@ -0,0 +1,133 @@ +package net.canarymod.api.packet; + +import net.canarymod.api.world.blocks.Block; +import net.canarymod.api.world.blocks.BlockType; +import net.canarymod.api.world.position.Position; + +/** + * Packet #53 BlockChange + * + * @author Jason (darkdiplomat) + */ +public interface BlockChangePacket extends Packet { + + /** + * Gets the X coordinate + * + * @return X coordinate + */ + public int getX(); + + /** + * Sets the X coordinate + * + * @param x + * the X coordinate + */ + public void setX(int x); + + /** + * Gets the Y coordinate + * + * @return Y coordinate + */ + public int getY(); + + /** + * Sets the Y coordinate + * + * @param y + * the Y coordinate + */ + public void setY(int y); + + /** + * Gets the Z coordinate + * + * @return Z coordinate + */ + public int getZ(); + + /** + * Sets the Z coordinate + * + * @param z + * the Z coordinate + */ + public void setZ(int z); + + /** + * Gets the {@link Position} + * + * @return the {@link Position} + */ + public Position getPosition(); + + /** + * Sets the {@link Position} + * + * @param position + * the {@link Position} to set + */ + public void setPosition(Position position); + + /** + * Gets the {@link BlockType} + * + * @return the {@link BlockType} + */ + public BlockType getType(); + + /** + * Sets the {@link BlockType} (id and data) + * + * @param type + * the {@link BlockType} to set + */ + public void setType(BlockType type); + + /** + * Gets the Type ID + * + * @return the Type ID + */ + public int getTypeId(); + + /** + * Sets the Type Id + * + * @param id + * the Type ID + */ + public void setTypeId(int id); + + /** + * Gets the Block Data value + * + * @return the data + */ + public int getData(); + + /** + * Sets the Block data value + * + * @param data + * the Block data + */ + public void setData(int data); + + /** + * Gets the {@link Block} + * + * @return the {@link Block} + */ + public Block getBlock(); + + /** + * Sets the {@link Block} + * + * @param block + * the {@link Block} + */ + public void setBlock(Block block); +} diff --git a/src/main/java/net/canarymod/api/Packet.java b/src/main/java/net/canarymod/api/packet/Packet.java similarity index 93% rename from src/main/java/net/canarymod/api/Packet.java rename to src/main/java/net/canarymod/api/packet/Packet.java index e076adf5..fd91813c 100644 --- a/src/main/java/net/canarymod/api/Packet.java +++ b/src/main/java/net/canarymod/api/packet/Packet.java @@ -1,4 +1,4 @@ -package net.canarymod.api; +package net.canarymod.api.packet; /** * Packet interface. diff --git a/src/main/java/net/canarymod/api/world/blocks/Block.java b/src/main/java/net/canarymod/api/world/blocks/Block.java index 0da35181..36e437c0 100644 --- a/src/main/java/net/canarymod/api/world/blocks/Block.java +++ b/src/main/java/net/canarymod/api/world/blocks/Block.java @@ -3,13 +3,14 @@ import net.canarymod.api.entity.EntityItem; import net.canarymod.api.entity.living.humanoid.Player; import net.canarymod.api.inventory.Item; +import net.canarymod.api.packet.BlockChangePacket; import net.canarymod.api.world.World; import net.canarymod.api.world.position.Location; import net.canarymod.api.world.position.Position; /** * Interface representing a block in minecraft. - * + * * @author Chris (damagefitler) * @author Jason (darkdiplomat) */ @@ -17,162 +18,162 @@ public interface Block { /** * Get this blocks type - * + * * @return type id */ public short getTypeId(); /** * Set this blocks type - * + * * @param type - * the type id + * the type id */ public void setTypeId(short type); /** * Get this blocks data - * + * * @return data */ public short getData(); /** * Sets the block's data - * + * * @param data - * the data to set + * the data to set */ public void setData(short data); /** * Gets the block's BlockType - * + * * @return {@link BlockType} */ public BlockType getType(); /** * Set this blocks type - * + * * @param type - * the {@link BlockType} to set + * the {@link BlockType} to set */ public void setType(BlockType type); /** * Get the current dimension for this block - * + * * @return world */ public World getWorld(); /** * Set this block dimension - * + * * @param world - * the {@link World} to set + * the {@link World} to set */ public void setWorld(World world); /** * Get the face that was clicked. - * + * * @return {@link BlockFace} */ public BlockFace getFaceClicked(); /** * Set the clicked BlockFace - * + * * @param face - * the {@link BlockFace} + * the {@link BlockFace} */ public void setFaceClicked(BlockFace face); /** * Get the block that is next to this block on the given face * That means the block north or south east etc from this block - * + * * @param face - * the {@link BlockFace} to check + * the {@link BlockFace} to check + * * @return the adjacent block */ public Block getFacingBlock(BlockFace face); /** * Get the block relative from this block - * + * * @param x - * the block x + * the block x * @param y - * the block y + * the block y * @param z - * the block z + * the block z + * * @return the relative block */ public Block getRelative(int x, int y, int z); - /** - * Send update packet for this block - */ + /** Send update packet for this block */ public void update(); /** * Get this blocks position on the X axis - * + * * @return x coordinate */ public int getX(); /** * Get this blocks position on the Y axis - * + * * @return y coordinate */ public int getY(); /** * Get this blocks position on the Z axis - * + * * @return z coordinate */ public int getZ(); /** * Set this blocks position on the X axis - * + * * @param x - * x coordinate + * x coordinate */ public void setX(int x); /** * Set this blocks position on the Y axis - * + * * @param y - * y coordinate + * y coordinate */ public void setY(int y); /** * Set this blocks position on the Z axis - * + * * @param z - * z coordinate + * z coordinate */ public void setZ(int z); /** * Gets this blocks location, with world info - * + * * @return the {@link Location} */ public Location getLocation(); /** * Gets this blocks position. - * + * * @return the {@link Position} */ public Position getPosition(); @@ -181,9 +182,9 @@ public interface Block { * Sets the status of this block. * The meaning of a specific number can vary. * For detailed information see the javadocs of the respective hook. - * + * * @param status - * the block status + * the block status */ public void setStatus(byte status); @@ -191,35 +192,35 @@ public interface Block { * Gets the status of this block. * The meaning of a specific number can vary. * For detailed information see the javadocs of the respective hook. - * + * * @return status */ public byte getStatus(); /** * Checks if the block is air - * + * * @return {@code true} if air; {@code false} otherwise */ public boolean isAir(); /** * Gets the {@link BlockMaterial} this Block is made of - * + * * @return the {@link BlockMaterial} */ public BlockMaterial getBlockMaterial(); /** * Gets the Id of the Block as it would be dropped as an {@link Item} - * + * * @return the id */ public int getIdDropped(); /** * Gets the damage of the Block as it would be dropped as an {@link Item} - * + * * @return the damage */ public int getDamageDropped(); @@ -227,22 +228,22 @@ public interface Block { /** * Gets the amount that would be dropped when the Block is harvested.
* NOTE: Some blocks are random on the amount so returns may differ for those each call - * + * * @return the quantity that would be dropped */ public int getQuantityDropped(); /** * Drops the Block into the world as an {@link EntityItem} - * + * * @param remove - * {@code true} to replace the block with air; {@code false} to leave the block as is + * {@code true} to replace the block with air; {@code false} to leave the block as is */ public void dropBlockAsItem(boolean remove); /** * Gets a {@link TileEntity} at the same location as the Block - * + * * @return {@link TileEntity} at the location or {@code null} if none */ public TileEntity getTileEntity(); @@ -250,10 +251,27 @@ public interface Block { /** * Simulates a right click on the block.
* Useful for forcing changes to blocks like levers, buttons, doors, etc... - * + * * @param player - * the {@link Player} to use with activation. Can be {@code null} + * the {@link Player} to use with activation. Can be {@code null} + * * @return {@code true} if the Block responded; {@code false} if not */ public boolean rightClick(Player player); + + /** + * Sends the update packet to the specified {@link Player}(s) without modifing the world.
+ * Useful for displaying things like borders to a specific player(s) + * + * @param players + * the {@link Player}(s) to send info to + */ + public void sendUpdateToPlayers(Player... players); + + /** + * Gets a {@link BlockChangePacket} of the Block that would be used in an update + * + * @return the {@link BlockChangePacket} of the Block + */ + public BlockChangePacket getBlockPacket(); }