mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 16:49:12 +00:00
Add support for edited clients; Properly support chat filtering; Fix issue #11; Make certain Mining messages filterable.
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
require 'java'
|
||||||
|
|
||||||
|
java_import 'org.apollo.game.event.impl.ForwardPrivateMessageEvent'
|
||||||
|
java_import 'org.apollo.game.model.World'
|
||||||
|
java_import 'org.apollo.game.model.settings.PrivacyState'
|
||||||
|
|
||||||
|
on :command, :filter do |player, command|
|
||||||
|
player.send_message('Your message filter is now ' + (player.toggle_message_filter ? 'enabled.' : 'disabled.'))
|
||||||
|
end
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<plugin>
|
||||||
|
<id>message-filter</id>
|
||||||
|
<version>1</version>
|
||||||
|
<name>Message Filter</name>
|
||||||
|
<description>Adds support for a server-side message filter, for clients that have not been edited.</description>
|
||||||
|
<authors>
|
||||||
|
<author>Major</author>
|
||||||
|
</authors>
|
||||||
|
<scripts>
|
||||||
|
<script>filter.rb</script>
|
||||||
|
</scripts>
|
||||||
|
<dependencies />
|
||||||
|
</plugin>
|
||||||
@@ -38,7 +38,7 @@ class MiningAction < DistancedAction
|
|||||||
# the ore
|
# the ore
|
||||||
def start_mine(pickaxe)
|
def start_mine(pickaxe)
|
||||||
@started = true
|
@started = true
|
||||||
mob.send_message "You swing your pick at the rock."
|
mob.send_message("You swing your pick at the rock.", true)
|
||||||
mob.turn_to @position
|
mob.turn_to @position
|
||||||
mob.play_animation pickaxe.animation
|
mob.play_animation pickaxe.animation
|
||||||
@counter = pickaxe.pulses
|
@counter = pickaxe.pulses
|
||||||
@@ -51,14 +51,14 @@ class MiningAction < DistancedAction
|
|||||||
|
|
||||||
# verify the mob can mine with their pickaxe
|
# verify the mob can mine with their pickaxe
|
||||||
if not (pickaxe != nil and level >= pickaxe.level)
|
if not (pickaxe != nil and level >= pickaxe.level)
|
||||||
mob.send_message "You do not have a pickaxe for which you have the level to use."
|
mob.send_message('You do not have a pickaxe for which you have the level to use.')
|
||||||
stop
|
stop
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
# verify the mob can mine the ore
|
# verify the mob can mine the ore
|
||||||
if ore.level > level
|
if ore.level > level
|
||||||
mob.send_message "You do not have the required level to mine this rock."
|
mob.send_message('You do not have the required level to mine this rock.')
|
||||||
stop
|
stop
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -66,6 +66,12 @@ public final class Player extends Mob {
|
|||||||
*/
|
*/
|
||||||
private transient Deque<Point> clicks = new ArrayDeque<Point>();
|
private transient Deque<Point> clicks = new ArrayDeque<Point>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The version of the client this player is using. This is not the same as the release number, instead denoting the
|
||||||
|
* custom version.
|
||||||
|
*/
|
||||||
|
private transient int clientVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This player's credentials.
|
* This player's credentials.
|
||||||
*/
|
*/
|
||||||
@@ -181,6 +187,11 @@ public final class Player extends Mob {
|
|||||||
*/
|
*/
|
||||||
private transient int worldId = 1;
|
private transient int worldId = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether this player has the message filter enabled.
|
||||||
|
*/
|
||||||
|
private boolean filteringMessages = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the {@link Player}.
|
* Creates the {@link Player}.
|
||||||
*
|
*
|
||||||
@@ -290,6 +301,15 @@ public final class Player extends Mob {
|
|||||||
return clicks;
|
return clicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value denoting the clients modified version (0 if it is an unmodified jagex client).
|
||||||
|
*
|
||||||
|
* @return The version.
|
||||||
|
*/
|
||||||
|
public int getClientVersion() {
|
||||||
|
return clientVersion;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the player's credentials.
|
* Gets the player's credentials.
|
||||||
*
|
*
|
||||||
@@ -689,7 +709,7 @@ public final class Player extends Mob {
|
|||||||
* @param message The message.
|
* @param message The message.
|
||||||
*/
|
*/
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
send(new ServerMessageEvent(message));
|
sendMessage(message, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -698,7 +718,11 @@ public final class Player extends Mob {
|
|||||||
* @param message The message.
|
* @param message The message.
|
||||||
*/
|
*/
|
||||||
public void sendMessage(String message, boolean filterable) {
|
public void sendMessage(String message, boolean filterable) {
|
||||||
|
if (clientVersion > 0) {
|
||||||
send(new ServerMessageEvent(message, filterable));
|
send(new ServerMessageEvent(message, filterable));
|
||||||
|
} else if (!filterable || !filteringMessages) {
|
||||||
|
send(new ServerMessageEvent(message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -752,6 +776,15 @@ public final class Player extends Mob {
|
|||||||
this.chatPrivacy = chatPrivacy;
|
this.chatPrivacy = chatPrivacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value denoting the client's modified version.
|
||||||
|
*
|
||||||
|
* @param clientVersion The client version.
|
||||||
|
*/
|
||||||
|
public void setClientVersion(int clientVersion) {
|
||||||
|
this.clientVersion = clientVersion;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the design flag.
|
* Sets the design flag.
|
||||||
*
|
*
|
||||||
@@ -906,6 +939,24 @@ public final class Player extends Mob {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggles the message filter.
|
||||||
|
*
|
||||||
|
* @return The new value of the filter.
|
||||||
|
*/
|
||||||
|
public boolean toggleMessageFilter() {
|
||||||
|
return filteringMessages = !filteringMessages;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the message filter is enabled.
|
||||||
|
*
|
||||||
|
* @return {@code true} if the filter is enabled, otherwise {@code false}.
|
||||||
|
*/
|
||||||
|
public boolean messageFilterEnabled() {
|
||||||
|
return filteringMessages;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Toggles whether the player is running or not.
|
* Toggles whether the player is running or not.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -135,9 +135,7 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
|
|||||||
private void decodePayload(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
|
private void decodePayload(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
|
||||||
if (buffer.readableBytes() >= loginLength) {
|
if (buffer.readableBytes() >= loginLength) {
|
||||||
ByteBuf payload = buffer.readBytes(loginLength);
|
ByteBuf payload = buffer.readBytes(loginLength);
|
||||||
if (payload.readUnsignedByte() != 0xFF) {
|
int clientVersion = 255 - payload.readUnsignedByte();
|
||||||
throw new Exception("Invalid magic id.");
|
|
||||||
}
|
|
||||||
|
|
||||||
int releaseNumber = payload.readUnsignedShort();
|
int releaseNumber = payload.readUnsignedShort();
|
||||||
|
|
||||||
@@ -195,13 +193,14 @@ public final class LoginDecoder extends StatefulFrameDecoder<LoginDecoderState>
|
|||||||
for (int i = 0; i < seed.length; i++) {
|
for (int i = 0; i < seed.length; i++) {
|
||||||
seed[i] += 50;
|
seed[i] += 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
IsaacRandom encodingRandom = new IsaacRandom(seed);
|
IsaacRandom encodingRandom = new IsaacRandom(seed);
|
||||||
|
|
||||||
PlayerCredentials credentials = new PlayerCredentials(username, password, usernameHash, uid);
|
PlayerCredentials credentials = new PlayerCredentials(username, password, usernameHash, uid);
|
||||||
IsaacRandomPair randomPair = new IsaacRandomPair(encodingRandom, decodingRandom);
|
IsaacRandomPair randomPair = new IsaacRandomPair(encodingRandom, decodingRandom);
|
||||||
|
|
||||||
LoginRequest request = new LoginRequest(credentials, randomPair, reconnecting, lowMemory, releaseNumber,
|
LoginRequest request = new LoginRequest(credentials, randomPair, reconnecting, lowMemory, releaseNumber,
|
||||||
archiveCrcs);
|
archiveCrcs, clientVersion);
|
||||||
|
|
||||||
out.add(request);
|
out.add(request);
|
||||||
if (buffer.isReadable()) {
|
if (buffer.isReadable()) {
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ public final class LoginRequest {
|
|||||||
*/
|
*/
|
||||||
private final int[] archiveCrcs;
|
private final int[] archiveCrcs;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The version denoting whether the client has been modified or not.
|
||||||
|
*/
|
||||||
|
private final int clientVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The player's credentials.
|
* The player's credentials.
|
||||||
*/
|
*/
|
||||||
@@ -51,13 +56,14 @@ public final class LoginRequest {
|
|||||||
* @param archiveCrcs The archive CRCs.
|
* @param archiveCrcs The archive CRCs.
|
||||||
*/
|
*/
|
||||||
public LoginRequest(PlayerCredentials credentials, IsaacRandomPair randomPair, boolean lowMemory,
|
public LoginRequest(PlayerCredentials credentials, IsaacRandomPair randomPair, boolean lowMemory,
|
||||||
boolean reconnecting, int releaseNumber, int[] archiveCrcs) {
|
boolean reconnecting, int releaseNumber, int[] archiveCrcs, int clientVersion) {
|
||||||
this.credentials = credentials;
|
this.credentials = credentials;
|
||||||
this.randomPair = randomPair;
|
this.randomPair = randomPair;
|
||||||
this.lowMemory = lowMemory;
|
this.lowMemory = lowMemory;
|
||||||
this.reconnecting = reconnecting;
|
this.reconnecting = reconnecting;
|
||||||
this.releaseNumber = releaseNumber;
|
this.releaseNumber = releaseNumber;
|
||||||
this.archiveCrcs = archiveCrcs;
|
this.archiveCrcs = archiveCrcs;
|
||||||
|
this.clientVersion = clientVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -69,6 +75,15 @@ public final class LoginRequest {
|
|||||||
return archiveCrcs;
|
return archiveCrcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value denoting the client's (modified) version.
|
||||||
|
*
|
||||||
|
* @return The client version.
|
||||||
|
*/
|
||||||
|
public int getClientVersion() {
|
||||||
|
return clientVersion;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the player's credentials.
|
* Gets the player's credentials.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user