mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-07 16:49:12 +00:00
Properly encode StringAttributes.
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package org.apollo.game.model.entity.attr;
|
package org.apollo.game.model.entity.attr;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link Attribute} with a string value.
|
* An {@link Attribute} with a string value.
|
||||||
@@ -30,7 +31,12 @@ public final class StringAttribute extends Attribute<String> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public byte[] encode() {
|
public byte[] encode() {
|
||||||
return value.getBytes(Charset.forName("UTF-8"));
|
byte[] bytes = value.getBytes(Charset.forName("UTF-8"));
|
||||||
|
int length = bytes.length;
|
||||||
|
|
||||||
|
bytes = Arrays.copyOf(bytes, length + 1);
|
||||||
|
bytes[length - 1] = 0;
|
||||||
|
return bytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user