mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-27 13:15:52 +01:00
Fix documentation.
This commit is contained in:
parent
783281ca2c
commit
45169905fe
@ -24,7 +24,11 @@ import net.minecraft.server.Packet;
|
|||||||
|
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
|
||||||
public class StructureCache {
|
/**
|
||||||
|
* Caches structure modifiers.
|
||||||
|
* @author Kristian
|
||||||
|
*/
|
||||||
|
class StructureCache {
|
||||||
// Structure modifiers
|
// Structure modifiers
|
||||||
private static Map<Integer, StructureModifier<Object>> structureModifiers = new HashMap<Integer, StructureModifier<Object>>();
|
private static Map<Integer, StructureModifier<Object>> structureModifiers = new HashMap<Integer, StructureModifier<Object>>();
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public class StructureModifier<TField> {
|
|||||||
* @param fieldIndex - index of the field.
|
* @param fieldIndex - index of the field.
|
||||||
* @param value - new value of the field.
|
* @param value - new value of the field.
|
||||||
* @return This structure modifier - for chaining.
|
* @return This structure modifier - for chaining.
|
||||||
* @throws IllegalAccessException The field doesn't exist, or it cannot be accessed under the current security contraints.
|
* @throws FieldAccessException The field doesn't exist, or it cannot be accessed under the current security contraints.
|
||||||
*/
|
*/
|
||||||
public StructureModifier<TField> write(int fieldIndex, TField value) throws FieldAccessException {
|
public StructureModifier<TField> write(int fieldIndex, TField value) throws FieldAccessException {
|
||||||
if (fieldIndex < 0 || fieldIndex >= data.size())
|
if (fieldIndex < 0 || fieldIndex >= data.size())
|
||||||
@ -158,7 +158,7 @@ public class StructureModifier<TField> {
|
|||||||
* @param fieldIndex - index of the potential field.
|
* @param fieldIndex - index of the potential field.
|
||||||
* @param value - new value of the field.
|
* @param value - new value of the field.
|
||||||
* @return This structure modifer - for chaining.
|
* @return This structure modifer - for chaining.
|
||||||
* @throws IllegalAccessException The field cannot be accessed under the current security contraints.
|
* @throws FieldAccessException The field cannot be accessed under the current security contraints.
|
||||||
*/
|
*/
|
||||||
public StructureModifier<TField> writeSafely(int fieldIndex, TField value) throws FieldAccessException {
|
public StructureModifier<TField> writeSafely(int fieldIndex, TField value) throws FieldAccessException {
|
||||||
if (fieldIndex >= 0 && fieldIndex < data.size()) {
|
if (fieldIndex >= 0 && fieldIndex < data.size()) {
|
||||||
@ -172,7 +172,7 @@ public class StructureModifier<TField> {
|
|||||||
* @param fieldIndex - index of the field to modify.
|
* @param fieldIndex - index of the field to modify.
|
||||||
* @param select - the function that modifies the field value.
|
* @param select - the function that modifies the field value.
|
||||||
* @return This structure modifier - for chaining.
|
* @return This structure modifier - for chaining.
|
||||||
* @throws IllegalAccessException The field cannot be accessed under the current security contraints.
|
* @throws FieldAccessException The field cannot be accessed under the current security contraints.
|
||||||
*/
|
*/
|
||||||
public StructureModifier<TField> modify(int fieldIndex, Function<TField, TField> select) throws FieldAccessException {
|
public StructureModifier<TField> modify(int fieldIndex, Function<TField, TField> select) throws FieldAccessException {
|
||||||
TField value = read(fieldIndex);
|
TField value = read(fieldIndex);
|
||||||
@ -189,16 +189,20 @@ public class StructureModifier<TField> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets all non-primitive fields to a more fitting default value. See {@link DefaultInstance}.
|
* Sets all non-primitive fields to a more fitting default value. See {@link DefaultInstances#getDefault(Class)}.
|
||||||
* @return The current structure modifier - for chaining.
|
* @return The current structure modifier - for chaining.
|
||||||
* @throws IllegalAccessException If we're unable to write to the fields due to a security limitation.
|
* @throws FieldAccessException If we're unable to write to the fields due to a security limitation.
|
||||||
*/
|
*/
|
||||||
public StructureModifier<TField> writeDefaults() throws IllegalAccessException {
|
public StructureModifier<TField> writeDefaults() throws FieldAccessException {
|
||||||
|
|
||||||
// Write a default instance to every field
|
// Write a default instance to every field
|
||||||
for (Field field : defaultFields) {
|
for (Field field : defaultFields) {
|
||||||
FieldUtils.writeField(field, target,
|
try {
|
||||||
DefaultInstances.getDefault(field.getType()), true);
|
FieldUtils.writeField(field, target,
|
||||||
|
DefaultInstances.getDefault(field.getType()), true);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new FieldAccessException("Cannot write to field due to a security limitation.", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
Loading…
Reference in New Issue
Block a user