#help-development
1 messages · Page 446 of 1
am i crazy or strings used to be castable to itemstacks?
What
is this the way to do it?
You can only cast an object to a type if an object is actually this type.
A String is never an ItemStack
What?
Your jvm doesnt just grab all your memory on default
Super buildtools?
To be fair, we do access transform a lot of what Mojang writes so we can use them in CraftBukkit, so I wouldn't attribute the public access modifier entirely to Mojang
(This is the client)
oh lol
btw you should probably ask on fabric/forge discord if you are writing mods.
But dont ask on forge discord about fabric help. You will get bullied.
from onCommand method, if only the command is given, no sub command, is the strings array null?
i think that yes
Okay
Yo 7smile7 I got the generator stuff done, i just have a little question. When I place a generator, atm im checking through the gens.yml file. Is this okay here? or should i do that the same way as the gens? If that makes sense
I was thinking you were the best person to ask, as you know what I'm talking about. (If you remeber lol)
My proposal was: One file per player
are there any existing apis to track spigotmc external download links for resources
Exactly what i have.
But i have a overall file for the generators salesprice and stuff
And names, and what type of block it is.
You dont want to constantly check files. Thats very expensive.
Especially not for configurations.
onEnable -> load everything into a class
Alright, ill change it thanks 🙂
https://spiget.org/
This is pretty much all that exists
that's what I'm using rn for just about everything
and I either didn't look hard enough or didn't find something to automatically track external downloads
kinda hard to do though
I dont think you can track those because external download could need more than one step
I'm thinking for my use case only accounting for github repos and then using github's api
because otherwise like
idk
I just don't think anything else is plausible
inb4 you come across me over the plugin size limit so serving a static file from my vps
Tf are you coding that’s that big
Mans shading all of maven central
Is there a way to make it so the give command doesn't discard the excess items and instead just drops them to the ground? Like Essentials breaks it I think?
You’d need a custom give command
Sure. Just add all items and use the Map<Integer, ItemStack> returned by the addItems method
to drop all overflown items on the players feet
so I'd need to make a custom give command
Yeah ofc
Is there any stash*?* type plugin like the one on hypixel that excess items goto a like item limbo?
Unless you intercept the PlayerCommandPreprocess event
I mean you’d still need custom logic if you intercept it
Sure you could make some kind of system to store excess items
Keep them in a database or what not
I’m not sure if any exist already
can I have a plugin that modifies another plugin? like super the essentials give command? or something?
It is
that's very true
But you can’t really edit their command from your plugin
Maybe if you did some bytecode jank
There is also a temp inventory implemented in such scenarios too
In case you didnt know about it
What
well right now the issue I'm having is if you give item, it says not enough space and just deletes it
Sorry not temp inventory
declaration: package: org.bukkit.inventory, interface: Inventory
The returned hashmap is all the items that couldnt fit
is their a way to tell what painting the player places down
EntitySpawnEvent
operator overloading when
Right click on the folder tree and create java class
Can you help me in voice?
you cant stream here
private call
idk how you need more help with making a class
I cant to send here picture
?img
Not verified? Upload screenshots here: https://prnt.sc/
you still didnt add the file tree
see there is no class file
show the file tree and i can tell you why
how can I add it
So far, every thing you ask for is already implemented in kotlin 😛
see
you dont have the file tree
this is a file tree
you need to include it in your screenshot
I want to change the NMS version of the plugin and the file is read only
I have
I know how to do it but tell me how can I create a class file
it wont work like that, but create file and name it something.class
but it not with the C logo
becuase the C logo is intellij decompiling it i would guess, you still cant edit the jar nms by converting the jar to a zip then to a folder
you need to download the source from github and modify that
if anythng that plugin needs a major refractor
man im not gonna use kotlin
cursed shit
jree
lol
fuckery
Hey
yeH
dont really want to have load/store semantics cuz that only makes the program longer
so register based
One question guys, should I make an interface for my GUI Inventories?
i had to translate assembly into binary and hex on my exam
the course is about processor itself(ALU and stuff)
wdym an interface
probably want to separate gui from listener
as every instance would register another listener
i would say keep the listener in there
okok
or how was it called
if you have the listener elsewhere you can only have 1 inventory
keep the listener in that class
all listeners for all inventories will be called for inv click event
yes, how are you gonna tell if its yours
have a Map<Inventory, CustomInv> to dispatch events
you keep the inventory instance
thats just a pointless class imo
f
new MyOwnHolder()```
let me see
if (!(inv.getHolder() instanceof MyOwnHolder)) return;```
yo
where does this LF char come from
i have this with no other plugin
it's a \n that doesn't compile correctly ig
One way, is to just use an inventory holder
you are trying to add multiple lines¿
I don't think so
its a list, so just make a method to split at /n and convert to a string list
Could just use substring on /n and it gives you a list automatically
Or split works too
Have you tried \r\n
yep
i get the same weird unicode block with ch in it
but I fixed it with the lists
not a nice solution but meh
Sounds like encoding problem
yep thought so too, but I have everything set to UTF-8
Would suggest setting the string specifically to utf8
Hmm
What was the code?
Because that LF character means line feed which is correct
Were you using character literals?
That is were you using single quotes or double quotes
double quotes
Try with single quotes
Double quotes means you want to actually show the character and it not be interpreted where as single quotes means take this literally. Hence the term character literal
Is there any way I can prevent the player's cache from being saved in the world?
wdym
what is that?
Ah ok, sorry I'm using the translator as I don't speak your language. I wanted to prevent the player's data from being saved, because every time I enter I'm in the last position I was and with the same items. If you can help, thank you
which is your main language?
I don't really understand what you mean by that
Portuguese
it is working as it should?
They dont want the player data and location saved
how so?
that
They probably have some kind of minigame where they dont want that saved. So they want it wiped on exit
yes
you could set it to wherever you want them to spawn after the minigame ends
I think you are failing to understand
Not all minigames are controlled by plugins
They probably have a manual controlled one
And their issue now seems to be just wiping inventoried and resetting the locations
Does that make more sense?
yeah
Is it possible to save a class to a file using FileConfiguration
Like, a serialized version of the class
I know how to save fields individually but is it possible to simplify that if the class is too big
then we should know how the minigame works right?
I just wanted to know this because like, if I'm in a minigame world, and I leave the game, I'm back in the minigame world. But I was actually supposed to be born in the lobby
yes, there's an interface you can implement. lemme find the javadoc rq
I would listen to player quit event and if they are in a determined world then set their location at the lobby and clear their data
Dont need to. They either need a plugin or make use of settings and in game elements to acconplish this. If it is a manual minigame they could easily setup a couple command blocks for this
thanks
listen to frostalf
declaration: package: org.bukkit.configuration.serialization, interface: ConfigurationSerializable
There is some plugins and will have to look for them that do wipe inventories on exit
I use plugins
As for resetting location there is a setting you can use but for it to work you would need your lobby world to be the first world
which?
I dont know it off the top of my head. Just take a look in server.properties, spigot.yml or bukkit.yml
OK, thanks for the help
Anyways time for me to drive home 
Oh yes! I use that but how can I write it using FileConfiguration?
assuming you have a field of FileConfiguration named config and one of a class implementing the aforementioned interface named foobar:
config.set("key", foobar)
to get it use config.get("key"), i believe you can cast it afterward
Yep you cast it after :3
indeedio, idk where but i have seen an empty string be passed in as the key too so if you want to just directly store it on the root you could do that
been a while since i messed with configs so take that with a grain of salt
Thanks to both!
anytime!
I'm using split config files anyways!
So key won't be an issue
1 file per object
noice
?paste
You just started, that's fine as it seems
pretty sure this.config is gonna npe but i might be wrong
I tried to make a class but couldn't make it work
well yes, besides that
Abstract your configs
this.config = YAMLConfiguration.load(file)
in my main class I have public static GUIConfig guiConfig; onEnable(): guiConfig = new GUIConfig(this)
this is wrong?
No
But still
Line 30 will npe
this.config.load(guiFile);
to
this.config = YAMLConfiguration.load(file)
i should deffo sleep
public GUIConfig(Realms plugin) {
this.plugin = plugin;
File guiFile = new File(this.plugin.getDataFolder(), "guis.yml");
if (!guiFile.exists()) {
guiFile.getParentFile().mkdirs();
this.plugin.saveResource("guis.yml", false);
}
this.config = YamlConfiguration.loadConfiguration(guiFile);
}```
this is better?
i was thinking the npe would be from calling load on a null object, didnt even think that it would npe on any config call
yeah
put
this.config = YamlConfiguration.loadConfiguration(guiFile);
Inside a try/catch
Your call, just safe practice
But good that you know to check how a method is implemented
what should I catch for?
I need some more assistance
If you're around
So, I'm doing the exact same way we agreed on
But it doesn't like the fact that I'm storing another object inside of it
!!me.tomisanhues2.ultrastorage.utils.UpgradeType {}: 1
[08:01:50 WARN]: could not determine a constructor for the tag tag:yaml.org,2002:me.tomisanhues2.ultrastorage.utils.UpgradeType
[08:01:50 WARN]: in 'reader', line 12, column 7:
[08:01:50 WARN]: !!me.tomisanhues2.ultrastorage.u ...
These are my serialize/deserialize for that class
@NotNull
@Override
public Map<String, Object> serialize() {
Map<String, Object> map = new HashMap<>();
map.put("upgrades", upgrades);
return map;
}
public static UltraChestUpgrades deserialize(Map<String, Object> map) {
Map<UpgradeType, Integer> upgrades = (Map<UpgradeType, Integer>) map.get("upgrades");
return new UltraChestUpgrades(upgrades);
}
is it a good idea to check by inventory holder == null and name.equals(foo) for checking if it is my inventory¿
ah yes directives.put(name, readOperand(null, line.substring(line.lastIndexOf(' ') + 1), 0));
just compare inventory instances
Brush help me out
are you registering the serialzier
wdym
Yup
store the inventory in a list for example
ConfigurationSerialization.registerClass(UltraChest.class);
ConfigurationSerialization.registerClass(UltraChestUpgrades.class);
and check if it is in there?
This was working perfectly when I was storing inside PDC
idk what you are doing, o you have a custom inv class?
?paste main class and the config Serializable class(s)
Hold on
tag:yaml.org,2002:me.tomisanhues2.ultrastorage.utils.UpgradeType
Why is it trying to do something with that class
Oh...............
It's a fking enum
That's not serialized
LMAO
Do I do it exactly like I would do with classes for an enum?
Thanks bbygrl
Honestly I should do it but yeah
I could store it as a string tbh
But... not good practice
so the material enum isnt config serializable and niether do the other 2 interfaces it has, so im guessing the set method is calling toString
actually i dont think anything is even setting the material directly
I figured it out
material is rather trivial to serialize and deserialize tho?
public enum UpgradeType implements ConfigurationSerializable {}
@NotNull
@Override
public Map<String, Object> serialize() {
Map<String, Object> map = new HashMap<>();
map.put("upgradeType", this.name());
return map;
}
public static UpgradeType deserialize(Map<String, Object> map) {
return UpgradeType.valueOf((String) map.get("upgradeType"));
}
Simple as that
Cool stuff
have i just had intellij open while i watched a movie
ram eater
i onlyjust noticed so ig it did some form of sleeping
Well, I just changed my program to go from PDC storage to a file system same efficient as before but with the added bonus that users can change stuff individually and see all data for storages
return Collections.singletonMap pls
pdc is great for stuff people normally dont need to modify/see/edit
Yes indeed
What I did was
I made every chest have just 1 PDC value
Which is a UUID
And then I have a cache
So the UUID belongs to a file
i got bored one day so i made a player data class in my lib so i can create playerdata for players and that data is a yaml config on their pdc
Oh yes
That's actually cool stuff
I wanna find a way to simplify the need
Of making a serialize() deserialize() methods
For every class you want to serialize
Like... I have a class with 20 fields... gotta add them all manually
i got the idea from alex saying "i made the same as that because sever owners would complain that it takes too long to shutdown with their 24545 players"
wym
lol yeah right
is there a way to center the sword?
Loop all the fields in the class and add them to the map
hmmmm
Yeah but then I suppose there's the issue with
Sometimes you don't want everything
So then the alternative is doing it 1 by 1 lol
Can't have it both ways
You could use the one annotation gson uses for that
And if field have annotation, exclude it ^
offset the entire armorstand
and if i wanna rotate the armorstand, how i calculate this? xd
also swords look bigger on the hand than on a head
uhh
your offset gets rotated too
like
offset = 0.5, 0, 0 (imagine)
newOffset = offset.rotateAroundY(yaw)
alright just gimme this function rotateAroundY xd
or if you want to be clever, rotateAroundAxis(getDirection())
It's part of bukkit's vector
what represents getDirection()? EntityLiving#getDirection()?
thank u man
I need some help with git
I'm full lost
I'm currently on a branch which I made to do some big changes
And I'm ready to push them onto the main branch
But this IntelliJ git tab is confusing me
I commit all the changes to my current branch
commit and push to your current branch
and I'd just open a pull request on github and handle it there
or you can checkout master, Git -> Merge, and select your current one
it's easier
java is weird, it complains that i must be final when i use i but i can just make another final variable with its value 🤔
makes sense ?
somehow does
cant it implicitly copy i?
One question guys, I made a class that generates a config based on a .yml file, how could I check if the inventory was created by that class?
if all code ran on 1 thread it would be simple
but because java is multithreaded this becomes a bit hard
or well supports multithreading
hmm
Hey Guys! How do i create a Mob, thats following the Player like a pet (For example a Zombie which is normally Running after the player and follows him) and (in case of a zombie) does not attack the player but instead attacks other mobs, which are not the same "team" as the mob (not spawned by this player) Does somebody know how i can implement this?
I tried to use This Tutorial of Codedred to implement that the pet follows the player but i dont like this style of how the entity follows you. Its just so fast, unnatural and also very complicated https://www.youtube.com/watch?v=Fnonn5chXk4.
Does somebody know another way to implement this?
Custom pathfinder goals is here! I went very in-depth the best way I could to explain how custom pathfinders work. I hope you all enjoy and understand the video :D Thanks for watching!
P.S
Sorry about the damn zombie noise in the background forgot I had my mc sound on :(
Want more videos?
Become a Patreon support to gain access to more videos!...
codedred was the reason i started exposing collections 💀
How do you mean that?
ah fuck he's in here
fancy
yeah it generates a compiler warning
💀
im a web developer but decided to learn how to make plugins... for no reason at all but anyway, i have this: ```import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.*;
public final class Test extends JavaPlugin {
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Location loc = event.getPlayer().getLocation();
loc.setY(loc.getY() - 1);
Block b = loc.getBlock();
b.setType(Material.STONE);
}
}``` how do I put this in my server now?
im also having fun today
Your listener is also your plugin class ehh
you'd need to register the class anyways
me keeping resources from being gced, fun

looks like me writing a command framework
this is a bit more than a command framework
ok but then i just put this file in the plugin folder of my server? in another folder? what do i do?
mine ended up being jank so i just decided to use acf
After registering the listener (you didn't), compile and put it on the plugins folder
ok thx
might want to follow some tutorial
you coded that?
why does that task bar have farenhight on
is that a project you're doing for yourself tho?
yes
could I check the code
because I like american time format and this bitch checked automatically
I am making rn some guis and I am having headaches
smh
well there's a bit
there musnt be pain if you followed my steps
ffs
you didnt, so prepare to die
which steps
IfStatementModel
and a bit more
told you to use a map<inv, custom inv>
instead of messing with inv holders and putting a listener for each inv
why does it need a class for it
@tardy delta can you criticise my code?
1 sec
atleast something that sounds better than looking at assembly all day
each model looks something like this
go full on pls
main:
name: "Realms Menu"
size: 27
fill: true
items:
settings:
name: "Open Realm settings"
material: REDSTONE_TORCH
amount: 1
command: "realms settings"
custom_model_data: null
slot: 9
players:
name: "Manage the players in your realm"
material: PLAYER_HEAD
amount: 1
command: "realms players"
custom_model_data: null
slot: 11
tp:
name: "Go to your Realm"
material: GRASS_BLOCK
amount: 1
command: "realms go"
custom_model_data: null
slot: 13
delete:
name: "Delete your realm"
material: BARRIER
amount: 1
command: "realms delete"
custom_model_data: null
slot: 17```
this is the config where I am checking from
ehh
just make a whole class that parses that stuff
and you just associate an action to "delete", for example
this looks jank
like how I do here
wdym
how should I do it?
encapsulation
a getter, same as you did for everything else
do you have one GuiConfig globally?
getGuiConfig() return this.guiConfig?
thats what a getter is
wdym by that
srry for the noob questions
well you are always doing Realms.guiConfig
without code, it looks like he does
okok
your getDefaultBackgroundItem creates the same item every time but you keep calling that method in a loop, so id make a BACKGROUND_ITEM static field
does anyone have a guide on how to publish a sonatype repository for a multimodule project?
to avoid creating it over and over
maven or gradle
maven
add the server block in settings.xml and add the distribution management section to parent iirc
ah
before you ask how to add the server block i have no idea
check how jefflib does it
same issue after putting it in the parent
https://paste.md-5.net/bahizuvuki.java
this looks better @tardy delta ?
looks a bit better
yay
compared to the code I was coding last month I think I got better ngl
id probably create a static method somewhere, not in that class, to go from a config section to one of your custom guis
hmm
you can do that by just
new GUI(guiIdentifier)
and it returns one of my guis
it feels weird to interact with a config in a gui class
I was thinking of making the setItems a method in GUIConfig
and pass the inventory to that method
that would work better?
id make some kind of guimanager
oh and the most important question
how would I check if it is one of my guis?
checking for inventoryholder == null and name?
one way i have seen people do it is have a custom InventoryHolder class
but the name thing also works
have a Map<Inventory, GUI> in your gui manager which server as a way of finding the gui that was clicked
what do I do then, custom InventoryHolder, the name or the hashmap?
Doing it this way you can have your click consumers in teh GUI class
ye i havent seen him using click consumers tho
yet
brief explanation on what those are?
yo your password is in there
It alows you to have a single listener for ALL GUIs
might want to change that now
ooh
oh crap
oh wait my click consumer is in the gui item class
forgot to change it yesterday
raw text 💀
also idk maybe you need to send a hashed password
lemme open wireshark rq
Uhhh
How can I serialize a Material
Since it doesn't implement ConfigSerializable
in 'reader', line 35, column 7:
? !!org.bukkit.Material
just serialize Mateiral.name()
I hate using strings but I guess
don;t serialize a Material, you only need its name
and later call valueOf
Converting Vector to pitch/yaw
Do I need to change the storage type to a <String, Integer> and parse it every time?
I doubt it
MAp<Material, int> sounds like what looks like an itemstack
i think that they get capped to (-128, 127) at SOME point
https://documenter.getpostman.com/view/25405096/2s8ZDVb4jt#34e6521d-456d-4903-a59d-c6b98f56d0af
not sure tbh.
How can I check what I'm sending via WireShark?
Pastes.io API for https://pastes.io
Pastes.io is a simple and efficient pastebin for mainly code to be distributed neatly and efficiently across the web. Website where you can paste and store any type of text or code snippets online and share it with your friends.
well you can make a Map<ItemStack, Integer> and then just copy the ItemStack serializer and modify it to serialize your amount instead
if you want itemmeta to exist for your item as well
I thought but
Map<String, Integer> itemString = new HashMap<>();
for (Map.Entry<Material, Integer> entry : this.items.entrySet()) {
itemString.put(entry.getKey().name(), entry.getValue());
}
Solved it
Not the prettiest solution
don't you care about meta?
No
eh
Not for those
ok then
you can see it in your browser
open devtools
It's just the material and amount
go to network or requests idk what the tab is called
and look for a request to the login api
when you login
open dev tools on that site im requesting?
or anywhere in browser
on the login panel of the site
and then login
and check what it sends
but i gtg now srry
aight thx
imma firegure it somehow
well I don't get any new data in Network tab when I execute my code
any easy way to turn an org.bukkit.Color into ChatColor? the problem is that ChatColor seemingly doesn't allow for RGB and I want RGB for team names in scoreboard
uhh so
Bungee's ChatColor has a ChatColor.of
but in paper it's deprecated in favor of adventure
i do use paper in this project (shhhh no need for ?whereami i am fully aware of what the fuck i'm doing) but i'm fine with using bungee still
deprecation =/= unusability
hehehe
though it does seem like bungee's chatcolor takes in a java.awt.Color
hm
how'd i get around tht
?jd-bcc
java.awt.Color has a getHSBColor method, but org.bukkit.Color only has asARGB, asBGR and asRGB
hm
no shit?
java.awt.Color has a constructor that takes in r, g, b, and a as floats
it's especially helpful when the two methods i'm looking for has no docs
thanks elgar very cool
oh ty
no prob
there's also a constructor that only takes in r, g, and b if you don't care about alpha
yeah i'm using it rn
aight
btw how'd i convert from a bungee chatcolor to a spigot chatcolor
i only see the opposite
from spigot to bungee is straightforward
other way around isn't
You can do ChatColor.of("123123") and it parses #123123
does it require some witchery and use of another random class
hmm
still bungee though
isnt there a way to see who cloned it?
names
can't you clone without being authenticated
you can clone without logging in can't you
Anyone familiar with Rest?
Im trying to login to pastes.io via Java
like this: https://paste.md-5.net/buzuhojawa.cs
but get this error: https://paste.md-5.net/uyiqegequt.makefile
How should I handle having my premium plugin (private repo) being a fork of a my free plugin (public repo)
We could host some form of version control on our own dedi, we would prefer not to do that though
No, It can be anonymous
probably reqwuires a missing header for browser
if thats meant for me
I'm following this https://documenter.getpostman.com/view/25405096/2s8ZDVb4jt#34e6521d-456d-4903-a59d-c6b98f56d0af
Pastes.io API for https://pastes.io
Pastes.io is a simple and efficient pastebin for mainly code to be distributed neatly and efficiently across the web. Website where you can paste and store any type of text or code snippets online and share it with your friends.
ooh I was missing s in https
How to make it so that items from the inventory can only be taken?
Prevent items from being added?
NumberFormatException: For input string: "arr_st+i_off" smh
and me who thought writing parsers was fun
yes
That is the answer...
You just prevent them from being added to the inv by cancelling the InventoryClickEvent and InventoryDragEvent
wondering how id write a regex to split lda [arr_st + i_off] into lda and [arr_st + i_off] and ignore spaces within [] lol
guys how i can use hex color?
(lda)\s*(\[.+\])
Group 1 is lda, group 2 is [arr_st + i_off]
Whitespace inside of the [] being ignored entirely, whitespace between lda and [ is ignored as well
well lda is just an opcode, so should be anything with letters
Then you can replace lda in that RegEx with something like (\w{3})
(or {2,3} if it's 2-3 chars)
(\w{3})\s*(\[.+\])
Fun feature in RegEx, you can name your groups as well
(?<opcode>\w{3})\s*(?<instruction>\[.+\])
Then you can get opcode and instruction as groups instead of 1 and 2
im wondering if there isnt just a better way 🥹
what's the correct maven scope for shading again?
not sure how optimized String::split is
I've been on gradle for too long
for parsing a whole sourcecode file
compile
thanks
or leave it blank
Default is compile, yeah
ah it'll not document it then
/scoreboard objectives setdisplay belowName - what's the alternative for spigot?
nvm accidentally figured it out lol
Gradle on top
scoreboard.registerNewObjective("kingdoms", "dummy", "Kingdoms")
.displaySlot = DisplaySlot.SIDEBAR
\s+ is at least one whitespace character
You can use * instead of + if you want 0 or more
well i mean so the fast way of split() isnt used
internally just compiles a pattern every invocation then
Yes
i probably want to write my own split
I do kind of wish they would add a String#split(Pattern)
Pattern#split(CharSequence)
time to reverse engineer lol
this all needs to work
everything behind ; is just removed
I mean I'd avoid RegEx all together then. Looks to me like you can just split based on one whitespace and limit the split
well there theoretically isnt a limit for operands
imma just go hunt for spaces and if that space is within [] ignore it
String[] parts = instruction.split("\s", 2);
String opcode = parts[0];
String args = parts[1];
int commentIndex = args.indexOf(';');
if (commentIndex > -1) {
args = args.substring(0, commentIndex);
}```
limit being the max amount of strings in the result array?
Yes
So lda [arr_st + i_off], despite having 3 whitespace chars, limits the split to only 2 elements. It would result in ["lda", "[arr_st + i_off]"]
what when you have smth like add [a] b
will that also just return an array with two parts?
ah it concats all params
imma just go implement my own split method
?rules
Please read the rules: http://j.md-5.net/1ikUQuU
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
idk if you can 'parse' that with a simple split operation
Pattern#split can it so yes
id rather not use patterns for every line of code so imma write something more simple
ehhhh
[, [i_off], ] now 💀
last and first part are just gone cuz of that prevSpace var
Good afternoon, I want to ask for help, namely how to save and load my classes from the config?
you want to save your class as a yml config section and retrieve it back to a class?
The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...
Yes
just messing around with setting and getting values from that config ^^
sta [i_off] 0 -> [sta, 0, [i_off], ] lol
ah wait im an idiot
basicaly you save its fields
and contruct new instance
new Class(valueFromConfig, valueFromConfig2);
why do you even need this tho
how to block the removal of things from the armor stand?
interactAtEntityevent?
just this way?
would it be easier to serialize the classes?
yup
I read that there is such a method, but for some reason it does not work for me.
says no such method exists.
oh sorry, its for paper
but spigot has it
has what
what project version
spigot just has this locktype thing
Oh, I did.
i get this error when i connect to it connection timed out no further information what should i do to fix it
can some one help me fix this issue
Some users get this issue in 1.8.x, yet I do not. Its due to a GSON issue not being inside spigot 1.8, so I then shaded it into the plugin
which is why it worked for me and not others. What should I do about this?
Should I just make my own custom parser for the JSON data, find a different one
well why dont you just share the shaded jar
so it works fr everyone the same way it works for you
I believe I did?
which is the weird part
Seems to be the same file size too
Indeed it is
Make sure you relocate it
pp 
😏
i'm a mature gentleman
Sorry, what do you mean by this exactly?
using maven shade plugin, you're able to relocate libraries and whatnot
We just refer to it as PPM so we dont have to type "PP" Everywhere, Plugin Package Manager
gradle 😭
relocate
Moving the package of the shaded gson so it doesn't conflict with existing versions
me either!
Okay thank you both, will look into it
please help, when saving the config this
Are you trying to save a CraftAttributeMap???
no
Then why is it trying to save that to your file?
You're probably trying to save an entire entity for some reason
yes
ArmorStand
Yeah don't do that
Entities cannot be saved in a config in any way?
Save the important information that you need or use NMS and save it to json
why
^
entities are really already stored in a file
if you manage to read it (and i think there are open source nbt readers for minecraft) you won't need this witchcraft
Okay, I understand, but can I save inventory? Or do I need to get a list of items?
probably better to save a list of items
itemstacks are natively supported for serialization by bukkit
Someone can help me importing the config?
what config
I got this method: ```java
@Override
public void onEnable() {
saveDefaultConfig();
getCommand("fg").setExecutor(new CommandManager(this));
prefix = config.getString("prefix");
// Message
onEnableMessage();
}```
That goes to:
public CommandManager(Plugin plugin){
subCommands.add(new RandomSubCommand(plugin));
}```
That goes to:
```java
public RandomSubCommand(Plugin plugin) {
super();
this.plugin = plugin;
}```
Only to do this:
```java
String prefix = ChatColor.translateAlternateColorCodes('&', config.getString("prefix"));
Error:
The NullPointerException, (commonly referred to as NPE), is thrown in the following cases, but not sealed to: 1. null is passed into a method or constructor which does not allow it; 2. When trying to access a field on an object pointing to null; 3. Casting null to a primitive. See https://stackoverflow.com/a/3988794/17047120 for information on how to debug NPEs.
public RandomSubCommand(Plugin plugin) {
super();
this.plugin = plugin;
}
Plugin plugin;
Configuration config = plugin.getConfig(); // Line 22```
It shouldnt be null, the plugin exists, the config exists and the path is there.
What should i change?
assign config in your constructor
okay
same as you do for plugin
are there any shop plugins that dont have an econemy tied so you can trade items for items?
should replace plugin with config, or pass both?
you move the Configuration config = ... into the constructor
oh
lol
Just changed java public RandomSubCommand(Plugin plugin) { super(); this.config = plugin.getConfig(); }
you removed this.plugin = plugin
yes
if this is line 21 this.config = plugin.getConfig(); you are passing null
This is line 21: String prefix = ChatColor.translateAlternateColorCodes('&', config.getString("prefix"));
is that another field?
public class RandomSubCommand extends SubCommand{
public RandomSubCommand(Plugin plugin) {
super();
this.config = plugin.getConfig();
}
Configuration config;
String prefix = ChatColor.translateAlternateColorCodes('&', config.getString("prefix"));
yep
I already told you ALL fields are initialized at class instantiation. You can;t use config as it's not been assigned yet. your constructor has not run
OHH
RIGHT
SORRY
Well, it didnt crash, but know the command doesnt work, lol
nah nvm
i was spelling wrong
Why is my plugin giving me errors when i try to open the MenuInventory?
error: https://paste.md-5.net/ibirazawem.bash
code: https://paste.md-5.net/gifetihogi.java
whats at line 81
public void openInventory(final HumanEntity ent) {
ent.openInventory(inv1);
}
the middle one
oh thanks
@EventHandler public void onPlayerChat(AsyncPlayerChatEvent event) { Player player = event.getPlayer(); String chatMessage = event.getMessage(); ChatColor currentColor = ChatColor.valueOf(player.getDisplayName().split("§")[1]); String replacedMessage = currentColor + chatMessage.replace("ꐥ", ChatColor.WHITE.toString()).replace("ꐦ", ChatColor.WHITE.toString()).replace("ꐧ", ChatColor.WHITE.toString()).replace("ꐨ", ChatColor.WHITE.toString()).replace("ꐩ", ChatColor.WHITE.toString()).replace("ꐪ", ChatColor.WHITE.toString()).replace("ꐬ", ChatColor.WHITE.toString()).replace("ꐫ", ChatColor.WHITE.toString()).replace("ꐬ", ChatColor.WHITE.toString()).replace("ꐭ", ChatColor.WHITE.toString()).replace("ꐮ", ChatColor.WHITE.toString()).replace("ꐯ", ChatColor.WHITE.toString()).replace("ꐰ", ChatColor.WHITE.toString()).replace("ꐱ", ChatColor.WHITE.toString()).replace("ꐲ", ChatColor.WHITE.toString()).replace("ꐳ", ChatColor.WHITE.toString()).replace("ꑊ", ChatColor.WHITE.toString()) + currentColor; event.setMessage(replacedMessage); }
guys someone know why don't work?
the simbol is emoji
Does the deserialization works perfectly with ItemStack using the serialization of .serialize()?
yeah
Okay, I've just tested it out, and yeah it does, my problem is that if I try doing a test deserializing the serialized itemStack on my main hand for example, and then re giving it, that works, but not with Gson
I mean, it doesn't hold the ItemMeta with Gson
item meta is serialized seperately
wdym?
the serialize method just handles the stuff not on meta, the other stuff is handled in its specific file
But why doing something like this would work even on meta and not on Gson?
im pretty sure that entire system is designed on yaml and configuration serializ-able, for gson you either need to write a type adapter to serialize/deserialize or convert the stack to b64
Do you have any snippets?
ive got stuff for b64, one sec
https://paste.md-5.net/aguduleray.php I've tried using this, but this doesn't hold nbt stuff and I can't left that on its own
that is pretty much a type adapater, just not made to work as one
😦
public static ItemStack itemStackFromBase64(String base64) {
try {
@Cleanup final ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(base64));
@Cleanup final BukkitObjectInputStream dataInput = new BukkitObjectInputStream(inputStream);
return (ItemStack) dataInput.readObject();
} catch (IOException | ClassNotFoundException e) {
e.printStackTrace();
return null;
}
}
``` & ```java
public static String toBase64(final ItemStack item) {
try {
@Cleanup final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@Cleanup final BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream(outputStream);
dataOutput.writeObject(item);
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
``` The @Cleanup is from lombok
why do people keep insisting to use base64
also why are you using Cleanup instead of try-with-resources o0
7smile gave me it
yikes
What do you suggest then for an itemstack saving on a db
the byte array
who really wants to make a type adapter that serializes everything on an item
including all possible nbt values
someone knwo? sorry for re - tag
why would you put a byte array in a json file
just use BukkitObjectOutputStream -> ByteArrayOutputStream -> you have a byte array
why json in the first place? i thought it was for a sql db or sth
it was using gson so json
b64 for items in json, yaml just use the bukkit methods, db uses byte[]
I was talking about this
thats just a method in my lib
free to use if i ever need
the only place ive used it so far is in a gson type adapter
idk base64 is just byte[] with extra steps
again why would i put a byte array in json
Byte array in json 💀
Nah fam just stick with base64
byte aeray in a json file is not a pretty sight
its not pretty but its better than spending 9 hours serializing every edge case of an item stack
why would one transform it into sth anyway when one already has yaml, which basically is json
I mean, just do ItemMeta#getAsString() and you already have json
go convert bukkits config serializable to work in json
Json is fine for low player counts as data storage which is probably where it was being used
idk json is just "hard-to-read yaml" lol
I actually quite like json I use it for everything non spigot
also how do you convert the ItemMeta.getAsString() back to an ItemMeta
Bukkit has a static method
How would I be able to put an item inside of a chest, generated by minecraft, for example in a village
but if I want to get them back i have to use the deprecated namespace key constructor right?
is there an easier way to read these back without having to use the forbidden constructor
ItemFactory#createItemStack
no
NamespacedKey.fromString
Right? drives me up the wall
Why do you want byte array in json
and it works majestically
If you wanna get technical, it's SNBT
I used it for translating a name
how new is quite
whatever, it's a string that one can throw into a json file and then it's done
Early 1.19 I think I added it?
no need to do any byte[] or base64 shit
yeah definitely 1.19.X
I wouldn't rely on SNBT for serialization
hi Choco, I have found your legal address and am now driving to your location to calmly ask you to PR a better components system
damn thats too new
I'm still coding in ancient 1.18.2
1.18.2 added it
Rip
I just checked
still too new
I wouldn't rely on SNBT for serialization
declaration: package: org.bukkit.inventory, interface: ItemFactory
what isn't too new
Use byte serialization because at least that way it can be future-proofed with Bukkit's serialization versioning
pdc is kinda new 🥴
The ItemFactory parser doesn't do any data fixer uppers
i only learnt about PDC in 1.16
namespacedkeys are fairly new
1.17
item ids
tbh everything after 2003 is too new
Poor punctuation. It was a statement
1.13 is also already 5 years old
my first plugin was 1.13 🥲
?188
?1.8
Too old! (Click the link to get the exact time)
holy hell
7.5 years
almost matches my younger sister
do you think she'd like coding in 1.8 api
How od i block players from clicking on item 8 in their inventory?
what if i need an IF statement checking for an inventory? What inventory do i check for?
there's a magic thing called inventory viev
view*
which has a top & bottom inventory
you can find it in the event
vers inventory when
When I try to set the type of bed to air aka deleting the bed, the bed drops on the ground, how can I prevent this?
set both parts of the bed to air
I have the same problem with lanters and ladders
and I set an entire layer, not just a block
Hey,
i have a Problem i recentry swaped Distro to EndevourOS so i run the BuildTools with following command
sudo java -jar BuildTools.jar --rev 1.19.3 --remapped
after it compleded Sucessfully:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Spigot-API 1.19.3-R0.1-SNAPSHOT .................... SUCCESS [ 7.786 s]
[INFO] Spigot-Parent dev-SNAPSHOT ......................... SUCCESS [ 0.005 s]
[INFO] Spigot 1.19.3-R0.1-SNAPSHOT ........................ SUCCESS [ 37.921 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 45.959 s
[INFO] Finished at: 2023-04-04T20:26:07+02:00
[INFO] ------------------------------------------------------------------------
the remap jars cant be foud
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Could not find spigot-1.19.3-R0.1-SNAPSHOT-remapped-mojang.jar (org.spigotmc:spigot:1.19.3-R0.1-SNAPSHOT).
Searched in the following locations:
file:/home/tom/.m2/repository/org/spigotmc/spigot/1.19.3-R0.1-SNAPSHOT/spigot-1.19.3-R0.1-SNAPSHOT-remapped-mojang.jar
and the jars are not present in the .m2 local folder
try moving the --remapped to before the --rev
nop
?nms
look just above that section in the log. It shoudl list what it's installing into .m2
Hello guys,
any thought of identify a custom inventory but not method like hashmap or inv holder
just upgrading my plugin from old version to 1.19.4 ⛏️
instance is the correct way to identify an inventory
umm ...
which means that i have to create a class of extended Inventory?
[INFO] Installing /home/tom/BuildTools/Spigot/Spigot-Server/target/spigot-1.19.3-R0.1-SNAPSHOT.jar to /root/.m2/repository/org/spigotmc/spigot/1.19.3-R0.1-SNAPSHOT/spigot-1.19.3-R0.1-SNAPSHOT.jar
[INFO] Installing /home/tom/BuildTools/Spigot/Spigot-Server/dependency-reduced-pom.xml to /root/.m2/repository/org/spigotmc/spigot/1.19.3-R0.1-SNAPSHOT/spigot-1.19.3-R0.1-SNAPSHOT.pom
[INFO] Installing /home/tom/BuildTools/Spigot/Spigot-Server/target/spigot-1.19.3-R0.1-SNAPSHOT-remapped-obf.jar to /root/.m2/repository/org/spigotmc/spigot/1.19.3-R0.1-SNAPSHOT/spigot-1.19.3-R0.1-SNAPSHOT-remapped-obf.jar
[INFO] Installing /home/tom/BuildTools/Spigot/Spigot-Server/target/spigot-1.19.3-R0.1-SNAPSHOT-remapped-mojang.jar to /root/.m2/repository/org/spigotmc/spigot/1.19.3-R0.1-SNAPSHOT/spigot-1.19.3-R0.1-SNAPSHOT-remapped-mojang.jar`
the shoud be there but they arent
it looks like you are using gradle. Did you add your local repo?
mavenLocal is added
then no clue
if I want to check how long ago was some timestamp
Should I use SimpleDateFormat or DateTimeFormatter
How can I retrieve tags given on an ItemStack by for e.g. /give @s item{...,Tags["the-thing-I-want-to-check"]}
Thanks for ur help , it works !
how to make armor stand indestructible?
I thought Invulnerable was responsible for this, but nothing changes
what would be the best way to make it so that non whitelisted players spawn into a different world than the whitelisted ones?
make a config
teleport on first join
