#Split strings discussion
1 messages · Page 1 of 1 (latest)
hey
ok
adds STRING_ARRAY as datatype
Wait
is that compatible with your other api, (which i'm using) the one for the blocks
sure
So as far as I understand you have a string like "A☇B☇C" and you want it to be a List "A", "B", "C"
exactly
you can just do DataType.STRING_ARRAY with the lib I've sent
okay
yeah but this strings can also contain spaces... will it break?
The split method has a problem: it breaks when you have a string which contains the separator
spaces dont matter?
whats so special about spaces
spaces are characters
newlines are characters
i don't know, its the first time i'm trying this
"☇" is a character
one thing tho
if you try and save a "☇" then it obviously breaks
ah
lets say you have the list:
"A☇G", "B", "C"
and save and restore then you get
"A", "G", "B", "C"
why don't you just use one of the libraries we've sent?
The name of the thread is confusing
gep i just wanted to escape the gui discussion+
i did not bother to think of a name
Yeah i know, i'm just trying to understand how does this thing work
Split strings discussion
its very simple
string.split goes through your string
okay tysm
and every time it finds the delimeter it splits the string there
my library uses native string arrays, no need to worry about any delimiters
sure, you can use itemstacks or itemstack arrays
didnt know you need that
(string as in cotton or smth)
oh yeah you could also just serialize, but thats a mess
yeah i understand how split works, at first i thought it will just do the first one that it finds
yeah no its not like Cs strtok
i'm saving data to a block so when i break it i get the item back with all the correct itemmeta's values
so i was doing the lore
and i stumbled around this problem
so thanks, all!
then just use DataType.ITEMSTACK and save that inside the block's PDC
library is the way to go
delimeter based string storage is funny and hacky
but I will find your delimeter and break your plugins legs
if I ever come on your server
actually my CBD lib even has an example to save itemstacks inside blocks without any other libraries -> https://github.com/JEFF-Media-GbR/CustomBlockData-Example
as said, this one doesn't use MorePersistentDataTypes but instead manually serializes the itemstack. you can avoid that by using MorePersistentDataTypes, too
You have an API for everything 🤣