mirror of
https://github.com/GTNewHorizons/CraftTweaker.git
synced 2026-11-24 22:04:23 +00:00
Make things undoable -- should (mostly) fix /mt reload
This commit is contained in:
1 parent
e4a0cc8f35
commit
8fff244d95
4 files changed
+79
-31
No files matched your search
@@ -58,6 +58,7 @@ public class MineTweakerImplementationAPI {
|
||||
private static final ListenPlayerLoggedIn LISTEN_LOGIN = new ListenPlayerLoggedIn();
|
||||
private static final ListenPlayerLoggedOut LISTEN_LOGOUT = new ListenPlayerLoggedOut();
|
||||
private static final ListenBlockInfo LISTEN_BLOCK_INFO = new ListenBlockInfo();
|
||||
private static final EventList<ReloadEvent> ONROLLBACK = new EventList<>();
|
||||
private static final EventList<ReloadEvent> ONRELOAD = new EventList<>();
|
||||
private static final EventList<ReloadEvent> ONPOSTRELOAD = new EventList<>();
|
||||
|
||||
@@ -573,6 +574,9 @@ public class MineTweakerImplementationAPI {
|
||||
* @param handler
|
||||
* @return
|
||||
*/
|
||||
public static IEventHandle onRollbackEvent(IEventHandler<ReloadEvent> handler) {
|
||||
return ONROLLBACK.add(handler);
|
||||
}
|
||||
public static IEventHandle onReloadEvent(IEventHandler<ReloadEvent> handler) {
|
||||
return ONRELOAD.add(handler);
|
||||
}
|
||||
@@ -623,6 +627,8 @@ public class MineTweakerImplementationAPI {
|
||||
}
|
||||
|
||||
MineTweakerAPI.tweaker.rollback();
|
||||
ONROLLBACK.publish(new ReloadEvent());
|
||||
|
||||
if (MineTweakerAPI.server != null) {
|
||||
if (!MineTweakerAPI.server.isCommandAdded("minetweaker")) {
|
||||
server.addCommand("minetweaker", "", new String[]{"mt", "crafttweaker", "ct"}, new ICommandFunction() {
|
||||
|
||||
@@ -52,6 +52,7 @@ public class MTTweaker implements ITweaker {
|
||||
|
||||
Object overrideKey = action.getOverrideKey();
|
||||
if (wereStuck.contains(action)) {
|
||||
MineTweakerAPI.logInfo("WAS STUCK");
|
||||
wereStuck.remove(action);
|
||||
|
||||
if (overrideKey != null) {
|
||||
@@ -76,7 +77,8 @@ public class MTTweaker implements ITweaker {
|
||||
|
||||
@Override
|
||||
public List<IUndoableAction> rollback() {
|
||||
List<IUndoableAction> stuck = new ArrayList<IUndoableAction>();
|
||||
// Note: Requires a OnRollback event to be fired. If this is called from MineTweakerImplementationAPI it's handled there.
|
||||
List<IUndoableAction> stuck = new ArrayList<>();
|
||||
for (int i = actions.size() - 1; i >= 0; i--) {
|
||||
IUndoableAction action = actions.get(i);
|
||||
if (action.canUndo()) {
|
||||
|
||||
Reference in new issue
Block a user