Improved ship scanner usability for new captains and admins

This commit is contained in:
Unknown 2019-06-15 03:00:01 +02:00 committed by unknown
parent 08937e6702
commit cae95a4f26
5 changed files with 32 additions and 24 deletions

View file

@ -186,7 +186,7 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
optimumSpeed, blockToDeployPerTick)); optimumSpeed, blockToDeployPerTick));
} }
sequencer.setBlocksPerTick(blockToDeployPerTick); sequencer.setBlocksPerTick(blockToDeployPerTick);
sequencer.setCaptain(playerName); sequencer.setRequester(playerName, isShipToken);
sequencer.setEffectSource(new Vector3(this).translate(0.5D)); sequencer.setEffectSource(new Vector3(this).translate(0.5D));
sequencer.setCallback(this); sequencer.setCallback(this);
sequencer.enable(); sequencer.enable();
@ -718,15 +718,13 @@ public class TileEntityShipScanner extends TileEntityAbstractMachine implements
final boolean isSuccess = deployShip(fileName, x, y, z, rotationSteps, false, reason); final boolean isSuccess = deployShip(fileName, x, y, z, rotationSteps, false, reason);
// don't force captain when deploying from LUA // don't force captain when deploying from LUA
playerName = null; final EntityPlayer entityPlayer = world.getClosestPlayer(pos.getX() + 0.5D, pos.getY() + 0.5D, pos.getZ() + 0.5D, 8.0D, false);
/*
final EntityPlayer entityPlayer = world.getClosestPlayer(pos, 8);
if (entityPlayer != null) { if (entityPlayer != null) {
playerName = entityPlayer.getCommandSenderName(); playerName = entityPlayer.getName();
} else { } else {
playerName = ""; playerName = "";
} }
/**/
return new Object[] { isSuccess, Commons.removeFormatting( reason.getUnformattedText() ) }; return new Object[] { isSuccess, Commons.removeFormatting( reason.getUnformattedText() ) };
} }

View file

@ -694,9 +694,6 @@ public class TileEntityShipCore extends TileEntityAbstractShipController impleme
if (tileEntitySecurityStation != null) { if (tileEntitySecurityStation != null) {
tileEntitySecurityStation.players.clear(); tileEntitySecurityStation.players.clear();
tileEntitySecurityStation.players.add(entityPlayerMP.getName()); tileEntitySecurityStation.players.add(entityPlayerMP.getName());
} else {
WarpDrive.logger.warn(this + " Failed to find controller block");
return false;
} }
final AxisAlignedBB aabb = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ); final AxisAlignedBB aabb = new AxisAlignedBB(minX, minY, minZ, maxX, maxY, maxZ);
@ -706,9 +703,12 @@ public class TileEntityShipCore extends TileEntityAbstractShipController impleme
return true; return true;
} }
private static final VectorI[] SUMMON_OFFSETS = { new VectorI(2, 0, 0), new VectorI(-1, 0, 0), private static final VectorI[] SUMMON_OFFSETS = {
new VectorI(2, 0, 1), new VectorI(2, 0, -1), new VectorI(-1, 0, 1), new VectorI(-1, 0, -1), new VectorI(-1, 0, 0), new VectorI( 1, 0, 0),
new VectorI(1, 0, 1), new VectorI(1, 0, -1), new VectorI( 0, 0, 1), new VectorI( 0, 0, -1) }; new VectorI(-1, 0, 1), new VectorI(-1, 0, -1),
new VectorI( 1, 0, 1), new VectorI( 1, 0, -1),
new VectorI( 0, 0, 1), new VectorI( 0, 0, -1),
new VectorI(-2, 0, 0), new VectorI( 2, 0, 0) };
private void summonPlayer(@Nonnull final EntityPlayerMP entityPlayer) { private void summonPlayer(@Nonnull final EntityPlayerMP entityPlayer) {
// find a free spot // find a free spot
final BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(pos); final BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(pos);

View file

@ -355,11 +355,14 @@ public class JumpShip {
return isSuccess; return isSuccess;
} }
public void setCaptain(final String playerName) { public void addPlayerToEntities(final String playerName) {
if (entitiesOnShip == null) {
entitiesOnShip = new ArrayList<>(); entitiesOnShip = new ArrayList<>();
}
final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerName); final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerName);
if (entityPlayerMP == null) { if (entityPlayerMP == null) {
WarpDrive.logger.error(String.format("%s setCaptain: captain is missing", this)); WarpDrive.logger.error(String.format("%s Unable to add offline/missing player %s",
this, playerName ));
return; return;
} }
final MovingEntity movingEntity = new MovingEntity(entityPlayerMP); final MovingEntity movingEntity = new MovingEntity(entityPlayerMP);

View file

@ -15,7 +15,8 @@ import net.minecraft.world.World;
public class DeploySequencer extends JumpSequencer { public class DeploySequencer extends JumpSequencer {
private String playerName; private String playerNameRequester;
private boolean isRequesterCaptain = false;
private ISequencerCallbacks callback; private ISequencerCallbacks callback;
/* /*
@ -31,9 +32,10 @@ public class DeploySequencer extends JumpSequencer {
super(jumpShip, world, isInstantiated ? EnumShipMovementType.INSTANTIATE : EnumShipMovementType.RESTORE, destX, destY, destZ, rotationSteps); super(jumpShip, world, isInstantiated ? EnumShipMovementType.INSTANTIATE : EnumShipMovementType.RESTORE, destX, destY, destZ, rotationSteps);
} }
public void setCaptain(final String playerName) { public void setRequester(final String playerName, final boolean isCaptain) {
this.playerName = playerName; this.playerNameRequester = playerName;
ship.setCaptain(playerName); this.isRequesterCaptain = isCaptain;
addPlayerToEntities(playerName);
} }
public void setCallback(final ISequencerCallbacks object) { public void setCallback(final ISequencerCallbacks object) {
@ -56,9 +58,9 @@ public class DeploySequencer extends JumpSequencer {
protected void state_chunkReleasing() { protected void state_chunkReleasing() {
super.state_chunkReleasing(); super.state_chunkReleasing();
if (playerName != null) { if (playerNameRequester != null) {
// Warn owner if deployment done but wait next tick for teleportation // Warn owner if deployment done but wait next tick for teleportation
final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerName); final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerNameRequester);
if (entityPlayerMP != null) { if (entityPlayerMP != null) {
Commons.addChatMessage(entityPlayerMP, new WarpDriveText(Commons.styleCorrect, "warpdrive.builder.guide.ship_deployed")); Commons.addChatMessage(entityPlayerMP, new WarpDriveText(Commons.styleCorrect, "warpdrive.builder.guide.ship_deployed"));
} }
@ -67,8 +69,9 @@ public class DeploySequencer extends JumpSequencer {
@Override @Override
protected void state_finishing() { protected void state_finishing() {
if (playerName != null && !playerName.isEmpty()) { if ( playerNameRequester != null && !playerNameRequester.isEmpty()
final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerName); && isRequesterCaptain ) {
final EntityPlayerMP entityPlayerMP = Commons.getOnlinePlayerByName(playerNameRequester);
if (entityPlayerMP != null) { if (entityPlayerMP != null) {
final TileEntity tileEntity = targetWorld.getTileEntity(new BlockPos(destX, destY, destZ)); final TileEntity tileEntity = targetWorld.getTileEntity(new BlockPos(destX, destY, destZ));
if (tileEntity instanceof TileEntityShipCore) { if (tileEntity instanceof TileEntityShipCore) {
@ -77,7 +80,7 @@ public class DeploySequencer extends JumpSequencer {
Commons.addChatMessage(entityPlayerMP, new WarpDriveText(Commons.styleCorrect, "warpdrive.builder.guide.welcome_aboard")); Commons.addChatMessage(entityPlayerMP, new WarpDriveText(Commons.styleCorrect, "warpdrive.builder.guide.welcome_aboard"));
} else { } else {
WarpDrive.logger.warn(String.format("Failed to assign new captain %s", WarpDrive.logger.warn(String.format("Failed to assign new captain %s",
playerName)); playerNameRequester));
} }
} else { } else {
WarpDrive.logger.warn(String.format("Unable to detect ship core after deployment, found %s", WarpDrive.logger.warn(String.format("Unable to detect ship core after deployment, found %s",

View file

@ -167,6 +167,10 @@ public class JumpSequencer extends AbstractSequencer {
this.v3Source = v3Source; this.v3Source = v3Source;
} }
public void addPlayerToEntities(final String playerName) {
ship.addPlayerToEntities(playerName);
}
public void enable() { public void enable() {
isEnabled = true; isEnabled = true;
register(); register();