#help-development
1 messages ยท Page 2115 of 1
so the whole PDC is stored inside an NBTCompoundTag called "BukkitValues"
so stubborn for what
thats stupid..
in some cases
why isnt there a fucking wrapper for nbt then if its that simple???
yeah I also don't understand that
i will do it
block_coord:
1,1,1
old_block
huh
nop
no mfnalex you cannot advertise promote your blockpdc in this case
customblockdata
whatever
"advertise" lol
exactly
i let redempt do it
i would like to not save blocks
yeah wait, now explain pls
you wanna map data in a PDC to a certain block "location"?
and when the chunk loads, i will get the blocks that i need to set again
so I can advertise my lib: https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
I advertise really good site download my plugin on.... spigotMC XD
you can do stuff like this:
- Save the data you want for every block you like
- Listen to CHunkLoadEvent, then do CustomBlockData.getBlocksWithData() or similar
- reset your blocks
alternatively, I have a library where you can simply store a List<Location> or Map<Location,BlockData> inside the chunk's pdc
https://paste.md-5.net/gezigawari.rb Hi why do i get this error if anyone can help me? it worked fine a bit ago now it seems to be broken
-> https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/ allows to use lists, maps, etc in PDC
in my case i just need the block type
?paste your code
what portion of it?
then you can use the second lib I sent and store a Map<Location,Material> inside the chunk PDC
the CustomMobs class
it sounds interesting but I'm just going to use the built-in bukkit stuff since it's a simple plugin
im trying to avoid libs
Alright, let me know if you want to try it out in the future
does that class access WilloMobTC class?
this is the whole code
what's WilloMobTC line 22?
i actually need to save the whole block data...
this is willomobtc
my lib can also save BlockData in PDC
it provides DataType.BLOCK_DATA
but why?
22 is CustomMobs.values() for loop
libs exist to make your life easier
consider your code as stolen now ๐ต๏ธโโ๏ธ
why don't you just shade it? ๐
if you steal it, you have to obey the license though ๐
alrighty
i don't know why but sometimes i just get this weird errors when initializing classes
is your whole code on github?
your problem is probably that you have a kinda "recursion" in your enum class
you are probably using values() inside the declaration of the enum itself
again the whole enum is what i sent, theres not mention of values there
that is, one of your Mob classes accesses the enum
uhh
which cannot be
it works like this:
- Java static inits your enum
- It creates one instance of every of your mobs
- one of those mob classess access the enum
- FAIL! Your enum class isn't fully loaded yet
could this be it?
you can avoid this by not making it an enum, but simply a normal class with many public static final fields
is that in one of your mob classes?
if yes, that's the problem
yeah
yes. let me show you how I'd do it instead: (one second, I gotta open intelliJ)
okay
Avoid this:
public enum MyMob {
FirstMob, SecondMob, ThirdMob
}
ANd do this instead:
public static class MyMob {
public static final MyMob FirstMob = new FirstMob("FirstMob", ...);
public static final MyMob SecondMob = new SecondMob("SecondMob", ...);
private static final Map<String, MyMob> BY_VALUES = new HashMap<>();
public MyMob(String name, ...) {
BY_VALUES.put(name, this);
}
public static MyMob valueOf(String name) {
return BY_VALUES.get(name);
}
}
then make all your mobs extend MyMob and call super(name) in the constructor
because they are supposed to be static final constant values
that's the whole idea of an enum
they are supposed to be immutable
okay... i'll see. Thank you
np
e.g. take a look at bukkit's Enchantment class
it's basically a "fake enum" too
i assume BY_VALUES is supposed to be a map?
oooh yes ofc
my bad, I typed it in notepad
ok that makes more sense
fixed, thanks
conventions
I TYPED IT IN NOTEPAD; DON'T BOTHER ME BRUUUUH
I will only talk to imajin again after they played the 2015 or 2016 trivia with me
to explain it again: you access the values() method before the $VALUES field has been "finished". Since enums are supposed to be "static final" and immutable, this thing doesn't exist yet unless the whole class has been initialized / until all your mobs have been created.
got it thank you
oh btw another tiny thing
you used toString on the enum
you should rather use name() on enums
although actually it doesn't matter since it returns the same thing lol
lol
Anyone has an api/library for loading spigot and bungee files without being all time changing the code?
wdym "loading spigot and bungee files"?
I mean a library which can load yaml files no matter if spigot or bungee
SnakeYaml
it's what bukkit uses internally
you can just shade it yourself
Does it contains sections?
no
Oh ok
I done a simple one
every "section" is simply a Map<String,Object>
But i cannot implement the section part
imagine this:
mnfalex can you help me?
section:
name: "mfnalex"
age: 27
now you can use SnakeYaml and do this:
Map<String,Object> section = myYaml.get("section");
section is now a map that contains:
name -> mfnalex (String)
age: 27 (int)
@quaint mantle getLocation always returns null
then there is no location at the given node
Here you have https://paste.md-5.net/iforoxamim.java
I dont know how to code the getKeys(boolean deep);
Afk 5 minutes, then iโll answer
hmm
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
Player p = (Player)commandSender;
Cash cash = new Cash();
Configs.load();
if(command.getName().equalsIgnoreCase("paracek")) {
p.sendMessage(Configs.get().getLocation("location") + "");
if(p.getLocation().distance(Configs.get().getLocation("locations")) < 4) {
cash.getCash().setAmount(Integer.parseInt(strings[0]));
p.getInventory().addItem(cash.getCash());
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "money take " + p.getName() + " " + cash.getCash());
}
}
return true;
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent e) throws IOException, InvalidConfigurationException {
Player p = e.getPlayer();
Bank bank = new Bank();
Location location = e.getBlock().getLocation();
if(!(e.getItemInHand().isSimilar(bank.getBank()))){
return;
}
if(!(e.getBlock().getState() instanceof TileState)) {
return;
}
Configs.load();
Configs.get().set("locations", location);
Configs.save();
Block block = e.getBlock();
BlockState blockState = block.getState();
TileState tileState = (TileState) blockState;
PersistentDataContainer container = tileState.getPersistentDataContainer();
NamespacedKey key = new NamespacedKey(Main.getInstance(), "blocks");
container.set(key, PersistentDataType.INTEGER, 1);
tileState.update();
}
``` @tender shard
?paste
so basically your getKeys(boolean) method should look like this:
if(!deep) return nodes.keySet();
return getKeysDeep(nodes, new ArrayList<String>);
and getKeysDeep:
private static List<String> getKeysDeep(Map<String,Object> origin, List<String> list) {
for(String key : origin.keySet()) {
list.add(key);
Object thing = origin.get(key);
if(thing instanceof Map map) {
getKeysDeep(thing, list);
}
}
}
oh and of course you still have to join the inner keys using "." to the "parent" keys you already have
so getKeysDeep should also take a string called "parentPath" or similar
Allright, thanks. Now i will have to look how its with lambda :D
If you ask why im using Jackson its because i will add Json support too
there is no location saved at the node that you are accessing using getLocation
private static List<String> getKeysDeep(Map<String,Object> origin, List<String> list, String parentPath) {
for(String key : origin.keySet()) {
list.add(parentPath.isEmpty() ? key : parentPath + "." + key);
Object thing = origin.get(key);
if(thing instanceof Map map) {
getKeysDeep((Map<String, Object>) thing, list, parentPath.isEmpty() ? key : parentPath + "." + key);
}
}
return list;
}
something like this should work, but I haven't tested it
also erm why the heck are you checking the command's name?
are you registering the same CommandExecutor class to different commands?
i dont know, its an habit
hm okay yeah I also did that 10 years ago but it's basically totally useless lol
to entering if statement
your onCommand method will never be called for any other command anyway
i dont know why but i feel like i have responsibility to enter an if
what I also don't understand: you called the node "locations", but you always only save one location inside it? isn't "locations" supposed to hold more than one location?
yes, but i dont know how to do it
actually
I have told you that many times
use a List<Location>
and save that
and to retrive it, you can do
List<Location> locations = (List<Location>) config.getList("locations");
WHY THE HECK CAN INTELLIJ NOT AUTOCOMPLETE THE PUBLIC STATIC VOID MAIN METHOD
because you usin light theme
not everyone lives in a basement
write
psv
Set if he doesnt need dupes or ordering of insertion
Sad
Oh ig they changed it
pretty sure it used to be psv
psm also works because autocomplete
I mean that makes sense, cuz psv is only public static void
actually even p works
LOL
i made it list but still returning null
from command
p.getLocation().distance(Configs.get().getLocation("locations")
does someone an idea on how to improve this?
static String pad(String string, int length, char filler) {
int originalLength = string.length();
int difference = length - originalLength;
StringBuilder stringBuilder = new StringBuilder(string);
for(int i = 0; i < difference; i++) {
stringBuilder.insert(0, filler);
}
string = stringBuilder.toString();
return string;
}
dont tag him, you are not paying for fast support
and which are the chinese characters?
I already told you this 3 times. you don't have any location saved at the node "locations"
?
?
He should use @ everyone XD
exactly! You saved a List<Location>
yet you are trying to get a location
however at "locations", there is no Location. There is a List<Location>
Oh lmao i think its ?learnjava moment
@everyone
I thought it returns all locations on file
?
getLocation(X) obviously returns a location that's saved at node X.
If there is no location at X, for example because X doesn't exist, or because X is not a Location, but... a String, or a List<Location>, then obviously getLocation(X) returns null
List<Location> locations = config.getList("locations");
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.
i know wtfffffffffff
What is this trying to do?
e.g.
"mfnalex" -> "0000000000mfnalex"
it basically fills the string with "filler" chars until the string has "length" length
Ohh
And where does it take the chinese characters? x2
then ig better the method name
e.g.
public static void main(String... args) {
String string = pad("mfnalex",20,'0');
System.out.println(string);
should print 0000000000000mfnalex
That can be use for code obfuscation?
I need this for my string encryption because obviously %%__USER__%% has different lengths. some people have a user id of 1726, others have an ID of 1751261. So I need to "pad" the string to have a fixed length all the time
if its all about numbers convert it to bin, hex, whatever
no that makes no sense, since spigot itself replaces the placeholder when downloading the jar
So can or not?
I cannot convert anything or whatever
But could the method used for method obfuscation?
I upload
String string = "%%__USER__%%adsasdasd";
then two people download it. some people get this:
String string = "123asdasdasd";
other people get
String string = "814561asdasdasd";
Why I still can't extend EntityVillager, I have both Spigot and Spigot-Api
regex issue
I need ideas to make
something with generics
yes thats because
it's quite easy, look at this:
i forgot
node1: Something
node2:
- something1
- something2
what the f*ck is hashsets
obviously node1 is a string, node2 is a list of strings
yes thank you for helps
a HashSet is a collection (similar to a list) that can hold many objects, but every object only once. and objects are "identified" by their hashcode (Object.hashCode())
yes i forgot what it is while dealing with yaml file
Sorry but no need to lie
you definitely never knew what it was
You dont forget stuff like that this easily
Does anyone know why this doesn't get my item in the main hand except for everything else?
for (int i = 0; i < 41; i++, itemStack = this.player.getInventory().getItem(i)) {
if (itemStack != null) {
Bukkit.getLogger().info(itemStack.getType().name());
}
}
nvm I figured it out
Is there a way to get the "weight" of an entity?
i know?
erm wtf is the "weight" of an entity?
(Aka the thing you use to calculate how fast an entity falls)
they all fall equally fast, don't they?
useless guess
Nope
can you give an example?
For example, a player falls faster than a dropped item
hm
well nonetheless I have to armchair quarterback: gravity has nothing to do with weight
๐
I mean
I'll just explain what I want, I'm trying to make a function to launch an entity to a location with an arch
a feather is equally attracted by gravity as an anvil is
I got this but it doesn't work 100% of the time (mainly to be attributed to the gravity variable)
public static Vector calculateVelocity(Vector from, Vector to, double heightGain, double gravity) {
// Block locations
int endGain = to.getBlockY() - from.getBlockY();
double horizDist = Math.sqrt(distanceSquared(from, to));
// Height gain
double maxGain = Math.max(heightGain, (endGain + heightGain));
// Solve quadratic equation for velocity
double a = -horizDist * horizDist / (4 * maxGain);
double b = horizDist;
double c = -endGain;
double slope = -b / (2 * a) - Math.sqrt(b * b - 4 * a * c) / (2 * a);
// Vertical velocity
double vy = Math.sqrt(maxGain * gravity);
// Horizontal velocity
double vh = vy / slope;
// Calculate horizontal direction
int dx = to.getBlockX() - from.getBlockX();
int dz = to.getBlockZ() - from.getBlockZ();
double mag = Math.sqrt(dx * dx + dz * dz);
double dirx = dx / mag;
double dirz = dz / mag;
// Horizontal velocity components
double vx = vh * dirx;
double vz = vh * dirz;
return new Vector(vx, vy, vz);
}
private static double distanceSquared(Vector from, Vector to) {
double dx = to.getBlockX() - from.getBlockX();
double dz = to.getBlockZ() - from.getBlockZ();
return dx * dx + dz * dz;
}
if we were being technical, weight = force of gravity * mass, or F=mg where g = 9.81ms^-2
why did you say u "forgot" then
not ^-2
if only Minecraft used "mass" for entities
if you would be a big beginner u would understand.
oh wait of course, yes
g = 9.81m/s/s
but i guess you are not
I got confused by the notation you used
N/kg
big beginner?
a tall, fat beginner?
So is there any way I can find the "gravity" of mobs?
lmao everyone was a beginner
anyway, gravity is not affected at all by the weight of the object
only air resistance is affected by that
I use an entity util
which of course results in a slower fall
but the gravity itself doesn'T care about any air
u dont need to censor it tbf
no definitely not
its allowed to swear as long as its not excessive
fuck
yeah but I don't want to have to map out every entity
you could probably get the "gravity speed" with NMS
let me check if I find something
ig you'll struggle then
it just pissed me that ur trying to look like u knew what something is, when u clearly have read the term for the first time
that's what I was looking for
unless there's pathfinders that modify gravity but i dont think there are ;-;
just to not feel embarrassed i assume
I don't think so
well there MUST be one
I can clearly tell you that i know all lists maps and sets well
otherwise items would fall at the same speed
maybe not very functional but yes i know
I think it'd be pathfinders more than anything
Oh really?
can you please open a thread to mock each other, instead of doing it here?
what is a TreeMap
I believe certain entities just have their delta movement monitored and altered
queue situations
a mapped tree
tree and hash
nah im not trying to mock him
a map that sorts by a comparator
ik
alphabetical order i remembered as
so no hashing in principle
anyway pls stop this weird discussion, there's currently people actually looking for help
Several people are typing...
There ya go @tender shard
thanks lol
I think you'll have to decompile spigot / the orginal minecraft server, and then have a look at the entity's tick() or baseTick() method
Anyone has a Bootstrap library for loading bungee and spigot plugins?
there you'll probably see how "velocity" for falling stuff works, and then also see where that value comes from
idk if u need a library for that lol
but in reality just extract your bootstrap logic
I mean plugin.yml instead of spigot.yml
@tender shard I love how you asked me to open a thread and then said it in here lmao
No no you dont understand
oh no wait
and then delegate and invoke from respective entry points
I wanted the other persons to open a thread
they were like "ha you don't know java" "yes I do" "no you don't" - I wanted them to open a thread for it ๐
so that we can keep discussing actual questions here ๐
ha you don't know java
@granite beacon ur website is awesome btw
Thanks I'm working a new version (https://pns.dev) sorry more off topic ๐
who needs a topic
I mean is it really off topic when there is no real topic going on
this is spigot
big brain lol
boooooooooooost
So
I don't know who here was talking about entity falling speed
but
NMS Entity has an interface called "MoveFunction" with an "accept" method
I'll try to find something that implements this
I was
i may have just written the worst case of indentation madness (and i love it)
I was trying to figure out how on earth I can get the gravity variable to plop into that function
LivingEntity#travel(Vec3)
every LivingEntity has a falling speed delta of 0.08
it's basically hardcoded into the method itself as a local variable
so there is no way to figure it out easily
this is the base value for all living entities
what about non living entities?
that's too fancy
I couldn't find that yet
if u have an edited spigot version
it's a lot easier to read as 1 letter variables
would that work out
Poons what you could do is to super call it and override what needs to be overridden
or just override it completely
or use cheat engine to modify the variables on runtime
I think they want to find out the falling speed delta for existing builtin entities
^
but where would they get it from?
they want to find out "how fast would this entity fall if it would start falling now" AFAIK
yo my config is resetting to default on restarts n reloads
main: https://paste.md-5.net/ebacaguher.java
config: https://paste.md-5.net/uboqixuxin.java
u can do byte code manipulation to redirect to ur own method thoughh right
I just checked the NMS Item class and couldn't find anything in there
uh to some extent
maybe it's inside the WorldServer / ServerLevel class
predicting is impossible, but like, again delta movement can be relatively reliable
yeah but we need something like this:
double playerDeltaV = player.getFallingSpeed(); // would be 0.08
the falling speed isnt constant tho, there are a lot of things taken into account
I found it in LivingEntity but I just checked and "items" (dropped items) indeed fall slower but I couldn't find anything related to that
it is consistent for players at least
honey blocks, water, and slow falling just to name a few
yeah sure
I don't need to worry about those though
I am simply looking for where Items override the 0.08 value in air
cuz all of that can be considered "falling"
ive tried a bunch of different stuff but i cant get it to work, i even put my default config thing in the plugin and then removed copydefaults n stuff but nothing seems to work rn
the config resets, or the actual file resets?
then you are obviously saving it somewhere
i thought maybe setup but thats only if it doesnt exist
final Map<String, ?> map = (Map<String, Object>) config.getMapList(path);
Material material;
Object objmaterial = map.get(ItemPaths.MATERIAL);
if(objmaterial instanceof String){
material = Material.getMaterial((String)objmaterial);
}else{
material = Material.AIR;
}``` This code should handle npe's correct?
mye
well getMaterial is nullable
oh yeah ๐คฆโโ๏ธ
your whole logic is a bit flawed
why is save() returning null all the time
TextComponentImpl{content="", style=StyleImpl{color=null, obfuscated=not_set, bold=not_set, strikethrough=false, underlined=not_set, italic=not_set, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[TextComponentImpl{content="ยง2Guild > ยงa[VIP] FabledLivid ยง3[E]ยงf: ", style=StyleImpl{color=null, obfuscated=not_set, bold=not_set, strikethrough=false, underlined=not_set, italic=not_set, clickEvent=ClickEvent{action=run_command, value="/viewprofile c5b96c06-149a-4c43-818c-eb2f883ee6b9"}, hoverEvent=HoverEvent{action=show_text, value=TextComponentImpl{content="ยงeClick here to view ยงaFabledLividยงe's profile", style=StyleImpl{color=null, obfuscated=not_set, bold=not_set, strikethrough=false, underlined=not_set, italic=not_set, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}}, insertion=null, font=null}, children=[]}, TextComponentImpl{content="bot is deing", style=StyleImpl{color=null, obfuscated=false, bold=false, strikethrough=false, underlined=false, italic=false, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}]}
How can I get the string from [TextComponentImpl{content="ยง2Guild > ยงa[VIP] FabledLivid ยง3[E]ยงf: "
TextComponent.getText() ?
well if u just want that just use .08?
@tender shard maybe I'm just looking for the wrong thing but I essentially want to have a function that will allow me to specify a height increase which will get the velocity needed to push an entity towards a location assuming there's nothing in the way.
Oop embeds are turned off
oh so given a max height, you want to be able to still make sure it lands where it should?
Correct
I did some searching on spigot/online and nothing lead me to a conclusive method I could use that was relatively accurate
mye
?
I mean problem is living entity kinda applies a lot of things when ever you apply a vector
one way would be to override w/a custom entity
I wouldn't be opposed to using one
let me try a few things rq
Alright, really appreciate it :)
Is there a function to see if there is a Worldguard protection in a location?
there's WorldGuard's API ๐
do you only care about worldguard, or other protection plugins as well?
RegionManager regions = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(e.getEntity().getWorld()));
ProtectedRegion r = regions.getApplicableRegions(BlockVector3.at(e.getLocation().getX(), e.getLocation().getY(), e.getLocation().getZ()))
I have seen the api, but I can't find any function that returns me if that location is protected or not
well
that's because there is no such thing as "protection" in worldguard per se
do you wanna check if there's a region at all? or do you wanna check if a player is allowed to build/break blocks there? etc
And then you can use r.getFlag(Flags.OTHER_EXPLOSION) or whatever protection you want to check for
probably not very useful but here's my WorldGuardWrapper for AngelChest:
https://paste.jeff-media.com/?148408d2a7eb4bb7#EzYYv4yGwQMJyKnFrhWd4g9AWmUaJH57b7QZGvfmH6Tv
Check that this area is protected by Worldguard
I just sent you the code you need to do that ^ @rain grove
I already told you - regions are not "protected" per se
players can for example be allowed to build but not break blocks
That returns if the protected region exists, and if it doesn't, it returns null?
so you have to tell worldguard what to test for
It returns a list (or array don't remember)
If it's empty then it doesn't have any region
Oh thanks! @tender shard thanks to you too
I'm going to try and see what I can do with it
Yes
I have add in dependencies both Spigot-Api and Spigot (version 1.18) but still can't extend to EntityVillager
Is there way of doing something like a Boostrap<T> class (with methods: onEnable, onReload, onDisable, getPlugin) so i can use that method without knowing if T is either JavaPlugin or Plugin?
Because the class is done, but i dont know how to them register the all the things by getting the plugin instance
Thank You
who know would so cool, but also impossible?
the ability to put custom items in the creative inventory
whut?
thatโs not how that works
A question about opinions. What is the best way to handle the config files in the plugin?
I mean, architecturally. Placing everything in the onEnable isn't the only option, right?
im boutta 1v1 your lib with my lib
there is a getText() method you can use
can you change an item's texture based on nbt/meta data with spigot?
It's acually just a Component
are you using adventure?
what's adventure?
yes
oh. i think i found my solution.
I can make it into Gson
that could work
So I have the GSON object here: ```{"strikethrough":false,"extra":[{"strikethrough":false,"clickEvent":{"action":"run_command","value":"/viewprofile 248d876f-eb5e-42d4-ac53-7258ca5e12d0"},"hoverEvent":{"action":"show_text","contents":{"strikethrough":false,"text":"ยงeClick here to view ยงbLoudbookยงe\u0027s profile"}},"text":"ยง2Guild \u003e ยงb[MVPยง2+ยงb] Loudbook ยง3[STAFF]ยงf: "},{"bold":false,"italic":false,"underlined":false,"strikethrough":false,"obfuscated":false,"text":"tsdasdasd"}],"text":""}
How can I get a specific peice of text? Specifically this one:
There are multiple "text": so idk how to get the one I want
object.getAsJsonArray("extra").get(1).getAsJsonObject().get("text").getAsString();
A parser really helps with this kind of stuff, something like http://json.parser.online.fr/ since you can see the JSON as a hierarchy and it's much easier to actually follow.
It doesn't seem to be able to transfer it to an Array...
my bad
Did you get it working?
hold on
Thank you so much
I have been doing this for so long
Lifesaver :D
you could use PlayerItemConsumeEvent and check if it's a honey bottle
it doesn't return the item, so you could just delay check the inventory after
we can battle once you implement generic PDC types that work with Collection<T> ๐
bet ill add them
i was actually gonna add a bunch of PDC types to this library as well
basically just start with Boolean/UUID and then go from there
however generic Collection sounds fun
I donโt think there is one
Youโd have to basically cancel the drink event and replicate the honey drinking behavior yourself
There is
see my message
But that wonโt return the glass bottle at the end
Which is what they want
The consume event fires before the glass bottle is added
they could just check a few ticks later ๐คทโโ๏ธ
Thatโs how you get glitches and exploits
he could just do what hyper said and remove the glass_bottle one tick later but theres an issue with duplication doing that
you might not even need to run it one tick later
idk how that event works but i assume it would happen after the actual consumption of said item
Thatโs how you get some jerk with a modified client doing something stupid
It does not
ehh let them duplicate glass bottles oh well
The event is cancellable and therefore has to fire before the actual consumption
ahh i see
probably gets called when a player starts eating/drinking
Lol
and fire it one tick after PlayerItemConsumeEvent
Thatโs probably how I would do it to be fair
Not one tick after
Iโd just patch the spigot to call my event
But thatโs not really viable for public plugins
well if you want it to be a public plugin then you couldnt really add a patch to spigot
Unless you mean PR your own event for it then yeah
Yeah I donโt do much public plugin dev these days lol
ngl im sure a PR for that event would get accepted
Event API explained in 30 seconds
Can I use json for config?
I mean youโd have to make it a little more refined but the general gist might be fine
If you support it yourself
Spigot uses YAML
What does that mean
you have to set it up yourself
thanks this explanation helped a lot !
Ok
If you write a system to read in/write out JSON files as configs or depend on a library
no problem lol
my library supports saving and writing json for you, but no docs are implemented for it yet
You canโt use the normal spigot configuration api though
^
Cool
just use any sane JSON library and you are good to go
Gson is nice
sure. but admins will hate you
I think minecraft provides it these days lol
oh shit fr
Why
Oh
because json sucks if you wanna edit it by hand
i much rather prefer json for configs tho tbh
My client is a developer himself he'll be fineeeeee
so much nicer to use
JSON is way better, both for the programmer and the person manually editing configs by hand
But
Itโs harder to ELI5
So itโs not as popular with spigot
Why doesn't spigot support json
it actually does
look at ops.json for example
All of the spigot configs are YAML
Let me try to explain:
doSomething: true
someMessage: "%player% did something"
otherMessages:
bossbar: "This is a bossbar message"
actionbar: "And another actionbar message"
Easy, right? Nothing can go wrong
This however:
{
"doSomething": true,
"someMessage": "%player% did something",
"otherMessages": {
"bossbar": "This is a bossbar message",
"actionbar": "And another actionbar message"
}
}
It's so stupid. Admin edits a message, and forgets to add "," at the end, or accidently deletes a bracket = FILE IS BROKEN
Minecraft went over to JSON a while back
True
but json looks soooo much nicer
and is ez
But my client is a dev he'll be fine
json parsers exist
your "client"?
because yaml where you delete a tab and suddenly your sections are out of whack and the entire config file regenerates itself is way better
Also, Yaml is a bit forgiving with it's string formatting. You don't need the "" marks in some cases
as long as he knows how to read and format JSON, go for it
He's a TS dev I'm very sure he'll be fine
people pay you to do plugins, yet you still ask here for help for basic questions? your "client" must be very naive tbh
type script
I always make my personal configs with JSON, itโs so much cleaner than a YAML config
And it deserializes right into whatever object I want
The person I'm working for
sorry but you're talking bullshit
I hate YAML
{{{ is not cleaner than a yaml file
They don't pay me
you can hate what you want. YAML is cleaner, by it's definition
Itโs very clear nesting, it mimics the nesting of the code
In the eyes of a js dev same
I don't wanna say that yaml is better, I just wanna say that yaml is "cleaner" / "easier to use" for admins
JSON is easy for developers not end users. YAML on the other hand is very user friendly.
the funny thing is that yaml is also easier to use in spigot
wtf is ELI5?
What if I had 2 config 1 is json the other is yaml
Explain Like Iโm 5
then you already fucked up
True. I honestly love how easy it is to work with. It'd be nice if the api supported other file formats as well as it does YAML.
why would you have 2 different formats for config files?
either go full json or full yaml
Why not
YAML is easier to use in spigot if youโre doing a few large configs
because it's stupid
what is the purpose
But you're not me
If youโre doing a load of smaller config files JSON is easier long term
obviously they'd rather use "normal" config files
there is no need to use Json EVER or configs
json just makes users go into rage mode
and it doesn't have any advantages either
Change doesn't hurt :/
JSON is a better format for technically skilled end users, Iโm not disputing that YAML is easier for the masses to get a grasp of
Changes also take effort, which a lot of people don't want to exert.
tbh that's bullshit
JSON to me is for APIs lol
YAML is the superior version of json
Yaml is dumb
Itโs just not lol
YAML is JSON dumbed down for the average individual
It relys on tab to nest items
erm no
Yes
YAML is JSON with additional features + easy to read syntax
Yaml is Skript on drugs
I won't enange into nonsense discussions
you mean visa versa right
Skript is yaml on drugs *
Both
no yaml is yaml which is decent
JSON is perfect for a config, you build a config object which can either be loaded from a file or created programmatically in a trivial manner, and in file format perfectly mirrors the structure of the object it represents
skript is basically yaml but its shit
JSON is perfect for machine to machine messaging through an API. It allows different languages to communicate
enjoy your json all you want, I don't care. facts are: yaml is superior to json.
- syntax is waaaay easier for admins
- there's not a single disadvantage
tl;dr: yaml = json for humans, without downsides
So youre saying devs are stupid?
what
The syntax for YAML is clunky and itโs not a great representation of the objectโs structure
depends on who is "devs"
knowing how to read YAML/JSON doesn't make you a dev
Here's what I don't get. If your end users need to edit files and are get frustrated with JSON, why wouldn't you make it easier for them? You have to remember that what's easy for you may not be easy for others. That's part of the responsibilities developers have. Catering to your users.
if you prefer {{{"somekey":"value"}}}, sure, go ahead and continue to use json
True
If you press space once it becomes a new object
that's not even valid JSON!!!!!!
Yea
json is a nice idea. but for config files?! wtf?!
I think this is the jaeger talking
whoever uses json for config files is probably more drunk than I am rn
You just hate trying new things
I've def used JSON for configs before, but I would never in a plugin since most server owners are comfortable with YAML to somewhat degree
just make a in game config editor
I try new things all the time, wanna see proof?
that stores the config in json
Or a web editor.
that too
You're arguing with a 13 y/o
make a config editor like luckperms with syncing
you act like no one in here has argued with a 13 year old

I have to repeat myself: json is a nice thing. but it's shitty for config files
What if I don't give the end user the config
wha
then what's the point of the config
Instead I'll make a config command
if the user doesn't need to change it
If you were to make your settings modifiable via in game commands or web editor, then it really wouldn't matter what file format you store your data in. You could store your data in a .fuckyou file for all it matters. The difference is whether or not the end user will ever need to modify it manually.
If they don't then do what you want.
If they do, make it easy for them.
It does
My point is what If i don't let the user open said config file
It uses a frontend command to do so
you could be a dick and do what the mob drops plugin does and encode the config in base64
๐
Lol
Just cause they never use it doesn't mean you can't use something readable
I would make the config accessible
But you can config it on the server
Like lp and stuff
you could always just make 2 different sets of configuration honestly
Yeah but what if they want to modify while the server is off lol
/setshop material name price
They have the config.json file
Here's an example of a simple JSON config I used recently:
"minioConfig": {
"endpoint": "",
"accessKey": "",
"secretKey": "",
"region": "",
"bucketName": ""
},
"redisConfig": {
"host": "",
"port": 6379
}
}```
It's clear where each config object begins and ends, and the overall config object is a sequence of smaller configs that can be individually deserialized
just make 2 configs, one JSON and one YAML and the user can use whatever one they one
Yes
problem solved
Yeah
That's what I was thinkingtl
i wonder
Then that guy came and showed his opinion
both parties are satisfied
could you encode yaml to json??
I would assume yes
you can transpile any language into another one lol
yeah but like i wonder if gson or something has a method for it
My problem with yaml is tabs lol
you'd have to support it yourself
But why would you have 2 when one works 
stubbornness
Something like that
i just make my configs in json, if the end user doesnt like it oh well
cry about it end user
What if I just hard coded the configs
._.
Then what's the point of it?
The point of a config is so that you can configure settings. .-.
?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.
Yeah but yaml sucks
Does it really though? In what aspect specifically?
tbh yaml itself doesnt suck
Unblocked speedrun
the only part of yaml i do not like is actually handling it with the snakeyaml library
this argument ain't going anywhere
I can not understand the yaml thing on spigot
i much prefer gsons way with serializing java classes to json
if yaml had an option for that ide suck the author of that lib off
Trust me when I say, it's one of the easiest things you can use compared to something like GSON.
More tech illiterate people prefer yml.
it doesn't stuck just because you don't undetstand it though

Why can't i just use something like javascript or typescript for configs :(
bro
you can do that
mf runs javascript to produce values
You can, but your end users won't be happy when they need to edit things manually.
i cant
They won't know what they are doing.
just, pick a config option and go with it
Also yea, not really a config file at that point.
i mean it's a matter of knowing your users
i don't release anything for public consumption
tbh, let me tell you this: if you're too stupid to understand YAML, you're also too stupid to use other "config file languages"
anyone touching one of my configs is a developer who works for me
Id say Alex needs a drink but my man maybe had too much at this point

which one
Maybe some fresh air
well at least I know how to use a Map<String,Object> lol
wait wtf it Map<String, Object>
bro this is some next lvl shit for me
how tf you gon expect me to learn that
that's the most base form of JSON yeah
OHH
whats a Map<String, Object>
yeah
"gnon"*
whats the little < > thingies do
anyway i'm going to the slep now, enveryone hnave a nice dnay ๐
you too alex!
thnanks :3
Anyways in my yaml i have this
Shop:
Blocks:
Grass:
Name: grass
Material: grass_block
Prices:
Buy: 10
Sell:5
Pvp:
Sword:
Name: sword
Material: diamond_sword
Prices:.
Buy:10
Sell:5
How in the world would i get all the items in blocks
wym
you'd have to treat Blocks as a ConfigurationSection
getConfigurationSection("Shop.Blocks")?
I mean you can also have a config per thingy. You don't need one global config lol
and get all the keys
What the heck is all that ngl
If I were you I'd restructure your file.
But to answer the question. You'd need to loop through all sections using #getConfigurationSection()#getKeys(false).
ngl i barely have any idea wtf it does
But basically is searches a specific package inside of its own .jar file and finds classes that extend/implement another class
Will that get everything in a array?
Not exactly.
and then another class scans the received classes for an annotation, and registers whatever it is from there
It will return a list of strings, which correspond to the names of the sections in that list.
So in your case, it would just return an array with the value Grass
You can then use that to complete the path name you need to access those sub sections.
I want it to be array so that
(My js brain is kicking)
I can loop over all the items in the array and make the corresponding item with said config
I like mine more. It's gross but it's cleaner 
well the actual logic for this is a little gross, but when its actually used its really clean, eg: https://github.com/Burchard36/BurchAPI/blob/ec858b4806c85d028d7bbc8676a73091e8c14cb3/src/main/java/com/burchard36/api/command/CommandInjector.java#L29
i need a better chaining method though
Take for instance this yaml file.
shop:
stone:
price: 12
bedrock:
price: 10
grass_block:
price: 13
If you were to loop over shop using #getConfigurationSection("shop").getKeys(false), you would then have a String array of [stone, bedrock, grass_block]
This is where you can take advantage of the for loop and use the current iteration to get what you need.
So while you are looping, you can use #getInteger("shop." + section + ".price")
Ahhh i understand
New question how do I make it reload the plugin on config save?
Actually
I don't think it needs to
You will have to reload the config if you add anything to the file. That's why JavaPlugin#reloadConfig() exists.
Common practice is to just make a reload command as part of your plugin.
/yourplugin reload
It could do more, but all it would need to do is just run reloadConfig()
If I change the config while plugin is active then i read the config i assume it won't break
as long as you save any changes
The thing about spigot yaml files you need to watch out for is the cache.
Ok cool
When you are editing the config.yml using the api, you are working with the cached version.
So if you make changes to the actual file that's on the disk, you will need to call reloadConfig().
Otherwise, if you are using code to set values, you don't have to.
You do have to save your changes with code though if you want them to be written to disk.
What is the api
You will if you are using ConfigurationSection or FileConfiguration.
Any class provided by spigot is part of the API.
What
The thing that you are using to write code for your plugin depends on the spigot API. The API provides several classes and methods which you use to make your plugins. You know that thing you have to do at the beginning of every plugin? Extending JavaPlugin? That's part of the API.
Creating commands with CommandExecutor, part of the api.
Modifying yaml files with ConfigurationSection, part of the api.
If you were to remove the spigot dependency, you'd quickly see how many errors your IDE would throw since it doesn't know what things are.
You have to set peopleโs scoreboard to that scoreboard you created
yes, 2nd screenshot
Hi guys, every time I refresh my server, my config file gets empty, probably because the lists and maps are empty after reload. How can I keep all data after reload?
Tbh just stop using the spigot default configuration methods they kinda suck
?paste
https://paste.md-5.net/silipuhona.java
Use this utility you could also use some other yaml parsers out there this util just replaces the crappy default getConfig methods and such
Use
"ConigUtils utils = new ConfigUtils(JavaPlugin);"
Than ConfigUtils#getConfigFile snags the File save is easier as well create File if it doesn't exist etc etc.
It preserves comments as well
Something which spigot just added iirc anyways this utils works preserving comments etc from 1.8 to latest
so this always saves the config after reloading
im saving and loading the config file but it still refreshs
hey could someone tell me what 'clazz' is? is it just a variable name since you can't use 'class'
What was the idea behind the InventoryMoveItemEvent (it work inconsistency)?
Because you get different result of amount if you have 1 stack or 2/3 stacks.
no is when hopper move items (mostly).
Ohhh
can also be from other container to hopper
Depends on the time ig as its pretty fast
But spigot not provide the original item stack amount on the first item hopper try put in the chest. I could have made it better self ๐
Spigot modify first stack it try add to container and no option to get right amount.
U can make a PR in the GitHub repo and fix it for everyone
only way is ether hacky or directly use nms self to fix it.
do they even have github? i think spigot have own web page for the source and is not good on make a good pr for it ether. Is some rules to follow and also need self test it out if it works ๐
Oh yea, they shifted to their own site
how can i get maps from config
How can I teleport a player into a world to the last location they were in?
I'm guessing their location is stored in player data in the world file right?
Show ur config
Config.yml
sorry for values ๐
Can u just send it here
As it's hard to see from the img
Copy the whole thing into this chat
8b6619f9-f9a5-3bd6-8842-712369e22e19:
playerdata:
AhmetKeรงi: 313
RonaldoMessi: 919
Just loop through all the keys in player data
Same question
player uuid who executed a command to write the file
Okay
.
what it will return
It will return all the keys, loop through them, add them to a map while getting the values using the same key
its returning the uuid
yes what should i do next
Get config -> get UUID section -> get player data -> get all of its keys, loop through em, put em in a hashmap with their values (get using key)
how can i get playerdata's keys
for(String i: PersonConfig.get().getKeys(false)) {
PersonConfig.get().get(i + ".playerdata").???????
}
Get.get?
get() is getting the config
get().get() what does that mean
Okay
If u get the config and then get its keys, it will return the uuid
yes it is
In the ?????? Part, u can use get keys and store them
i cant
And then loop over
there is no specified methods
Wdym
What does .get(path) return
hashmap
I think that's what u want?
anyone?
at which moment?
if they login they spawn at their last location?
im pretty sure they will spawn in the correct world
What is it then
I need to do it on command tho
so when they switch between worlds using a command I'd like to get the location they were last at in that world
ah
object
save their location before they go to another world
Wait a second
get is the internal method
that doesn't save across server resets tho
wdym server resets?
Is there smth like getConfigurationSection?
server restarting
Save it to a file or a db
save it to a persistent storage
it should already be stored in the world data tho
when they logout
no
thats only the last location they were in
Aight gimme a bit I'll revert to u
it doesn't store for each world?
?javadoc
means that you have to store their locations
