use of com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier in project Minestuck by mraof.
the class SburbHandler method predefineTitleLandAspect.
public static void predefineTitleLandAspect(MinecraftServer server, ICommandSender sender, ICommand command, String playerName, String sessionName, TitleLandAspect aspect) throws CommandException {
PlayerIdentifier identifier = predefineCheck(server, sender, playerName, sessionName);
Session session = sessionsByName.get(sessionName);
SburbConnection clientConnection = SkaianetHandler.getClientConnection(identifier);
PredefineData data = session.predefinedPlayers.get(identifier);
if (clientConnection != null && clientConnection.enteredGame())
throw new CommandException("You can't change your land aspects after having entered the medium.");
if (sender.sendCommandFeedback())
if (data.title == null)
sender.sendMessage(new TextComponentString("Beware that the title generated might not be suited for this land aspect.").setStyle(new Style().setColor(TextFormatting.YELLOW)));
else if (!LandAspectRegistry.containsTitleLandAspect(data.title.getHeroAspect(), aspect))
sender.sendMessage(new TextComponentString("Beware that the title predefined isn't suited for this land aspect.").setStyle(new Style().setColor(TextFormatting.YELLOW)));
if (data.landTerrain != null && !aspect.isAspectCompatible(data.landTerrain)) {
data.landTerrain = null;
if (sender.sendCommandFeedback())
sender.sendMessage(new TextComponentString("The terrain aspect previously chosen isn't compatible with this land aspect, and has therefore been removed.").setStyle(new Style().setColor(TextFormatting.YELLOW)));
}
data.landTitle = aspect;
CommandBase.notifyCommandListener(sender, command, "commands.sburbSession.landTitleSuccess", playerName, aspect.getPrimaryName());
}
use of com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier in project Minestuck by mraof.
the class SburbHandler method shouldEnterNow.
public static boolean shouldEnterNow(EntityPlayer player) {
if (!MinestuckConfig.playerSelectedTitle)
return true;
PlayerIdentifier identifier = IdentifierHandler.encode(player);
Session s = getPlayerSession(identifier);
if (s != null && s.predefinedPlayers.containsKey(identifier) && s.predefinedPlayers.get(identifier).title != null || MinestuckPlayerData.getTitle(identifier) != null)
return true;
titleSelectionMap.put(player, new Vec3d(player.posX, player.posY, player.posZ));
MinestuckChannelHandler.sendToPlayer(MinestuckPacket.makePacket(MinestuckPacket.Type.PLAYER_DATA, PlayerDataPacket.TITLE_SELECT), player);
return false;
}
use of com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier in project Minestuck by mraof.
the class SburbHandler method titleSelected.
public static void titleSelected(EntityPlayer player, Title title) {
if (MinestuckConfig.playerSelectedTitle && titleSelectionMap.containsKey(player)) {
PlayerIdentifier identifier = IdentifierHandler.encode(player);
Session s = getPlayerSession(identifier);
if (s == null)
if (singleSession)
s = sessions.get(0);
else
s = new Session();
if (title == null)
generateTitle(identifier);
else {
for (SburbConnection c : s.connections) if (c.enteredGame() && title.equals(MinestuckPlayerData.getTitle(c.getClientIdentifier()))) {
// Title is already used
MinestuckChannelHandler.sendToPlayer(MinestuckPacket.makePacket(MinestuckPacket.Type.PLAYER_DATA, PlayerDataPacket.TITLE_SELECT, title.getHeroClass(), title.getHeroAspect()), player);
return;
}
for (PredefineData data : s.predefinedPlayers.values()) if (title.equals(data.title)) {
MinestuckChannelHandler.sendToPlayer(MinestuckPacket.makePacket(MinestuckPacket.Type.PLAYER_DATA, PlayerDataPacket.TITLE_SELECT, title.getHeroClass(), title.getHeroAspect()), player);
return;
}
MinestuckPlayerData.setTitle(identifier, title);
MinestuckPlayerTracker.updateTitle(player);
}
Vec3d pos = titleSelectionMap.remove(player);
player.setPosition(pos.x, pos.y, pos.z);
MinestuckItems.cruxiteApple.onArtifactActivated(player.world, player);
} else
Debug.warnf("%s tried to select a title without entering.", player.getName());
}
use of com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier in project Minestuck by mraof.
the class Session method write.
/**
* Writes this session to an nbt tag.
* Note that this will only work as long as <code>SkaianetHandler.connections</code> remains unmodified.
* @return An NBTTagCompound representing this session.
*/
NBTTagCompound write() {
NBTTagCompound nbt = new NBTTagCompound();
if (isCustom())
nbt.setString("name", name);
NBTTagList list = new NBTTagList();
for (SburbConnection c : connections) list.appendTag(c.write());
nbt.setTag("connections", list);
NBTTagList predefineList = new NBTTagList();
for (Map.Entry<PlayerIdentifier, PredefineData> entry : predefinedPlayers.entrySet()) predefineList.appendTag(entry.getKey().saveToNBT(entry.getValue().write(), "player"));
nbt.setTag("predefinedPlayers", predefineList);
nbt.setBoolean("locked", locked);
nbt.setInteger("skaiaId", skaiaId);
nbt.setInteger("derseId", derseId);
nbt.setInteger("prospitId", prospitId);
return nbt;
}
use of com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier in project Minestuck by mraof.
the class Session method checkIfCompleted.
/**
* Checks if the variable completed should be true or false.
*/
void checkIfCompleted() {
if (connections.isEmpty() || SessionHandler.singleSession) {
completed = false;
return;
}
PlayerIdentifier start = connections.get(0).getClientIdentifier();
PlayerIdentifier current = start;
main: while (true) {
for (SburbConnection c : connections) {
if (!c.enteredGame) {
completed = false;
return;
}
if (c.getServerIdentifier().equals(current)) {
current = c.getClientIdentifier();
if (start.equals(current)) {
completed = true;
return;
} else
continue main;
}
}
completed = false;
return;
}
}
Aggregations