#help-development
1 messages Β· Page 1970 of 1
even Java's API's for futures creates threads
unless you are confusing child threads with daemon ones o.O
When the chunk unloads then the entity object is invalidated.
You should usually not have hard references to game objects anyways.
If you want to tick it again when the chunk loads then you should save its
state in the ChunkUnloadEvent in its PDC and load it again in the ChunkLoadEvent.
can do it for y
u can do it urself
cuz I can do it
and im not that good (not as good as most people here)
thanks! didnt know there where events for that!
Distributing work over multiple ticks is the more correct description of the word async than using threads is.
You can have code that uses threads that is not asynchronous. You can have asynchronous code that does not use threads.
Async is not interchangeable with parallel/multi threaded.
But tell me if you find other sources on that topic.
well technically true since the definition just means not occurring at the same time, however these days asynchronous in how most use it is generally synonymous with multithreading.
It literally just hacks worldedit tasks into smaller pieces and computes N of those over several ticks.
https://www.spigotmc.org/threads/buildtools-runtime-exception.546207/
Can you help me with this
How does it perform things async but they happen in main thread
that doesnt make sense
it does when you know the definition
oh then im just stupid
but as I also said, these days the definition of it is changing
In the broader sense yes. Especially in the spigot community. But i would still try to separate them just for the sake of exactitude.
"You can have code that uses threads that is not asynchronous. You can have asynchronous code that does not use threads." How?
Oh right, u can use threads and the tasks happen at the same time
Think of data transmission with two devices on each end.
Each device has its own clock and the transmission of data does not have to happen in sync.
This makes the transmission async but not parallel.
you can have two threads that are synchronized
async is splitting tasks into several tasks
then performing seperately
with a time in between, that isnt too big or too small, so they do not lag the machine
is that correct
Help me
but should be in milliseconds
No. But splitting tasks into several tasks then performing them seperately is async.
yep better stated then what I was going to type
the time between the tasks isn't the relevant part
thats what i said but removing the white space
No its not
oh the time thing is wrong
just as long as the tasks are not being done at the same time is what is relevant. AKA the definition of asynchronous is not occuring at the same time
Async does not mean that you split something into little tasks and compute them separately.
But splitting something into little tasks to compute them separately is an async action.
An apple is a fruit but not all fruits are apples.
so yes, 7smile7 is technically correct
private void a(){
//shit ton of code here
}
//into
private void b(){} private void c(){} private void d(){}
//then
private void a(){
b(); sleep(10) c(); sleep(10); d();
}```
imagine sleep thing is scheduling
and not pausing the whole thread
will it be what you mean
or just use a loop that pauses for a bit of time before it goes through the loop again π
would be the easier way to demonstrate that
1.8 is outdated and unsupported. If you have issues with that then you need to look in ancient forum posts from half a decade ago.
for(int i = 0; i == 100; i++){
if(i == 33){
doTask();
}
if(i == 66){
doFirstTask();
}
if(i == 99){
doSecondTask();
}
}```
smth like this?
probably need to use an older version of buildtools, or you need to update git and have too old of a version. going to be one of those things. I don't think it would be an issue of too new of a version of git though π€
even if the difference is 1 millisecond?
would technically meet the definition of not occurring at the same time, if the task completes in a millisecond
ive been trying to make a so-what blank spigot plugin but doesnt ever seem to work. ive used Maven for the dependencies, pls help
time to make a AsyncMethod class, with a run method, and a method to check if method is done
B)
basically async is breaking up a task into smaller pieces to be done over a period of time
as long as the those small pieces are not done at the same time
could you use your own threads instead of using the asynchronous tasks?
Show what you got so far π
Mainly your pom.xml and tell us how you build plugins.
yes you can
what is better, multithreading or async
depends on the task
Sounds like a completable future with extra steps
oh right that exists
perfect
so what i should do for max performance is to
make an async task
and only do the next task
if that task is .isDone()
if not then i have to wait
If you want to know how to split workloads and schedule them async i would recommend this thread π
https://www.spigotmc.org/threads/guide-on-workload-distribution-or-how-to-handle-heavy-splittable-tasks.409003/
would thread.join() make the entire server wait for the thread?
what the fuck bro
crap
Joining will block the thread it is called on
ur seriously a wikipedia
well if you want performance, probably better off spinning up a separate thread for that asynchronous task
If you want to sync with the main thread then you should use the BukkitScheduler
so for performance, multithreading combined with async
probably better to sync to a method then the whole thread lol
but yeah scheduler is the better way on that one
Further down in this thread i talk about starting a new thread and then using the scheduler to get back on the main thread.
https://www.spigotmc.org/threads/guide-threading-for-beginners.523773/
quite a few of us are quite knowledgeable in many areas π
so im kind of a developer who doesnt have a pc to develop anything so heres my pom.xml -
Ill take a read, thanks
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.itzzbuoyy.myplugin</groupId>
<artifactId>MyPlugin</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<includes>
<include>plugin.yml</include>
</includes>
</resource>
</resources>
</build>
</project>
In spigot very often using another thread is not possible. So if you do something that needs the main thread then
you need to find a way to do it async on the main thread.
Threads should mainly be used to access IO or compute something expensive.
?paste
ok!
What does that even mean? Do you write on your smart fridge?
Donβt you
I write on it all the time o.O
anyways what I was going to say in response to that is really all you need is a smart phone or tablet π
gone are the days of needing a pc for programming XD
on android
some1 know why the armor stand is dont rotating to my direction?
well they are not necessarily gone, just no longer a strict requirement
Programming plugins without the ability to run the game sounds painful though
This is the alternative to joining.
You start a new task in the BukkitScheduler and the
runnable gets executed when the next tick starts and all runnables are ran.
what a nice illustration you created
i used to have a pc but it isnt in the shape to be used now. can be called d3ad pc
fancy π thanks
why sometimes the thread is more big then others?
Because the tick time in spigot varies a lot. Sometimes a chunk gets loaded. Entities get spawned. Someone dies in a world and the world gets unloaded etc.
The tick time is quite volatile.
ah sure
but one doubt
a player can right-click, send a packet to the server that the player clicked on, but it will happen that it was made after 20ms, but if I get this packet in an async scheduler I make it make that packet more fast?
is this ok?
Your phrasing is a bit odd. But yes packets are received parallel to the main thread. So you can listen for incoming packets at a frequency that is higher than
20 tps
I would need to use the lib protocol to be able to receive these packets, right?
well seems 7smile7 has it handled from here so off to bed it is for me.
You can also inject your own packet handler into the netty pipeline. But protocollib is simpler.
Wait arent you german too?
Lol, no
I thought so lol
I am not even remotely close to having german in me either XD
XD
7smile7 have you know how i can fix that
i have asked u before
my lineage is the French one sadly, but I live in the US. I just don't have the same sleep schedule as everyone else in the US π
Same for me here. When my semester break hits im all over the place. ^^
Well then good night i guess π
also you are correct for most people they should use API's π
I would have to read the thread again. Not a big fan of tinkering with quaternions or euler angles.
Salut c'est ici que je peux mentionner des soucis avec spigot?
I think you should take a look at the rules again π
but the problem is not that entity and because when I spawn the entity does not move towards me, but continues to move the method of making the entity to me
but if i move it sharply it rotate, it's very strange
Also this is not for spigot related problems but only development support
If i understood you correctly
oh okay :/
on the site I don't know how to create a topic :/
What problem do you have? You can always ask in #help-server
ok
pls help my plugin doesnt work its a blank one
How do you compile?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
what
well your issue is going to be compiling obviously
android JDK isn't exactly the same as Java JDK
Ok so the first thing that jumps to my eye is your java version. You should use java 17 when developing spigot plugins.
What do you mean by "blank"
so by blank i mean the plugin doesnt have any content, it just has the onEnable and onDisable
plugin.yml?
@lost matrix https://youtu.be/9pamCIgnQxI
plugin.yml
do you see the ''dir'' on action bar is changing but the armor stand dont rotate
just when i move ungly
Intellij Mobile when
so your coding on mobile? or is this a pc running the android operating system
im coding on mobile...
Then rotate it right after spawning towards the nearest player? What exactly is the problem? π
what... and your putting the plugin in a java server not a bedrock one right? Minecraft java is pc
no look
private void makeLook(ArmorStand armor, Player player) {
final Location loc = player.getLocation();
final Location eloc = armor.getLocation();
final Vector dif = getDirection(eloc, loc);
dif.setY(0);
armor.teleport(armor.getLocation().clone().setDirection(dif));
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("Β§cDir: x - " + dif.getX() + " z - " + dif.getZ()));
}```
if you see is calling this method everytime on a thread
are you getting a specific error?
i just want when the entity spawn is alright rotate to player direction
console keeps telling couldnt load <plugin name>
same if the player move slow
hold on ill get a log file
I see...
if you want use the code
Hm weird. What version are you on?
What do you do in the PlayerMoveEvent?
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml```
do you not know how to read errors?
1.12.2
nothing?
like i sayed im using a thread
invalid plugin.yml -> invalid CEN header (bad signature)
You need to fix that
Then why does it only rotate if the player moves? Makes no sense.
i do, but i cant find any errors in the plugin.yml
is this i want know
ok, how do i do that?
No idea. Never coded on android or even heard of your IDE ^^
I'm so confused how you can code on mobile without going insane and wouldn't the slightest idea how to fix anything wrong sorry
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Bukkit.getOnlinePlayers().forEach(player -> management.showInfo(player));
}
}, 0, 1L);```
other thing
Ohboy
if it is a hologram like they said in the beginning it will always rotate towards the player
If you want then you can shorten that to:
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> Bukkit.getOnlinePlayers().forEach(management::showInfo), 0, 1);
no boy
is a aremor stand
ah well you said hologram in the beginning
ok ty
anyways that is obviously my queue to leave now XD
This looks like it needs to be split in at least 3 methods
Anyways this is nothing someone could help you with. It is probably some oddity within your code or with the version you are using.
I cant find anything in your code that would cause this.
this sad
All you can do is debug. Everything.
so if I read everything correctly, the issue is the armor stand is rotating?
if that is correct in my understanding, then the issue is going to be in the locations
player location is only ever updated when player moves
The issue is that it is not rotating instantly when it spawns but only if the player moves a bit
sounds like a client side glitch
but also, players moving also cause updates to happen too
Newer versions have a method to assures that the entity is spawned with the right metadata right away. Not sure if 1.12 has that
hm
I don't think 1.12 does
in versions before 1.16 I recall that metadata packet is separate
Should still be a separate packet. But spigot only sends the metadata for spawned entities so one tick later.
With this method its sent right away
so what i can do
Debugging. I would start with calling makeLook a tick later.
a tick later using a syhnc run task later?
Sure. There is not really an alternative to running something a tick later ^^
yeah debugging is going to be your best option here. I would even test with more the one client too
to rule out client causing it
what
Every tick.
u didnt show how u did it
u prob would want to add that its running every tick, for no brains like me who got confused
your math is incorrect btw
This thread would need some overhaul either way...
i cant understand so mutch words
Its kinda old and i wrote it about one year after i touched my first programming language
?
and in here
We are talking about something else XD
there is no constructor
@AllArgsConstructor annotation from lombok
the recommendation is that you add debug code to output to console data. Ideally output every step of the way from when the entity spawns, to when you update it and when player moves.
I have a feeling that either it is going to be a client side thing or it has to do with how you are using the locations
but hard to tell with limited view in terms of code though.
and u didnt show how u used ur code
and if you use the setheadpose method
Its more of a general proof of concept guide rather than code you could copy.
you make a new object of the PlacableBlock
most of us here well some of us who are knowledgeable generally don't spoonfeed and rather give proof of concepts as it forces you to learn it either way to make it work π
then after the loop you make a Thread with the workloadthread class
never wanted to copy it
just wanted to see how your own example works
Ah i see the confusion. Yes. Instead of setType() i created a placeable block (That is the part where i split the workload)
and add it to a queue. Good catch i should add that.
Anyways its a really good guide
BTW, if you make a thread manually
and pass a runnable to it
it will run once, unless you change that
right?
No the workload thread is started a single time when the server starts and from then on it always runs.
You keep that instance of course. And then you just call addLoad(WorkLoad)
And it will get computed when the server has time for it.
changing the instance of the runnable, will also change the thread that has been made out of the runnable???
Might be in the next tick. Might be in 3 seconds.
you have the runnable in your main for example, then on ur enable u make the thread with the runnable, when u add the load with Main.getRunnable().addLoad(load); for example, u added it to that runnable, but the thread has received the runnable without the adding, since onEnable ran first?
Oh wait
Hey so right now I am using the PlayerCommandPreprocessEvent to check for used commands by players. Is there a similar event which also has track of the console?
if you create your own thread, the thread will exit once it is done with the code it executed. That is if there is no loop condition in the code, it will just run through it a single time.
I wish you provided a github for it tbh
People will copy it for sure, but that's nothing of your worries, it's their problem that they won't progress, and on the other hand it will help people who didn't get it since 50% of the example is missing
Actually writing one at this instant
is there a event that can be used to detect when a sculk sensor is triggered by chance?
i just giveup i dont know how fix that
other thing
how i set the entity nbt?
Arent they introduced in 1.19?
1.18 has them and we do have a custom recipe to get them
edit: introed in 1.17
also, figured it out with BlockReceiveGameEvent
It was mostly for to make sure vanished staff didnt get picked up by the sculk sensors we had around xD
Is possible do that?
This seems to do it, can check how they did it
https://www.spigotmc.org/threads/1-8-x-1-18-x-v7-18-0-maven-single-class-nbt-editor-for-items-skulls-mobs-and-tile-entities.269621/
@lost matrix u can use linear processing instead of looped processing too
right?
so u couldve spawned the particles with the first method, the one that waits 45ms between each session of computing
Pose:Head:[90f,0f,90] but doenst have that nbt
Why would yoy want to ro that?
Sculk sensors were in the 1.17 release
same with bundles
but the deque will eventually get empty so uhhh
ig i was wrong
but you can make a method to refill the deque
so in the run method just check if its empty and refill
its honestly confusing, i think ill wait until you finish the github
since there are some missing things
for change the entity head pose
I DONT WANT USE EULER ANGLE
this part is so confusing
it was not explained at all
ive been on it for like 40 mins
i dont get it
Its a bit poorly written. Im working on a better version that makes more use of safeguard statements.
okay
what i get from the code
is that there cant be more than 2 workloads rescheduled
how to make it only work on legs?
meta.addAttributeModifier(Attribute.GENERIC_MOVEMENT_SPEED, new AttributeModifier("extra_speed", 0.4, AttributeModifier.Operation.ADD_NUMBER));
this the current thing im doing to the meta of it
AttributeModifier(UUID uuid, String name, double amount, AttributeModifier.Operation operation, EquipmentSlot slot)
declaration: package: org.bukkit.attribute, class: AttributeModifier
tysm
np
you can use random uuid for it if u want
how
UUID.randomUUID()
that
Why do u want ask
I Just want do It because i cant change the headpose withiut use vrctora
Why wouldnt just use vectors?
Guys I was wondering, does it exists a simpler way to ban a player instead of getting the ban list and updating it?
some create their own ban handling system instead of using vanilla banning
-.-
What are good uses of reflection besides sending a packet on multiple versions
Good uses of reflection? Thatβs an oxymoron
How could I make a player invincible to lava/fire damage without fire resistance, is there any event that is run when a player gets hit by fire tick? Or just something that makes a player fully invincible to any attack
Entity damage event and cancel if itβs for a certain reason
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent, enum: DamageCause
Thanks
I mean it was a valid answer. What were you expecting? The way you described is literally how you add someone to the ban list lol. You get it, and add the player to it. You cannot get simpler than that.
It's still one line. Bukkit.getBanList(BanList.Type.NAME).addBan("name", "reason", null, "banner")
hi choco β€οΈ
that one line could become, one line π Bukkit.ban(uuid, "reason", null, "banner")
is there a way to add a single .class file into dependency? or do i have to make it to a jar first? (am using gradle)
Wat
no
he went to papers discord after xd
How can I make these items that are getting placed in your inventory if you click a red recipe?
Pretty sure this is client side.
100% client side, yeah
CommandSender#sendMessage(BaseComponent...) is deprecated, i found the one using Identity, however idk how to use it
Pretty sure you can use Identity.nil() (iirc)
yep
why does Damageable#setDamage(damageableMaterial#getMaximumDurability() - 1) break the item
not really
π
you already break instantly in creative
also how tf is that even a function
block break event is called after the block is broken
i believe both
but you should still try it and see
how do I save a config file to the plugins/plugin directory, I'm using this.saveDefaultConfig() but the directory isn't appearing
lol
how can I put nbt in a tileblock in 1.18?
hm?
let's say i have a chest
im not sure if you can add custom data to them
and i wanna put some nbt tags into it
use PDC not nbt
i am trying to use nbt because i wanna test a concept
hold on lem,me get the video
what r u trying?
https://www.youtube.com/watch?v=0NxJWN7gGHI&t=428s if you go to 6:25 you can see how the hopper treats the spawner as a chest
This Minecraft glitch allows for FIVE pig spawners to generate?!
Β» Gamersupps! - Get a free sample pack! - https://gamersupps.gg/discount/AntVenom
Β» Breaking Minecraft Playlist - https://www.youtube.com/playlist?list=PLR50dP3MW9ZWMSVz2LkRoob_KRf72xcEx
Β» Get a Minecraft Server - http://mcph.to/AntVenom
Special Thanks to Matthew Bolan for introd...
it happens because the chest spawns on top of the spawner in world gen and so the spawner has the nbt of the chest
i want to try and replicate this behaviour
but thats also easy to use with PDC
anyway, you can get the nms-Block via the World (CraftWorld->WorldServer->getTileEntityAt or smth)
Max durability: 1561 Durability to Damage: 1560
Why does the item breaaakak?
i set the damage to 1560
the max durability is 1561
but item be gone
i got the block already, im just looking for the correct method to manipulate the tileentity compound
yes i could make some magic with it myself but i saw this vid and i wanted to see if i was able to replicate it using nms code
without making my own hopper ticking
Hey there! Is there an event triggered when farmland turns into dirt by dehydration?
should be BlockPhysicsEvent
but pay attention because block trampling is not the only thing that calls it
I have a custom durability system
and whenever the item gets to the breaking point
i just want to assign it a broken nbt instead of it actually breaking
so i need to prevent the breaking
I have this in place to make it set to 1
wrong one
((Damageable) meta).setDamage(itemStack.getType().getMaxDurability() - Math.max(1, durabilityToSet));
Try 2 I guess
I think I found something better π
declaration: package: org.bukkit.event.block, class: MoistureChangeEvent
so anyone
didnt work
are you sure it's the same thing? isnt this called when farmland becomes dry/wet
he wants to know when tilled soil becomes untilled
What is durability to set
Oh, this is not the same the thing?
soil can become dry and not untill for a while
huh?
with moisture level i guess they mean the wet state of the block
The variable, durabilityToSet
ye
what is it equal to
uh its set to Math.max(0, (int) (durability * itemStack.getType().getMaxDurability()))
and durability is customDurability / customMaxDurability
you're casting it to int
won't that return 0 everytime?
5/7 = 0 if it's an int
so it gives a value in 0s
i cast durability * itemStack.getType().getMaxDurability()) to int
so it would be like idk 1203 instead of 1203.000022
yeah
Well if durability is over 1, then the item is always gonna break
yeah but why would it ever be over 1?
wait wait
Max durability: 1561 Durability to Damage: 1560
I set the damage to 1560
and it breaks
i dont see how any of this is related lol
Hmm BlockPhysicsEvent is not called when a player jumps on a farmland block
So guys (and gals), once more I need advice.
better said related to the Scoreboard thingy.
I set with Team#addPlayer in a for(player all : bukkit.getonlineplayers()) each role in the tablist. so far so good, however the addPlayer(OfflinePlayer) is deprecated.
JavaDocs refering to addEntry(String) but what do I put there? Playername, UUID Trimmed or UUID Untrimmed?
print out the result of your calculation
I am pretty sure you always set it to 0, as I said
I dont...
Durability to Damage is the proof of that
the player name
Player#getName

π
PlayerInteractEvent
Block physics is more when world physics makes something change rather than a direct player action
Hi, How do I change the texture of a player head block to a custom head?
declaration: package: org.bukkit.inventory.meta, interface: SkullMeta
isnt PlayerInteractEvent associated with mouse clicks?
Depends. Do you want to use the texture of another player or a base64 encoded one?
PIE is also when you walk onto a pressure plate
Trampling will also trigger that event with EquipmentSlot.FEET
base64 I guess since I'm using skins from Minecraft Heads and those don't have player names
Hm. Wasnt there a recent PR for a GameProfile abstraction?
PlayerProfile or something
Ah i see. If you are using the latest 1.18 version then ill have a really easy method for you.
yes I am using 1.18
Alright one moment
Doesn't support Base64 textures afaik
Is it possible with Multiverse that all worlds that have ever been created are unloaded and not reloaded when the server is started and if so, how?
It does if you decode the base64 into a url
Can I just skip the base64 then? Minecraft Heads has direct url to the skin file
yep
How do I change the head texture then?
PlayerProfile
Does Player#performCommand work with bungeecord commands? Or do i need to use Player#chat?
I got a question about the spigot 1.8 api, how could I check if a material id equals xx:xx for example. Because it returns an int, and I can't check this:
type.getId == xx:xx
Well looks like it really doesnt support bas64 textures.
Then ill just provide my util method:
private static final Map<String, ItemStack> base64HeadCache = new Object2ObjectOpenHashMap<>();
private static GameProfile createProfileWithTexture(final String base64Data) {
final GameProfile gameProfile = new GameProfile(UUID.randomUUID(), null);
gameProfile.getProperties().put("textures", new Property("textures", base64Data));
return gameProfile;
}
public static ItemStack produceHead(final GameProfile gameProfile) {
final ItemStack newHead = new ItemStack(Material.PLAYER_HEAD);
final SkullMeta headMeta = (SkullMeta) newHead.getItemMeta();
final Field profileField;
try {
profileField = headMeta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(headMeta, gameProfile);
} catch (final ReflectiveOperationException e) {
e.printStackTrace();
}
newHead.setItemMeta(headMeta);
return newHead;
}
public static ItemStack getHeadFromBase64(final String name, final String base64Data) {
return UtilItem.base64HeadCache.computeIfAbsent(name, pName -> UtilItem.produceHead(UtilItem.createProfileWithTexture(base64Data))).clone();
}
1.8 support was dropped quite a while ago. If you have questions regarding that ancient version you are best of searching in forum posts from half a decade ago.
How could I do it in 1.12 then
But doesn't that only affect items? I'm trying change the texture of a block in the world.
What is xx:xx
Id and subid, for example: 162:13
alright thanks
getId is gonna come from the material, getData is gonna come from the item or block
Thats also possible by using the Skull TileState:
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Skull.html
The reflection should be the same i think.
declaration: package: org.bukkit.block, interface: Skull
As multiple things use the same material and just distinguish by data
I'm sorry, I don't know what that means.
You use the methods in that Javadoc to do what you wanted
Honestly the PlayerProfile should support applying signed textures and base64 encoded ones...
It supports base64 if uou decode it
Yeah itβs just a base64 encoding of the texture and cape URL and other associated info
Which is pretty much whatβs inside player profile
There is a player profile api 
declaration: package: org.bukkit.profile, interface: PlayerProfile
And like I said, just decode the base64 or use the URL from minecraft-heads
ah i see
It doesnβt look like you can set the signature for that though
Maybe I should PR a method that takes a base64 string
Which is unfortunate
I don't really understand any of this.
Furthest I got on my own was finding a forum post that was using GameProfile and TileEntitySkull
Sounds like you got what you need then
except that I can't use TileEntitySkull for some reason. Intellij just says that it "can't resolve symbol 'TileEntitySkull'"
you need to run buildtools for that probably
TileEntitySkull is a nms class. You shouldnt use that if you want to keep compatability.
Well I also managed to find another forum post saying that "all nms packages unobfuscated net.minecraft.world.level.block.entity.TileEntitySkull" but I have no idea what that means
that's probably 1.18
that is more then one
i thnk thats the name
the direction in which the entities are looking
the player has one of those lines sticking out of its eyes
Try this and tell me if it works:
public void changeHeadTexture(Block headBlock, URL textureURL) {
PlayerProfile profile = Bukkit.createPlayerProfile(textureURL.toString());
PlayerTextures textures = profile.getTextures();
textures.setSkin(textureURL);
profile.setTextures(textures);
Skull skull = (Skull) headBlock.getState();
skull.setOwnerProfile(profile);
skull.update(true);
}
anyways there are probably entities riding the player
origin realms π
π³
I am trying to figure out how they hide back pack in firstperson mode
so this could be the key
how it works
things is all other players have armorstands on the top of heads
but I don't have one
wdym would you see it in first person?
so I try to recreate backpack
I got it working
but when u look at floor
in first person you can see back pack
never tried something liek that
Everything about that is spitting errors and I don't know what I am supposed to do with it.
show em
I mean, I don't even know how to insert the skin url in there
does anyone knows how to prevent a file from being deleted in the file explorer or smth related?
Hm? Do you not know where you would get a URL for your texture? Or do you not know how what a URL is? Or do you
not know how to "convert" a String to a URL. More info pls.
i looked it up but couldnt find really useful things
I mean, I understand that I am supposed to put the URL somewhere on this line: public void changeHeadTexture(Block headBlock, URL textureURL) but not how. do I just replace the URL with it?
Thats a method. I think you should take a step back and
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
At least the basics
I know the basics, it's just that I have always struggled with writing code without concrete examples
I mean you cant really do anything besides keeping a file handle open.
do you mean using the securitymanager
The procedure here is:
- Copy paste the method
- If your IDE doesnt find any errors -> just call the method where you need it
what i'm trying to do is to prevent a db file being delete on runtime
Nobody should be deleting a db at runtime
Who is deleting the file?
Thereβs only so much you can do about user stupidity
stupid users
I wouldnβt worry about it
Thatβs not exactly something they can do by accident
rename it "dont-delete-me-you-moron.db"
What are you trying to do? Multiple lines above a user?
if someone has full access to the database you can't provide any way to block them from using it entirely
You can simply change the name above a players head without using armor stands
I don't know the terms, but for example my first roadblock was not figuring out that in getServer().getPluginManager().registerEvents(this, this); you are not supposed to write ``listener:this, plugin:this`
try it
thats literally copying a tutorial lol
if i told you to use marker theres a reason
else than the fact that a non marker one would partially block incoming hits
yes, because I don't understand how to properly write code without seeing a functioning example. tutorials are useless to me.
i dont even know a lot of youtubers that write good code
that's a clear sign that tells you you should not be using spigot's api
PLEASE GHELP
i need a 3x3 square of DIFFERENT random slection of these blocks;
Material.DIRT, Material.STONE, Material.COBBLESTONE, Material.LOG, Material.WOOD, Material.BRICK, Material.GOLD_BLOCK, Material.NETHERRACK, Material.ENDER_STONE
everything i have tried doesnt work. whether there are repeating blocks or it just does all the same blocks. PLEASE YO NECESITO AYUDAR
Well how am I supposed to learn then? I don't learn from tutorials because I just can't seem to understand them.
spigot's api is not the sole and only purpose of java
- Create an array of all the types
- Write 3 nested for loops for x, y and z
- For every iteration select a random type from the array and set it to the location
just make some java project
You need Java tutorials not Spigot tutorials
^
and after a while look again at it and try to figure out what you could do better
Spigot tutorials are assuming a baseline understanding of Java prior to even beginning
Yeah that's how I write Java as well, I find functioning snippets and adapt them. I just can't seem to understand syntax without seeing an example.
watch kody simpson to learn basics
he epic
If you donβt understand the syntax yet then itβs too early to be writing spigot plugins, is what weβre saying
doesn't the fact that you extend JavaPlugin in your main class tell you that you are not ready to use spigot's api if you don't know what does it do
why do you use the api if you don't understand what you are coding
Because I wanted to make a plugin.
yes but then there are repeating blocks? they all need to be different
Oh so you need each block to be unique?
yes
it won't make you better but it will make you someone who can kind of understand easy spigot's api code but with fundamental lack of skill, oop and syntax knowledge
Then make an array. Shuffle it. And just increment an index from 0 to 8
For now I am completely fine with that. I just wanted to make a quick simple plugin.
how do you shuffle an array ive never done that
array.shuffle or smthn
go ahead then but using an advanced java library as spigot's api is not a good way to learn java
iirc Collections has a shuffle method
Hm. I only know Collections.shuffle to be honest.
You can use that, or you can shuffle it manually
?
how shuffle manually
you can just call it and pass an array
create an array
can someone write me an example?
call Collections.shuffle(myarray)
boom u have shuffled array
also google is your friend
Collections.shuffle(Arrays.asList(array))
I have figured out everything else I need for my plugin so far, despite not understanding what I am doing.
i'm pretty sure the shuffle method does not return anything so if you don't store a reference to the array it's an useless call
It mutates the input collection
Arrays.asList wraps the array in a list
oh right it's not List.of
Calls to the list will modify the array
my brain kind of translated it as calling the arraylist constructor
isnt Arrays.asList immutable in some way?
that's List.of
array.aslist returns a mutable list that refers to the original array
It does not allow add() iirc
you can change elements but not extend/reduce the size
"mutable array" lul
ah shuffle only needs the iterator and the underlying array
that returns a completely immutable list
Mutable or otherwise
why
how would i change every block in the 3x3 area without just setting every block induvidually
i can
i just done want to
I donβt think you can
uh no
Why should there be a way for that? How would you even define such a method? With a 3 dimensional array of Materials?
but with like a for loop
bruh
idk
is this java8+ or something?
never knew that existed damn
ah wait
but it seems to be package visibility
Yea
@turbid shoal minecraft doesnβt expose an array of blocks for you to modify lol
You set them inside your for loop but you still have to set each block
could i do ti with worldedit api?
...
WorldEdit also sets them one at a time
it still sets each block individually
Itβs the only way to do it
i have to do like 81 blocks
im not the biggest java expert
for (yada yada yada)
{
b.setType(yada);
}
Block middle = ...;
int radius = 3;
for (int x = -radius; x <= radius; x++) {
for (int y = -radius; y <= radius; y++) {
for (int z = -radius; z <= radius; z++) {
Block relative = middle.getRelative(x, y, z);
relative.setType(Material.GOLD_BLOCK);
}
}
}
Thats literally it
Lol
but how would i change the location for the loop
it would set the same location right?
?
Block middle = ...;
wdym
like i have 81 different locations that i need to set
are they related?
9 different 3x3 areas
in any way
then loop over that locations?
how do i cahgne the location in the loop thoguh
its called a data structure
Iterate
just create an array, set, list, or whatever of the locations
You probably have a collection of those locations somewhere, right?
then iterate through them
^
javas variable name choice is pretty neat
Block center;
for (int x = -1; x <= 1; x++) {
for (int y = -1; y <= 1; y++) {
for (int z = -1; z <= 1; z++) {
center.getRelative(x, y, z).setType(Material.STONE);
}
}
}```
thx
But 3d for loops are pretty tedious to write
You should write a helper method or something
the Arrays class
I've got it like this
CuboidRegion.cubeRadius(center, 1).forEachBlock(b -> b.setType(Material.STONE));```
is that worldedit api?
smh
im dumb
No it's my own library
i think im good
But you can pretty easily write your own helper method like that
Especially if you learn about lambdas
i dont even know hat that is
Okay then start simple
i think i got it to work
Reminds me when i first learned about streams. I found them so cool that i literally did stuff like this
IntStream.rangeClosed(-radius, radius)
.forEach(x -> IntStream.rangeClosed(-radius, radius)
.forEach(y -> IntStream.rangeClosed(-radius, radius)
.forEach(z -> middle.getRelative(x, y, z).setType(Material.GOLD_BLOCK))));
that looks so ugly lol
could be me tho π
public List<Block> getInRadius(Block center, int radius) {
List<Block> blocks = new ArrayList<>();
for (int x = -radius; x <= radius; x++) {
for (int y = -radius; y <= radius; y++) {
for (int z = -radius; z <= radius; z++) {
blocks.add(center.getRelative(x, y, z));
}
}
}
return blocks;
}```
You can do something like this
is that for a sphere or
Then do
List<Block> blocks = getInRadius(center, 3);
for (Block block : blocks) {
block.setType(Material.STONE);
}```
Much cleaner than doing a 3d for loop every time
true
ok this is very stupid question
but hwo do you reference a specifc array thing within .setType();
What
List#forEach kekw
like
π
If you have a Block[] blocks
second part
You could do blocks[0].setType(Material.STONE)
naw. i prefer the old fashioned for π
ew
like loc1.getBlock().setType(Array[1]);
only things is that it requires final or effective final variables π₯Ί
what error?
Do you have an array called Array
can u show code too
Because if so please don't do that
just use an array kek
Yeah show us more code please
its spread out
meh colorizing strings and sending them around
this is probalby going to look reallyu sloppy, its legit my first plugin ever ok
so
yeah
how do uyou do the discord formatting thing
?paste
put it there
also something
I def overuse that
its the wrong colour lol
grr nvm
List<Material> jigBlocks = Arrays.asList(Material.DIRT, Material.STONE, Material.COBBLESTONE, Material.LOG, Material.WOOD, Material.BRICK, Material.GOLD_BLOCK, Material.NETHERRACK, Material.ENDER_STONE);
Collections.shuffle(Arrays.asList(jigBlocks));
jig1pos1.getBlock().setType(jigBlocks[1]);
what am i adoing wrong
you cant get from a list like that
java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "result" is null
at org.bukkit.inventory.ShapedRecipe.<init>(ShapedRecipe.java:46) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at me.tristandasavage.bedwars.ItemManager.createLocatorCompass(ItemManager.java:84) ~[Bedwars but not.jar:?]
at me.tristandasavage.bedwars.ItemManager.init(ItemManager.java:25) ~[Bedwars but not.jar:?]
at me.tristandasavage.bedwars.Main.onEnable(Main.java:19) ~[Bedwars but not.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[purpur-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugin(CraftServer.java:564) ~[purpur-1.18.1.jar:git-Purpur-1547]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.enablePlugins(CraftServer.java:478) ~[purpur-1.18.1.jar:git-Purpur-1547]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:732) ~[purpur-1.18.1.jar:git-Purpur-1547]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:508) ~[purpur-1.18.1.jar:git-Purpur-1547]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:349) ~[purpur-1.18.1.jar:git-Purpur-1547]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1218) ~[purpur-1.18.1.jar:git-Purpur-1547]
at net.minecraft.server.MinecraftServer.lambda$spin$1(MinecraftServer.java:322) ~[purpur-1.18.1.jar:git-Purpur-1547]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
any idea why im getting an error for ItemStack.getType() when im not running it lol
?npe
lol
itemstack is null
?
purpur-api-1.18.1-R0.1-SNAPSHOT.jar
haha fail
I wish
you are doing [0] but you need .get(0)
post the line that is throwing the error
kekw
no but im not doing the line that makes it error
anywhere in the functin
k thx
you have a variable named "result" which is null. Go figure out why.
?paste the code
Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "result" is null
or just figure it out kekw
except i dont
at org.bukkit.inventory.ShapedRecipe.<init>(ShapedRecipe.java:46)
You're passing null to this constructor
https://paste.md-5.net/egohivimap.java is the function
oh
ShapedRecipe recipe = new ShapedRecipe(locatorcompasskey, locatorcompass);
Which one of these is the result
Whichever it is, it's null
result for what
The recipe
wdym. The result of your recipe...
I don't see it being defined anywhere here
its defined earlier
where are locatorcompasskey and locatorcompass coming from?
public static ItemStack locatorcompass;
public static final NamespacedKey locatorcompasskey = new NamespacedKey(Main.plugin, "locatorcompass");
that is not being defined
but it gets defined in the function
BELOW where you create the recipe
ItemStack lc = new ItemStack(Material.COMPASS);
ik
locatorcompass, locatorcompass2, locatorcompass3
why not name it the correct tiers
some asshole wanted it like that
You never actually set the locatorcompass variable
[22.02 14:57:13] [Server] [WARN] java.lang.IllegalStateException: Asynchronous block remove!
??????????????????????
what does this mean
arror in console
Means you're removing a block and you're not doing it on the main thread
You are removing a block async
are you doing stuff async?
Minecraft doesnβt allow that
So you can't do that
PSA: if you want help, show some goddamn code and the full error
Itβs not thread safe
go back to the main thread using Bukkit.getScheduler().runTask(plugin, () -> {})
[22.02 14:57:13] [Server] [WARN] Exception in thread "Timer-53"
[22.02 14:57:13] [Server] [WARN] java.lang.IllegalStateException: Asynchronous block remove!
[22.02 14:57:13] [Server] [WARN] at org.spigotmc.AsyncCatcher.catchOp(AsyncCatcher.java:14)
[22.02 14:57:13] [Server] [WARN] at net.minecraft.server.v1_8_R3.Block.remove(Block.java:317)
[22.02 14:57:13] [Server] [WARN] at net.minecraft.server.v1_8_R3.Chunk.a(Chunk.java:536)
[22.02 14:57:13] [Server] [WARN] at net.minecraft.server.v1_8_R3.World.setTypeAndData(World.java:396)
[22.02 14:57:13] [Server] [WARN] at org.bukkit.craftbukkit.v1_8_R3.block.CraftBlock.setTypeIdAndData(CraftBlock.java:137)
[22.02 14:57:13] [Server] [WARN] at org.bukkit.craftbukkit.v1_8_R3.block.CraftBlock.setTypeId(CraftBlock.java:130)
[22.02 14:57:13] [Server] [WARN] at org.bukkit.craftbukkit.v1_8_R3.block.CraftBlock.setType(CraftBlock.java:121)
[22.02 14:57:13] [Server] [WARN] at org.bukkit.craftbukkit.v1_8_R3.block.CraftBlock.setType(CraftBlock.java:116)
[22.02 14:57:13] [Server] [WARN] at com.chapster.pgp.commands.Jigsaw$3.run(Jigsaw.java:101)
[22.02 14:57:13] [Server] [WARN] at java.util.TimerThread.mainLoop(Timer.java:555)
[22.02 14:57:13] [Server] [WARN] at java.util.TimerThread.run(Timer.java:505)
And the code
Minecraft requires all the game logic to be on the main thread
You canβt change the world state async
Dont do anything with the spigot api from another thread. Ever.
lol
Guys you're all saying the same thing but I feel like he doesn't even know what a thread is
it shows error when it gets tio this
new java.util.Timer().schedule(
new java.util.TimerTask() {
@Override
public void run() {
Collections.shuffle(Arrays.asList(jigBlocks));
jig1pos1.getBlock().setType(jigBlocks.get(0));
jig1pos2.getBlock().setType(jigBlocks.get(1));
jig1pos3.getBlock().setType(jigBlocks.get(2));
jig1pos4.getBlock().setType(jigBlocks.get(3));
jig1pos5.getBlock().setType(jigBlocks.get(4));
jig1pos6.getBlock().setType(jigBlocks.get(5));
jig1pos7.getBlock().setType(jigBlocks.get(6));
jig1pos8.getBlock().setType(jigBlocks.get(7));
jig1pos9.getBlock().setType(jigBlocks.get(8));
player.sendMessage(ChatColor.GREEN + "GO");
player.getInventory().setItem(0, dirt);
player.getInventory().setItem(1, stone);
player.getInventory().setItem(2, cobble);
player.getInventory().setItem(3, log);
player.getInventory().setItem(4, plank);
player.getInventory().setItem(5, bricks);
player.getInventory().setItem(6, gold);
player.getInventory().setItem(7, netherrack);
player.getInventory().setItem(8, endstone);
blockPlaceToggle = true;
}
},
2100
);
Yeah why are you doing that
even a timer lol
what is wrng with that
bruh
.-.
Timer... lol
something tells me that this is stackoverflow
ITS MY FIRST PLUGINS
ITS MY FIRST PLUGINS
ITS MY FIRST PLUGINS
ITS MY FIRST PLUGINSITS MY FIRST PLUGINS
ITS MY FIRST PLUGINS
ITS MY FIRST PLUGINS
ITS MY FIRST PLUGINS
ITS MY FIRST PLUGIN
dont spam
Quit fucking spamming holy shit
For the last time
now you are spamming and looking even worse
it is
You cannot modify the world state in minecraft off the main thread
youre just learning stuff it doesnt matter, just try to understand things
Use the Bukkit scheduler not Timer
?scheduling
Bukkit.getScheduler().scheduleSyncDelayedTask(pluginHere, () -> {
// whatever you want to happen
}, delay);```
delay is in ticks
So if you want it to delay by 5 seconds, that's 100 ticks
also i dont know why Arrays.asList(jigBlocks)
if you want to schedule things, never use timer, use the bukkit scheduler
ok yeah i was trying to find scheduler but spuigot forums didnt help
while jogBlocks is already a list
so i just used java
Java uses another thread to do it
so is the scheduler the problem?
Yes
yes
is there a way to make things stackable/unstackable
You mean items?
wait nvm its already an unstackable item i just fucked something up
Ok
xD
#runTaskLater π
If you want to make an item unstackable the easiest way is to give each one a random piece of metadata so that they're slightly different and can't stack
You can't really make unstackable items stackable
Force of habit I guess
kekw
I don't use the scheduler methods anymore I just do
20 ticks in second right?
Yes
epic
created your own methods?
π€
ah saw that in other plugins too
wait this looks way simpler
dont use that
ok
if you dont understand what is happening
it just doesnt the same thing inside the method
^^^
and you dont have access to that
I'm always the first one to plug my library but you really shouldn't use it until you have a solid grasp of java
is there a reason why this is saying its bound but without actually changing the pdc or the lore
https://paste.md-5.net/asubomukow.java
do i have to do this in the main lcass?
No you can do it anywhere but you need a reference to the plugin
You're not calling setItemMeta
when i reference to the plugin it gives error
You have to do stuff like this
oh my bad lol
"expression unexcpected"
why the hell am i saying my bad so much today
ItemStack item; // Assume this is set
ItemMeta meta = item.getItemMeta();
meta.setLore(List.of("a", "b"));
item.setItemMeta(meta);```
yep ik
Show code
are you allergic to variable names
Bukkit.getScheduler().scheduleSyncDelayedTask(PGP, () -> {
PGP is probably the class name
You need the plugin instance
Which you can do a number of ways
its the name of the plkugins
Could do Bukkit.getPluginManager().getPlugin("PGP")
Could do JavaPlugin.getProvidingPlugin(PGP.class)
Could make a static instance getter
Oh right my bad lol
(Constructors exist)
But you have to understand why the original did not work
PGP is not a value, it's a class name
A type
its not a class
PGP.class is an object representing the PGP class
You need the PGP instance
Not the class and not the typename
ITS NOT A CLASS
...
whats even the difference between #getPlugin and #getProvidingPlugin
Okay
then why did you put PGP as the plugin instance
Well what are you expecting then
because PGP is the name of the plugin
The language doesn't know what you mean when you just type PGP
But you still need the instance
you need the instance not the name of it
I bet he named his class Main
waht does instance mean
oh boy