From f20e738f675c02e7bbabaff2ab0de387cb5b766e Mon Sep 17 00:00:00 2001 From: Major- Date: Thu, 5 Dec 2013 16:37:44 +0000 Subject: [PATCH 1/9] Delete drops.rb. --- data/plugins/drops/drops.rb | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 data/plugins/drops/drops.rb diff --git a/data/plugins/drops/drops.rb b/data/plugins/drops/drops.rb deleted file mode 100644 index 34c70ee7..00000000 --- a/data/plugins/drops/drops.rb +++ /dev/null @@ -1,6 +0,0 @@ -require 'java' - -java_import 'org.apollo.game.model.Player' -java_import 'org.apollo.game.event.impl.PositionEvent' -java_import 'org.apollo.game.event.impl.SetTileItemEvent' - From 030242351d64849ff9ef8b48812a71e08a2b868d Mon Sep 17 00:00:00 2001 From: Major- Date: Thu, 5 Dec 2013 16:40:37 +0000 Subject: [PATCH 2/9] Remove release command. --- data/plugins/hello/hello.rb | 6 ------ 1 file changed, 6 deletions(-) diff --git a/data/plugins/hello/hello.rb b/data/plugins/hello/hello.rb index d1c89716..c595ebff 100644 --- a/data/plugins/hello/hello.rb +++ b/data/plugins/hello/hello.rb @@ -2,13 +2,7 @@ require 'java' java_import 'org.apollo.game.model.Animation' java_import 'org.apollo.game.model.World' -SERVER_RELEASE = World.world.release_number - on :command, :hello do |player, command| player.play_animation Animation::WAVE player.send_message("Hello, World!") end - -on :command, :release do |player, command| - player.send_message("This server is currently running the #{SERVER_RELEASE} release.") -end \ No newline at end of file From 3d53188ccf601a6eb97097f7d894d7f280eaded5 Mon Sep 17 00:00:00 2001 From: Major- Date: Thu, 5 Dec 2013 16:41:26 +0000 Subject: [PATCH 3/9] Delete empty dialogue. --- data/plugins/dialogue/dialogue.rb | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 data/plugins/dialogue/dialogue.rb diff --git a/data/plugins/dialogue/dialogue.rb b/data/plugins/dialogue/dialogue.rb deleted file mode 100644 index b917ede9..00000000 --- a/data/plugins/dialogue/dialogue.rb +++ /dev/null @@ -1,5 +0,0 @@ - - -def dialogue(name, &block) - -end \ No newline at end of file From c231a5abf52fb868648a15675c00834748e4203c Mon Sep 17 00:00:00 2001 From: Major- Date: Thu, 5 Dec 2013 16:41:46 +0000 Subject: [PATCH 4/9] Delete test.rb. --- data/plugins/testing/test.rb | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 data/plugins/testing/test.rb diff --git a/data/plugins/testing/test.rb b/data/plugins/testing/test.rb deleted file mode 100644 index ddc705fc..00000000 --- a/data/plugins/testing/test.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'java' - -java_import 'org.apollo.game.model.Player' -java_import 'org.apollo.game.sync.block.SynchronizationBlock' - -on :command, :headicon, RIGHTS_ADMIN do |player, command| - args = command.arguments - unless (args.length == 1) - player.send_message("Usage - ::headicon [id]") - break - end - - player.head_icon = args[0].to_i - player.send_message("Adding headicon") - player.block_set.add SynchronizationBlock.create_appearance_block(player) -end - -on :command, :prayicon, RIGHTS_ADMIN do |player, command| - args = command.arguments - unless (args.length == 1) - player.send_message("Usage - ::prayicon [id]") - break - end - - player.prayer_icon = args[0].to_i - player.send_message("Adding prayicon") - player.block_set.add SynchronizationBlock.create_appearance_block(player) -end \ No newline at end of file From 6e4372ba56680f43c2402618bb30047e708b3498 Mon Sep 17 00:00:00 2001 From: Major- Date: Sun, 8 Dec 2013 20:48:47 +0000 Subject: [PATCH 5/9] Update CameraMovementEvent.java. --- src/org/apollo/game/event/impl/CameraMovementEvent.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/org/apollo/game/event/impl/CameraMovementEvent.java b/src/org/apollo/game/event/impl/CameraMovementEvent.java index 4f21631b..01daca8c 100644 --- a/src/org/apollo/game/event/impl/CameraMovementEvent.java +++ b/src/org/apollo/game/event/impl/CameraMovementEvent.java @@ -5,7 +5,7 @@ import org.apollo.game.event.Event; /** * An event sent when the user moves the camera. * - * @author Toby + * @author Major */ public class CameraMovementEvent extends Event { @@ -48,4 +48,4 @@ public class CameraMovementEvent extends Event { return cameraY; } -} \ No newline at end of file +} From 0306fd4230aec5750d96a323d39a4d0d004f49dc Mon Sep 17 00:00:00 2001 From: Kyle Stevenson Date: Sun, 29 Dec 2013 15:17:34 -0800 Subject: [PATCH 6/9] Add privacy options support. --- data/events.xml | 6 + .../impl/PrivacyOptionEventHandler.java | 22 +++ .../game/event/impl/PrivacyOptionEvent.java | 98 ++++++++++++++ src/org/apollo/game/model/Player.java | 128 ++++++++++++++++++ .../io/player/impl/BinaryPlayerLoader.java | 8 ++ .../io/player/impl/BinaryPlayerSaver.java | 5 + .../r317/PrivacyOptionEventDecoder.java | 27 ++++ .../r317/PrivacyOptionEventEncoder.java | 28 ++++ .../apollo/net/release/r317/Release317.java | 4 + 9 files changed, 326 insertions(+) create mode 100644 src/org/apollo/game/event/handler/impl/PrivacyOptionEventHandler.java create mode 100644 src/org/apollo/game/event/impl/PrivacyOptionEvent.java create mode 100644 src/org/apollo/net/release/r317/PrivacyOptionEventDecoder.java create mode 100644 src/org/apollo/net/release/r317/PrivacyOptionEventEncoder.java diff --git a/data/events.xml b/data/events.xml index f539d808..742f42d4 100644 --- a/data/events.xml +++ b/data/events.xml @@ -1,4 +1,10 @@ + + org.apollo.game.event.impl.PrivacyOptionEvent + + org.apollo.game.event.handler.impl.PrivacyOptionEventHandler + + org.apollo.game.event.impl.KeepAliveEvent diff --git a/src/org/apollo/game/event/handler/impl/PrivacyOptionEventHandler.java b/src/org/apollo/game/event/handler/impl/PrivacyOptionEventHandler.java new file mode 100644 index 00000000..7630f8e1 --- /dev/null +++ b/src/org/apollo/game/event/handler/impl/PrivacyOptionEventHandler.java @@ -0,0 +1,22 @@ +package org.apollo.game.event.handler.impl; + +import org.apollo.game.event.handler.EventHandler; +import org.apollo.game.event.handler.EventHandlerContext; +import org.apollo.game.event.impl.PrivacyOptionEvent; +import org.apollo.game.model.Player; + +/** + * Handles {@link PrivacyOptionEvent} from the client to the server. + * + * @author Kyle Stevenson + * Date: 12/24/13 + * Time: 2:03 AM + */ +public class PrivacyOptionEventHandler extends EventHandler { + @Override + public void handle(final EventHandlerContext ctx, final Player player, final PrivacyOptionEvent event) { + player.setPrivacyPublicChat(event.getPrivacyPublicChat()); + player.setPrivacyPrivateChat(event.getPrivacyPrivateChat()); + player.setPrivacyTradeCompete(event.getPrivacyTradeCompete()); + } +} diff --git a/src/org/apollo/game/event/impl/PrivacyOptionEvent.java b/src/org/apollo/game/event/impl/PrivacyOptionEvent.java new file mode 100644 index 00000000..eafdb2ab --- /dev/null +++ b/src/org/apollo/game/event/impl/PrivacyOptionEvent.java @@ -0,0 +1,98 @@ +package org.apollo.game.event.impl; + +import org.apollo.game.event.Event; +import org.apollo.game.model.Player; + +/** + * An {@link Event} sent by the client or server to specify the options at the bottom of the game screen relating + * to the chat and trade privacy options. + *
+ * See http://rswiki.moparisthebest.com/index.php?title=317:Privacy_options + * + * @author Kyle Stevenson + * Date: 12/24/13 + * Time: 1:38 AM + */ +public class PrivacyOptionEvent extends Event { + /** + * Public chat setting + */ + private final int publicChat; + + /** + * Private chat setting + */ + private final int privateChat; + + /** + * Trade/compete setting + */ + private final int tradeCompete; + + /** + * Creates a privacy option event. + * + * @param publicChat The byte value of the public chat privacy option. + * @param privateChat The byte value of the private chat privacy option. + * @param tradeCompete The byte value of the trade/compete privacy option. + */ + public PrivacyOptionEvent(final int publicChat, final int privateChat, final int tradeCompete) { + this.publicChat = publicChat & 0xFF; + this.privateChat = privateChat & 0xFF; + this.tradeCompete = tradeCompete & 0xFF; + } + + /** + * Public chat unsigned byte value. + * + * @return The public chat unsigned byte. + */ + public int getPublicChat() { + return publicChat; + } + + /** + * Public chat privacy option. + * + * @return The public chat privacy option. + */ + public Player.PrivacyOption getPrivacyPublicChat() { + return Player.PrivacyOption.valueOf(publicChat); + } + + /** + * Private chat unsigned byte value. + * + * @return The private chat unsigned byte. + */ + public int getPrivateChat() { + return privateChat; + } + + /** + * Private chat privacy option. + * + * @return The private chat privacy option. + */ + public Player.PrivacyOption getPrivacyPrivateChat() { + return Player.PrivacyOption.valueOf(privateChat); + } + + /** + * Trade/compete unsigned byte value. + * + * @return The trade/compete unsigned byte. + */ + public int getTradeCompete() { + return tradeCompete; + } + + /** + * Trade/compete privacy option. + * + * @return The trade/compete privacy option. + */ + public Player.PrivacyOption getPrivacyTradeCompete() { + return Player.PrivacyOption.valueOf(tradeCompete); + } +} diff --git a/src/org/apollo/game/model/Player.java b/src/org/apollo/game/model/Player.java index 5c8bf896..949e6026 100644 --- a/src/org/apollo/game/model/Player.java +++ b/src/org/apollo/game/model/Player.java @@ -98,6 +98,80 @@ public final class Player extends Mob { } + /** + * An enumeration representing the different states for chat and trade options in the protocol. + * + * @author Kyle Stevenson + */ + public enum PrivacyOption { + + /** + * Represents the on-state which displays all messages. + */ + ON(0), + + /** + * Represents the friends-state which only displays messages from friends and staff members. + */ + FRIENDS(1), + + /** + * Represents the off-state which displays no messages except those of moderators and staff members. + */ + OFF(2), + + /** + * Represents the hidden-state which displays text over player's heads but not in the chat box. + * This only applies to the "public" option. + */ + HIDE(3); + + /** + * Gets the privacy option for the specified numerical value. + * + * @param numericalValue The numerical level. + * @return The privilege level. + * @throws IllegalArgumentException If the numerical level is invalid. + */ + public static PrivacyOption valueOf(final int numericalValue) { + for (final PrivacyOption option : values()) { + if (option.numericalOption == numericalValue) { + return option; + } + } + throw new IllegalArgumentException("invalid numerical level"); + } + + /** + * The numerical level used in the protocol. + */ + private final int numericalOption; + + /** + * Creates a privacy option. + * + * @param numericalValue The numerical value. + */ + private PrivacyOption(final int numericalValue) { + this.numericalOption = numericalValue; + } + + /** + * Gets the numerical option. + * + * @return The numerical option used in the protocol. + */ + public int toInteger() { + return numericalOption; + } + } + + private PrivacyOption privacyPublicChat = PrivacyOption.ON; + + private PrivacyOption privacyPrivateChat = PrivacyOption.ON; + + private PrivacyOption privacyTradeCompete = PrivacyOption.ON; + /** * The player's appearance. */ @@ -347,6 +421,33 @@ public final class Player extends Mob { return prayerIcon; } + /** + * Gets the privacy option of private chat. + * + * @return The privacy option. + */ + public PrivacyOption getPrivacyPrivateChat() { + return privacyPrivateChat; + } + + /** + * Gets the privacy option of public chat. + * + * @return The privacy option. + */ + public PrivacyOption getPrivacyPublicChat() { + return privacyPublicChat; + } + + /** + * Gets the privacy option of trade/compete. + * + * @return The privacy option. + */ + public PrivacyOption getPrivacyTradeCompete() { + return privacyTradeCompete; + } + /** * Gets the privilege level. * @@ -665,6 +766,33 @@ public final class Player extends Mob { this.prayerIcon = prayerIcon; } + /** + * Sets the privacy option for private chat. + * + * @param privacyPrivateChat The privacy option. + */ + public void setPrivacyPrivateChat(final PrivacyOption privacyPrivateChat) { + this.privacyPrivateChat = privacyPrivateChat; + } + + /** + * Sets the privacy option for public chat. + * + * @param privacyPublicChat The privacy option. + */ + public void setPrivacyPublicChat(final PrivacyOption privacyPublicChat) { + this.privacyPublicChat = privacyPublicChat; + } + + /** + * Sets the privacy option for trade/compete. + * + * @param privacyTradeCompete The privacy option. + */ + public void setPrivacyTradeCompete(final PrivacyOption privacyTradeCompete) { + this.privacyTradeCompete = privacyTradeCompete; + } + /** * Sets the privilege level. * diff --git a/src/org/apollo/io/player/impl/BinaryPlayerLoader.java b/src/org/apollo/io/player/impl/BinaryPlayerLoader.java index 8fdd4a9d..599160b8 100644 --- a/src/org/apollo/io/player/impl/BinaryPlayerLoader.java +++ b/src/org/apollo/io/player/impl/BinaryPlayerLoader.java @@ -53,6 +53,11 @@ public final class BinaryPlayerLoader implements PlayerLoader { PrivilegeLevel privilegeLevel = PrivilegeLevel.valueOf(in.readByte()); boolean members = in.readBoolean(); + // read settings + Player.PrivacyOption privacyPublicChat = Player.PrivacyOption.valueOf(in.readByte()); + Player.PrivacyOption privacyPrivateChat = Player.PrivacyOption.valueOf(in.readByte()); + Player.PrivacyOption privacyTradeCompete = Player.PrivacyOption.valueOf(in.readByte()); + // read position int x = in.readUnsignedShort(); int y = in.readUnsignedShort(); @@ -75,6 +80,9 @@ public final class BinaryPlayerLoader implements PlayerLoader { Player player = new Player(credentials, new Position(x, y, height)); player.setPrivilegeLevel(privilegeLevel); player.setMembers(members); + player.setPrivacyPublicChat(privacyPublicChat); + player.setPrivacyPrivateChat(privacyPrivateChat); + player.setPrivacyTradeCompete(privacyTradeCompete); player.setDesigned(designed); player.setAppearance(new Appearance(gender, style, colors)); diff --git a/src/org/apollo/io/player/impl/BinaryPlayerSaver.java b/src/org/apollo/io/player/impl/BinaryPlayerSaver.java index 05420ca6..9182b667 100644 --- a/src/org/apollo/io/player/impl/BinaryPlayerSaver.java +++ b/src/org/apollo/io/player/impl/BinaryPlayerSaver.java @@ -33,6 +33,11 @@ public final class BinaryPlayerSaver implements PlayerSaver { out.writeByte(player.getPrivilegeLevel().toInteger()); out.writeBoolean(player.isMembers()); + // write settings + out.writeByte(player.getPrivacyPublicChat().toInteger()); + out.writeByte(player.getPrivacyPrivateChat().toInteger()); + out.writeByte(player.getPrivacyTradeCompete().toInteger()); + // write position Position position = player.getPosition(); out.writeShort(position.getX()); diff --git a/src/org/apollo/net/release/r317/PrivacyOptionEventDecoder.java b/src/org/apollo/net/release/r317/PrivacyOptionEventDecoder.java new file mode 100644 index 00000000..4f70275e --- /dev/null +++ b/src/org/apollo/net/release/r317/PrivacyOptionEventDecoder.java @@ -0,0 +1,27 @@ +package org.apollo.net.release.r317; + +import org.apollo.game.event.impl.PrivacyOptionEvent; +import org.apollo.net.codec.game.DataType; +import org.apollo.net.codec.game.GamePacket; +import org.apollo.net.codec.game.GamePacketReader; +import org.apollo.net.release.EventDecoder; + +/** + * An {@link EventDecoder} for the {@link PrivacyOptionEvent}. + * + * @author Kyle Stevenson + * Date: 12/24/13 + * Time: 1:44 AM + */ +public class PrivacyOptionEventDecoder extends EventDecoder { + @Override + public PrivacyOptionEvent decode(final GamePacket packet) { + final GamePacketReader reader = new GamePacketReader(packet); + + final int publicChat = (int) reader.getUnsigned(DataType.BYTE); + final int privateChat = (int) reader.getUnsigned(DataType.BYTE); + final int tradeCompete = (int) reader.getUnsigned(DataType.BYTE); + + return new PrivacyOptionEvent(publicChat, privateChat, tradeCompete); + } +} diff --git a/src/org/apollo/net/release/r317/PrivacyOptionEventEncoder.java b/src/org/apollo/net/release/r317/PrivacyOptionEventEncoder.java new file mode 100644 index 00000000..9f75f321 --- /dev/null +++ b/src/org/apollo/net/release/r317/PrivacyOptionEventEncoder.java @@ -0,0 +1,28 @@ +package org.apollo.net.release.r317; + +import org.apollo.game.event.impl.PrivacyOptionEvent; +import org.apollo.net.codec.game.DataType; +import org.apollo.net.codec.game.GamePacket; +import org.apollo.net.codec.game.GamePacketBuilder; +import org.apollo.net.meta.PacketType; +import org.apollo.net.release.EventEncoder; + +/** + * An {@link org.apollo.net.release.EventEncoder} for the {@link PrivacyOptionEvent}. + * + * @author Kyle Stevenson + * Date: 12/24/13 + * Time: 1:44 AM + */ +public class PrivacyOptionEventEncoder extends EventEncoder { + @Override + public GamePacket encode(final PrivacyOptionEvent event) { + final GamePacketBuilder builder = new GamePacketBuilder(206, PacketType.FIXED); + + builder.put(DataType.BYTE, event.getPublicChat()); + builder.put(DataType.BYTE, event.getPrivateChat()); + builder.put(DataType.BYTE, event.getTradeCompete()); + + return builder.toGamePacket(); + } +} diff --git a/src/org/apollo/net/release/r317/Release317.java b/src/org/apollo/net/release/r317/Release317.java index 9a903a67..90e0ca0a 100644 --- a/src/org/apollo/net/release/r317/Release317.java +++ b/src/org/apollo/net/release/r317/Release317.java @@ -11,6 +11,7 @@ import org.apollo.game.event.impl.OpenInterfaceEvent; import org.apollo.game.event.impl.OpenInterfaceSidebarEvent; import org.apollo.game.event.impl.PlayerSynchronizationEvent; import org.apollo.game.event.impl.PositionEvent; +import org.apollo.game.event.impl.PrivacyOptionEvent; import org.apollo.game.event.impl.RegionChangeEvent; import org.apollo.game.event.impl.ServerMessageEvent; import org.apollo.game.event.impl.SetTileItemEvent; @@ -116,6 +117,8 @@ public final class Release317 extends Release { register(241, new MouseClickEventDecoder()); register(86, new ArrowKeyEventDecoder()); + register(95, new PrivacyOptionEventDecoder()); + SpamPacketEventDecoder spamEventDecoder = new SpamPacketEventDecoder(); register(77, spamEventDecoder); register(78, spamEventDecoder); @@ -154,6 +157,7 @@ public final class Release317 extends Release { register(SetTileItemEvent.class, new SetTileItemEventEncoder()); register(PositionEvent.class, new PositionEventEncoder()); register(UpdateRunEnergyEvent.class, new UpdateRunEnergyEventEncoder()); + register(PrivacyOptionEvent.class, new PrivacyOptionEventEncoder()); } } \ No newline at end of file From 3b05c681c3c1bb22f12ac5858df7282af1725797 Mon Sep 17 00:00:00 2001 From: Kyle Stevenson Date: Sun, 29 Dec 2013 15:20:38 -0800 Subject: [PATCH 7/9] Add maven support. --- .gitignore | 1 + pom.xml | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 .gitignore create mode 100644 pom.xml diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..e420ee4b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target/* diff --git a/pom.xml b/pom.xml new file mode 100644 index 00000000..22a1daf2 --- /dev/null +++ b/pom.xml @@ -0,0 +1,37 @@ + + 4.0.0 + apollo + 1.0 + apollo-rsps + + + org.apache.commons + commons-compress + 1.1 + + + org.jruby + jruby-complete + 1.7.9 + + + com.google.collections + google-collections + 1.0 + + + io.netty + netty + 3.3.0.Final + compile + + + junit + junit + 4.11 + + + \ No newline at end of file From d9dc0ef09a5738796fd7af1581e0d289be3e28f4 Mon Sep 17 00:00:00 2001 From: Kyle Stevenson Date: Sun, 29 Dec 2013 15:21:15 -0800 Subject: [PATCH 8/9] Add IntelliJ project files to gitignore. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index e420ee4b..21a5676c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ target/* +.idea/* +*.iml From dafd0368d07f423cf305d9a62d7065b30691da9f Mon Sep 17 00:00:00 2001 From: Kyle Stevenson Date: Sun, 29 Dec 2013 15:22:11 -0800 Subject: [PATCH 9/9] Ignore data/savedGames and data/fs. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 21a5676c..f5f7ab5e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ target/* .idea/* *.iml +data/fs/* +data/savedGames/*