mirror of
https://github.com/dmulloy2/ProtocolLib.git
synced 2024-11-24 11:36:51 +01:00
Fixed a number of minor bugs.
This commit is contained in:
parent
023c3908ae
commit
95dbddf9bb
@ -99,8 +99,8 @@ public class AsyncMarker implements Serializable, Comparable<AsyncMarker> {
|
|||||||
private transient int workerID;
|
private transient int workerID;
|
||||||
|
|
||||||
// Determine if Minecraft processes this packet asynchronously
|
// Determine if Minecraft processes this packet asynchronously
|
||||||
private static Method isMinecraftAsync;
|
private volatile static Method isMinecraftAsync;
|
||||||
private static boolean alwaysSync;
|
private volatile static boolean alwaysSync;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a container for asyncronous packets.
|
* Create a container for asyncronous packets.
|
||||||
|
@ -121,6 +121,8 @@ public class DetailedErrorReporter implements ErrorReporter {
|
|||||||
@Override
|
@Override
|
||||||
public void reportDetailed(Object sender, String message, Throwable error, Object... parameters) {
|
public void reportDetailed(Object sender, String message, Throwable error, Object... parameters) {
|
||||||
|
|
||||||
|
final Plugin plugin = pluginReference.get();
|
||||||
|
|
||||||
// Do not overtly spam the server!
|
// Do not overtly spam the server!
|
||||||
if (++errorCount > maxErrorCount) {
|
if (++errorCount > maxErrorCount) {
|
||||||
String maxReached = String.format("Reached maxmimum error count. Cannot pass error %s from %s.", error, sender);
|
String maxReached = String.format("Reached maxmimum error count. Cannot pass error %s from %s.", error, sender);
|
||||||
@ -167,8 +169,7 @@ public class DetailedErrorReporter implements ErrorReporter {
|
|||||||
writer.println(addPrefix(getStringDescription(sender), SECOND_LEVEL_PREFIX));
|
writer.println(addPrefix(getStringDescription(sender), SECOND_LEVEL_PREFIX));
|
||||||
|
|
||||||
// And plugin
|
// And plugin
|
||||||
if (pluginReference.get() != null) {
|
if (plugin != null) {
|
||||||
Plugin plugin = pluginReference.get();
|
|
||||||
writer.println("Version:");
|
writer.println("Version:");
|
||||||
writer.println(addPrefix(plugin.toString(), SECOND_LEVEL_PREFIX));
|
writer.println(addPrefix(plugin.toString(), SECOND_LEVEL_PREFIX));
|
||||||
}
|
}
|
||||||
|
@ -53,8 +53,8 @@ public class NetworkServerInjector extends PlayerInjector {
|
|||||||
|
|
||||||
private volatile static CallbackFilter callbackFilter;
|
private volatile static CallbackFilter callbackFilter;
|
||||||
|
|
||||||
private static Field disconnectField;
|
private volatile static Field disconnectField;
|
||||||
private static Method sendPacketMethod;
|
private volatile static Method sendPacketMethod;
|
||||||
private InjectedServerConnection serverInjection;
|
private InjectedServerConnection serverInjection;
|
||||||
|
|
||||||
// Determine if we're listening
|
// Determine if we're listening
|
||||||
|
@ -604,10 +604,11 @@ public class PlayerInjectionHandler {
|
|||||||
*/
|
*/
|
||||||
public void scheduleDataInputRefresh(Player player) {
|
public void scheduleDataInputRefresh(Player player) {
|
||||||
final PlayerInjector injector = getInjector(player);
|
final PlayerInjector injector = getInjector(player);
|
||||||
final DataInputStream old = injector.getInputStream(true);
|
|
||||||
|
|
||||||
// Update the DataInputStream
|
// Update the DataInputStream
|
||||||
if (injector != null) {
|
if (injector != null) {
|
||||||
|
final DataInputStream old = injector.getInputStream(true);
|
||||||
|
|
||||||
injector.scheduleAction(new Runnable() {
|
injector.scheduleAction(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -202,7 +202,7 @@ public class StructureModifier<TField> {
|
|||||||
*/
|
*/
|
||||||
public boolean isReadOnly(int fieldIndex) {
|
public boolean isReadOnly(int fieldIndex) {
|
||||||
if (fieldIndex < 0 || fieldIndex >= data.size())
|
if (fieldIndex < 0 || fieldIndex >= data.size())
|
||||||
new IllegalArgumentException("Index parameter is not within [0 - " + data.size() + ")");
|
throw new IllegalArgumentException("Index parameter is not within [0 - " + data.size() + ")");
|
||||||
|
|
||||||
return Modifier.isFinal(data.get(fieldIndex).getModifiers());
|
return Modifier.isFinal(data.get(fieldIndex).getModifiers());
|
||||||
}
|
}
|
||||||
@ -219,7 +219,7 @@ public class StructureModifier<TField> {
|
|||||||
*/
|
*/
|
||||||
public void setReadOnly(int fieldIndex, boolean value) throws FieldAccessException {
|
public void setReadOnly(int fieldIndex, boolean value) throws FieldAccessException {
|
||||||
if (fieldIndex < 0 || fieldIndex >= data.size())
|
if (fieldIndex < 0 || fieldIndex >= data.size())
|
||||||
new IllegalArgumentException("Index parameter is not within [0 - " + data.size() + ")");
|
throw new IllegalArgumentException("Index parameter is not within [0 - " + data.size() + ")");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
StructureModifier.setFinalState(data.get(fieldIndex), value);
|
StructureModifier.setFinalState(data.get(fieldIndex), value);
|
||||||
|
@ -193,10 +193,11 @@ public class BukkitConverters {
|
|||||||
public Entity getSpecific(Object generic) {
|
public Entity getSpecific(Object generic) {
|
||||||
try {
|
try {
|
||||||
Integer id = (Integer) generic;
|
Integer id = (Integer) generic;
|
||||||
|
ProtocolManager manager = managerRef.get();
|
||||||
|
|
||||||
// Use the
|
// Use the
|
||||||
if (id != null && managerRef.get() != null) {
|
if (id != null && manager != null) {
|
||||||
return managerRef.get().getEntityFromID(container, id);
|
return manager.getEntityFromID(container, id);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import java.util.HashSet;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReadWriteLock;
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ public class WrappedDataWatcher {
|
|||||||
private static Method getKeyValueMethod;
|
private static Method getKeyValueMethod;
|
||||||
|
|
||||||
// Entity methods
|
// Entity methods
|
||||||
private static Field entityDataField;
|
private volatile static Field entityDataField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether or not this class has already been initialized.
|
* Whether or not this class has already been initialized.
|
||||||
@ -275,12 +276,13 @@ public class WrappedDataWatcher {
|
|||||||
* @throws FieldAccessException If we're unable to read the underlying object.
|
* @throws FieldAccessException If we're unable to read the underlying object.
|
||||||
*/
|
*/
|
||||||
public Set<Integer> indexSet() throws FieldAccessException {
|
public Set<Integer> indexSet() throws FieldAccessException {
|
||||||
try {
|
Lock readLock = getReadWriteLock().readLock();
|
||||||
getReadWriteLock().readLock().lock();
|
readLock.lock();
|
||||||
return new HashSet<Integer>(getWatchableObjectMap().keySet());
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
return new HashSet<Integer>(getWatchableObjectMap().keySet());
|
||||||
} finally {
|
} finally {
|
||||||
getReadWriteLock().readLock().unlock();
|
readLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,12 +292,13 @@ public class WrappedDataWatcher {
|
|||||||
* @throws FieldAccessException If we're unable to read the underlying object.
|
* @throws FieldAccessException If we're unable to read the underlying object.
|
||||||
*/
|
*/
|
||||||
public int size() throws FieldAccessException {
|
public int size() throws FieldAccessException {
|
||||||
try {
|
Lock readLock = getReadWriteLock().readLock();
|
||||||
getReadWriteLock().readLock().lock();
|
readLock.lock();
|
||||||
return getWatchableObjectMap().size();
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
return getWatchableObjectMap().size();
|
||||||
} finally {
|
} finally {
|
||||||
getReadWriteLock().readLock().unlock();
|
readLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,18 +340,18 @@ public class WrappedDataWatcher {
|
|||||||
* @throws FieldAccessException Cannot read underlying field.
|
* @throws FieldAccessException Cannot read underlying field.
|
||||||
*/
|
*/
|
||||||
private void setObjectRaw(int index, Object newValue, boolean update) throws FieldAccessException {
|
private void setObjectRaw(int index, Object newValue, boolean update) throws FieldAccessException {
|
||||||
WatchableObject watchable;
|
// Aquire write lock
|
||||||
|
Lock writeLock = getReadWriteLock().writeLock();
|
||||||
|
writeLock.lock();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Aquire write lock
|
WatchableObject watchable = getWatchedObject(index);
|
||||||
getReadWriteLock().writeLock().lock();
|
|
||||||
watchable = getWatchedObject(index);
|
|
||||||
|
|
||||||
if (watchable != null) {
|
if (watchable != null) {
|
||||||
new WrappedWatchableObject(watchable).setValue(newValue, update);
|
new WrappedWatchableObject(watchable).setValue(newValue, update);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
getReadWriteLock().writeLock().unlock();
|
writeLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user