sigh
This commit is contained in:
		| @@ -20,7 +20,7 @@ package baritone.api; | ||||
| import baritone.api.cache.IWorldScanner; | ||||
| import net.minecraft.client.entity.EntityPlayerSP; | ||||
|  | ||||
| import java.util.Set; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * @author Leijurv | ||||
| @@ -43,7 +43,7 @@ public interface IBaritoneProvider { | ||||
|      * @return All active {@link IBaritone} instances. | ||||
|      * @see #getBaritoneForPlayer(EntityPlayerSP) | ||||
|      */ | ||||
|     Set<IBaritone> getAllBaritones(); | ||||
|     List<IBaritone> getAllBaritones(); | ||||
|  | ||||
|     /** | ||||
|      * Provides the {@link IBaritone} instance for a given {@link EntityPlayerSP}. This will likely be | ||||
| @@ -52,7 +52,14 @@ public interface IBaritoneProvider { | ||||
|      * @param player The player | ||||
|      * @return The {@link IBaritone} instance. | ||||
|      */ | ||||
|     IBaritone getBaritoneForPlayer(EntityPlayerSP player); | ||||
|     default IBaritone getBaritoneForPlayer(EntityPlayerSP player) { | ||||
|         for (IBaritone baritone : getAllBaritones()) { | ||||
|             if (player.equals(baritone.getPlayerContext().player())) { | ||||
|                 return baritone; | ||||
|             } | ||||
|         } | ||||
|         throw new IllegalStateException("No baritone for player " + player); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Returns the {@link IWorldScanner} instance. This is not a type returned by | ||||
|   | ||||
| @@ -21,10 +21,9 @@ import baritone.api.IBaritone; | ||||
| import baritone.api.IBaritoneProvider; | ||||
| import baritone.api.cache.IWorldScanner; | ||||
| import baritone.cache.WorldScanner; | ||||
| import net.minecraft.client.entity.EntityPlayerSP; | ||||
|  | ||||
| import java.util.Collections; | ||||
| import java.util.Set; | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * @author Brady | ||||
| @@ -40,14 +39,9 @@ public final class BaritoneProvider implements IBaritoneProvider { | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public Set<IBaritone> getAllBaritones() { | ||||
|         return Collections.singleton(primary); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public IBaritone getBaritoneForPlayer(EntityPlayerSP player) { | ||||
|         // TODO implement on bot-system branch | ||||
|         return primary; | ||||
|     public List<IBaritone> getAllBaritones() { | ||||
|         // TODO return a CopyOnWriteArrayList | ||||
|         return Collections.singletonList(primary); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|   | ||||
| @@ -26,8 +26,8 @@ import baritone.utils.Helper; | ||||
| import net.minecraft.world.World; | ||||
| import net.minecraft.world.chunk.Chunk; | ||||
|  | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.CopyOnWriteArrayList; | ||||
|  | ||||
| /** | ||||
|  * @author Brady | ||||
| @@ -37,7 +37,7 @@ public final class GameEventHandler implements IGameEventListener, Helper { | ||||
|  | ||||
|     private final Baritone baritone; | ||||
|  | ||||
|     private final List<IGameEventListener> listeners = new ArrayList<>(); | ||||
|     private final List<IGameEventListener> listeners = new CopyOnWriteArrayList<>(); | ||||
|  | ||||
|     public GameEventHandler(Baritone baritone) { | ||||
|         this.baritone = baritone; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user