#help-development
1 messages Β· Page 125 of 1
Is there a way to hide an npc from the player list without removing its skin?
I solved it thanks to his input
p.spawnParticle(Particle.ASH, p.getLocation(), 50);
}, 1L, 100L);``` so this would run every tick for 100 ticks
right?
This would start after 50ms and run every 5 seconds
ohh
timers don't stop unless explicitly cancelled
1L
1L = 50ms
how do i get the taskId?
preferably don't and use the returned bukkit task instance
which has a cancel method on it
if you just wanna execute something 100 times you could just:
final AtomicInteger counter = new AtomicInteger(0);
scheduler.runTaskTimer(plugin, task -> {
if (counter.getAndIncrement() > 100) {
task.cancel();
return;
}
... do your thing
}, 1L, 1L)
not, I just wrote this off the top of my head
so
what packet would i use to remove an NMS player from someone's view
that might not be valid java code xD
20 ticks/second, 1000ms = 1 second, so 1 tick is about 50ms.
yes
send an entities destroy package
ClientboundRemoveEntitiesPacket?
ClientboundRemoveEntitiesPacket
yea
notably don't ever send that to the player itself xD
that will completely fuck the client up
pretty sure you dont need to use atomicinteger for that
a normal int won't work
as you are using it inside a lambda, which requires captured variables to be effectively final
is it ClientboundRemoveEntitiesPacket(EntityId)
yea
okay cool
there is a constructor that takes an int varargs
So a hashmap
Well then if you need that a hash map is probably the best option
An ORM basically helps you do stuff with a database
Object Relational Mapping, its what you are trying to do
Links data from a database to objects
so that you can interact with data on your database progmatically without having to handle all the queries yourself
Yea
Java has millions of them
Hibernate seems to be the most popular one, not sure if its any good though haven't touched java in quite some time
it keeps saying that it can't delete this createdfiles.lst file
and if i delete it normally its fine
but its really annoying
Are you trying to delete it programmatically?
Its convenient thats all
there is a kt one which is much better iirc
but thats for kt
someone knows how to add an id to a block? it's because i created a custom block and i need to identify it to create some functionalities.
You cant have custom blocks in minecraft yet
i created one with mob spawners and armorstands
Only through some hackery
You could create a "fake" ID by using PDC
Ah
Spawners are persistent data holders. So just use the pdc.
yeah, but that works as an nbt tag?
uh no
Yes the pdc is stored in the nbt tag
but i tryied to use it and i check if the tag was added to the block and it wasn't there
You need to update the BlockState after editing the pdc
can i add a tag directly like: tiledata.setBoolean("Customblock", true);?
Sure. You can also just add an id. data.set(someKey, PersistentDataType.INTEGER, 20)
How can I relocate the dependencies of my dependencies without writing them all? Because it's endless. Or is there an option to relocate everything? With maven
If you relocate your dependencies then the relocation is transitive.
*If the relocated dependency shades its content
I have relocated a dependency but its dependencies are not
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}.dependencies</shadedPattern>
</relocation>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.1.2</version>
</dependency>
maybe I relocated it wrong
You have the maven shade plugin set up, right?
i'm asking because the tag is added but when i tryied to check it, it's not there
yes
maybe show the whole pom
Well your pattern only shades net.kyori
Look into the kyori dependency and see under which path it shades its own dependencies
Maybe its different
it's gradle and i don't know how shade work on it
https://github.com/KyoriPowered/adventure
Its done with the shadow plugin. Let me take a quick look.
https://github.com/KyoriPowered/adventure-platform
maybe it's here idk
What problem do you have anyways? Because you should not need worry about this in the first place. Its a really weird issue.
my plugin interferes with another one because of a kyori adventure dependency that is not relocated
should i write net.kyori.* ?
Alright boys... I fixed my eclipse and now I have my project as a Maven project. I need in export the jar and include this in it as a dependency. Can someone walk me through it?
this didn't work
update(true)
i made it work but it overrides all my nbt tags
how would you do it
Keys may only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.```
get the nms world with like reflection, get the tile entity at the blocks position and get the nbt tag
Your Key is invalid
nbt can have anything as a key i think π
PDC works just fine and shoudl be used over NBT
but i made it work but all my tags were override
hey elgar, how do I remove the NPC from the tab list without removing its skin?
shade net.kyori
i believe you told me yesterday how to remove them from tablist but it removes their skin
Skins shouold be maintained so long as they have been spawned on the client
no π you can create nbt tags which reference objects at runtime but convert to compounds when saved π i did that π
that isn't the case unfortunately
should I try delaying the remove thingy a few ticks?
you could try it. I've played with skins/names and updating packets but I've not tested in depth
okay
here i tryied with nms and here is the result:
looks good right
at first the tag exist but when i check the block the tag disapears
wait
im pretty sure tile entities dont store tags
at runtime
so use pdc
the chunk pdc
or a map at runtime and save it when the chunk is unloaded
a TileEntity retains its PDC data between sessions. Can you explain your issue again as I've not read that far back.
what other tags? Other PDC tags?
here is the code:
nms tags
those dont work with tile entities
they dont store NBT for performance and memory reasons
you are trying to use NMS tags and PDC at the same time?
did it work without using the pdc?
yeah
all my nms tags store as spected
that is a PDC tag you are adding. Lower case only
That tag will not work correctly as your key is invalid
Read teh javadoc on how to format a NamespacedKey correctly https://hub.spigotmc.org/javadocs/spigot/org/bukkit/NamespacedKey.html
how would i make the player disappear along with their armor, but still be able to be hit (with packets)
i can't understand why is not a valid key
a key must be ALL lower case. No upper case characters
It should be possible, but not sure why you would want to.
bump
My code: https://paste.md-5.net/afoquzoban.cs
how the hidePlayer works is that it makes the player invincible too
:/
because i tried it and nobody can hit me :/
all of those NBT values you are setting and available via the API
i heard that i have to do it with packets
yes, but you can't modify the entity inside
You don;t seem to be setting anythign which is not exposed by the API
I'll be away for 15 mins
Anyone know how to summon a firework that doesn't have any of the white firework particles in it?
will give more context in a second when I have the information easily showable
the 2 important things in that photo are the firework in the background and the chat showing the firework meta
in the firework you can see that there are white particles mixed with the reds
but in the meta no such explosion exists
i think you have to edit the meta of the fireworks
Anyone know how I can remove those particles?
lol np, Im manually setting the firework meta alr
how come my NMS fake player's skin isn't double layered?
You didn;t send the player meta packet
if you are just using packets you send java new ClientboundSetEntityDataPacket(npc.getId(), npc.getEntityData(), true)If they exist in the World you instead wrap the ServerPlayer in yoru own class and set java this.getEntityData().set(Player.DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0xFF)
Someone's got an idea on how to exctract chat color from a string?
Like if the string is &6Some string I only wanna have the &6
probably regex is your best bet
Alright boys... I fixed my eclipse and now I have my project as a Maven project. I need in build the jar and include this in it as a dependency. Can someone walk me through it?
Is there a way to create a mob with a nametag that has multiple lines? I've tried working with scoreboards but that doesn't work on mobs apparently.
Cannot resolve method 'setScoreboard' in 'LivingEntity'
I thought about it and I actually need the last used color in a string (if there's any)
e.g. &6Some fance &4String should return &4
Hey, I am trying to give a Player_Head a custom texture, but I am having issues with the dependencies. The tutorial I am watching told me to replace "spigot-api" with "spigot" in the pom file, but I get an error saying it can't find that dependency. Does anybody know what I am missing?
Install that version with BuildTools
bump ^
Probably just 1
Oh, I had the wrong version specified. Thanks!
@EventHandler
public void onEvent(SameEvent event) {
checkA(event);
checkB(event);
}
private void checkA(SameEvent event) {}
private void checkB(SameEvent event) {}
So Intellij is letting me import GameProfile now, but when I compile I get an error saying "cannot access com.mojang.authlib.GameProfile"
Using Maven?
Yes
Then build using Lifecycles Package, not artifacts
I used install from Lifecycle
?paste teh full error then
You are using the wrong version for your target java version
what spigot version are you building against?
I think I was building against 1.18.2. Is there a way I can confirm?
In that case you don;t need GameProfile at all
Oh, what would I use instead?
Thanks!
why would you want a new thread for every chunk?
In PlayerMoveEvent, compare chunk in getFrom and getTo. If not the same, remove old chunk enchants and apply new chunk enchants.
I can get block data after click in PlayerInteractEvent?
because better performance
since its looping hundreds of blocks
It won't be "better performance"
For blocks like trapdoor flower_pot etc.
but it would be tho :/
why are you looping hundreds of blocks?
Yeah, no clue what a "prison enchant" is and no clue why you need to loop hundreds of blocks
Spigot is a state change system. you don;t do anything unless you are triggered
No clue what that is
;-;
yes
they would change to air and give money / tokens
but if i do it on 1 thread
it'll lag
a ChunkSnapshot?
alr
wait, so how would i make a thread per chunk?
im a little confused
You don't. That would be crazy
yes
generally reading blocks Async will not cause issues, but you must be Sync to make changes
yeah
so you do all your processing Async, then jump back sync to make changes
π
I got banned from paper now too
lol
why
wait
I can get block data after click in PlayerInteractEvent?
For blocks like trapdoor, door, flower pot etc
sorry, only kicked
but I dont wanna "shame anyone" so yeah
there was some disagreement with a person who had kick perms and me, and then I got kicked
lets not go into details
bruh
singleton is cleaner lol
Always use DI except for one case which is passing the plugin's instance, Use a singleton for that.
Bukkit doesn't allow you to create an instance of your main class, so there is only one - therefore using DI for that is just stupid and takes more code.
testability
reusability
robustness
maintainability
modularity
logger is fine for instance
(since you test loggers by appending them anyway)
and no singleton is not cleaner
singleton is less verbose probably
but it is definitely by all means less cleaner
yeah
maintainable refers to the future work you have to put in
modular refers to how isolated different functionalities of your plugin is
robustness refers to how resistant your code is towards changes
testability refers to how easy your components are to test, in terms of unit tests, integration tests, sys tests and acceptance tests
reusability refers to how easy a component of your system is to reuse
DI means your components depend on dependencies at type level, for instance a constructor is just a function that takes a set of types and returns a type
this allows us to depend on high level types, interfaces that is
and then they can be mocked for testing
when we have classes that depend on abstraction we gain dependency inversion for instance
and is a SOLID principle
anyway Pvbble
we can look at it from the other perspective
what are the disadvantages of mono/poly state
oh poly state is just the term for static state
mono state refers to when you have like a single static state within bounds of a class
in other words, the disadvantage of static and singletons
first you typically conclude a design where a class depends on your singleton
If runtime.maxMemory() represents the Xmx value, then what is the runtime.totalMemory() method represent?
that leads to that every instance of said class depends on that singleton
which in other words make the design tightly coupled
iirc current memory allocated kytdk
no i mean the classic way
yeah im confused
//inside class
var instanceField = Singleton.instance();
no not really
if you have it through the constructor then first of all half of the meaning concerning singleton disappears as you cant have them lazily
and secondly the class becomes mockable through mockito
we also see what the class depends on more explicitly
no
the point of a singleton is to provide a single instance of a class as well as a global access point to that instance
by definition
What exactly do you not understand?
whats the difference between max and total?
total is used + reserved
max is the max allowed for this jvm instance
But the jvm does not reserve all its memory from the beginning.
no
You can do that with jvm args (Xms) and you also should do that if you run a mc server.
In this case total == max
used in static context has inherently nothing to do with singleton
but it does extend its usecase sure
bump cause still lost on this, (see messages below replied one for the rest of the context)
there is have an event to check if player is walking or not?
so if I wanted to get the memory to player ratio I would use max memory since it includes all the possible memory that could be used by the jvm?
What are you trying to do?
the entire point of static singleton was to have them lazy because they may not actually be called at all thus saving some memory etc
that was back in the days when we didnt have obscene amounts of memory
What do you mean "memory to player ratio"
memory/playercount
I want if player is walking, some method will called
Used or max
PlayerMoveEvent
yeah probably max
There is no method for when a player starts/stops walking because movement is done stateless.
Whats the overall idea?
I still dont understand your plan. Do you want to know how much memory you can "use" per player currently?
yes
Well then its max.
i don't understand with "done stateless"
What do you want to achieve?
I want if player start/stop walking, something happened
yeah what though
but, can someone tell me about PlayerMoveEvent?
what is something
lyey basically, the whenever the player moves just a little bit that event gets called
even head movement
during the time player moves from x to y the event is called continuously in principle
oh, I understand
will it working to check if player is sprinting with isSprinting() in during the player moves?
yep
ok, thanks
oh yeah pvbble ping me when u're done with ur little essay
:]
(hopefully I can answer it satisfyingly)
myes
first and foremost, you rarely do use singletons in static context (if you have a robust design)
then just because a single instance of the class is what fits your system as of the present moment does not mean you should allude towards the singleton design pattern
the issue is that static singletons are usually used like this (which they should be):
class CassandraDatabase {
static CassandraDatabase instance;
static CassandraDatabse instance() {
if (instance == null) {
synchronized (CassandraDatabase.class) {
if (instance == null) instance = new CassandraDatabase();
}
}
return instance;
}
}
class SomeFunctionality {
void performWork(DatabaseType dbType, Query query) {
switch (dbType) {
case DatabaseType.CASSANDRA -> {
CassandraDatabase.instance().fetch(query);
}
}
}
}```
now ofc we can use it like:
record SomeFunctionality(CassandraDatabase database) {
}
//or lazy
record SomeFunctionality(Supplier<? extends CassandraDatabase> database) {
}
the last one is just unnecessarily complicated but is sometimes needed, the former gets rid of lazy initialization
alr good luck
but like I hope you see, if we use SomeFunctionality(CassandraDatabase database), the dependency becomes transparent through out the class
and we depend on a type rather than a single unit
which makes it a bit more robust if we want to reuse it
lets say with another instance of that database class which is configured differently
it does sound a bit nerdy and useless, but much about good software practices has turned into writing code that is extendable to the degree that we can change it without causing the entire system to fall apart
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Hello everyone, I have a question regarding packets
The "minecraft:register" and the corresponding "unregister" channel
Do they actually have an effect inside the server?
Or are they for me to query?
Its only used to register custom channels if both parties support it
Yeah I read every single source I could gather
Several forum entries, this entire Wiki and even the Dinnerbone posr
But it's still quite unclear to me what's actually happening
So is this some sort of handshake?
Nope. Just a normal channel where you can send packets which tell the other party that you want to register a new channel
and that it should listen to this new channel for packets.
But this has to be supported by the receiving side. Which is not the case for the notchian client.
Wait let me double check on that last part
Yes of course, if either doesn't support it, packet sending would be useless to begin with π
I am just checking on the semantics
If my client sends the registration with the channel name I want
How do I respond on the server
Do listeners listen on the register channel so I can act upon it and send a corresponding registration packet back?
What do you guys think the best approach for this is:
I need to generate a randomized 6 character code (made from numbers and letters) often, but I also need to make sure it's unique. How do I ensure that the code is unique in the most efficient way possible?
I was thinking of just generating a code normally and if already exists in a giant list of used codes, generate another. But this doesn't sound like a good idea in my head
(When a code is generated, it'll expire after 2 minutes, in case you're about to say that I'll run out of possible codes eventually)
Yeah but the client has no logic for them. So it doesnt matter if the notchian client acks the registration because its useless information to him anyways.
There has to be a mod that does something with it on the client
This is where Fabric or Forge comes in
That doesn't matter
I am asking in a mod context, obviously the client won't care (if nothing tells it about a new channel)
Either one of two has to send the register message
All I was wondering is if I send this registration packet, how do I recognise this?
Do I add a listener to the register channel?
If one sends a register, they both understand it exists and can send outgoing or receive incoming messages
Calculate the collision probability and multiply by the severity of the collision to make a decision on that.
huh
For Bukkit, we have a messenger class that can register an incoming channel
collisions?
Ah, so either sends it and it's automatically open for both
Yes
Ah, that's where the Dinnerbone post confused me with "one sends it, the other does the same"
So I just need to do it one way
oh boy
Do you allow only small letters?
Doesn't matter
I could do small letters only too
It doesn't even have to be 6 characters- I just don't want it to be a UUID, I need the code to be easily copy/pasted or legible to any user if you know what I mean
Ok so then a-z A-Z 0-9
= 62 variations per slot.
Your word is 6 slots long meaning there are a total of 62^6 cominations
Which means you can safely generate them for hours without a collision
okay
so i have a reasonable way to say that i'm too lazy to add some protection for that
thanks
Thats also what UUIDs do btw. They are so unique that once generated are very safe
So i would just use UUIDs...
^
its a code someone is gonna copy paste somewhere
Which code isnt?
I mean like
UUIDs just look ugly
and not very professional (to see in an application)
What...
UUIDs are used in enterprise applications all the time
its the gold standard for ids
it looks very ugly to non-programmers i could say
Its as professional as it gets
Oh and, now when I send this from the client
Will the server register the channel for me or will I still have to use registerXPluginChannel?
Ah i see what you mean
what I'm working on right now is supposed to be a code
that end users will see
and use
You dont want ids you want something exposed to the user
mhm
You'll have to register an incoming plugin channel from Bukkit
That's more or less a Bukkit thing though
Hmm ok, that begs the question why I even need to send a register packet then if I register the channel myself
Right, you don't. What modding framework are you using on the client?
Fabric and Forge handle those both for you
Here's an example of how I handle client-server communication for VeinMiner:
https://github.com/2008Choco/VeinMiner/blob/master/veinminer-bukkit/src/main/java/wtf/choco/veinminer/network/BukkitChannelHandler.java
https://github.com/2008Choco/VeinMiner/blob/master/veinminer-fabric/src/main/java/wtf/choco/veinminer/network/FabricChannelRegistrar.java
(this being Bukkit and Fabric)
I am planning to target both of them
So I guess I will just ignore the register/unregister packets altogether
Yeah. With Fabric they use the ClientPlayNetworking class to register incoming listeners, and you can use that same class to send outgoing messages
Forge has a whole network protocol API around it as well
(I actually really like and prefer Forge's API)
So I guess the way I will do this
Is trying to send a packet from the client to ensure the Plugin is installed and if not, the mod is internally disabled
And the other way around, it's probably simpler
I don't know though, the server will still send a packet though to the client?
And be it into the void of a notchian client?
I guess I could send an ACK from the client to queue available clients so the server knows to where it cam send messages
How can you spawn a villager with a profession but not allow trading with the villager?
cancel the interact event
Ah ok
How do i let my armorstand float on water?
Because if i put gravity on false i cant ride it anymore..
put it in an invisable boat π
How can i do that?
spawn the boat
How can I relocate the dependencies of my dependencies? With maven
then call EntityBoat#setInvisable(true);
Thank you! :D
currently I put in my project the dependencies of my dependencies and relocate them but it is endless because they all have dependencies
I already have this link open but it doesn't help me
What part do you need help with?
I would like to know how to relocate an entire depencency
i have this
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.1.2</version>
</dependency>
and this
<relocation>
<pattern>net.kyori</pattern>
<shadedPattern>${project.groupId}.${project.artifactId}.dependencies</shadedPattern>
</relocation>
but adventure dependencies like kotlin are not relocated
i've been looking for days and I can't find a solution
Simply add the other relocations
lol, adventure has multiple dependencies
and each dependency of adventure has a lot of dependencies
it's endless
Yeah
manually it takes me 2 seconds to move the dependencies into the jar
there must be an option or something I did wrong in the pom
i'm not sure about the pattern here
How to check if a player put a block on the grass or in the water?
Listen to the block place event and check where it was placed
Yes, but, System.out.println(world.getBlockAt(loc).getType().name()); send me a block type, I placed, not water or grass
where Location loc = e.getBlockPlaced().getLocation();
declaration: package: org.bukkit.event.block, class: BlockPlaceEvent
thanks a lot
Players put it from out of water or player puts it in water
I just want to prevent players from destroying water and grass by placing a block.
and the getRelative(BlockFace.DOWN) to see if its placing on grass
I can get block data after click in PlayerInteractEvent?
For blocks like trapdoor, door, flower pot etc
One tick delay
Its always one tick delay...
It is good but I must check it instant and this is my problem
Instant means the block has not been used yet
Yea I know but I must check it
For Speed Builders
?paste
Hi folks, does anyone know any code for an ItemStack I've made, I need to make it so that when I change the item's lore, name, or attribute, it also updates it in the player's inventory without having to have it again. Does any of you know how to do it?
Then just check:
if pot empty -> right click with flower -> see if it's the flower you want
Speed builders check if buildings is perfect copy after BlockPlaceEvent and BlockBreakEvent but should check building is perfect after PlayerInteractEvent
So for all other blocks I must use other implementation? Trapdoor, door, flower pot etc?
Use pdc to contain all stacks. Then check if the item has that pdc if it is change all the qualifications. And reload
hey
Yeah or do what smile said
is everyone know how to spawn Entity player using bukkit api??
Thank you!
World#spawn
impossiable
Not really
hmm how to make nms entity have mob AI?
Nope. Minecraft has no "Player" entity which is disconnected from a client.
You use goals
like it has player model but it is chicken
This will be really hard because you cant just spawn a player with ai goals.
Yeah add all chicken goals to the player entity
ok thank you
let my find about that
There is ofc more work than that
Since you need to detach the entity from the player connection
Its way easier to just use LibsDisguises and disguise a custom entity
Or just use Citizens
Yes it can fix all stuff
bruh citizens api?
I found znpcs api better
hmmm
i just want to make my npc can attack player and can be attack it look so hard
Just realized. hashCode actually uses the jvm memory address if no implementation is given.
So my take was still technically correct.
manually it takes me 2 seconds to move
how do i do 2 things in one case ->
here is what i want to do
case "up_right" -> worldY -= speed, worldX += speed;
i can only change the world y or world x but i need do to them both at once and making 2 case statements for "up_right" doesnt work
not using lambdas case statements fall through
Hey, what are InventoryView properties?
Alright, so, I need a way to differentiate between inventories. I was thinking of using some sort of id. What would be the best way to do this?
like inventory you created with your code ?
add inventory [name] = before the inventory code part
how can players do that? Rename an anvil?
I didn't know :o
That's actually cool. I might use it as a hidden easteregg name then. Thanks
i see so you can make a inventory with the same properties use p.getname and save the inventory data for that player and load it every time the player uses /inv or something
hi. Is there any way to disable when interating with redstone ore it hngs to a glowing stae? it messages up my erver.
p is nice and short, you can change it easily as well
Compare the inventories yourself
No
Itβs not nice
We should be able to know what the variables are without looking at the code
Same goes for methods etc
help lease..
E could be anything
well if you read the code p is means player and its just shortened
Exception event etc
You shouldnβt need to read the code to know
well if I do Object obj = .... then it isn't a problem
What if you have a huge method and you use p as a variable
help
Should we read through that whole block just to know
i think that's being too specific i mean how many people dont think Obj is short for object
Yes I mean like in Java
Iβve tried disabling player interact event for red stone ore
But doesnβt fix it. At all
There should be a state for the block
hello ^^
Does anyone know how to avoid the shaking of the
ArmorStand when being teleported?
https://www.youtube.com/watch?v=M1rERVWm2Oo
Is there a way to create a mob with a nametag that has multiple lines? I've tried working with scoreboards but that doesn't work on mobs apparently.
Cannot resolve method 'setScoreboard' in 'LivingEntity'
have you tried using array's ?
Arrays? How would that work in this case?
β¬οΈ
@cedar yoke
public void someMethod(final Plugin p, final Player p2) {
do something...
/* 300 lines of code
Hey this isn't working.
do smth with p and p2
*/
}```
How would anyone know what those are
Without looking at the whole method
can you send me you code
sure
any idea how to do it? I just need the block to stay the same. It fucks with my plug-in when it updates
It's basically the scoreboard copied from some spigot thread that explains them but swapped the player with my custom mob, which is a Zombie.
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard board = manager.getNewScoreboard();
Objective objective = board.registerNewObjective("showhealth", "health");
objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
objective.setDisplayName("/ 20");
yeti.setScoreboard(board);
I'll need to display a custom variable but I'll figure that out with the thread if the displaying works
Not sure. You could probably have a scheduler that sets the state when someone clicks on the block?
Something like that
I tried but like
Every time that the block updated at all to a new block it fucks it.
Well, what do I return in getInventory() then?
List<String> name= new ArrayList<>();
name.add(" ");
Arrays.asList
What are you trying to achieve? Checking your own custom inventories?
Yep
Oh, thanks
public abstract class InventoryBase {
//define your inventory
private final Player player;
//getter etc
}
public class InventoryData {
private static Map<Player, InventoryBase> INVENTORIES = ...;
}
Something like this
I prefer doing it like this
Doesnβt matter in this case
Yeah, don't store the whole player object in a map
Not really
Just store the UUID instead of the whole player, you can get the player later on with the UUID anyway
Yep
Itβs removed when they close the inventory
How were we supposed to know that
It's still better to store the UUID instead of the Player object though
Sure
Anyways that how custom inventories should be stored instead of using inventoryholder
You might prefer them but itβs still not intended for that
You may use whatever you like
Because why would you store a reference when it doesnβt exist?
"Anyways thats how you re-invent the wheel"
You can still get an offline player object
Iβm not reinventing anything
with an UUID
But the inventory doesnβt exist anymore
But itβs still not intended for that
It still works without any problems though Β―_(γ)_/Β―
may someone help me? :(
Packets. Use packets.
I have seen that armor stand lag so many times now
Heck, I've even once made a gravity gun mod, and I had to use packets because of the lag that the normal teleport method has
i need an idea, i dont need a code, btw i just teleporting the armorstand to player location with an asynchTimer :c
i do it
new BukkitRunnable() {
@Override
public void run() {
teleportArmorStand();
}
}.runTaskTimerAsynchronously(armorStandNMS.getPlugin(),0,1).getTaskId();
public void teleportArmorStand() {
double y = maxY - teleportValue();
Location entity_location = entity.getLocation();
Location location = entity_location.add(0,y ,0);
clientbound.teleport(location);
teleportEntity(clientbound.getHandle());
}
private void teleportEntity(Entity craft){
ClientboundTeleportEntityPacket teleportEntityPacket = new ClientboundTeleportEntityPacket(craft);
sendPacket(teleportEntityPacket,clientbound.getPlayer());
}
clienctbound.teleport(location) =>
public void teleport(Location aum){
try{
armorStand.getClass().getMethod("teleport",Location.class).invoke(armorStand,aum);
}catch (Exception e){
e.printStackTrace();
}
}
Well you have to manage it completely, that is on restart, as well as spoofing
Hence why UUID is almost always better
Though I suppose a WeakHashMap might be a fair choice
wtf
reflection? for this? is this a joke? π
all versions :')
what class is "armorStand"?
Also MethodHandles 
NMS armorstand?
Object
but what class is it actually?
CraftArmorStand
CraftArmorStand? NMS Armor stand?
oh okay
yeah but
erm
why do you need a CRAFT ArmorStand to teleport it?
teleport is exposed in the Entity interface
bad named xD
.-. i'm using NMS
Entity myArmorStand = ...;
myArmorStand.teleport(...)
no, you use craftbukkit code
org.bukkit.craftbukkit is not NMS
no xDD
this is also a joke right?
org.bukkit.craftbukkit.VERSION.CraftArmorStand
you have a CraftArmorStand, get the NMS entity with getHandle(), then get the BUkkit Entity again with getBUkkitEntity()?
lol
Yeah you're trolling lol
sorry I didnt realize
just joined this chat a minute ago π
sometimes people actually do stuff like this so I wasnt sure lol
do you know about "org.bukkit.craftbukkit.v1_19_R1.entity.CraftArmorStand " ?
sure
craftArmorStand.getHandle() its
xd
its not the org.bukkit.entity.Entity
Sure, comparing uuids might be more viable but thatβs not what I was talking about
yes, org.bukkit.craftbukkit.v1_19_R1.entity.CraftArmorStand#getHandle returns net.minecraft.world.entity.decoration.ArmorStand. But org.bukkit.craftbukkit.v1_19_R1.entity.CraftArmorStand implements org.bukkit.entity.Entity and that exposes the teleport method, so you can treat any CraftArmorStand like a normal bukkit entity
Yes, but I was just trying to imply the additional complexity Player as K type will provide
now i understand you
I mean it doesnβt really
It does
no need to use CraftArmorStand when you only use interface methods
btw i'm doing that here armorStand.getClass().getMethod("teleport",Location.class).invoke(armorStand,aum);
Because Player objects are much more fragile due to the state they need to encapsulate
yes, that's totally unneeded
you can just do armorStand.teleport(aum)
then cast it to org.bukkit.entity.Entity
Stop instancing it as an Object then
if you want to go "for all versions", then using org.bukkit.craftbukkit... is the opposite of what you want lol
so net.minecraft.world.entity.decoration.ArmorStand. But org.bukkit.craftbukkit.v1_19_R1.entity.CraftArmorStand into org.bukkit.entity.Entity ?
the teleport method on org.bukkit.entity.Entity has been around since FOREVER
I will try to explain:
EVERY org.bukkit.craftbukkit.v1_19_R1.entity.CraftArmorStand is also a org.bukkit.entity..ArmorStand
i didn't know it was possible
I still think you're trolling, or maybe you watched a tutorial on youtube that's trolling
too many tutorials and code suggestion from the IDE
noup, just think was different lol
?paste your whole class pls
You should always use the interface classes
they will work in all versions
no need for reflections and stuff
and an armorstand should (almost) never be stored as plain Object
but simply as bukkit (not craftbukkit) Entity or as bukkit ArmorStand
everything else is just making stuff overly complicated and/or slower
but then i should do for all versions to get compile well
holy shit
?paste
I made a plugin for myself that has a player death event listener. It has a config.yml file but i want to add a "β€οΈ" emoji to show how much health the killer had left. But the plugin's default encoding cannot show that and shows some other random thing. How can i fix this?
be sure you created/saved the config.yml with utf8 encoding
Everyone trolling you alex
Hey, rookie question but, does an item update in an inventory when you set the ItemMeta?
iirc no
Managed to fix it by using the unicode number (\u2764)
?paste
Hey, how can I show a block to only certain players?
The other players cannot see it
Player#sendBlockChange
Ah, so no need for packets
yeah, no packets needed for this since 1.13 or so, I think π
?paste
you can really improve that
how
early returns
https://blog.frankel.ch/even-more-readable-code-without-if-else/
Check out this.
A couple of years ago, I wrote a post focused on how to avoid sequences of if-else statements. In that post, I demo several alternatives: the usage of proper OOP designmapswhen thereβs no return, switch statements in a case. Recently, I stumbled upon a slightly more complex use-case. This post describes it, and details what additional options ar...
https://paste.md-5.net/atuwexorag.cs
This is some code for a mob I'm working on but line 70 and 77 are just not doing anything. The variable sh is fine when I print it but it doesn't change the nametag.
Early returns are best practice, however they are odd to get your head around. You are instinctively thinking "under what conditions SHOULD my code run" not "when should my code NOT run".
yeah math hard there π
what does the divisor do
?
why dont u just store the value
too many if else statements to parse a double by iterating over the chars
so made a dedicated class
with some validation too
kinda
u could do smth like
StringReader reader = new StringReader(source, 0);
String dstr = reader.collect(/* condition */ c -> isDigit(c) || c == '.', /* skip */ c -> c == '_');
double d = Double.parseDouble(dstr);
current logic to modify operands value
lol
how tf
a ghost
hmm lets just not try to overoptimize things
does anyone know how to like give something if a player kills someone else
cuz apparently playerDeathEvent doesn't work
how do I add a server resourcepack to custom gui
This channel now called Development showcase
we do that sometimes
What's that math project thing about ur working on? @tardy delta
can I create custom gui, with custom model data and custom slots? it should look like your own inventory, but of another player
.
I don't know, I know it should look something like this, but with cobblestone background and on the right shield and sword I think? (can I send pic in DMS?)
u can send here
I can't, I'm not verified because no staff wants to unverify my account on spigot
sent
what packet is sent to the server when the client gets info about it and how do I modify the info it sends from the plugin?
wait, can't I just retexture the chest gui?
yes
those are just hidden slots
Is it from Origin Realm?
mcc
making these with mods are possible
uhh?
I think if I use normal chest, retexture it using resourcepack, an put the head as head item, and on the right the shield and on leaft armor
With resource pack too
Info about about ?
it refers to server
So what info ?
The server sends a lot of info
motd, player list, player count... info you can see on the server in the server list
Yes you can change it, use a packet wrapper like ProtocolLIB and change those fields
and how do I change it without a wrapper?
so?
declaration: package: org.bukkit.event.server, class: ServerListPingEvent
Yes you can do it
But you'll need to do some InventoryClickEvent listening to avoid them using some slots
thats no problem
hmm and is there a way to add extra info for non-clients?
why would you use the ping format for non minecraft clients π€
a discord bot for example?
yea but why not just expose a proper API for that from the server
instead of hijacking the minecraft port
idk I thought I'm too lazy to make something by myself so I'll just modify the existing
Making that will break the minecraft protocol
uh why?
As you read, it's strict
The client reads specific fields
Adding a field or removing one will consider the server as broken
break-your-server plugin
hello ^^
Does anyone know how to avoid the shaking of the
ArmorStand when being teleported?
https://www.youtube.com/watch?v=M1rERVWm2Oo
new BukkitRunnable() {
@Override
public void run() {
teleportArmorStand();
}
}.runTaskTimerAsynchronously(plugin,0,1).getTaskId();
public void teleportArmorStand() {
double y = maxY - teleportValue();
Location location = entity.getLocation().add(0,y ,0);
teleport(location);
teleportEntity(((CraftArmorStand)armorStand).getHandle());
}
private void teleportEntity(Entity handle){
ClientboundTeleportEntityPacket teleportEntityPacket = new ClientboundTeleportEntityPacket(handle);
sendPacket(teleportEntityPacket,player);
}
public void teleport(Location aum){
armorStand.teleport(aum);
}
If you're still lazy which is great but not too great, just encode some message using chatcolors in the motd would do the trick
finally free from chat reporting
just don't have servers
Can't you make the armorstand sitting on the player ?
why are you teleporting AND sending a teleport packet?
nameTag get bugged into the player :(
Doesn;t matter. you don;t need the packets at all
you are calling Bukkits teleport, you don;t need any NMS
yep if i dont send the packet the armorStand dont change the position in the client
:(
yes it will
i did it and it doesn't :C
It will unless you did something wrong. It can;t fail to update the client.
I will test
uh does anyone have experience using git, say I changed 5 files from a repo from my knowledge I should create a pull request and not just commit them right?
uhm do I have to wait for his problem to be solved to post my problem?
but dont I need to make a whole branch on their repo to create a pull request? π€
ArmorStand entity_armorstand = new ArmorStand(EntityType.ARMOR_STAND, (Level) worldServer);
armorStand = (org.bukkit.entity.ArmorStand) entity_armorstand.getBukkitEntity();
//so i send this packets
private void packetsCraftItem(Entity craft, int id) {
ClientboundAddEntityPacket clientboundAddEntityPacket = new ClientboundAddEntityPacket(craft);
packetMetaData(craft,id);
sendPacket(clientboundAddEntityPacket);
}
If it's not your repo, you have to fork the repository and commit push to your fork. All the changes made from a branch can be converted into a PR to the original repo (so it's recommended to create a branch in your fork per PR)
Do you want the armorstand to be visible only by one player ?
public class HandlerOfEvents implements Listener {
@EventHandler
public void death(PlayerDeathEvent event) {
if(event.getEntity().getLastDamageCause().getCause().toString().equals("end_crystal")) {
event.getEntity().sendMessage(event.getEntity().getKiller() + " Killed you with an end crystal");
}
}
}
I'm trying to detect whenever you die from an end crystal and get whoever killed them
oh thanks ill give that a try
is there any way to do that after I just git cloned the repo and edited it
You should not create a Bukkit Entity then. Use directly a NMS ArmorStand
And ?
I recommend finding tutorials online. There are plenty of them that provide step by step solutions
First, debug the death cause and die from an ender crystal
Then when you find the cause name
What context ?
but how do I get the killer?
eh nothing is easy with git π
You'll have to destroy few repositories before starting to understand x)
^
should I do this?
@EventHandler
public void death(PlayerDeathEvent event) {
event.getEntity().sendMessage(event.getEntity().getPlayer().getKiller().toString() + " & " + event.getEntity().getLastDamageCause().getCause());
}
smh
getKiller returns a Player and can be null
now i'm working directly with NMS but still teleporting with dealy :(
brb
there is no way to improve it, except sitting the entity
back
or maybe teleporting the armorstand on the playermoveevent but I'm not sure about that
but name tag display bad, also if the player go into the water the armorstand is disassembled
then how do I get the killer
number ?
yeah like
i think they mean the id
declaration: package: org.bukkit.inventory.meta, interface: PotionMeta
you'd use this method
api 1.8 π
bruh
is there any way to use a plugin coded in the deobfuscated spigot(nms)?
yeahhhhhh :p
?paste
@long zephyr The stand teleports and moves just fine using only Bukkit teleport. It will only update location 20 times a second as thats the max tick rate. https://paste.md-5.net/ofejiwozod.java
pot.setMainEffect(PotionEffectType.HEAL);
What version of spigot do I need for my plugin to work for all versions of minecraft?
You build against the oldest version of Spigot you want your plugin to work on
and set the API version in the plugin.yml if you are going back a long way so it can understand legacy Materials
I want the plugin to work from 1.8 to 1.18 which api should I use more recommended for a 1.8 server?
if you want it to work on 1.8 then 1.8
ah a switch doesnt work on a null value :/
not at all or will it fall through to default?
java 18 supports it
by not using inheritance
on java 17 smh
can i do something more with actionbar than just sending it without any params?
(i mean stuff like title that has fade times)
Well what you want is composition
if you want to pass Test2 to Test as a form of "parent"
or implement cloneable
no
Unless you mean something really differently, the sematics of such code cannot be replicated at all
Yeah, then make super have a constructor that takes in an instance of itself to copy the values
how would it not work?
If you are a fan of reflections you could use that, but I'd not use that
And I am sure that lombok has an annotation for that, but similarly I'd not do that
how can I display text above players head. Like how much hearts this player has or something like that
its not about liking but also performance along other things
I assume through scoreboards but I never tested that
not slow, just slower
:o
ty i'll check what you did, ty <3
use invisible entities π
Does TextComponent exist in 1.8.8 spigot?
Should I import it through net.md_5.bungee.api.chat.TextComponent or java.awt.TextComponent?
ohh wait i can't show action bars in 1.8?
no it does not
java.awt.TextComponent is in the awt package - which like the JFX and swing packages is strictly forbidden to use in spigot
While you can use it, it is likely that you shouldn't
good, by any chance can you change the name of the spigot website?
if so, how would it be?
Hmm. So, how do I show action bars in 1.8.8?
not really
with reflection
good ol' reflection
does anyone have a clue why Inventory#setItem doesnt remove the item from a slot? java if (event.getClickedInventory() instanceof AnvilInventory inv) { ItemStack clickedItem = event.getCurrentItem(); if (clickedItem != null && clickedItem.getType() == Material.DIAMOND && event.getSlot() == 2) { event.getView().setCursor(clickedItem); inv.setItem(2, null); } }
Or am I supposed to donate for the name change? If so, where did you donate and to whom did you inform?
Hi, im having trouble with my teams/scoreboard
can anyone help
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
yea i believe for 10 bucks you will get permission to change your name. its on the homepage of spigot
donations are processed manually, might take a few days
set it to air
that's weird
i mean its the output slot of an anvil i dont think it really likes that
Ahh anvils can be tricky
so remove(clickedItem)
ye
idk what ur tryna do but i think you need to use AnvilPrepareEvent
and use #setResult
cant
Might have to remove it every tick
well wat u tryna do
Or you can't, idk
im adding a second item to the output slot after you take the first one out
Anvils are weird
its janky ik but i need it to work
I think u have to also replace the input slot then
thats what i thought too but how am i supposed to do the text input
could use chat
or make a completely custom anvil block and use that for repairs, and the default one for combining and renaming
cause i just need this for repairs
can i implement vault economy without downloading external plugins like essentials?
yes
i added vault api and it still throws Disabled due to no Vault dependency found! (i have depend vault in plugin yml and vault installed), how can i fix that

