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