#help-development
1 messages · Page 2027 of 1
ok sure
wasn't it mojang that brought about that change
not for NBT
nah normal nbt tags use strings
oh right
and pdc is a bukkit invention im pretty sure
Yes
it was added in spigot 1.14.1
and since 1.16.3, even chunks have PDC
that makes you able to store information inside blocks
World also implements PersistentDataHolder in 1.18.2 (or in 1.19? i dont remember)
nah I think I've seen it being merged so it's probably already added lol
Would it be better for me to make a folder for items, and have a class for every item, instead of loading then in 1 area?
Idk it feels inefficient the way im doing it so far
inefficient or unorganized?
one should be able to look at their code and instantly find what they are looking for - If you follow RAD you would break it up into logical chunks that do specific things - however that also has its own issues
fair i just like organization
only question is: how would I load all of the items
items as in?
I assume basically the same way you're doing it now
do you use the package and import tags now?
1.18.2
how do I use net.minecraft imports?
bind against spigot instead of spigot-api
I changed spigot-api to spigot errors?
What errors
Did you run bt yet?
1.18.1-R0.1-SNAPSHOT not found
what is bt
BuildTools
?bt
?bt
that plugin doesnt actually really do that
I have to redo the plugin don't I
No
you just need to setup maven or gradle properly
You just have to run buildtools
where do I put the .jar?
It's as simple as invoking a java jar
Anywhere, though I recommend putting it in an empty folder so you can delete the folder afterwards
I cant figure out how to download it from the website lol
... you sure you actually need it if you cant run build tools?
Also you need to pass a few arguments to the bt jar but I have no idea what they are given that I am a staunch anti-nms crusader
the ones selecting version etc
All you need is version
what version?
Assuming you don’t want 1.18.1
oh wait you can force a push using git push origin master -f
even if there is a conflict
useful to know
Or just git push -f
i dont have upstream set yet
yeah, try not to force git
That being said DO NOT FORCE PUSH
Any way to store ItemStacks or Entity in PDC
ItemStacks, sure
you can store a uuid
Write your own serializer I guess
to an entity
or do you want to store the entity data
dear god how many custom stuff do you have LMAO
for entities, you gotta serialize them somehow, someone here did a library
respect
I just clicked the jar
I have a ton of custom stuff on the compilation side of things, but noone needs that
"My server runs on Minecraft version I just clicked the jar"
didnt you ask on how to use NMS?
yes
I've sent two blog posts about using NMS, if you don't read them, then it's your problem
?bootstrap or just do these steps
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
they had problems finding the buildtool instructions ...
?bt
We already linked them that site a couple of times - Sometimes ignorance isn't bliss.
well if they don't read, that's none of our business
actually im using paperwight
remove them from the file
.gitignore:
target/*
// but NOT target/log.xml
or use the command
thanks
need a, .gitinclude
true
you know what
dont give them ideas
I just clicked the file in intellij and used git -> add
no idea how it did it, but it did it
lol
it just ran the git add xyz command
yeah u can like override the git ignore
if you specify a file directly it'll warn you but will let you add the file regardless of gitignore association
did they fix that?
thats a feature
it's not really a problem
I CANT FIGURE THIS OUT
In 99% of cases you are doing it knowingly
it used to continue to ignore the file
they are using maven though iirc
its a plugin to remap the paper server
Why do you need nms in the first place?
are you using maven or gradle?
for packets
if ur using maven use specialsource
There are libraries for that
I have you sent you two blog posts explaining what you need to do
you didn't read them
maybe they only watch YT
And we have sent you the buildtools instructions multiple times so that cannot be the issue either
I DONT KNOW HOW TO USE BT
lol allatori stores it's own log output inside a comment within it's log.xml file. that's... a weird way to do it
?bt
download and run buildtools with --remapped, include the uploaded jar in your project through mavenlocal, dependency descriptor io.papermc.paper:dev-bundle:minecraftversion-R0.1-SNAPSHOT, enable specialsource for building and youre good.
thats a full guide
I KNOW
excluding specialsource setup because i dont use maven
CAN YOU STOP SHOUTING NOW
so? whats going wrong
have you even tried
you havent told us anything
I KNOW TO BUILD IT
I DONT KNOW HOW TO USE IT AFTER BUILD
lmfaoo
I suggest everyone to do the same
INCLUDE IT FROM MAVEN LOCAL
I can even show you
I JUST DESCRIBED HOW
.
i DID RUN BT
Just use protocol API instead of nms
thats not all it says
I tried but I couldn't figure out
PROTOCOLLIB
here is how i do it in gradle
I need maven
^
Ugh, I should really try to introduce a third build tool into this world to cause more havoc
I dont get it
step 0, download and install Java 17 JDK from oracle.com
step 1, download BuildTools.jar from spigotmc.org
step 2, go to the directory you downloaded BuildTools.jar to
step 3, open command prompt (or terminal) and type in java -jar BuildTools.jar --remapped --rev 1.18.2
step 4, ... profit?
BT WONT WORK FOR ME TO COMPLICATED
It makes me feel better I am not the only one who has this type of argument problem
I thought you ran it before?
u make a new Maven project in something like IntelliJ and add org.spigotmc:spigot as a dependency
I DONT KNOW HOW TO DO THAT
PotionEffectType#getName() returns this?
ANY YOUTUBE TUTOIRALS
theres also specialsource stuff but idk how it works
Then you add tons of plugins and plugin configurations and you are done
gjfidjgisg
If BuildTools is too complicated for you then networking and packets may be expecting too much
they have a maven project already, and have built the jar
what if theyre me, what if they hold their shift key
just I need it for me plugin
mf turned irish
But you may not be capable of doing it
As I said, for packets https://github.com/dmulloy2/ProtocolLib/wiki/Adding-ProtocolLib-as-a-Dependency is sufficent
Regardless of how much you “need” it you’re just not competent enough to pull it off
It is at least 200 times easier to use than nms
Especially because it has documentation
at least for sending packets
whats that one retrooper contributed to
PacketEvents?
yeah
Is it possible to store objects in config files?
wiki.vg???
Step 5, cry
thats a constant step
step 6, fuck off and inject your own handler into the player's netty pipeline
it is just the documentation of the protocol, but not the documentation on how nms works
Because I'm having this weird bug, I'm trying to save a ChatColor object in the config and every time I reload the plugin it removes it, specifically the objects of type ChatColor, but when I turned them into a string, it doesn't remove them. Does this mean storing these isn't possible?
isnt this literally what PL does
that is because chatcolor is not ConfigurationSerialisable
but its much more stuff with PL than standard netty iirc
its a single line of code to inject your handler
then ofc you need the handler
single, 3000 char line of code
but that's beside the point
What does that mean?
actually like, 80 chars
TL;DR you can't save it
Any object that is stored in the config needs to implement https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/serialization/ConfigurationSerializable.html
declaration: package: org.bukkit.configuration.serialization, interface: ConfigurationSerializable
unless, ofc, you just write the color code
Except for maps, lists, strings and primitive wrapper objects that is
So there are specific objects I can store in the config?
Yes
everything that implements the interface geol sent
because you keep ignoring the blog post I sent
?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.
thank me later
Now you can just delete that folder if I am right
@tender shard ignore @sonic idol
What does 'implements the interface' mean?
they are just trolls
he already did
Uh, like implement the interface
if you don't know that, you should get a book about java
Any class that more or less has class ABC implements XYZ { in it's head
It documents pretty much all of it I’d say
interfaces are one of the basic concepts of java
THIS CHANNEL IS HELPING PEOPLE
packet sending is probably not documented there
NOT, NOT HELPING PEOPLE
I see, I will look into it, thanks for the help! :D
THIS CHANNEL IS FOR HELP BY VOLOUNTEERS, IF YOU ARE A SPOILED 5 YEAR OLD HELLSPAWN BRAT THEN PEOPLE WON'T HELP YOU
WE ARE NOT PAID ENOUGH TO HELP BLOODY MORONS
IM 13
I HARDLY BELIEVE THAT
@sonic idol you don’t have the requisite base understanding to be helped
YOU CANT JUST BELIVE THAT SOMEONE IS UNDER AGED
YOU ARE STILL UNDER AGE YOU MORON
You don’t have enough knowledge for us to build on and help you
13 is a child
IM 13 IM 13
Lol
@ancient plank uh, I think you need to deescalate this situation right now
jesus christ just ignore trolls
IM NOT A TROLL
they want a reaction
(or 13 and less if allowed by guardian/parents)
lol I just wanted to ping them too
sadly blocking on discord is not as usefull as block over at irc
@sonic idol regardless of whether you’re a troll or not, you simply don’t know enough for us to help you
block them
and you're done
No lmao
because in irc space ignoring someone means ignoring
still useful
IM GETTING HELP SOMEWERE ELSE IM LEAVING SPIGOT MC DEVELPEMENT COMPLETY
yes
yeah, why are we wasting our own time
does BetterDiscord have a noption to completely make blocked messages invisible?
i found a css a while back
i don't have BD anymore tho
@tender shard Can you resend that file or whatever
for custom values
cant remember what its called e.e
file?
oh you mean my lib for storing itemstacks in PDC?
wonder how they will do on the papermc server
good lib @tender shard
how can i calculate factorial
ty, would this be a good way to store what it called, items for backpacks?
Just run the algorithm to calculate a factorial
manually
Was is the 4! = 1 * 2 * 3 * 4 stuff or nah?
yes
long val = x;
while (--x != 0) {
val *= x;
}
pretty easy until you optimise it
sure!
ah, i just noticed the difference between --x, x--
IntelliJ is really weird sometimes...
why does it ask me to update gson, but doesn't ask me to update Stepsister?
okay, wtf
what? 😄
tbh i dont understand this joke but i wish i did
cause ik abt the stepsister but idk what the joke is
how to send a command to console using my plugin?
tf is stepsister
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "commandwithoutslash");
i tried this stuff
getServer().dispatchCommand(getServer().getConsoleSender(), "tps"))
but it didnt worked trying yours
you added an extra ) at the end
and you forgot ;
my library to create a discord verification code and to check if someone refunded the plugin
o
i might use this tbh
but you don't have any paid plugins?! 😄
yes, but when i make one
and how to get a exact player name?
if i will
player.getName() ?
Bukkit.getPlayer(partialName).getName();
partialName?
oh
Cannot resolve method 'getPlayer()'
cant i make this field empty?
like this
Player p = Bukkit.getPlayer("").getName();
that will probably choose or no player or the first one in the player list
response.editMessageFormat(String.valueOf(Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "tps")));
no error coming
and this thing is not working too
what do you think it should give you?
I am not sure getting the string result of dispatchCommand() is really that useful to you
Returns:
returns false if no target is found
Is it possible to store chars in a config file?
sure - can store numbers as well
mm
I see, thanks!
you were testing to see if you could run the command?
but its not working tho
yes if my plugin*
all you will get is true or false as a string result
then how to send it to discord am using jda?
are you trying to get the TPS value as a response?
yes
you will have to catch the response
but its not sending any command in the console tho
so its giving you a false reply?
maybe
hahaha
okay, you need to figure out which side is not working for you
"TPS" is not a valid command on my servers
however "tps" is a valid command (that said my response comes from TabTPS)
ok
how do in only drop enchanted items on Deathevent ?
my guess is that you would have to check the players inventory for them
Do I have to use hasmaps to make.. hashmaps?
Or can I just go like this or smth:
test = {"NoStack":true};
kinda lazy and dont wanna have to type out hasmaps
:/
get the drops and check the items
the player has not dropped the items yet in onDeathEvent, in fact the player is not dead yet either
If you wait a few ticks, they have
when the event exits they are
for (ItemStack items: event.getDrops()){
if(items.getEnchantments().isEmpty()){
}
}
Thats my current code , sorry i dont know how to use codeblocks
I’ve gotten the drops many times, no problem with it
ah, then check for non-enchantes and remove them
yes u need to instantiate the map
how so?
u could do like
Map<String, Boolean> theMap = new HashMap<>() {
{
this.put("NoStack", true);
}
};```
it still drops everything when i die
i forgot the eventhandler, sorry i am stupid haha
than thas why it didnt work with 2 of my versions before 😄
still dropps everything
yup
getServer().getPluginManager().registerEvents(new PlayerDeathListener(),this);
how do i do that ?
it works, thanks a lot
can i dm you really quick ?
i cant cause we arent friends
if he checks the player inventory there is no need to wait
yeah drop happens after ondeath
there are possibly two issues that I can think of with using the drop instead: concurrent players dying and keep inventory turned on
can anyone help me? switched my plugin from 1.16 to 1.18 and it's now saying it cant find my main class. tried everything, but nothing works
did you recompile it with java 16?
17
16? thought it was 17
the server
Send your plugin.yml
what version of java is your server running on?
17
main: com.servers.AllOfTheThings.Main
name: AllOfTheThings
version: 2.2
description: All moderation and extra items for the server.
api-version: 1.18
api-version
And com.servers.AllOfTheThings.Main exists?
heh, you knew I was gonna ask that
That's odd, could you paste the full error?
?paste
api-version
The version of the API you want to use.
1.13, 1.14, 1.15, 1.16,1.17 and 1.18 are the available versions.
This will signal to the server that your plugin has been coded with a specific server version in mind, and that it should not apply any sort of backwards compatibility measures.
Is there any error around it?
i did, 1.18
you are running on 1.16
no i switched it from 1.16 to 1.18
spigot-api-1.18.2-R0.1-SNAPSHOT.jar:? how come you think that this is 1.16?
so its on a 1.16 server
?stash
or 1.18
It seems like your Main class isn't being compiled
Not really even sure how that's possible
How are you building the jar
How are you compiling your plugin? Manually, maven?
artifact layout
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/plugin/java/PluginClassLoader.java#67 yeah, I think that points to compile problems
i think if you specify a repo that doesnt match the api-version intellij is stupid about it
manually i believe
ah that explains it
Ok
so instead of src, it's java?
Yeah
ill try that
You might also want to unzip the jar to check if all files are where you think they are
that would be a plugin if anything
I'd check your artifacts to see if it's set up correctly.
The way I used to do this was as follows.
File ---> Project Structure ---> Artifacts ---> Click the + Icon ---> Select JAR ---> Choose from modules with dependencies ---> Click OK.
Then select everything except your plugin's compile output and delete it from the Output Layout section.
maven is something lol
I like Maven
except when I need to do anything complicated
that's when Maven becomes 100x worse
i should probably use maven
the other day I had a fucking anger meltdown because I couldn't figure out how to do the following:
- Compile submodule
agent - Compile submodule
libwith the binary ofagentinsidelib's binary
save yourself and learn gradle
that is where you are wrong
Maven's module system is... full of historical design issues.
Gradle is absolute pain
that is true
Maven is at least faster than Gradle so that's why I use it.
That is something you do not hear often
...yeah.
that speed argument is a red herring
it is relative to how the tools are used
Tip, set the following environment variable: MAVEN_OPTS=-Xmx1G -Xms512M
Sorry but this argument has always been bullshit
1G of mem seems quite a lot low
There is such thing as a "bottleneck" when it comes to software
if you delete you cache everytime you use gradle, yes it is slower, just the same as it is with maven if you delete its download cache
Works well for me lol
I can affirm that gradle is a bit unnecessary slow
Maven's implementation happens to be faster than Gradle's because Maven's implementation is more simple.
If you were to use both with caches enabled, Maven would still be faster.
I can attest to this because I've used both.
if you properly used both tools, faster would depend on the scale/size of the code you were building
Then just benchmark it on the same project lol
don't both use javac internally?
Well it depends
I know that maven can use eclipsec, but that isn't default iirc
Gradle allows you to use either javac on the command-line or the Compiler API.
there are many fanatics that do just that to argue the "speed"
and how does maven do it?
Well, that is effectively how you argue speed
probably the same there though. Which would invalidate the speed argument
When you have the exact same inputs, the only variable being the buildsystem, and one buildsystem ends up slower than the other, you can argue that that buildsystem is slower.
here you go, and it is still relative
although apparently gradle uses incremental builds, not sure how it is handled
Isn't Maven 3.6 also outdated?
gradle 5 is also outdated
From my experience maven suffers in speed when if I were to have a bunch of modules/subprojects, whereas gradle seems to be performing relatively well in that aspect
Gradle is for-profit
Yeah
I blame this primarily on Maven not being designed around modules initially
I have maven 3.6.3 installed, so maven 3.6 is not that outdated
Yuh fair
I thought there was a Maven 4?
Maven's implementation of modules is also just really bad
I need to optimize my gradle project, takes like atleast 15 seconds to build my project smh
It's because of remapping all my sub projects 
After the daemon is started mine all build in <1s
I was too lazy to do it right I just wanted it to work
From a clean build
I can build my Maven project in like 2s
And that's for every run, no need for a daemon
Well sometimes it goes up to 13s but that's like when I compile a project for the very first time
Actually
I don't know why it does that
Timing is a bit inconsistent 🤷♂️
because it has to go retrieve your dependencies
Ah
There is one problem I have with both Maven and Gradle
And that's just the fact that they've got terrible APIs
Maven is a bit too "enterprise Java," while Gradle is just impossible to use because of its dynamicness.
(Note: I'm basing this off my experience with Maven's Resolver API and Gradle's Plugin API)
Maven's resolver api is interesting to say the least. Ended up writing my own one
It makes sense
It's just not fun to use
I've been trying to find alternatives to it
A problem I have libs is that they're overly reliant on javadocs.
It is really hard to find the "start" of a library, essentially
The piece of code that allows you to access the entrypoint
Maven has examples but honestly they're shittily organized
i usually call that the bootstrap
Well, in the resolver's case it is not a bootstrap but rather a context
And then you create another context from that context which allows to resolve stuff
(Also: Maven Resolver essentially forces consumers to use dependency injection frameworks)
But before that you need to register you local maven repository at which point you gotta create another context
(It has a manual service locator system, but that's going to be removed eventually)
I read it and was like "NOOOOOO, not my maven"
Dependency injection frameworks are cool, except for a few things
Vectors Help
- It is impossible to track the structure of a library when DI is used
- There is a minor overhead to them (unless you use something like Dagger)
(Also they're just not as easy to use as they could be, but that's my opinion)
kekw (╯°□°)╯︵ ┻━┻
:dynoError: The Fun module is disabled in this server.
Fun is dead
:(

?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
how do I make a server send a message?
wait I said the wrong thing lol
I mean how to make a player send a message
thanks
I have created a custom enchant which works fine but when I add any other enchant with it using anvil the powers of the custom enchants goes
So is there any way to fix it
how are you making the custom enchant
you shouldn't use custom enchantments at all
you should use PDC to store custom enchantments
the Enchantment class/interface isn't meant to be used by plugins at all
uhhh, how is itemMeta null?
item = p.getInventory().getItem(mainEvent.getHand());
if(item != null){
itemMeta = item.getItemMeta();
itemPerst = itemMeta.getPersistentDataContainer();
error states it is.
Material.AIR returns null ItemMeta
Not an error, a warning
private void getItem(){
item = p.getInventory().getItem(mainEvent.getHand());
if(item != null){
itemMeta = item.getItemMeta();
itemPerst = itemMeta.getPersistentDataContainer();
}else{
itemMeta = null;
itemPerst = null;
}
}
I registered an enchantment then i called a event and wrote the functionalty of the enchantment
Unless, well
Unless this happens
are you using a weird fork?
i did'nt get what are u trying to say
send the full code including all the imports, and then show the exact error you're getting
you should not register custom enchantments. You should use the ItemMeta's persistent data container and store information about your enchantment there
error here
what's InteractEntityEvent line 48?
oh
itemPerst = itemMeta.getPersistentDataContainer();
your item is AIR
the event is called once per hand
any way to check which hand?
if you only want to check the main hand, return if the getHand() is == EquipmentSlot.OFF_HAND
how is that not descriptive?
getHand()
returns for which hand the event was called
oh
you could easily fix it by checking the items amount
instead of just doing
if(item != null)
check this:
if(item != null && item.getAmount() > 0)
or just if(event.getHand() == EquipmentSlot.OFF_HAND){return;}
yeah no
imagine you have a player only having stuff in the off hand
cause that way it also works with off hand
don't you wanna make that work too?
so yeah I wouldn't manually check for offhand at all but make it work for both hands
k
the API is a bit weird sometimes
one would expect the hand to return null instead of an ItemStack with Material.AIR and an amount of 0 lol
but yeah that's the way it is
now it doesnt work
it's not really "a lot" if there's nothing 😛
@EventHandler
public void interactEntity(PlayerInteractEntityEvent event) {
if(item != null && item.getAmount() > 0 && !alreadyRan){
okay I'll go home
???
Boolean alreadyRan = false;
@EventHandler
public void interactEntity(PlayerInteractEntityEvent event) {
if(item != null && item.getAmount() > 0 && !alreadyRan){
its not passing this value now
:P
yes there is
LivingEntity#setHealth
oh nvm it's Damageable#setHealth
is the entity a dropped item?
... you do realize dropped items are entities as well right?
any entity that has health can be killed with setHealth
otherwise use remove or something
whats the entity?
what is it then
entity reveal
that has a setHealth method
what are you talking about
send your code please.
wdym yes bro
something doesnt sound right here
y e s
which one
yeah cast it
Entity doesnt have that method
you need to at least cast it to a Damageable
so LivingEntity
no its not because otherwise arrows and items would have health and ai
or at least allocate memory and process time for it
when making a class should it be?
ClassName
className
Classname
when making a var what should i tbe?
ok
String StringName?
variables either stringName or stringname
Classes: MyClass, Class, MyLongClassName
Methods: myMethod, method, myLongMethod
Fields: (Same as methods)
Variables: (Same as methods)
Constants: MY_FIELD, FIELD, MY_LONG_FIELD
when should i use a vinal
if you dont expect something to change
actually only do that on static final
otherwise it sucks
oh ye
thats a better way to describe it
Wtf is a field?
a variable in a class
I probably know
or object
?
Wait
Then what’s a variable lol
Like I would assume a field is the thing you pass into a method
And a variable is a variable in a class
Am I mixing them up?
protected float num = 4.9f; /* field */
private void method(String str /* parameter */) {
int i = 0; /* variable */
}
thats getting really technical
Thank you
That helps
np
Technically untrue
Things like primitive variables within methods don't technically have a memory location
they do
on the stack
That's not a memory location though
yes it is bruh
its not a heap location
the stack is also stored in memory
as well as vm internals
and native allocated memory
I would imagine JIT converts it to use the actual stack pointer
all count as memory locations
wdym
its on the stack frame
its not on a stack
i believe
also a stack pointer is also just a pointer to memory
The x86 instruction set uses a pointer to refer to the topmost element of a stack, as the stack is separate from memory and is instead part of the CPU.
(The stack pointer is actually just a register as well, x86 identifies it as rsp)
Either way, the way it was phrased suggests that each element of a stack has its own pointer
Which just simply isn't true
or in the cache of each core
how would i remove the [ ] , from a list and then send it to a player
And it's more of an implementation detail that the JVM's stack uses memory
yeah i know
join it manually
how u mean
I believe there's a method to join lists now...?
ohh
StringBuilder b = new StringBuilder();
for (... elem : list)
b.append(elem).append(" ");
String str = b.toString();
``` will result in something like `1 2 3 4 5 `
with a space at the end
That's probably not what you want though :p
You'd have to use a regular for-loop and track the index
If index != the last index, then add a comma
why a comma
he says without a comma
Oh in that case then just add a space
No need to track the index if said list of elements comes before something else.
Also
StringBuilder b = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
if (i != 0) {
b.append(" ");
}
b.append(elem);
}
String str = b.toString();
true
It's just obscure
Since people always use StringBuilder
Which StringJoiner is a wrapper of
ah
Anyway, so a variable is truly just a name assigned to some local variable index, if the compiler has decided to persist the value so that it actually uses up a local variable slot.
Sometimes the compiler optimizes away variables
Mainly if they're not re-used
what is a stringjoiner lol
Joins strings
StringJoiner j = new StringJoiner(", ");
j.add("Hello").add("World!");
System.out.println(j.toString());
^ This outputs "Hello, World!"
its kinda cool
Nothin' wrong with using StringJoiner, it's just your typical utility.
Funny how nobody knows it exists though.
Oh yeah it also supports prefixes/suffixes
cant that all be simplifiyed by
String message = String.join(" ", messageList);
Yeah
ok
is that a method
i think think so
It's a Java 9 method iirc
let me send u my code
i bet it will be an Iterable
or array
💀
they are very not cooperative
Fibers ftw
Player p = (Player) sender;
List<String> messageList = new ArrayList<>();
String message = String.join(" ", messageList);
for (int i = 0; i < args.length; i++){
messageList.add(args[i]);
}
p.sendMessage(message);
i WoNdEr wHy iTs NoT WoRkINg
why did paper deprecate LITERALLY THE ENTIRETY OF net.md_5.bungee.api.ChatColor
pfffft
...okay that's a great question
probably something to do with adventure
im glad i relized it before banging my head on the wall
i dont want adventure i just want simple chat colors bruh
NamedTextColor
T o o b a d
but also just bc its deprecated doesnt mean its not usable 🙄
Nah
You should make them increase exponentially
how do i set the command sender as the console
afaik, just another Components#text with an empty text format array
i just realized i want this to be compatible with spigot so ill just use bungee chatcolor
which is annoying to use
because its deprecated
and intellij avoids deprecated shit
You can use the adventure bukkit plattform or however it is called
if you have twenty taskes which use the same field and you add a lock to that, wont the tasks be executed slower because they have to wait for the lock to release?
if (!(sender instanceof Player)) {
sender.sendMessage("Use command 'say' in the console");
} else if (sender.isOp()) {
Player p = (Player) sender;
List<String> messageList = new ArrayList<>();
for (int i = 0; i < args.length; i++) {
messageList.add(args[i]);
}
String message = String.join(" ", messageList);
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "say " + message);
} else {
sender.sendMessage("You don't have permission to run this command");
}
should i return true at the end of all the if statments
idk a lock that prevents two threads from accessing the variable at the same time
Depends on what you like
what would u recoment
hmm yes it says that it will slow down performance
should i use a for statment or a
Collections.addAll(messageList, args);
whats wrong with messageList.addAll(args) lol
So just synchronized or a more intricate lock?
Recement
ye i guess
what
There are hundreds of locks out there. Examples include ReadWriteLock and ReentrantLock among others
oh but in general locks slow down performance right?
Cement
what is that
Yes. But it really depends on the form of the lock on how much the performance drops. A simple synchronized block is going to be much faster than for example a ReentrantReadWriteLock
😋🤤
im so lost
I love cement, and lean 💜
haha guys purple drink funny right??!
Hahahahaha
Get it
Cause it’s purple
I’m sorry I didn’t mean to bring this chat down into chaos
i hate that the bukkit logger doesnt support colors
at least not for me
the console sender does
but the plugin loggers dont
.
ah im bad
You might be able to use ANSI escapes though
Is there a way I can pass a variable from one listener to the other. I need a hologram variable, but I don't have it in the other listener, can't get it through the world or anything nor can I save it in a db
ok i got something
Or just use sth like CAS (which avoids all of these rigorous locks)
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Though CAS will always be slower than a direct assignment
Myes but it will most likely out perform synchronized or any lock implementation
And multiple threads CASing at the same time will be slower than a single thread CASing
I mean, in/with synchronized all the threads that operate on said variable has to still wait for one and another
Yes
And then iirc synchronized is by definition always LIFO, whereas if you’d use sth like Lock you could opt in for a FIFO implementation. Idk if thats even a thing in CAS, probably too unpredictable.
oh
In terms of speed, if you’re just managing a variable probably wrapping it with a AtomicReference and using getAndUpdate or updateAndGet will do the job
Some time ago synchronized was supposedly much slower than the ReentrantLock but that’s no longer the case, they’re almost equally fast. Not sure if same thing could be said to ReentrantReadWriteLock. However they’re great when it comes to more advanced multi threaded operations, they they get outperformed by CAS in trivial cases.
yeah
because all levels mean severeness
except info
as it provides information
so ye
thats the logic behind it
what about threadlocal?
That’s just a Map<Thread,O> at most
A bit more sophisticated
But it keeps an instance per thread
ye
for instance when SimpleDateFormat (which no one should ever use) was the way to format dates, people often had to use a thread local when dealing with date formats across multiple threads as it wasn’t thread safe because it had some damn static shit inside it
Yeah you could really ask who wrote the jdk
👀
Well fortunately we do have better shit now
i forgot lol
DateFormatter and LocalDateTime
Yeah LocalDateTime, LocalDate, OffsetTime, OffsetDateTime, JapaneseDate, DayOfWeek etc
Aj yeah
TemporalAccessor (and its subclasses) and DateFormatter in principle is what you want to use
DateTimeException?
i forgot, something about a temporal accessor, i was using Instant too
what are these \s characters
there are normal spaces under there
But yeah fourteen, ThreadLocal is more of a one instance per thread, whereas AtomicReference deals with same variable across multiple threads
by introducing synchronized mechanism or something related?
No
they avoid locking
ThreadLocal has nothing do with locking because it doesn’t address the problem of sharing a variable across threads since it just provides a new instance per thread instead
AtomicReference makes sure the value of the variable is uncached (in simple terms) when other threads look at it. And it has some methods such as updateAndGet, which will try to update the variable by comparing and setting (CAS)
Yes
In principle
Altho it has methods to get the value as if the variable weren’t volatile
im not completely understanding what volatile means, does it keeps the value of a variable up to date on the threads which use it?
Synchronized is just like a key, whatever thread has it can do what it wants whilst all other threads must way until said thread is done with what it wanted to do
ye i understand that
volatile is interesting…
I believe volatile is in reference to memory ordering or some shit?
I dunno, been a while since I worked with concurrency
Yeah
Like it’s very low level and intricate if you want to understand exactly what’s going on under the hood
something to do not apply memory optimisations to it or something lol
I mean... not that complicated. It basically prevents a value from being stored in the cpu cache so that different threads dont have
different views of a value.
👀
Myeah, but like think of it as a thread might have a local list of variables with values, to some extent volatile makes sure that whenever the value of a variable changes, that local lists get updated.
Yeah
It does establish a happen before relation/semantic
There is probably a bit more to it. But thats the essence.
Indeed
is there a way to make a new block with a custom texture?
best naming scheme
gradient to double to float Tealight blindlead
Meh. There are some ways but they are all hacky and fragile
hm
wouldnt you still need for the texture to it being applied by a resourcepack?
gradient 2dimensional 2floats Topleft bottomright
hey does anyone here know what's the equivalent of PathfinderGoal in the mojang mappings? Apparently it's just Goal but that doesn't seem quite right
How do i get so color vises work in cobfig file? Like normal minecraft codes tag me