#help-development
1 messages Β· Page 2138 of 1
ah intellij, the pro java programmers ide
I wanted to write a plugin to allow this but I already died at the basic things. IntelliJ plugins are way too complicated lol
I doubt it. Do Ctrl+Shift+F and look for "GameProfile". Now, does it show you Player (the NMS class)?
ServerPlayer*
speaking of NMS: why do you have to use nms for some stuff? surely that could just be built into the bukkit api right
yeah sure, just contribute it if something's missing
after all, spigot is made by volunteers, so not EVERYTHING is included there
makes sense
I don't get how bukkit API works do they have to recode for all the new nms methods each version
i was just curious
because I know a lot of stuff can break
but ye in a mod env
well the API itself is only interfaces. the implementation however is the interesting part π
so it adds the mojmaps as a source file
I would cry doing implementation
hm yeah but... I want to see all USAGES of GameProfile
well I built an api because of that...
@ivory sleet look at this pls:
We map methods that we use so that they're not obfuscated and need not be updated from version to version. The only time things need to get updated is if server internals change how things are handled
(it's too much time wasted mapping everything)
AAH FLASHBANG
in my plugin, I can just do Ctrl+B and it shows me all usages of that field in all classes. But in a decompiled class (Villager), I mark the "WANTED_ITEMS" fields and do Ctrl+B. It tells me there are NO usages at all, but obviously it's even used in the same class
and that sucks. it should at least find usages in the same decompiled class
#general idk the answer to this question its too complex for my brainn
you can not possibly be serious
i'VE LOST MY eye vision
go see a doctor
no I'm not it seems pretty good but I'm doing something very very wrong and its not working very well lol
where? I have the "find usages" set to "all places"
intellij doesn't like to index decompiled stuff
yeah I know, and that's what I'm complaining about π
I think at least my fckn expensive ultimate version should be able to do this
nms would be so easy if middle-clicking a method actually took you to its definition
that works fine for me
the "find usages" is the thing that's not working
for me
so theoretically if i were to make this rank plugin would i need vault intergration for the prefixs?
I middle-click EntityInsentient's G() and it takes me to EntityLiving's e() for no reason
ugh why don't you use mojang mappings
with mojang mappings, that works totally fine for me
makes it too easy
alex look at my cursor
fuck it doesnt even copy the cursor
wait let me edit the photo
that's hella easy wtf
alr lemme try
imagine knowing what you're referencing when coding π€‘
but erm
Spigot doesn't have any sources anyway
only spigot api has it
Sources not found for: org.spigotmc
1.17.1-R0.1-SNAPSHOT
import both
that doesn't help
it still won't have sources for spigot itself
since there are no public sources for this
only thing I could imagine that'd work is to manually "mvn install" the thing that buildtools creates
but still that doesn't create any sources .jar
mojang definitely likes verbose variable names lol
I would have simply used "GOLEM_GOSSIP_DISTANCE" instead of HOW_FAR_AWAY_TO_TALK_TO_OTHER_VILLAGERS_ABOUT_GOLEMS lol
Both names are not wrong
yeah, well they take all enterprise and object oriented conventions, principle and patterns dead serious
had a singleton for sneaky throws
eh I like it
when they add something into Minecraft, or change something
they keep it that way..
which is good
@tender shard btw have you tried with sth like paperweight?
Hey are there any good docs for the mongo java api? the official spigot ones are outdated.
there are some up-to-date yt tutorials
nope, never touched that
ah kk ill go look them up ty
youtube tutorials >.<
am I the only one who prefers written tutorials? π
youtube videos are so long and you can't Ctrl+F
and they always have a 5 minutes intro like "yo guys wassup today I went up and had a shower and ate a loaf of bread" and only after 5 minutes do they even start to talk about the topic
a few years ago I wanted to get into iOS development and that dude was literally reading all the XCode reviews on the apple app store for like 10 minutes instead of simply saying "Okay, download XCode and then let's go" o0
how to get every Event in bukkit
a bit hard
written ones are allot easier
since classes load and unload dynamically
ok then I have an easier question
Imagine a Class has static variables.
how can I make the class set the static variables.
probably hard to understand..
basically in an Event you have a HandlerList.
and I want to ask how can I make that HandlerList get set.
you understand what I mean
in the event class.
get set?
yes.
there must only exist a single handler list per callable event class
yuh
you have a HandlerList in it.
yeah
and the event has not been called ONCE.
so the HandlerList inside it, is not yet created.
the question is how can I make it create the HandlerList, being HandlerList a static variable.
well
write sth like PlayerLoadEvent.class.method() would trigger the static initialization
if it hasnt been triggered already
the handler list is stored as a static variable :)
you can do a static method as well yeha
lachlan the problem is that, if lets say PlayerQuitEvent has yet not been called, then that class remains dormant (not loaded) thus its HandlerList instance does yet not exist
Conclure how could you not know it was me ππ
Jadss merely wanted to eagerly ensure the existence of the HandlerList instance
yes because the first event
yeah but if a static variable is created in the class, it exists already
that is called is absolutely ignored
lachlan well
all variables are linked dynamically during runtime
hence why its possible to split our systems up into different jar files
and dynamically load them
most people with uncolored names are a bit sus per say
hmmmmmmmmmmmmmmmm
We have Dms lmao
Jads what are you trying to achieve with this btw?
wouldn't you want to just create a listener class with an event handler for each?
Β―_(γ)_/Β―
Someone here last week wrote a Listener using generics that was able to listen to multple events (by accident)
I forget who
Jet something
hmm
maybe it was a "Jad" man, get it?
I dont like things like null pointers, narrow range of methods in Java and I use Kotlin for plugin development but I dont know is it a problem to use kotlin in big plugin projects. Is there anyone who is using kotlin for big plugin's development? Would you suggest using Kotlin?
thought the implementation would catch generic event observations
was it JetCobblestone? <#help-development message>
certain event classes simply are not "listenable" since they don't have any handlers assigned, e.g. InventoryEvent
yes
I will be using Kotlin for big projects
His was a Listener using generics so it only fired on listenable events
sounds weird
Ive tried with a generics approach w/ EventExecutor
but that still doesnt work
I made this in case it is useful to you https://github.com/lokka30/KotlinExample
Work for me? Never happened
hmm what
lets not publicly shame like this
He used an annonymous lambda which (for some odd reason) erased type.
ye ElgarL here is just one of the cool developers here
sec I'll see if I can find it
if someone has any problems with anyone, you can just blame me instead, I'm used to it for using light mode
ππ
what is the hardest thing to make in mc?
but became significantly easier with goal navigation and move control
Thsi is the period it was discussed.
world generation also has its abstractions nowadays
well I do packets to give good functionality to bukkit
ah elgar
since I'm assured bukkit won't give some stuff to developers, like signs to write text.
I was talking with him for a while abotu the type erasure issue.
altho wouldnt T be erased to whatever type Class<T> has
yes
However as Jadss is looking for a generic listener that can capture ALL fired events
ah yeah
type erasure is perfect for him
but idk if jadss is prepared to take those heights into consideration
I am
thats multiple listeners. The one Jet was writing used a single registered listener
I say.
I'm registering to every possible priority.
this system I did still kinda fails due to some events not being loaded..
Yes, every event and every priority. Using generics you'd only need one event
as previously said.
yeah jadss
so youd have to do some really bizarre shit using ClassLoaders and whatnot
well, but would you register to every priority?
Up to you. All Jets code is lined above the link I gave.
Yes, you'd have to do every priority.
Thanks
erasure is only on the Class<T>
How can I do a bungeecord proxy where eu players have good ping?
host it in the EU and have all the servers in the EU too
Like, I bought a 2nd bungeecord proxy for eu players, as the main one are good with usa players
How
Every server its in usa
i want good ping in usa and eu
hosting provider will sell servers in certain datacentres
you can't
network not fast enough to make ping good.
well
I mean the connections
ofc
One more question, Is there any reason why did you choose maven instead of gradle
So i really cant?
build an island in between usa and eu, hook it up with an undersea fibre optic connection, build a datacentre, you're set π
personal preference.
apparently more people use maven contrary to gradle in this community
but gradle is superior imho
Maven is older cleaner and simpler. It all depends what you need to do
I tried gradle and couldn't stand using it, it is definitely superior but I just prefer maven for my projects which don't require gradle's complexity.
Conclure.. You still gotta teach me generics lmao
honestly, most people make it sound like gradle is complex, which it isnt if you just boil down whats necessary to write
<T> this shit
Alrighty
basically object orientation but on type level
Confusion
:c
I want to ask question
when you do
Class.class, does it create a new instance of a Class<?> or not?
nope
huh
Class.class is a singleton
so I could do cls == eventClass (being cls the same instance as eventClass)
it returns the Class instance that was created during class loading for that very class
its a reference to the class available from the ClassLoader
and it's gonna be true?
yes
oke good.
remember, singletons (and sometimes multitons) must always be identifiable and comparable with ==
this is why enum constants are comparable using ==
didn't know class was singleton
yeah
I'm also singleton.
thats true tho :3
Did you need to use something like shade plugin in maven? I was trying to make a plugin that has papi api with kotlin - gradle and I had to use a plugin called shadow jar because when I build a fat jar instead of shadow jar it was ~8mb
I would argue maven is easier..
but not worth
Gradle is so Good, it makes my Compiling go π
well list me an advantage of Gradle over Maven.
Gradle avoids work by tracking input and output of tasks and only running what is necessary
it's Faster
by Default
Yeah and it works so well for me
I love generics
Fast enough PC and build time isn't an issue
mvn -T 8 package ftw
btw does someone know a java library to parse arguments similar to bash's getopts? e.g.
somecommand --title "some title" --description "some description" --field "title1" "description 1" --field "title2" "description 2" etc
should create a map similar to
title -> "some title"
description -> "some description"
fields ->
field1 -> "title1", "description 1"
field2 -> ...
when are the issues about bungeecord on github gonna get solved?
fix it yourself Β―_(γ)_/Β―
It depends. If the issue has reproduction steps, environment specifics, useful information about the code that may be causing it, and a proposed solution, things tend to get solved quicker
it is self explanatory tho.
Though generally speaking, in an open sourced project, the burden should lay primarily on contributors
well,
Not maintainers
and if you've submitted that as a feature requested on GitHub issues, then it's likely been taken notice
Not much else to do there unless you intend on adding it yourself and creating a PR
I really don't know how it is done..
I just feel really sad that it wasn't added to bungeecord, and spigot has that functionality with the flag "-nojline"
I really don't even know how to create Pull Requests (like seriously)
Just two different projects with two different purposes and implementations is all
else I would probably try it.
well... I guess you're right
still sad..
oh well
choco
how to do pull request.
Create a fork, commit on that fork
and then create a pull request from your fork -> master
fork the repo, clone your fork, commit your changes, click on "create PR"
seems like I'm using the word hologram too often lol
It's at that point you create a section
hologram:
text: ""
protected_text: ""
# etc.```
If you already have a public release with those config values though, you can fallback to them as well for legacy support
String text = config.getString("hologram.text", config.getString("hologram-text", "your default value"));
String protectedText = config.getString("hologram.protected_text", config.getString("hologram-protected-text", "your default value"));```
oh yeah thats cool
I'm not sure people realize that you can use another config get as a default lol
im loading a Location from a config
using the ConfigurationSerializable of the Location
and i have a custom world there
how can i make the plugin load the world before deserializing the location in order to it not throw an exception?
or is there a class that implements ConfigurationSection which does not deserialize things inside the yaml?
don't access the config until onEnable runs as worlds will be loaded by then
make sure yoru custom worlds are loaded too
sounds easy, but it's not that easy
because of the config updater, which I needed before spigot finally added the "keep comments" thingy
and it's quite hard to get change the config layout later on
I have a bungycoord network, I host it on one pc (so it's like (publicip): 25565 (lobby)
(publicip): 25575 (minigame) etc.)
Do i need to port forward/ open every port I use, or only 25565?
only 25565
unless you want them to be able to directly connect to bungeed servers
otherwise, bungee proxies the connection on the local network
Hey, I need help, I use maven build and i've set the output directory to be a custom one, there I always get two files, the original and the shaded one. Any way I could avoid it and output to my custom directory only one of them?
im trying to remake hypixel skyblock using spigot and mongo and im currently at the stage of adding cross-server support for profiles but when i do uuid.toString() (the uuid being the profile uuid, not the player) it returns a null pointer exception. how can i fix this issue because its really annoying and its really making it so i cant make any progress
are you using the UUID class or a different one?
im using the uuid class
is your UUID null?
how are you getting the UUID?
because i dont have anywhere in my code where it doesnt set the uuid
through a parameter
show the code
public void initialize(Player player, UUID profile) {
MongoCollection<Document> collection = getPlayerData(SkyBlock.getMongoClient());
try {
ArrayList<String> profiles = new ArrayList<>();
profiles.add(profile.toString());
collection.insertOne(new Document()
.append("_id", new ObjectId())
.append("uuid", player.getUniqueId().toString())
.append("name", player.getName())
.append("rank", Rank.DEFAULT.name())
.append("selectedprofile", profile.toString())
.append("profiles", profiles)
.append("gems", 0)
.append("firstlogin", dateTimeFormatter.format(localDateTime))
.append("lastlogin", dateTimeFormatter.format(localDateTime))
);
} catch (MongoException e) { e.printStackTrace(); }
}```
?paste
use this please I'm on phone
alr
the lines are weird
what if the player has no selected profile
is it defaulted on join?
do you wanna run a debug check?
maybe there's something going on with the loading
check if the selected profile is null
if (user.getSelectedProfile() == null) player.sendMessage("selected profile is null");
added that
and got nothing
its not the profile
do you know if the UUID is null ?
okay so the lockettex isnt working i do the sign and it says you must have 500.... 500 what?
any idea
you need money for that but this aint the right channel ^
i typed it in the other channel
The default Codec supports UUID insertion. You dont need to use .toString()
Same goes for LocalDate
And you dont want to manually add "_id" because it will throw an exception
The _id fields should be used in the filter instead.
And you should not separate initialization and insertion.
There is something called upsert = update if present, else insert
*And use the players uuid as _id. Thus field ist already indexed for faster queries.
I have imported the NMS package but i am unable to use EntityPlayer
ServerPlayer is EntityPlayer but different name
So how can i get Different names of other entities?
can I put return in a switch instead of break?
I want the function to end in some case
yes
ok
u can put return anywhere in a function
i would still go with the break
and assign a var which you return in the end instead
What is the BlockFace parameter on Block#applyBoneMeal for?
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/block/Block.html#applyBoneMeal(org.bukkit.block.BlockFace)
I know, but why it requires that parameter
so it can get the relative block, idk
If you use bonemeal on the bottom of a grass block it wont work.
I just switch my plugin from a java project to a maven project/file/something, where should I put the config.yml file ?
because they're not using maven on tutorials
src/main/resources
At least by default, depending on your pom it May be in a different place
Also, I recommending Reading the Guide for Bukkit over on the Bukkit fandom Wiki, it is incredibly outdated, but the maven concepts have Not changed much since then and I corrected what has changed
whats the slots for the border in the 9x6 inventory
like
ive been struggling for like 6000000 hours
Border as in what?
pixel?
wat
Any Multiple of 9 (including 0) and any multiple of 9 (including 0) plus 8
Additionally any Index between 0 and 9 and 9*5 to 9*6-1
wat
45 -53
It is that easy yes
i dont understand
for the left and right
you do this
for the top and bottom you do this
do you even know what i mean
Yes
to make like a hollow square
yes
check if the slot is divisible by 9 without remainder
9+slot*row
how did you do that
Huh
skill
hehehehe
nah just push backslash before any formatting
and it cancels it
ah
loop through every slot
so do we now make a twitter bubble against it?
check if the slot is divisible by 9
how
so a multiple of 9
?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.
yep
Just Loop from 0 to 7
^
no like
wouldnt that just
put the item on the right?
i want it to be on the left right top and bottom
no
multiple of 9 including 0 is the left
and then you also set it to multiple of 9 including 0 + 8
so either hardcode, or loop through and check for it
for the right
i tried hard code but my head hurts
loop throughs better cos you can do other items in the mean time
like summin in the center
0, 8, 9*5, 9*5+8
Are you even a programmer?
i am a god
if (slot % 9 == 0 || slot == 0) { //this checks if you should put something on the left
inv.putItem(slot, item);
inv.putItem(slot + 8, item); // this is for the right
}
slot being the number you're looping
or...
ok
Do you have any advanced gui tutorials
Like how can i store something in gui
Some players some objects
also is 9x6 the max inv
inv.setItem() ?
you want to store players in a gui ?
if (slot >= 0 && slot < 9) { //this is the top row
inv.putItem(slot, item);
}
if (slot >= 9*5 && slot <= (9*6-1)){ //this is bottom row
inv.putItem(slot, item);
}
bruh i tought it was 56\
Not the players, something i can representate the player
i dont know if putItem is the proper method
i havent actually done spigot in a bit
but u get what i mean
make a constructor using player head with it's meta and it's name, then setItem()
and for items just use setItem
works like so inventory.setImem(int, ItemStack)
for(int i = 0; i < 54; i++) {
}
the constructor would obviously return an ItemStack
yes
ok
those are the slots of the corners
corrected now
my brain sucks in the morning
if (slot % 9 == 0 || slot == 0) { //this checks if you should put something on the left
inv.setItem(slot, item);
inv.setItem(slot + 8, item); // this is for the right
} else if ((slot >= 0 && slot < 9) || slot >= 9*5 && slot <= (9*6-1)){ // top or bottom row
inv.setItem(slot, item);
}
How do I add an element to a config ?
a list?
well i'm making a player kill count and I need to store every player's kill count in my config
I tried some stuff but can't get it to work
what stuff did u try
so you get your fileconfiguration and set the value at <uuid>.kills or whatever
oh i used player name
use uuid
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
FileConfiguration cfg = main.getConfig();
if(!(cfg.contains(p.getName()))) {
cfg.set(p.getName());
this.saveConfig();
} else {
return;
}
}```
I have this so far
incase they change their name
you can use that too, but shouldn't
right, i'll change that
well
when you set something
you have to set it to something
you're just giving it where to set it
not an actual value
not sure what contains on FileConfiguration will return
cfg.set(p.getUniqueId(), killCount)
Condition 'slot == 0' is always 'false' when reached
yes since 0%9 = 0
for(int slot = 0; slot < 54; slot++) {
if (slot % 9 == 0 || slot == 0) { //this checks if you should put something on the left
inv.setItem(slot, noItem);
inv.setItem(slot + 8, noItem); // this is for the right
} else if ((slot >= 0 && slot < 9) || slot >= 9*5 && slot <= (9*6-1)){ // top or bottom row
inv.setItem(slot, noItem);
}
}
oh yeah
and since you used the || operator the second piece of it will never be reached
i forgot about this
it does start at 0
so either change it to | or remove that
Condition 'slot >= 0' is always 'true'
remove that too
cfg.set("kills" + p.getName(), killcount); so that would set the player's name into kills right ?
Condition 'slot <= (9*6-1)' is always 'true' when reached
why
in kills or + "."
otherwise you would just have a bunch of lines that say
killsGodCipher: 1
killsYada: 2
killsfrenchkiwi: 3
the . makes it a child
"kills."+p.getUniqueId().toString()
remove that too
why did i add so much unnecessary checks lool
set("killsGodCipher", 1000000000000000000000000000)
legitimately gained
obv.
doesn't event.getKiller() exist ?
no
shit how do i do ?
you have to get the entity's last damage cause
iirc
and that gives you another event instance where you can get killer
Entity killer = ent.getLastDamageCause().getEntity(); ?
ent being the killed player
it gives you an entity damage event
wait
i forgot how to do this
what event are you using
@EventHandler
public void onDeath(PlayerDeathEvent e) {
Entity ent = e.getEntity();
Entity killer = ent.getLastDamageCause().get;
if(ent instanceof Player && killer instanceof Player) {
Player p = (Player) e.getEntity();
Player k = (Player) p.getKiller();
addKill(k, 1);
}
}```
well it's a kill count
check if both the entity and damager are players
also check if the entity is dead
e.getEntity().getHealth() <= 0
okay
@EventHandler
public void onDeath(EntityDamageByEntityEvent e) {
Entity ent = e.getEntity();
Entity killer = e.getDamager();
FileConfiguration cfg = main.getConfig();
if(ent instanceof Player && killer instanceof Player) {
if (((Player) ent).getHealth() <=0) {
int i = cfg.getInt("kills." + killer.getUniqueId());
cfg.set("kills." + killer.getUniqueId(), i+1);
}
}
}``` would that work ?
okay
should be invoked anyways but explicit programming >>
what do you mean ?
Hey is it possible to have a string like
"&7Te&ast &7string"
but only translate &7 to a color rather than every single color code
so the output would be "Te&ast string" with all the words being gray
so u want the & in teast to not be colour coded?
I am actually dumb, I forgot that ChatColor.GRAY gives the color translated already
doesnt ChatColor.translate... do that?
It translates everything, not a specific color in a string
use Β§a
Dont
then don't
using that character is bad practice
if spigot somehow misses to translate it
itll crash the client or the server
one of them or both cant remember
@earnest forum thx it was what I wanted
its not
no problem
Can someone help me make a update notifier, so whenever I push an update on Spigot it tells people who have my plugin installed
?bing
Bing your question before asking it:
https://www.bing.com/
there are many resources with an tutorial
I can't find it
For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.
why bing ?
to hit the bong
fair
Error:
I did tho?
oh wait yeah i didnt im stupid
Yeah so that didn't work, I made a new update and when I reload the plugin(using plugman) it does not show it
it(the api) updates after ~3 hours
I see
yea lmao
isnt it basically the same thing
but for specific plugins instead of all of them
it just disable and enables the plugin
you shouldnt use that for specific plugins because you could break them with it
which is what reload does right
basically
if you want to instantly notify your customers, use a third-party api or whatever
spiget maybe, but never really used it
nvm. spiget also got the 2* hours gap
but github with a custom version file f.e.
so a hash sum f.e.?
hey just a quick question, for permissions do they have to be initialized on the server to be able to tell if the user has the permission?
~~say I have a permission "test.test1" but that wasn't a permission for any plugin on the server would spigot still output false if the player doesn't have that permission? ~~
I tried it to do something similar in my plugin, using a non declared permission, and I would always get true until I added it into my plugin as a permission.
I'm currently looking up info about it but if any of you know that would be a great help
Edit:
I'm dumb, it was because I was oped
Actually I have the same question
I added an else if the player doesn't have any permission, and this one always returns true
the others always are false
regardless of op, or perms
for some reason when i join the server nothing happens in the config
oh wait nvm didn't save the config
introduce variable is a thing
You know a way to make a player's armor invisible ?
So when he get invisibility effect, nobody see him even with armor
(i use spigot 1.8.8)
cfg.set("players." + p.getUniqueId().toString() + "." + "kills: " , killcount); I have this and i'm not sure what it'll do. The only path in my config.yml is players:, if i'm correct, it'll create a path that goes players: -> player's uuid -> kills -> my variable
remove the armor
I want him to keep armor
For its damage reduction
he can pvp with that
Its an effect that give him total invisibility
Im a little confused, I am trying to setup a custom chat format however the . I added at the end of the message doesn't line up in the chat with where it says it is in the format
%2$s is Minecraft's default message format
Can you explain more the issue ? I haven't understood
i don't think that's possible in spigot 1.8
hypixel does it
It is, i saw it on some servers
I know but it is possible with "classic" spigot
do they even use spigot ?
can't you set the players armor level to the same as the armor, then remove the armor until the invisibility wears off?
Yes
or am I brain farting again
but then it wouldn't show up as armour for the player
No, i thhink the enchantments wont work in that case
you could try using nms
basically the "." is supposed to go after the message in the example above asdasd but it doesn't work like that
true
Ye maybe there is a packet like ArmorDisplayOutput, i'll try it
for some reason when i die or when i get killed the killers kill count does not get updated nor does my death count get updated
where does it get stuck?
when i die and when someone kills me in the screen shot that event is not updating the config for some reason
is the event triggered?
yes when i die via getting killed by a player it gets triggered
hover over the Killed variable
what in the world are you doing there
is that an error
first of all, thats not how you handle null
try catch?
also you should never catch an NPE
no, just check the value for null
why are you not printing the stack trace for the error
second, what is a PlayerDeathCountManager? you just "pass" in a value to directly retrieve it again?
usually null pointer exception means theres something wrong
if e.getEntity().getKiller() == null is just gonna return null
usually you dont catch NPE's at all
you shouldn't even touch it
hashMap
that doesnt return an NPE
yes, return if thats true
nvm
if the killer is null
show us
so i have no way without checking for it being null with it trigereing a NPE
check it for null, if its null just return
since you obv. dont want it to continue
unless you only want death by players
i only want deaths by players
because players can die from like fall damage and thats why killers can be null
?paste
Player player = e.getEntity().getKiller();
if (player == null) return;
simple as this
its simple yet its going to cause a NPE
how
the check is preventing the npe
when you use getKiller() that doesnt return an NPE
were making a variable before the check
a variable can also hold null
just if you want to invoke something on null a NPE will be thrown
Player variable = Bukkit.getPlayer("NotAPlayer"); //no NPE
variable.sendMessage("hi"); // NPE
because of that
Object obj1 = new Object();
Object obj2 = null;
obj1.equals(obj2); // no NPE - just strictly false
obj2.equals(obj1); // NPE
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
FileConfiguration cfg = main.getConfig();
if (cfg.contains(p.getUniqueId().toString())) return;
if(!(cfg.contains(p.getName()))) {
cfg.set("players." + p.getUniqueId().toString() + "." + "kills: " , killcount);
cfg.set("players." + p.getUniqueId().toString() + "." + "level: " , level);
main.saveConfig();
} else {
return;
}
}``` why won't that work, it doesn't put anything in my config file
and also for some reason the death count is not updating in the config
i dont think u use fileconfiguration
isnt it yamlconfiguration?
on spigot tutorial it says FileConfiguration
but this doesn't create any path in my config
in most cases you dont need YamlConfiguration so FileConfiguration is fine
and also the kill count
debug it. let it print out the values
i have no errors, and my config file is empty pretty much
Am I doing something wrong ?
any design problems? whats ur opinion
I know I should make a package for that serializing btw
Try remove the : in your set
kills and level are enough
okay lemme try
wait
when is the config supposed to update ?
wait
i'm so dumb
nevermind
how do I use it afterward ?
in my server's file, the player is shown properly, but in my ide there's nothing
well in the server files i have ```players:
f0ecb64b-6845-405f-b15b-63dd2439859f:
'kills: ': 0
'level: ': 0
but nothing in the ide
I don't know about designing the code.
For me, I would code something that 3-year-later me can still understand where to fix or add new features.
Not really an advice for all cases, but try designing in a way that is comfortable for both you and future you.
they aren't gonna update lol
yes they aren't gonna update ahahaha
i'm so confused
those aren't connected to the server
if i modify it, won't it reset the old one in the server
they shouldn't be updating
and delete everything the old one had ?
if the file already exists in the folder it will not
only if the file doesn't exist it will create a new one that has everything you put in there
i'm confused but i think i got it
those are just placeholders
now when you wanna update them
do you want it to be player kills only?
if you want it like that you can listen to player death event
i need to use the kills from the config to update the level in the config too
like every 25 kills, add 1 level
yea so whenever you change it
check if the kills are divisible by 25 and if yes add another level
@EventHandler
public void playerDeath(PlayerDeathEvent e) {
Player victim = e.getEntity();
if (e.getEntity().getKiller() instanceof Player) {
Player killer = e.getEntity().getKiller();
ConfigurationSection playerSection = cfg.getConfigurationSection("players."+killer.getUniqueId().toString()); // get player's data section
if (playerSection.get("kills")+1 % 25 == 0) { //if divisible by 25 add a level
playerSection.set("level", playerSection.get("level")+1); // add level
}
playerSection.set("kills", playerSection.get("kills")+1); //increase kill counter
}
}
no
wait
you told me not to use getKiller() earlier
well it isn't lmao
well
@EventHandler
public void onDeath(EntityDamageByEntityEvent e) {
Entity ent = e.getEntity();
Entity killer = e.getDamager();
if (ent == killer) return;
FileConfiguration cfg = main.getConfig();
if(ent instanceof Player && killer instanceof Player) {
if (((Player) ent).getHealth() <=0) {
int i = cfg.getInt("players." + killer.getUniqueId().toString() + "." + "kills");
cfg.set("players." + killer.getUniqueId().toString() + "." + "kills", i+1);
i = cfg.getInt("players." + killer.getUniqueId().toString() + "." + "kills");
if (i % 2==0){
int lv = cfg.getInt("players." + killer.getUniqueId().toString() + "." + "level");
cfg.set("players." + killer.getUniqueId().toString() + "." + "level", lv+1);
}
main.saveConfig();
}
}
}``` I used this
should I change ?
oh okay
you dont need to convert the entity to player to get its health as well
it casted automatically
Is it possible to get an ItemStack by a uuid?
what do you mean ?
Every item has a unique ID
Now, I'm using the event HangingBreakEvent, however, I don't know how to get the broken hanging item
What slot in a player's inventory is the off hand?
Like the number of it in an array of inventory.getContents()
it doesn't update the kills π¦
If I display a scoreboard to a player, then reset it and set different values to it, and display it to another player, will it show them both the same values?
item != itemstack
but you could use the PDC
What do you mean?
?pdc
tried it
Whenever I have the hanging entity it doesn't show the persistent data container I've put
you can convert an item to an itemstack
Even a hanging one?
I'll check it out, thanks!
π
what?
I mean, when you reset a scoreboard, does it show the updates to the player?
so I have to use the player.setScoreboard() for him to see it?
Thanks for the help, it worked I actually messed up the PDC a bit π
Can horses even have owners?
idk, i mean set saddle
NullPointerException, Can you post your code from LocationData? or at least what you have near line 20
Cant find that error cus it spammed like 1k errors after that
In the code itself
Not 1k but large amount
Like your actual code
like the words you wrote
12.05 13:11:02 [Server] INFO java.lang.NullPointerException: null
12.05 13:11:02 [Server] INFO at fr.purpleyounoob.kiwipvp.killCount.<init>(killCount.java:23) ~[?:?]
12.05 13:11:02 [Server] INFO at fr.purpleyounoob.kiwipvp.Kiwipvp.onEnable(Kiwipvp.java:28) ~[?:?]
Can you post your code from there myb we can help more?
which class
FileConfiguration cfg = main.getConfig();
so main is null
nice, what is main?
public killCount(Kiwipvp kiwipvp) {
this.main = kiwipvp;
}```
how are you initializing it
getServer().getPluginManager().registerEvents(new killCount(this), this);
?conventions
Java Coding Conventions: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html
saveDefaultConfig();
is that the entire constructor π€
main class
Do you see the file in your server files?
yes
I have doubts
on ?
you
show is the fields
just paste the entire class
FileConfiguration cfg = main.getConfig(); this is a field isn't it
Can you send the whole KillCount class?
:/
?paste
?paste
oops
yea, they just define FileConfiguration cfg = main.getConfig(); as a field
you cannot do that
java will initialize the fields before the constructor
what is a field ? π
hmm ?
your "class variable"
?learnjava huh
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.
?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.
?
?
?
!
What is the most important server difference between spigot and modding
There is None in a technical sense
I mean, craftbukkit has a lot of changes to vanilla
I mean mod stuff are not automaticaly installing the mods while joining the server.
But spigots different.
The real killer is paper however
Spigot is all server sided
Forge is both client and sevrt sided so you can add new materials etc
Harder than server
Spigot is a Mod If you are pedantric. Plugins could also be considered mods I guess
And Well that concludes the discussion
Would it be possible if i want to make a client just addingn the client side automatical mod path?
Both Forge and spigot are recompile-based. Fabric & Sponge are ASM-based, but that is only a difference in specific implemenations of moddings
As someone that's is modding another Game that is written in Java from Scratch I can say that modding without a Toolchain is super hard If you lack the proper experience
It also Takes enormous amounts of dedication (i.e. 3+ years) to do
spigot is the interface to let addons (plugins) communicate with the server-software (CraftBukkit).
Still a mod
you dont really modify anything with it
Many mods only use the Forge API, does that mean that they are Not mods?
what does that matter?
If you Go by that Logic only Forge, SpongeVanilla, Bukkit and Fabric are mods
But really Plugins can already modify the game behaviour enough to be worthy of that title
thats not some sort of logic, thats what it is. spigot IS the interface to CraftBukkit
Isnβt that the case though? If you look at it more closely, spigot is the mod, plugins people make are the extensions of the parent mod.
Hence the name plugins
you dont modify minecraft, do you?
Going pedantric huh? Well spigot is Not the API
Not with forge no.
Spigot-api is
If we want to go pedantic, isnβt spigot more akin to a wrapper?
how is that pedantric?
Spigot officially is a wrapper, yes
I do modify it yes
how do you modify minecraft itself with spigot/plugins?
and any plugin is a wrapper of a wrapper?
all you do is sending packets and manipulate the way/which packet is sent
you dont do anything directly to minecraft
The game behaviour itself (even If the jar/class files are Not) are altered
So by that Logic there are very few mods as Most "mods" use the Vanilla protocol
mods actually modify the game, not just manipulate the game behaviour
The fact that something was added to a registry does Not Change this fact
In what way?
The real differnce between mods and Plugins is Just how we Name it
okay, so, the ensuing discussion after this statement depends entirely on whether we pick out the definitions now and look for gaps, or whether we debate our disagreements until we come to overlaps.
if (!(Bukkit.getOnlinePlayers().contains(args[0]))) {
}```would that work to check if the arg of a command is a player ?
thanks !
Player p = Bukkit.getPlayer(args[0]);
if(p == null){
sender.sendMessage("that is not a player!")
return true;
}
if you want to send the sender a message
12.05 14:27:19 [Server] INFO Caused by: java.lang.NullPointerException
12.05 14:27:19 [Server] INFO at fr.purpleyounoob.kiwipvp.kiwiListener.onDmg(kiwiListener.java:299) ~[?:?]
well, something on line 299 in kiwiListener is null obv.
@EventHandler
public void onDmg(EntityDamageByEntityEvent event) {
if (!(event.getEntity() instanceof Player)) return;
Player damaged = (Player) event.getEntity();
Player damager = (Player) event.getDamager();
if (damager.getItemInHand() == null) return;
ItemStack w = damager.getItemInHand();
if (w.getItemMeta().getDisplayName().equalsIgnoreCase("Withered dagger")) {
damaged.addPotionEffect(new PotionEffect(PotionEffectType.WITHER, 40, 2));
}
}```
if (w.getItemMeta().getDisplayName().equalsIgnoreCase("Withered dagger")) {
which line is 299?
this one
but i'm checking before if player has an item in hand
and i have the error when hitting without any items too
w can be null, as can getItemMeta
w can't be null
1.17.1-R0.1-SNAPSHOT