Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-09-06 08:02:50 +02:00
Ursprung
fd1ed63703
Commit
ac73478827
@ -155,11 +155,9 @@ public @interface Confirm {
|
|||||||
actor.setMeta("cmdConfirm", wait);
|
actor.setMeta("cmdConfirm", wait);
|
||||||
try {
|
try {
|
||||||
// This is really dumb but also stops the double //confirm requirement...
|
// This is really dumb but also stops the double //confirm requirement...
|
||||||
Field f = MemoizingValueAccess.class.getDeclaredField("memory");
|
Map<Key<?>, Optional<?>> memory = (Map<Key<?>, Optional<?>>) Reflect.memory.get(context);
|
||||||
f.setAccessible(true);
|
memory.put(Key.of(InterruptableCondition.class), Optional.of(wait));
|
||||||
Map<Key<?>, Optional<?>> memory = (Map<Key<?>, Optional<?>>) f.get(context);
|
} catch (IllegalAccessException e) {
|
||||||
memory.put(Key.of(ReentrantLock.class), Optional.of(lock));
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
// Waits till 15 seconds then returns false unless awakened
|
// Waits till 15 seconds then returns false unless awakened
|
||||||
@ -176,21 +174,25 @@ public @interface Confirm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean checkExisting(InjectedValueAccess context) {
|
boolean checkExisting(InjectedValueAccess context) {
|
||||||
Optional<ReentrantLock> lock = context.injectedValue(Key.of(ReentrantLock.class));
|
Optional<InterruptableCondition> lock = context.injectedValue(Key.of(InterruptableCondition.class));
|
||||||
|
// lock if locked will be held by current thread unless something has gone REALLY wrong
|
||||||
|
// in which case this is the least of our worries...
|
||||||
|
return lock.isPresent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Reflect {
|
||||||
|
static final Field memory;
|
||||||
|
static {
|
||||||
|
Field f;
|
||||||
try {
|
try {
|
||||||
// This is really dumb but also stops the double //confirm requirement...
|
f = MemoizingValueAccess.class.getDeclaredField("memory");
|
||||||
Field f = MemoizingValueAccess.class.getDeclaredField("memory");
|
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
Map<Key<?>, Optional<?>> memory = (Map<Key<?>, Optional<?>>) f.get(context);
|
} catch (NoSuchFieldException e) {
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
f = null;
|
||||||
}
|
}
|
||||||
if (lock.isPresent()) {
|
memory = f;
|
||||||
// lock if locked will be held by current thread unless something has gone REALLY wrong
|
|
||||||
// in which case this is the least of our worries...
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren