char list delete ...
This commit is contained in:
parent
5843594ba3
commit
dd72e2d367
7 changed files with 93 additions and 44 deletions
|
@ -6,6 +6,7 @@ import java.util.Map;
|
|||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import game.collect.Lists;
|
||||
import game.collect.Maps;
|
||||
|
||||
import game.Game;
|
||||
|
@ -27,6 +28,7 @@ import game.entity.types.EntityLiving;
|
|||
import game.gui.Gui;
|
||||
import game.gui.GuiConsole;
|
||||
import game.gui.GuiChar;
|
||||
import game.gui.GuiCharacters;
|
||||
import game.gui.container.GuiMachine;
|
||||
import game.gui.container.GuiMerchant;
|
||||
import game.init.EntityRegistry;
|
||||
|
@ -141,7 +143,7 @@ public class ClientPlayer extends NetHandler
|
|||
private boolean doneLoadingTerrain;
|
||||
// private boolean travelSound;
|
||||
private final Map<String, Integer> playerList = Maps.<String, Integer>newTreeMap();
|
||||
private final Map<Integer, PlayerCharacter> characterList = Maps.<Integer, PlayerCharacter>newHashMap();
|
||||
private final List<PlayerCharacter> characterList = Lists.<PlayerCharacter>newArrayList();
|
||||
// private final List<Entry<String, Integer>> players = Lists.newArrayList();
|
||||
private int selectedCharacter = -1;
|
||||
|
||||
|
@ -1525,15 +1527,20 @@ public class ClientPlayer extends NetHandler
|
|||
|
||||
for(Entry<Integer, PlayerCharacter> data : packet.getEntries()) {
|
||||
if(data.getValue() == null)
|
||||
this.characterList.remove(data.getKey());
|
||||
this.characterList.remove(data.getKey().intValue());
|
||||
else if(data.getKey() < this.characterList.size())
|
||||
this.characterList.set(data.getKey(), data.getValue());
|
||||
else
|
||||
this.characterList.put(data.getKey(), data.getValue());
|
||||
this.characterList.add(data.getKey(), data.getValue());
|
||||
}
|
||||
this.selectedCharacter = packet.getSelected();
|
||||
if(this.gameController.charEditor && this.selectedCharacter >= 0) {
|
||||
this.gameController.charEditor = false;
|
||||
this.gameController.displayGuiScreen(null);
|
||||
}
|
||||
else if(this.gameController.open instanceof GuiCharacters) {
|
||||
this.gameController.displayGuiScreen(this.gameController.open);
|
||||
}
|
||||
}
|
||||
|
||||
public void handleKeepAlive(SPacketKeepAlive packetIn)
|
||||
|
@ -1890,7 +1897,7 @@ public class ClientPlayer extends NetHandler
|
|||
|
||||
public Collection<PlayerCharacter> getCharacterList()
|
||||
{
|
||||
return this.characterList.values();
|
||||
return this.characterList;
|
||||
}
|
||||
|
||||
public int getSelectedCharacter()
|
||||
|
|
|
@ -2508,16 +2508,18 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
|
||||
switch (action)
|
||||
{
|
||||
case OPEN_EDITOR:
|
||||
case OPEN_EDITOR: {
|
||||
this.charEditor = true;
|
||||
// if(this.local)
|
||||
// this.server.resetProgress();
|
||||
NBTTagCompound tag = this.server.swapPlayer(this, null, EntityHuman.class);
|
||||
if(!this.characters.isEmpty() && this.selected >= 0)
|
||||
this.characters.set(this.selected, tag);
|
||||
int last = this.selected;
|
||||
this.selected = -1;
|
||||
this.sendPacket(new SPacketCharacterList(this.selected));
|
||||
this.sendPacket(!this.characters.isEmpty() && last >= 0 ? new SPacketCharacterList(this.selected, last, this.getCharacterInfo(tag)) : new SPacketCharacterList(this.selected));
|
||||
break;
|
||||
}
|
||||
|
||||
case CLOSE_EDITOR: {
|
||||
this.charEditor = false;
|
||||
|
@ -2538,16 +2540,29 @@ public class Player extends NetHandler implements ICrafting, Executor
|
|||
break;
|
||||
}
|
||||
|
||||
case SELECT_CHARACTER:
|
||||
case SELECT_CHARACTER: {
|
||||
int index = packetIn.getAuxData();
|
||||
if(index == this.selected || index >= this.characters.size() || index < 0)
|
||||
return;
|
||||
NBTTagCompound etag = this.server.swapPlayer(this, this.characters.get(index), null);
|
||||
if(!this.characters.isEmpty() && this.selected >= 0)
|
||||
this.characters.set(this.selected, etag);
|
||||
int last = this.selected;
|
||||
this.selected = index;
|
||||
this.sendPacket(new SPacketCharacterList(this.selected));
|
||||
this.sendPacket(!this.characters.isEmpty() && last >= 0 ? new SPacketCharacterList(this.selected, last, this.getCharacterInfo(etag)) : new SPacketCharacterList(this.selected));
|
||||
break;
|
||||
}
|
||||
|
||||
case DELETE_CHARACTER: {
|
||||
int index = packetIn.getAuxData();
|
||||
if(index == this.selected || index >= this.characters.size() || index < 0)
|
||||
return;
|
||||
if(this.selected > index)
|
||||
this.selected -= 1;
|
||||
this.characters.remove(index);
|
||||
this.sendPacket(new SPacketCharacterList(this.selected, index, null));
|
||||
break;
|
||||
}
|
||||
|
||||
case START_SNEAKING:
|
||||
this.entity.setSneaking(true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue