Change Tablist names for each individual Player. (Spigot) - plugins

Hello
I am currently making a Minecraft SkyWars-Plugin and want to make a better looking tablist.
The Problem:
Lets say you have PlayerA and PlayerB. If PlayerA looks on the tablist, his name should be green and the name of PlayerB should be red.
But if PlayerB looks at his tablist, PlayerB's name should be green and PlayerA's name should be red.
So basically your own name should be marked as green (Color code 'a') and the opponents should have a red name (Color code 'c').
How do I achieve that? Do I send packages to each Player for his tablist? If so, which packages should/can I use?
Thanks in advance.

Your problem can be solved in two ways.
If you want to show per-player visible colors only in a tablist, you can use Player Info packet (specification https://wiki.vg/Protocol#Player_Info) for tablist content modification. Full valid code can be very volume, so i give you an algorithm (below I mean "packet" is Player Info packet):
Send packet with action remove player (see wiki for action list) with PlayerA.uuid to PlayerA
Send packet with action remove player with PlayerB.uuid to PlayerA
Repeat 1 and 2, but send packets to playerB.
Send packet with: action add player, PlayerA.uuid and colored PlayerA's display name for PlayerA (which in your case is green) to PlayerA.
Send packet with: action add player, PlayerB.uuid and colored PlayerB's display name for PlayerA (which in your case is red) to PlayerA.
Repeat 4 and 5, but send packets to playerB and invert colors.
For packets management you can use ProtocolLib plugin.
If you want to show per-player visible colors in tablist and above the head, you can use similar algorithm with scoreboard teams packets. Or you can try to find implemented plugin api for per-player visible prefixes.

Related

How to get callback from esp so that I can know which light is turned on

I'm usingflutter blue plus and when I apply the read.characteristic() I get either the ESP32(I get data in list but it's conversion in string) or [0,0], how to know the status that this particular led is turned on.
I'm able to write succefully on ESP.
ESP
[
I'm trying to implement this using flutter blue image from

Two conveyors for a station

I have two conveyors running simultaneously, and then there is sorter which sorts the items coming from these two conveyors, one by one, so if the sorter is sorting the item coming from conveyor 1 then both the conveyors should stop and similarly for conveyor 2. So basically, if sorter is sorting any item, coming from conveyor 1 or 2 both the conveyors should stop in that case.enter image description here
So how should I do it?
Use a Custom Station (which I think you are using) and then, say, a Delay block to simulate the sorting. Use on-enter and on-at-exit actions of the Delay block to stop and start the conveyors (using their stop() and run() functions).
Because using a custom station requires you to 'split' the incoming and outcoming conveyors (cf. a normal Station), you will have to remember which conveyor they came in on (by storing that information inside a custom Material Item agent which is flowing through the process) so that you know which outbound conveyor to put them on.
From a visual perspective, you can also make sure the agent leaves the inbound conveyor and is removed from space (Convey block "Leave conveyor on exit" and "are removed from the space" option), but then have them appear in, say, a Rectangular Node defined on top of the custom station when they are in the Delay block ("Agent location" setting).
Below is a little minimal example model.
The agent flowing through the process has a parameter sourceConvey (of type Convey) which stores the Convey block it is arriving to the sorter from. (Could also have stored the conveyor space markup instance instead or, in this case since there are only 2 conveyors, just a boolean saying whether it is from 'conveyor 1' or not.)
The Source blocks set the agent's sourceConvey appropriately and then the outbound Convey block (convey2 in the picture) dynamically assigns the source and target conveyor based on where the thing came from:
agent.sourceConvey == convey ? conveyor2 : conveyor3
(Where conveyor2 is the top outbound conveyor and conveyor3 the bottom one.)
(You could also have used a SelectOutput with two outbound Convey blocks for each possible path.)

Anylogic Message Animation

I am trying to force agents of a population to exchange messages in AnyLogic. I would like each time agent A sends a message to B the icon of the message to move from A to B. How can I implement this?
The code Emile sent you works to move an agent from one place to another one. I understand you don't want to move your two agents, but instead you want to move only a "message icon" from one to the other. For that you can create an agent (let's call it agent "Message"), create it and locate it in the agentA, and tell it (as Emile said) to move to agentB: messageAB.moveTo(agentB.getPosition()); this way you'll get the effect you want.
You could also:
use a timer to move from one place to another, or
use an event and change the position of the icon dinamically depending on how much time you have remaining on that event
use a source/delay/sink for the same as in point 2
There are basically two ways to move an agent:
Jump to agent B: Instantly appears near agent B
Move to agent A at a certain speed
For each one the code is respectively as follows:
agentA.jumpTo( agentB.getXYZ() );
agentA.moveTo( agentB );
Where agentA and agentB refer to the agents which you might call differently depending where you are in the model.

Anylogic - Events triggered by message

i'm new to AnyLogic and i'm trying to built an ABM SIRS model for pertussis in Italy...but i'm stuck because I want infected agents to send a message to all the agents they are connected with.
I want the message to be an number ( [0,1] level of infectivity) and not a string and then the real problem is: once an agent gets this message it becomes infected with probability equal to the number in the message
Sending the message
Once the message is received
Thanks!
try this.
To understand, put your cursor into the "Expression" code box and hover over the little light bulb in the top left corner.
Also refer to my blog on the little light bulb which can be a life-saver in these situations: the magic lightbulb

Gamecenter Matchmaking - How do I distinguish between player 1 and 2?

I am beginning to write a game using gamecenter matchmaking. Right now, two players can connect to each other, but I am having trouble figuring out how to distinguish between player 1 and 2. For example, I want player 1 to be able to move player 1 and player 2 to be able to move player 2.
The implementation would be specific to your app so it would be hard to answer more specifically, but basically each person's instance of the app could have an object that is "local player" and an object that is "opponent"... Both of them get to move the "local player" in their local instance, and changes to their "player" are obviously mapped to the "opponent" at the other end.
Just do a random number exchance to decide who will be player1 and make the first move.
Generate a random number and store it in a variable.
Send that generated random number to opponent.
Just like this, your opponent sends his own random number to you.
When you receive it, compare with yours.
If yours is greater than his, then you are player1 and he is player2. So you will make the first move.
If yours is lesser than his, then you are player2 and he is player1. So he will make the first move.
If yours and his number are equal (a very rare case) repeat the procedure.
As a reminder, you need to distinguish message types. So use different message type headers. For example: 'R' for random, 'M' for moves.