Skip to content

Commit

Permalink
Let the event implementation inherit AbstractEvent to make sponge happy
Browse files Browse the repository at this point in the history
  • Loading branch information
ustc-zzzz committed Aug 22, 2018
1 parent e48b9c8 commit 1b6d573
Showing 1 changed file with 23 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.spongepowered.api.asset.AssetManager;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.event.impl.AbstractEvent;
import org.spongepowered.api.item.inventory.Container;
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
import org.spongepowered.api.util.Tuple;
Expand Down Expand Up @@ -183,26 +184,7 @@ private boolean isInventoryOpening(Player player, String id, Tuple<String, WeakR

private void fireLoadEvent()
{
Sponge.getEventManager().post(new VirtualChest.LoadEvent()
{
@Override
public void unregister(String identifier)
{
inventories.remove(identifier);
}

@Override
public void register(String identifier, VirtualChest chest)
{
inventories.put(identifier, chest);
}

@Override
public Cause getCause()
{
return SpongeUnimplemented.createCause(plugin);
}
});
Sponge.getEventManager().post(new LoadEvent());
}

private void updateInventories(Map<String, VirtualChestInventory> newInventories)
Expand Down Expand Up @@ -239,4 +221,25 @@ private Map<String, VirtualChestInventory> scanDir(File file)
}
return newInventories;
}

private class LoadEvent extends AbstractEvent implements VirtualChest.LoadEvent
{
@Override
public void unregister(String identifier)
{
inventories.remove(identifier);
}

@Override
public void register(String identifier, VirtualChest chest)
{
inventories.put(identifier, chest);
}

@Override
public Cause getCause()
{
return SpongeUnimplemented.createCause(plugin);
}
}
}

0 comments on commit 1b6d573

Please sign in to comment.