#help-development
1 messages · Page 1577 of 1
I know it's printing villager isn't valid, that's what I specifically told it to print
that is also specifically my issue
um... did discord die or smth the same thing just happened to my reply
umm so i looked more into this and apparently it requires a md5 hash, and i have 0 idea on how to get one and what hash is it even asking for. could you provide some insight?
DatatypeConverter.parseHexBinary(hash)
i haven't worked with hashes how do i go about generating one for my pack?
seems like something is busted with world loading
?
get the hash from some site
Why not use the spawn method with a consumer to set all your options?
upload the resourcepack zip file
http://onlinemd5.com/ for example works
just select sha1
ok thanks a lot!
🤷
then you want to put that sha1 into that method I sent you, as that will make it into a byte array
The consumer is run on the entity before its spawned so you get to do all your modifications before its added to the world.
Are you on windows?
useful but wouldn't really fix my current issue
Your issue is likely due to world loading and mob spawning timings
if you use a consumer it doesn't matter
your entity will be spawned when its ready
ok thanks a lot!
how would a consumer help when it's just not ever spawning
mac
consumers modify a spawn, right? they don't schedule one
They modify the Entity. I don;t believe your entity is not spawning
I just think its not spawned when you expect it to be
it never gets flagged as valid
Anyone knows if I can access the Vault API async?
depends on the plugins its hooked into
I think the only one I have right now is Towny? Is that safe?
probably not
damn i wish there was some actually good claims plugin
towny works nicely for users but is a pain for admins
anyway, thanks
The point of Towny is its run by users not admins
but its painful to manage
Set it up and you are done. No admin to do
such as "emergency mode" when it decides to corrupt once in a while
anyway, im getting carried away
ah well, yea corruption has been a thing for a long time
no issues in my experience, only on my end when i did something wrong
or rarely when the server crashed
I never experienced a corruption unless I did somethign silly myself.
had a lot of crashing back in the day when i was first starting
but that's why there are automatic backups!
I still remember when we could expect corruption with every update
Don’t
If it’s economy it will be most likely be essentialsx which iirc does not support it, maybe for permissions (luckperms)
GroupManager would likely be ok, but I'd not guarantee it
I just can't see how it's not spawning it when I ask it to
clearly it's not null
it just goes from existing to not existing instantly
Is the chunk actually loaded?
yeah and also ffs I think the consumer thing worked just now even though it shouldn't
argh
this is so dumb it's not materially any different...
oh and now it didn't work
cool
these rng-based issues are the best
Its different in the fact the consumer runs before spawning but the Entity is valid. Its possible the chunk is being unloaded if you are using Paper.
try {
//this.villager = (Villager) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.VILLAGER);
Consumer<? extends Villager> consumer = new Consumer<Villager>() {
@Override
public void accept(Villager entity) {
// do something
entity.setRemoveWhenFarAway(false);
entity.setPersistent(false);
entity.setAI(false);
new DeveloperMessage("Spawning entity: " + entity.getType());
}
};
this.villager = spawnLocation.getWorld().spawn(spawnLocation, Villager.class, (Consumer<Villager>) consumer);
this.uuid = villager.getUniqueId();
} catch (Exception ex) {
new WarningMessage("NPC " + npCsConfigFields.getFileName() + " tried to spawn in an invalid location. " +
"This may be due to region protection preventing it from spawning correctly. If not, delete the location" +
" in its configuration file and try setting it up again.");
ex.printStackTrace();
return;
}
if (this.villager == null)
new DeveloperMessage("Villager is null");
if (!this.villager.isValid())
new DeveloperMessage("Villager isn't valid");
still returning not valid
it does run the spawning entity message
If you are doing it in the consumer don;t bother checking isValid
It won't exist in the world yet
it never exists in the world
so all the code is running, but it never appears in game?
yes, that's what I'm saying
except on a reload
if I reload the plugin and this code runs again but the world's been loaded the whole time it works just fine
also this is a 1.17 exclusive issue
Then you issue IS that the world/chunk is not loaded
this code worked for every single update before this
the world is loaded, the location exists
you can't make a valid location with a valid world without the world fundamentally existing
also it runs after the world initialization
just because your location is valid doesn't mean teh chunk is loaded
chunk load I'm fairly sure is not instant when you call load
same as unload
you have to wait for it to be available
easy test, set yoru loaction to spawn
this world does not keep spawn chunks alive
fyi
you are likely going to have to delay your spawing a tick until the chunk is loaded.
try {
//this.villager = (Villager) spawnLocation.getWorld().spawnEntity(spawnLocation, EntityType.VILLAGER);
Consumer<? extends Villager> consumer = new Consumer<Villager>() {
@Override
public void accept(Villager entity) {
// do something
entity.setRemoveWhenFarAway(false);
entity.setPersistent(false);
entity.setAI(false);
if (!entity.isValid())
new DeveloperMessage("Minecraft is a busted-ass game");
new DeveloperMessage("Spawning entity: " + entity.getType());
}
};
this.villager = spawnLocation.getWorld().spawn(spawnLocation, Villager.class, (Consumer<Villager>) consumer);
this.uuid = villager.getUniqueId();
} catch (Exception ex) {
new WarningMessage("NPC " + npCsConfigFields.getFileName() + " tried to spawn in an invalid location. " +
"This may be due to region protection preventing it from spawning correctly. If not, delete the location" +
" in its configuration file and try setting it up again.");
ex.printStackTrace();
return;
}
the consumer dev message #1 runs
it's not valid even in there
Its not spawned yet so I would expect that to be false
yeah, yet
keeping the chunks alive seems to bypass the issue so I guess that's the issue (?)
I have to assume this changed for 1.17, how come this was never an issue before?
yep, your best approach, is place a ticket on the chunk, then fire in a delayed task the spawn
at the end of your spawn remove the ticket (if you are done spawning)
anyone knows how can I get server warns? i coded an easy launchpad plugin but if the velocity is too much, my console spams warnings about it. Is it possible to make an event when one of those warnings pops up?
[18:40:17 WARN]: Excessive velocity set detected: tried to set velocity of entity #0 to (9.890552185889112,5.0,-1.249544380443629).
if i do player.getLocation().distance(someOtherPlayer.getLocation()) what type of data will it return? a double or a vector?
distance (double)
though you should consider using distanceSquared as distance will sqrt the result
getServer().getLogger() I think. Although you probably should heed the warning and not set the velocity so high
any idea on what is the max velocity?
Nope, I would just try to tweak the numbers until you like the velocity & it doesn't spam
the plot thickens
the chunk claims it's loaded when the code runs
I guess it lies then
well it's a problem innit
abcd
I don't know if chunk tickets are something specific but I have changed the code to be initialized based on chunk loads
?paste
https://paste.md-5.net/azeqajavah.java you get the general idea
I'd also delay 1 tick after the chunk load event to run your code.
well it's not that the code in the chunk load doesn't work
it's that it doesn't run because the chunk is already loaded lol
at startup (1 tick after) get a list of loaded chunks
I already have another alternative that works based on delays after boot but I would really like to have a way of doing this that isn't 100% jank from the start
I will say this proves that the chunk was loaded the whole time
I believe there are different levels of loaded now
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/pull-requests/866/overview
Would be the PR to address a lot of the issues in regards to entities and chunk loading
My fix would probably be...
- Add a chunk ticket for any Entities I want to spawn.
- Run delayed any spawn code for those entities.
- Check if the Entity was already spawned in some other server startup.
- Use the spawned Entity or spawn a new one if none exists.
This page contains both my pom.xml and stacktrace, any idea what I'm doing wrong? https://paste.gg/p/anonymous/a06223f76af4434f9719584ae24316bc
I'm trying to use guice for my api and plugin
so what's the point of chunk tickets exactly? just loading chunks permanently?
java 1.8 and spigot 1.17 are not a match
Yep, it force loads and keeps the chunk loaded until all tickets are removed
why does this not cancel the event?
read the warnings your IDE gives
why does lmbishop have to be here :(((
lemme guess
I guess the point is to make sure the chunk doesn't try to unload between the time you load it and the time the frankenstein's monster of a code that enforces waiting delays after a chunk load right
you're here to abuse ewen again
String cannot be use with ==
how do i set the score of my scoreboard to 69
yep
.equals()?
how did u know ...
that was a typo with me putting it on the paste site, it wouldn't compile in the first place if that was my normal pom.xml 😅
You need to use equal or equalOrIgnoreCase
k, thanks
objectives don't have scores
I'd like to get the ip and username with the uid, anyone know how?
Dude, use your IDE
Yep, literally just prevents anything unloading until you are finished.
no, you get the score of a specific entry
getScore(string).setScore(int)
yo choco is it true that there's different chunk loaded states with 1.17?
the objective itself doens't have a score
this is such jank
xd
thx
and also doesn't really fix the core issue of it happening when the chunks are already loaded to start with
nope
become hacker man
then cry when you realize you dont know what the fuck youre doing
@worldly ingot Was it you the other day having a discussion about chunk load levels? Something about them being new?
Don't think so
host the server and when the player log in check console
ok
It possibly is a bug as it doesn;t happen on earlier versions
yeah it certainly didn't
You would have to come up with a reliable method to replicate it
uh
it's not too hard
on startup create a world, get a location in that world, spawn an entity on the same tick
or even better spawn 100 different entities spread out a little bit
you'll get about 20% of them
You would have to demonstrate that it would work 100% in 1.16
you can run the same code in 1.16
I've been doing it to thousands of entities and it never missed
https://hub.spigotmc.org/jira/browse/SPIGOT-6547 this might be related
as you will find in the issue, there is an open PR to introduce chunk loaded level (e.g. isEntityLoaded) to the API
I guess it's a deeper-seated issue
how can i use anvils to get user inputs? i cant manage to find anything on google
or some useful API
Inventoryframework doesnt explain it well enough
hey there so right now i have this JSON string. now im wondering how would i go about desteralizing this string to for example only get the info the json object has which id is 0?
my JSON string: [{"X":-887,"Y":100,"Z":482,"ID":0},{"X":-24,"Y":54,"Z":284,"ID":1}]
r u talking about getting the text field?
yea i wanna make an anvil gui to allow player input text
but i cant find anything working
@quaint mantle do you mind helping me once you're finished with @sharp bough ?
no, because i have no idea about your problem
i already saw that, i get an error
maybe i did something wrong
?
have you ever worked with json?
AnvilGUI is awesome
ofc i have
i am basically asking how i would go about getting the "ID" value from my json object
great
just not in Java
haha np man
Spigot has Gson built-in iirc
okay this is a bit of a lie, I have, but im not very good at it, i always use google lmao
JsonObject json = new Gson().fromJson(reader, JsonObject.class);
int id = json.get("id").getAsInt();```
hi, how can i get a instance of a block but a instance of a block vanilla
A Block is a representation of the location in the World
You can get a snapshot of that block
ok but if i do : Chest chestblock = (Chest)localisationofmyblock.getBlock(); it does not work
im in 1.16.5
Hey does anyone know a good tutorial of spigot?
(Chest) location.getBlock().getBlockData() I believe
i wanna learn
you would need to compile it yourself for java 16
actually wait
you're using java 8 right?
thank you but i would next do PersistentDataContainer tilesttc = chestnbt.getPersistentDataContainer();
yes
update to java 16
You do not use anything nbt to get the PDC
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) Client VM (build 25.291-b10, mixed mode, sharing)```
update to java 16
its juste a name
k
"chestnbt" are just "chestblock"
what's the event that fires when something grows (not when its random ticked)?
nevermind got it
trying to disable mushrroms destroying end portal
so, that can work ?
You would just location.getBlock().getState().getPersistentDataContainer()
Does that work for spawners?
ok thx
The method getPersistentDataContainer() is undefined for the type BlockState
its the error
cast to chest
How can I convert BlockData cbd = Bukkit.createBlockData(String); to IBlockData? I can't cast it...
((Chest) location.getBlock().getState()).getPersistentDataContainer()
IBlockData would be an NMS interface?
I think i found it...
BlockData cbd = Bukkit.createBlockData(entry.getValue());
IBlockData ibd = ((CraftBlockData) cbd).getState();
yep nms
Yeap this worked. Finally damn xD
Yes sorry lol.
Hey guys! I've been taking a look at adding custom tab complete suggestions to custom commands (in bungeecord). I've looked it up online and haven't found a clear answer on how to use it, or how to add the tab suggestions to a command. Are there any tips or resources I could use? Thanks :)
it was that thank you
what the fuck with passengers?
When i'm seeing in north side i'm catching this bug
(chest is armorstand)
yw
how to remove a path from .yml?
tried with config.set("path", null) but doesnt work
config.remove?
doesnt exists
or smth like this
i searched too 😅
it's time for javadocs!
sned your code
i mean the full thing
public static void deleteVariable(Player p, String name) {
File player = new File(instance.getDataFolder() + "/data/" + p.getUniqueId() + ".yml");
FileConfiguration playerConfig = YamlConfiguration.loadConfiguration(player);
for (Map.Entry<DataAPI, Player> e : data.entrySet()) {
if (e.getKey().getName().equalsIgnoreCase(name)) {
data.remove(e.getKey());
playerConfig.set(p.getUniqueId() + "." + e.getKey().getName(), null);
}
}
Main.getInstance().saveCustomConfig(playerConfig, player);
}
data.remove(e.getKey());?
you can't remove from a list while you iterate over it with a for loop
if i do Chest titlesttc = locplyrc.getBlock().getState().getPersistentDataContainer();
getPersistentDataContainer() are in red
remove after the iterator?
you can add it to a list to remove after, or use an Iterator
you didn;t cast the state to Chest
can you give me example for the Iterator?
i am sure you can google one
oh ok
ok but how can i do ????
the exact code I showed you and you quoted back to me
final Chest chest = (Chest) location.getBlock().getState();
final var pdc = chest.getPersistentDataContainer();
there
java
you can one-line it similar to how elgar did it
but then you don't have the chest, which is sad
why use var when you know what it is?
less typing 🙂
because I don't want to write out the class name ??
you always know what it is lol
java is not a dynamically typed language lol
So lazy... it's so much easier to read & understand if you don't do that.
thats what im thinking ^
I mean, if you need the type definition you do you /shrug
The compiler might be able to infer but if someone else comes along and reads your code they might have a difficult time inferring.
its their source code, let them do whatever they want
idk there is very specific java documentation on this
I know, but just seems like it'd be bad practice to use var
nobody told them to change it
@eternal oxide thx thx
Yeah dang, java is really the only language in which you can just let the compile infer the type
rust and kotlin are gonna cry in a corner
golang does too
Infer what type? 😮
tho I guess, flame ItemMeta not PDC
Lol
Type inference and anonymous exposure
So if the player that i want is lets say 20 blocks away from me on the x axis, will .distance() return 20.0?
yes
yes
Thankyou
well as long as there is no difference in y and z ofc
I would argue for that it may add readability when used in the right place
How would it?
How will that work?
I guess if the naming is obfuscated or something then it could to an extent I guess
it would be the magnitude of the vector
@eternal oxide oops, i have do
Chest chestnbt = (Chest) locplyrc.getBlock().getState();
PersistentDataContainer tilesttc = chestnbt.getPersistentDataContainer();
but the Chest chestnbt = (Chest) locplyrc.getBlock().getState() do a error
You might have something like ByteArrayInputStream in a twr block, in that case just declaring a var might make it easier to read.
runtime tho ?
var is also just useful if you actually name your variable.
final var persistentDataContainer = ...
final PersistentDataContainer persistentDataContainer = ...
like, it is just doubled
you speak to me ?
Probably imported the wrong Chest
So it would calculate like a 90° rectangle?
Yeah fair enough, I see the use-case here
Also anonymous exposure which is like super pog
Yo get the closest distance to the player
Or whatever it’s called
what i must import ?
What import have you used?
I mean the Pythagorean theorem
org.bukkitidk
e.g if i was +5 on x, y and z, then distance would return sqrt (sum of squares) away
you need the Block one
yes
omg why is he here
Ok, thankyou
declaration: package: org.bukkit.block, interface: Chest
this chest
specifically
so org.bukkit.block.Chest;
thx
yes
i think you need previous scores to set it
so you need a 0-68
but scoreboards cant even go past 16 i think
what ? Scores can definitely go up to 16 and way beyond
pretty sure you can only have 16 scores
I think idkidk is talking about order of scores on the scoreboard
Thats the value, not the positioning
You're setting the position to 69
Which isn't valid
you cant display more than 16 on sidebar
Yes
Oh wait yeah 🤔 hang on
individual scores
im talking about below names
but they are just trying to create a single score with value 69
.
which should be perfectly fine
oh
Are you making a separate Scoreboard for each player or is it all on the same scoreboard
same
i want everyone to see that ewen is fat
i might be wrong wait
private Scoreboard createScoreboard(String Ewen_Is_Fat_XD) {
final Scoreboard scoreboard = Bukkit.getScoreboardManager()
.getNewScoreboard();
final Objective objective = scoreboard.registerNewObjective(
"test", "dummy",
ChatColor.RED + "Ewen_Is_Fat_XD" + ChatColor.RESET);
objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
objective.setDisplayName(ChatColor.RED + "Ewen_Is_Fat_XD" + ChatColor.RESET);
objective.getScore("Ewen_Is_Fat_XD").setScore(69);
return scoreboard;
Why you bully him?😕
Try getScore(ChatColor.RED + "Ewen_Is_Fat_XD" + ChatColor.RESET)
Change this:
objective.getScore("Ewen_Is_Fat_XD").setScore(69);
to this
objective.getScore(ChatColor.RED + "Ewen_Is_Fat_XD" + ChatColor.RESET).setScore(69);
What do you guys do to run something every 10seconds? Do you multiprocess or smth? Or just puting it in a different class and doing while would work?
BukkitScheduler
Without blocking the whole plugin
?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.
?scheduling
BukkitScheduler
the block can have custom nbt ?
no
ok thx
tile entities yes
but no other blocks
true
tile entities is kinda like blocks with nbt
tbh i dont think you can set nbt of a tile entity in vanilla like custom nbt cuz i tried and it didnt work
Thats ok, we have PDC 🙂
thats 1.14+ xd
Life begins at 1.14
not everyone uses that
if your making a public plugin you probs wanna support to 1.12 atleast
nah lol
because some people still use old verisons
If only Mojang would add 1.8 pvp back we could all use the latest :(
we need toggle
The jeb_ patches look very useful
Yeah we do, I don't really understand why they insist on not adding a gamerule for it
I mean you want a unified experience over all of minecraft
they saw something wrong with 1.8 PVP
so bringing it back makes no sense
Sure it does. Get people to stop using the version that's like 6 years old. Clearly people liked it, why change it?
Compromise. Add both.
Let the server decide which it uses.
tbh old combat mechanics already does a LOT of what 1.8 did but people just are hardstuck on the "omg this one single thing is not the same I cannot uses it"
didnt work
Oh yeah for sure, OCM is fantastic. Only thing it really can't reproduce is sword blocking afaik
Still think it should be a Mojang feature so 1.8 can die
:/
doesnt it make a shield in off hand
idk I think they just gotta work on their new combat patches
Anothwr question, does using spigot latest version allow older versions of minecraft java to play on it? If so, where can i see how old?
Yeah but it's not perfect
which does what you are describing
Doesn't really feel the same
Yea but the extra effort on their end to implement a combat system back that feels "exactly the same" is a lot
for a system that, remind you, they do not see fit as a combat system for minecraft
Also, according to bstats 1.8 is dying steadily
It's a PvE system. IMO they're being a little petty not doing something about it, people very clearly avoid 1.9 combat, especially when it comes to pvp. All bug fixes & features are completely worthless to PvP servers because of that change.
idk man, according to bstats not even 9% of spigot servers run 1.8 at this point
so either there is not a single pvp server in the 1.9+ servers, or OCM is good enough for most people that aren't petty af or bstats sucks
9% of servers doesn't necessarily mean 9% of the playerbase. I mean just look at Hypixel, they HAVE to support 1.8 so they're effectively locked to 1.8's features. Imagine what they could do if they had access to all the new stuff.
Is there a way to see a players client version?
idk but maby its because 1.8.8 is not counting to 1.8
It's still built off the vanilla server software is it not? 🤔
nah
some hypixel gamemodes are 1.12
doubt it
Such as?
if hypixel server software is still based of vanilla, they are doing something wrong
buildbattle?
Well, either way, they're still locked to mainly 1.8 features because of clients :l
Nope, it supports 1.8
it does?
I mean it might have terracotta but it must just change the block to 1.8 clients
also very much something you could do btw.
enable 1.9+ features only for those clients
So you're saying the server should take the time to make sure their stuff supports both versions?
honestly they should just work out their combat update, release it any just keep watching 1.8 servers die
ok but im pretty sure there is some 1.12 stuff
Probably is
if you think your userbase is petty enough for care about 1.8 combats vs OCM
then yeah, your server will have to do more work
Could just be avoided if they added the gamerule, that's my point lol
People ARE petty enough to stay on 1.8
So all that effort & time going into new stuff is mostly wasted anyways
Ocm Not that Bad afaik
Might as well put a little time into re-adding 1.8 combat and have ALL features be used!
Not many points that are bad
dude, 1.16 was the most successful release of minecraft in a while
their work is definitely not wasted
Time to write a mod ;7
Well there already is one
Yeah OCM is great, and even my server we use latest with OCM. I'm not saying praise 1.8 and use it, nonono. I use latest.
It's just a MAJOR headache for everyone that people still play on a 6 year old version.
Neat
Building blocks are so wasted
1.8 🤢
but also whats keeping most people on 1.8 is performance
Well true but that's an entire different issue LOL
performance? 1.12.2 & 1.16 are mostly more stable
That's just java and bad optimization
1.16 and 1.17 are laggy af
buy a better computer
Well not everyone has money to do that
the server is just like uses so much memory
They overload a already broken enough game with more things. Making the game even more unstable
and it barley can handle 100 players
bungeecord cant even handle that much you have to balance out the players just to fix that
Rewrite resource intensive parts of the game would maybe welp
it is a decade old code base ¯_(ツ)_/¯
That's what I am syaing
they did a huge step by upgrading to java 16
isnt that enough for the following 5 years?
performance got worse in 1.17 tho
lol
At least it does smth
sodium works a lot better
for some people it actually doesnt(cuz people have said)
Well that's forge
lol
i never tried sodium tho
give it a shot
¯_(ツ)_/¯
Never even heard of Sodium, gonna try it. Ty 👀
Can't be worse
maybe one day
There is sodium and lithium
And like 2 more
1 of em was Phosphor
Sodium
Lithium
Phosphor
Hydrogen
Those are the mods maintained by JellySquid (and the Caffeine group)
is there an event for when the player has fully connected and loaded into the world?
PlayerJoinEvent fires before the player has loaded the world
it shouldnt?
Listen to PlayerJoinEvent and delay with one tick
yeah i am
Then what's the problem?
PlayerJoinEvent should fire as soon as the player loads into the world?
your server must be slow as ass if 1 tick delay doesnt fix it
i am prompting a resource pack installation it works fine locally but when i do it on my server (which gives me like 150ping and slow world load) it shows for a sec then dissapears before i even have the chance to interact with it
yeah it is
then just do more delay?
so is there an event for a full load/connection?
Don't think so
hmmm
pretty sure PlayerJoinEvent does that
no afaik joinevent fires even before the player loads the world
¯_(ツ)_/¯
better*
hey there how would i go about parsing (getting) the CheckpointCounter int?
json code:
{
"CheckpointInfo": {
"CheckpointCounter": 0
}
}
about 100 fps dropped
it dropped like 100 fps on 1.17
and?
it still dropped alot in singleplayer
Does anyone use Hibernate or something similar in their plugins at all?
?
I've been using a yaml file basically as a flat file database at this point and it's getting a bit ridiculous now
It's an ORM
this is for development help not for helping with a plugin
No lol, it's an ORM for managing relational databases
true to your name I guess
?paste
okay
i know a few people use it, but it's not very widespread
so i use the same method for connecting with mysql
it's too.. 'enterprisey' for a simple application such as a spigot plugin
i used this method on my discord bot
im now making my plugin
but now it breaks
on my plugin
when it works fine on my discord bot
its giving this error
True, I basically use it every day in work so I thought it'd be useful to use it in my plugin too
When I'm in creative and I use my number keys InventoryClickEvent doesn't have ClickType.NUMBER_KEY
halp
if you're used to using it then go for it
why does it think thats js its not even that similar to js
but i usually just handle the mappings myself
what is line 31..
whatever it is it's null
Class.forName("com.mysql.cj.jdbc.Driver"); is that correct?
LOLLLLLLL
no idea lol
idk if that would get the correct click type tho
hold on
i tried without cj
it has been months and forge still doesnt have 1.17
you still haven't told me what line 31 is
what is DriverManager
a java sql class
forge is really fucking late to the party
that connects to a database
still unconvinced that path is correct
what do you think it is
and you're not even doing anything with is
you have to do that
com.mysql.jdbc.Driver, you can check inside the spigot jar yourself
yes it is
it's mysql connector/j, which is packaged with spigot
how do i not package it with spigot
you don't not package it with spigot
now i know why it isnt working
you use it
yes but i am using another mysql connector
still not the right click type / inventory action
Does it return NUMBER_KEY?
action PLACE_ALL, type CREATIVE
try just calling getHotbarButton() See if it returns anything other than -1
you could always getClick().isKeyboardClick() then test the hotbar
nope slot is -1
Broken then 😦
Hi friends, what do you think of my code?
https://paste.md-5.net/fatucotiso.java
could consider deferring the handling of each argument to other classes if you ever plan on expanding that command
and you might want to inform the user that they can't access it from console rather than just having no feedback
not bad
it's kinda messy
just gonna have a lot more if/else if you ever plan on adding to that command, and soon you will have a 600 line long file
If am I going to be honest, horrible
is homesManager a class?
yes
any reason the whole thing is static
Your code is fragile and rigid to start with
What can I improve?
First of all that nasty if else statement chain
Create an abstraction for each sub command
Switches, language managers sub classes and general clean up to make the code easier to follow
A function/method should only do one thing so another tip is to extract larger methods
my brother ran 1.17 on java 8 in the minecraft launcher
how
he didnt change anything
Also please follow naming conventions for class names
well he didn't
Also try not to jump from low to high level but that’s kinda enterprise pedantic thingy
ok
and he played with me on it before
how to make this?
doesnt minecraft download java now
does it?
oh maybe it does but idk
What would you recommend I do?
Start with learning Java capabilities fully, like for instance abstract classes, interfaces and such.
Then learn SOLID and design patterns.
when you double click an item in your inventory to stack all items of the same type, is there a way to tell what slots you took items from?
But fragile means that changing one part of the code would end up changing the behavior of your another part of your code, which now when I think of it might not be very visible in your code.
Rigid means when you want to change something it often leads to you having to change major parts of your code and ultimately changing something isn’t as trivial as it could be.
Just a short explanation
Ohhhh
I got it, thanks. That's what was happening
Would it be recommended to put the ifs in the function?
To prevent this we to make sure higher level modules don’t depend on lower level ones. This can be done by adhering to SOLID. Although to understand SOLID fully a good knowledge of OO and Java is a fundamental demand.
sad when you want to require something thats in a folder up you have to do in lua lua package.path = package.path .. ';../?.lua'
Uh yeah dimensions arguably
Usually creating a lot of functions which get composed to larger ones cleans your code.
Partly because we can have useful names for every function we declare.
Would you like to make a messaging system by function, how would you recommend?
I currently use it.
🥲
Uh that can be useful but make those fields final
Also read on the official Java naming specifications
I figured out how to make a tab completer for my command, however for some reason it stops working when there are more than 1 arg. It should suggest a tab completion of the number of args the command has, however it only shows "1". Likewise, if (args.length == 2) doesn't do anything. Any reason why the args would get messed up like that? (Bungeecord)
Collection<String> suggestions = new ArrayList<>();
suggestions.add(String.valueOf(args.length));
return suggestions;
}```
That sound weird, your code looks like it would complete the args.length every time
I really miss the Brigadier system for spigot. I know Commodore exists for bukkit but doesn't look like it works for bungeecord
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack cannot be cast to class org.bukkit.inventory.meta.MapMeta (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack and org.bukkit.inventory.meta.MapMeta are in unnamed module of loader 'app')
MapView view = meta.getMapView();
view.setScale(MapView.Scale.FARTHEST);
meta.setMapView(view);
this.getMapItem().setItemMeta(meta);``` i have a error but why
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
IChatBaseComponent header = ChatSerializer.a("{\"text\":\"" + "§cWelcome!" + "\"}");
IChatBaseComponent footer = ChatSerializer.a("{\"text\":\"" + "§cEnjoy!" + "\"}");
PacketPlayOutPlayerListHeaderFooter packet = new PacketPlayOutPlayerListHeaderFooter();
try {
Field field = packet.getClass().getDeclaredField("f");
field.setAccessible(true);
field.set(packet, footer);
} catch (Exception x) {
x.printStackTrace();
}
((CraftPlayer) p).getHandle().playerConnection.sendPacket(packet);
}
I use this code but I get a nosuchfieldexception. How do I know whats the field called?
Do I have to manually check it?
Or like how is it in reflection?
Anyone know how to make a sign input gui? I have done a lot of research but cannot find a way to make one.
Well ItemStack is not ItemMeta so you can't cast it that way
thanks
A simple Google search finds a lot of guides
Here's even a library you can use and update if needed: https://github.com/Cleymax/SignGUI
I changed #getDeclaredField("f") to footer but now theres no errors, I just cant log in and it just kicks me
With a nullpointerexception on screen.
What version are you using?
1.16.5
Anyway for your nullpointer I'm guessing you need to set the header too
Decompile the class and see what it contains and then use reflection accordingly
Thank you, that fixed it.
Tho what do i need to check for to fill the declaredField?
The method parameter names?
Aigh
is there a way to be more specific with the PlayerDeathEvent without using EntityDamageEvent.DamageCause because it does not show entity type
doing that gets the player thats dying not the entity that is killing the player
getKiller can be used if it's a player
get entity type would be player because it is asking for the dying player not the damaging entity
getDamager also does not work for some reason
getKiller()?
only works if its a player that kills the player
okay i will try that thanks
get the last damage cause
it will return the associated damage event
from which you can get the entity
make sure it's an instance of EntityDamageByEntityEvent
with customizing death messages as context would that still work
Most of the time
if(player.getLastDamageCause().getEntityType().equals(EntityType.)); this works
thanks
The message will be messed up if something cancels the damage event
I would store entities in a weakmap
?paste
package net.redewhite.Data;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
public class Main extends JavaPlugin {
private static Main p;
public HashMap<DataAPI, Player> data = new HashMap<>();
public void onEnable() {
p = this;
saveDefaultConfig();
Bukkit.getPluginManager().registerEvents(new Events(), this);
for (Player p : getServer().getOnlinePlayers()) {
API.loadVariables(p);
}
}
public void onDisable() {
for (Player p : getServer().getOnlinePlayers()) {
API.saveVariables(p);
}
}
public HashMap<DataAPI, Player> getData() {
return data;
}
public static Main getInstance() {
return p;
}
public void saveCustomConfig(FileConfiguration ac, File a) {
try {
ac.save(a);
} catch (IOException e) {
e.printStackTrace();
}
}
public HashMap<DataAPI, Player> getDataHashMap() {
return data;
}
}
?paste
oh sorry
Just 2 👀
and you named your class "Main"
sorry guys im starting 😅
its fine its just i dont like the capital in Data
you have sent the wrong class
net.redewhite.Data.API.loadVariables(API.java:29)
and you should name your main class as the plugin name
you should learn to read these stacktraces
we need API.java
not Main.java
sorry
here is the API.class: https://paste.md-5.net/asoyemovoh.java
playerConfig.getConfigurationSection(uuid).getKeys(true) this is null
pretty sure
the error is because the configuration section is not set?
no
yeah, i think that is this
im gonna insert a if (!uuid == null)
not the uuid
i think you need to do before for loop if(!playerConfig.isSet(uuid)) return; but dont ask me on that one
yeah, i will do this
Is there any way to slap some data onto a player object that will stay on join/leave?
without writing to a file.
?pdc
?pdc
Lmaooo
O::::
Literally the use of a pdc
1.14+ though
Like you were describing it
the agressive double slap
I figured something like that existed lmao
am in 1.16.5
sad thing is its only for 1.14+
Good
1.16.5 has it
Good
very good
Imagine using 1.8 in 2021 lol
i'll do 1.17 once I stop doing my worldedit cheese with commands and just use their API
I mean pdc still has to write/read to the disk
Yeah it is??
only when you quit and join or is it when the server shuts down idk
I've had a server running on 1.17, it's pretty damn stable at this point
you good ? 1.17 is latest isn't it
But I am on Paper
idkidk that’s the part I’m unsure of lol
paper 1.17 has also been marked as "stable enough"
Shut it
That's so cool but who asked
Yatopia tho 
idk i saw it
Wow that's a relevant topic thanks for sharing said absolutely no one
How’s it going guys, SharkBlox here,
Did Fortnite actually copy this logo from Roblox? I guess it’s very possible!
Gameplay: https://www.roblox.com/games/3297964905/MP40-Weaponry-BETA?
USE STAR CODE: SharkBlox
➤ (My Instagram): https://www.instagram.com/sharkblox_yt/
➤ (My Twitter): https://twitter.com/SharkBloxYT
➤ (My Discord): https://dis...
No need to be rude now
solved, @granite stirrup thanks
So dumb they couldn’t convert to 1.17 smh
when you do Bukkit.gerServer().getVersion() you get the version of the spigot.jar of the server, or the version of the player?
it died
server
Player version lmao
Oh yeah didn’t they disband the project jeff
Mhm

What will I do now
but does the player version matter?
Player version does matter lol
I mean, in what way are you wanting to know how it matters?
if you allow a player using 1.8 join a 1.16 server, this works just fine right?
Dafuq does player version mean
What a good reason, totally couldn’t figure that out 😌
the client version
Oh, that ain’t a thing in spigot
If you use a plugin that allows that to happen, that method will return whatever the server is running on
how do you get client version?? nms?
No
but does it matter? does it make any difference? or should i just focus on the spigot.jar of the server?
Probably by intercepting packets or some shit if it even is possible
ah
Yeah probably in the handshake packets or something
@EventHandler
public void deathEvents(PlayerDeathEvent e) {
Player player = e.getEntity();
if(player.getLastDamageCause().equals(EntityDamageEvent.DamageCause.FALL));{
e.setDeathMessage(player.getDisplayName() + " landed on their feet and fucking died.");
}
if(player.getLastDamageCause().equals(EntityDamageEvent.DamageCause.BLOCK_EXPLOSION));{
e.setDeathMessage(player.getDisplayName() + " got 9/11'ed");
}
if(player.getLastDamageCause().equals(EntityDamageEvent.DamageCause.ENTITY_EXPLOSION));{
e.setDeathMessage(player.getDisplayName() + " got 9/11'ed");
}
if(player.getLastDamageCause().getEntityType().equals(EntityType.SKELETON));{
e.setDeathMessage(player.getDisplayName() + " was shot by a boner.");
}
if(player.getLastDamageCause().getEntityType().equals(EntityType.ZOMBIE)){
e.setDeathMessage(player.getDisplayName() + " was eaten alive");
}
}
``` i just tested this by tping to y100 and falling and the message was the skeleton message
oh i didnt realize
furthermore
whats that
?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.
A Switch statement would fit better here
Im going to kill my self, thank you.
ðŸ˜
get 9/11'ed?
shhh
it would
bro thats fucked up
Lmfao
?
Wouldn't kintetic energy fit better
maybe but explotions work too
actually no, a switch statement wouldn't fit better there
i mean in the future yes, but he isn't just checking the EntityDamageEvent but also the EntityType which is an obj
it'd work for the first couple though
where are they checking the entitytype?
for death message
also, I have a question ```java
event.setCancelled(true);
player.damage(1);
new BukkitRunnable() {
@Override
public void run() {
player.setFireTicks(60);
}
}.runTaskLater(plugin, 1);
is this a legit way to do it or am I being dumb
heres the full method ```java
@EventHandler(priority = EventPriority.HIGHEST)
public void onArrowHit(EntityDamageByEntityEvent event) {
if (!(event.getEntity() instanceof Player)
|| !(event.getCause().equals(EntityDamageEvent.DamageCause.PROJECTILE))
|| !(event.getDamager().getType().equals(EntityType.ARROW)))
return;
Player player = (Player) event.getEntity();
if (!PartyManager.inAMiniGame(player)) return;
event.setCancelled(true);
player.damage(1);
new BukkitRunnable() {
@Override
public void run() {
player.setFireTicks(60);
}
}.runTaskLater(plugin, 1);
}
Wat
i removed the semi colons but all of the messages are the default messages
@EventHandler
public void deathEvents(PlayerDeathEvent e) {
Player player = e.getEntity();
if (player.getLastDamageCause().getCause() == null) return;
if (player.getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.FALL){
e.setDeathMessage(player.getDisplayName() + " landed on their feet and fucking died.");
}
else if (player.getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.BLOCK_EXPLOSION){
e.setDeathMessage(player.getDisplayName() + " got 9/11'ed");
}
else if (player.getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.ENTITY_EXPLOSION){
e.setDeathMessage(player.getDisplayName() + " got 9/11'ed");
}
else if (player.getLastDamageCause().getEntityType() == EntityType.SKELETON) {
e.setDeathMessage(player.getDisplayName() + " was shot by a boner.");
}
else if (player.getLastDamageCause().getEntityType() == EntityType.ZOMBIE){
e.setDeathMessage(player.getDisplayName() + " was eaten alive");
}
}
@ivory sleet lua makes me very sad :( theres no switch cases
lol lua was the only reason I didn't get super into computercraft
That’s good
It protects you from writing rigid code
atleast i have fake switch cases

back in my day we just try catched everything! didnt even use if statements

local test= {
["Something"]=function() print("test1") end,
["Something2"]=function() print("test2") end,
["Something3"]=function() print("test3") end
}
local test2 = {"Something","Something2","Something3"}
for index, value in ipairs(test2) do
test[value]()
end
Map where the values are functions?
its kinda like switch cases

?
Why am I getting the error
[18:38:43 ERROR]: Could not pass event ProjectileHitEvent to LearningSpigot v1.0-SNAPSHOT
java.lang.NullPointerException: null
When doing this
@EventHandler
public void onShootSnowball(ProjectileLaunchEvent e){
System.out.println(e.getEntity().getType().toString());
if (e.getEntity().getType().equals(EntityType.SNOWBALL)){
addProjectile((Entity) e.getEntity());
}
}
@EventHandler
public void onShootSnowball(ProjectileHitEvent e){
System.out.println(e.getEntity().getType().toString());
if (e.getEntity().getType().equals(EntityType.SNOWBALL)){
removeProjectile((Entity) e.getEntity());
}
}
public class projectileHelper {
public static Set<Entity> projectiles;
public static boolean addProjectile(Entity e){
projectiles.add(e);
return true;
}
public static boolean removeProjectile(Entity p){
projectiles.remove(p);
return true;
}
}
something is null
yeah but also doesnt the projectile get deleted?
when it hits
so wouldnt it not work anyway???
no i mean in the game
it's for a particle system I'm using
wouldnt the entity not exist anymore after it hits?
so
the entity doesnt exist anymore isnt that object gonna be useless
but it has to be removed from the set, else you are leaking memory
the weird thing is when I print e.getEntity().getType() it print out the type
public void onShootSnowball(ProjectileLaunchEvent e){
System.out.println(e.getEntity().getType().toString());
if (e.getEntity().getType().equals(EntityType.SNOWBALL)){
System.out.println(e.getEntity().getType().toString());
}
}
but when I try to add it to the set it does the null error
and yeah that's why I did it
because the Set is null
your set is just null my man xD
