use of com.mraof.minestuck.network.skaianet.SburbConnection in project Minestuck by mraof.
the class ClientEditPacket method execute.
@Override
public void execute(EntityPlayer player) {
UserListOpsEntry opsEntry = player == null ? null : player.getServer().getPlayerList().getOppedPlayers().getEntry(player.getGameProfile());
if (!MinestuckConfig.giveItems) {
if (username == -1)
ServerEditHandler.onPlayerExit(player);
else if (!MinestuckConfig.privateComputers || IdentifierHandler.encode(player).getId() == this.username || opsEntry != null && opsEntry.getPermissionLevel() >= 2)
ServerEditHandler.newServerEditor((EntityPlayerMP) player, IdentifierHandler.getById(username), IdentifierHandler.getById(target));
return;
}
EntityPlayerMP playerMP = IdentifierHandler.getById(target).getPlayer();
if (playerMP != null && (!MinestuckConfig.privateComputers || IdentifierHandler.getById(username).appliesTo(player)) || opsEntry != null && opsEntry.getPermissionLevel() >= 2) {
SburbConnection c = SkaianetHandler.getClientConnection(IdentifierHandler.getById(target));
if (c == null || c.getServerIdentifier().getId() != username || !(c.isMain() || SkaianetHandler.giveItems(IdentifierHandler.getById(target))))
return;
for (int i = 0; i < 5; i++) if (i == 4) {
if (c.enteredGame())
continue;
ItemStack card = AlchemyRecipeHandler.createCard(SburbHandler.getEntryItem(c.getClientIdentifier()), true);
if (!playerMP.inventory.hasItemStack(card))
c.givenItems()[i] = playerMP.inventory.addItemStackToInventory(card) || c.givenItems()[i];
} else {
ItemStack machine = new ItemStack(MinestuckBlocks.sburbMachine, 1, i);
if (i == 1 && !c.enteredGame())
continue;
if (!playerMP.inventory.hasItemStack(machine))
c.givenItems()[i] = playerMP.inventory.addItemStackToInventory(machine) || c.givenItems()[i];
}
player.getServer().getPlayerList().syncPlayerInventory(playerMP);
}
}
use of com.mraof.minestuck.network.skaianet.SburbConnection in project Minestuck by mraof.
the class MinestuckPlayerTracker method updateGristCache.
/**
* Uses an "encoded" username as parameter.
*/
public static void updateGristCache(PlayerIdentifier player) {
GristSet gristSet = MinestuckPlayerData.getGristSet(player);
// The player
EntityPlayerMP playerMP = player.getPlayer();
if (playerMP != null) {
MinestuckPacket packet = MinestuckPacket.makePacket(Type.GRISTCACHE, gristSet, false);
MinestuckChannelHandler.sendToPlayer(packet, playerMP);
}
// The editing player, if there is any.
SburbConnection c = SkaianetHandler.getClientConnection(player);
if (c != null && ServerEditHandler.getData(c) != null) {
EntityPlayerMP editor = ServerEditHandler.getData(c).getEditor();
MinestuckPacket packet = MinestuckPacket.makePacket(Type.GRISTCACHE, gristSet, true);
MinestuckChannelHandler.sendToPlayer(packet, editor);
}
}
use of com.mraof.minestuck.network.skaianet.SburbConnection in project Minestuck by mraof.
the class GristHelper method notifyServer.
private static void notifyServer(PlayerIdentifier player, String type, Integer difference, String action) {
SburbConnection sc = SkaianetHandler.getClientConnection(player);
if (sc == null)
return;
EditData ed = ServerEditHandler.getData(sc);
if (ed == null)
return;
notify(IdentifierHandler.encode(ed.getEditor()), type, difference, action);
}
use of com.mraof.minestuck.network.skaianet.SburbConnection in project Minestuck by mraof.
the class SburbClient method getStringList.
@Override
public ArrayList<UnlocalizedString> getStringList(TileEntityComputer te) {
ArrayList<UnlocalizedString> list = new ArrayList<UnlocalizedString>();
NBTTagCompound nbt = te.getData(getId());
SburbConnection c = SkaiaClient.getClientConnection(te.ownerId);
if (// If it is connected to someone.
nbt.getBoolean("connectedToServer") && c != null) {
String displayPlayer = c.getServerDisplayName();
list.add(new UnlocalizedString("computer.messageConnect", displayPlayer));
list.add(new UnlocalizedString("computer.buttonClose"));
} else if (nbt.getBoolean("isResuming")) {
list.add(new UnlocalizedString("computer.messageResumeClient"));
list.add(new UnlocalizedString("computer.buttonClose"));
} else if (// If the player doesn't have an other active client
!SkaiaClient.isActive(te.ownerId, true)) {
list.add(new UnlocalizedString("computer.messageSelect"));
if (// If it has a resumable connection
SkaiaClient.getAssociatedPartner(te.ownerId, true) != -1)
list.add(new UnlocalizedString("computer.buttonResume"));
for (Map.Entry<Integer, String> entry : SkaiaClient.getAvailableServers(te.ownerId).entrySet()) list.add(new UnlocalizedString("computer.buttonConnect", entry.getValue(), entry.getKey()));
} else
list.add(new UnlocalizedString("computer.messageClientActive"));
if (SkaiaClient.canSelect(te.ownerId))
list.add(new UnlocalizedString("computer.selectColor"));
return list;
}
use of com.mraof.minestuck.network.skaianet.SburbConnection in project Minestuck by mraof.
the class SburbServer method getStringList.
@Override
public ArrayList<UnlocalizedString> getStringList(TileEntityComputer te) {
int clientId = te.getData(1).hasKey("connectedClient") ? te.getData(1).getInteger("connectedClient") : -1;
SburbConnection connection = clientId != -1 ? SkaiaClient.getClientConnection(clientId) : null;
if (connection != null && connection.getServerId() != te.ownerId)
connection = null;
ArrayList<UnlocalizedString> list = new ArrayList<UnlocalizedString>();
String displayPlayer = connection == null ? "UNDEFINED" : connection.getClientDisplayName();
if (connection != null) {
list.add(new UnlocalizedString("computer.messageConnect", displayPlayer));
list.add(new UnlocalizedString("computer.buttonClose"));
list.add(new UnlocalizedString(MinestuckConfig.clientGiveItems ? "computer.buttonGive" : "computer.buttonEdit"));
} else if (te.getData(getId()).getBoolean("isOpen")) {
list.add(new UnlocalizedString("computer.messageResumeServer"));
list.add(new UnlocalizedString("computer.buttonClose"));
} else if (SkaiaClient.isActive(te.ownerId, false))
list.add(new UnlocalizedString("computer.messageServerActive"));
else {
list.add(new UnlocalizedString("computer.messageOffline"));
list.add(new UnlocalizedString("computer.buttonOpen"));
if (SkaiaClient.getAssociatedPartner(te.ownerId, false) != -1)
list.add(new UnlocalizedString("computer.buttonResume"));
}
return list;
}
Aggregations