#help-development
1 messages ยท Page 1857 of 1
I have never in my life ever used the oracle javadocs
Hi, i'm trying to develop a command blocker plugin, but when i try to execute the command my console says that: java.lang.NullPointerException: Cannot invoke "org.bukkit.command.Command.getPermission()" because "command" is null
u're talking to me?
nope
oh, sorry
but you need to check if the command instance has a permission
hmm, something is still not going to me, look, for example I run 3 the same tasks, but I would like only one to be executed, the one that was launched as the last one.
cmd is not null.
everything runs
I was talking to svssoliny
oh its the chat event?
i tried to get the executed command's permission by command.getPermission()
with also: Command command = Bukkit.getServer().getPluginCommand(event.getMessage());
however pillow, if you for instance toggle the boolean within the async event handler method, you might need to implement a locking mechanism
doesnt work btw
Isnโt that what atomic variables are for
if(command.getPermissions() != null) {
//do something
}```
thx
atomic delegate classes have additional features which touch really low level stuff
can i ask another thing?
sure
well java if (command != null) { }
would be needed as well since Server::getPluginCommand return type is nullable iirc
nope, doesnt work
pillow do smtng like:
i use maven as compiler and i have imported a dependency named projectlombok, but i get a warning
class ChatListener implements Blah {
volatile boolean state;
final Object[] mutex = new Object[0];
void toggle() { //invoke if you need to change state
synchronized (mutex) {
this.state = !this.state;
}
}
boolean isOn() { //invoke if you wanna check the state
return state;
}
void onChat(event) {
}
}```
saying : [WARNING] Discovered module-info.class. Shading will break its strong encapsulation. [WARNING] OrientalCommands-1.0.jar, lombok-1.18.22.jar define 1 overlapping resource: [WARNING] - META-INF/MANIFEST.MF [WARNING] maven-shade-plugin has detected that some class files are [WARNING] present in two or more JARs. When this happens, only one [WARNING] single version of the class is copied to the uber jar. [WARNING] Usually this is not harmful and you can skip these warnings, [WARNING] otherwise try to manually exclude artifacts based on [WARNING] mvn dependency:tree -Ddetail=true and the above output.
I dont know very much about maven so I cant really help u here... all I know is that it builds stuff lol and I use intelliJ
me too
Why do you sync on an empty array
Can you not sync on a primitive
Or use the wrapper type
its just a warning... its not an error yet
i know, but it worries me a bit
try it out and if it throws an error someone here can probably help u
ok, thx again
np
sure
Hey! i'm starting with nms and i had a problem, the guy which i'm learning from made an event of when an entity dies and specified event.getEntity, i'm trying to spawn specific a pig but i can't find a way to specify to ((CraftEntity) ) that it has to be a pig, i have tried with Pig EntityPig EntityType.PIG and accessing the class where i create the custom mob, but i don't find any solution could someone help me?
Anyone knows what kind of weird reasons will Server#getWorld(String) return null even if the world of the exact name exists, and the call have been made with correct return value? Other than world name changing.
is there a way to replace an entity's InventoryHolder?
so for example changing a villager's merchant inventory view to a regular chest view
I know I can get the same effect with PlayerInteractEntityEvent detection, I'm just curious
Is the world loaded
Can't tell as of now, it was a bug report
Thatโs all the comes to mind
CraftEntity cant be a pig
or more like, CraftPig?
dude see the code
CraftPig doesn't work either
its more like casting a Type
trial and error in principle
oops fuck
Mostly error :p
me too
anyways cool idr really what the adv of using an array as your lock
so, there isn't nothing to do with that?
but iirc basically you just give up serialization
ofc a transient Object o = new Object[]
would be effectively equivalent
or might be the other way around
god
ugh
yes
you dont give up serialization
the first line is from one of my plugins and the second line is from my other. im not sure why (since they both use translateAltColorCodes) but everytime i put a double arrow symbol in one of my strings, it shows up in game with an A in front of it
set your compiler encoding to utf8
@quaint mantle do you mind helping me again?
if its from a file, read it with the utf8 charset
how do i do this
Or use the escaped Unicode value in code
do u use gradle?
yes
AYE
EntityTypes nms
compileJava.options.encoding 'UTF-8'
from what I understand from that line of code u just showed, u don't have enough knowledge java's syntax so I will suggest u to learn that java first,
but the problem is u can't cast a Type, u can only cast a value
lol i switched to gradle since shading with maven is too hard ๐ญ
does this need to go anywhere in particular or do i just shove it in
compileJava.options.encoding = "UTF-8"
for kotlin dsl iirc
shove it in your build.gradle at indent level 0
and obv not before the mandatory blocks u got
so im guessing maven builds with utf-8 default?
it would be highly stupid if it wouldn't
although I too have this in every pom
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
just to be sure lol
Does the default plugin.yml load field (POSTWORLD) mean after loading of one world or all worlds?
All the default worlds
I assume this doesnt include multiverse worlds
So if I want to create locations onEnable
I have searched and generally see two solutions
softdepend on multiverse
There is a world load event
But that is when load start right
Which you can also use
Its ok, not neat lol
does anyone know how to get the blocks that were changed from the multi block change packet with protocollib?
Hi, i'm developing a command whitelist plugin, but my plugin can't get other plugin's permission, why?
i used Bukkit.getServer().getPluginCommand() to get the command and getPermission() to get the permission
also i'm using luckperms as permissions plugin
declaration: package: org.bukkit.block, interface: Lockable
to remove the lock, do Chest.setLock(null)
don't access methods of objects that are null
I can't access the entity during onDisable nah
Tryna convert unix to timestamp! but won't wrk
First Login -> 14-12-53966 08:31
Just sais that in console
unix to timestamp? wdym
Like unix time to a datetime
.
hello! i was trying to make a plugin to store coordinates from a command in a config, but i dont really know which is the way to do it
i tried doing this
You would need to get x,y,z. Convert to string
if i grab the name of a file, will the name include the ".yml"
and then save it by using config.adddefaults(path, x)
of course
oh thanks
i'm gonna try it
how can i strip it off then
regex, or String.split, etc
as a string
and you can later do String.split(":")[0] for x
String.split(":")[1] for y
String.split(":")[2] for z
if you save it as x:y:z
and String.split(":")[3] for an exception ๐
i did it, but i doesnt store it in the config file ๐ฆ
Errors?
nop
And what's the pathname
it makes sense. the 0 is not exactly the "index" but the offset of the original memory address
bc there could be no path
x_loc
yeah
When exactly do Tasks disappear when the server is reloaded?
you should never reload the server, it's not really supported
then do config.addDefault("x_loc", location_x)
so don't worry about that
Probably after plugins are disabled
It's either config.addDefault("x_loc", location_x) or config.addDefaults("x_loc", location_x)
split returns an array
so split it and throw away everything after the last .
or just split at .
or just google for 2 seconds > https://stackoverflow.com/questions/941272/how-do-i-trim-a-file-extension-from-a-string-in-java
yeah it's sad lol
it's so much faster to google then to summarize the question and send screenshots on this dc
Ik lol
addDefaults, gives me this and without the "s" (addDefault) doesnt work either
can anyone check over this code and tell me if something is wrong? Last time I got an error and I removed a few components this is the link: https://paste.md-5.net/keluqigeru.java
I still don't know what this means bruh
how "doesnt" it "work either" without the s?
config.addDefault(String,Object) exists
yeah ik
but when i try the command it doesnt store the coordinates
do i need to add "saveConfig()"?
.
value1: test
and now you do getConfig().getString("value") it returns null
theres 2 i think
yeah cause it doesnt exist
but if you do getConfig().addDefault("value","something"); it will now return "something"
so what are you actually trying to do?
I swear permissions are stored inside permissions.txt or smthng
i'm checking
i need to store coordinates in config file
yes but the second one requires another Configuration object
the plural thing
with a command
Not all plugins register their permissions
but i see that it can detect only his own permissions
then just set them and save the config?
so, i have to implement luckperms?
getConfig().set("something","somevalue");
saveConfig();
oh i need to use set then
what are you actually trying to do?
thanks, let me try
a command whitelist plugin
just add your own thing
add your own permissions
ok
like /whitelist <playername>
you can either assign the permissions that other plugins actually register, or you'll have a bad time
then it gives the player the perm
but why don't you just assign those permissions instead?
and checks on join
Beat you too it
nope, i think you missunderstand
So you would need an event, a cmd thing
and that's it
You would need to just give that UUID a perm
i want to check if the player executing the command has the executed command's permission even if the command is not in the command whitelist
it worked thank you so much @tender shard ^^
np
if () {
p.hasPermission
but bukkit does that on its own already o0
and it gives NullPointerException
what gives NPE?
Idk this is way too overcomplicated than it should be
you know plhide?
one of those 8 line plugins that hides the /plugins list?
?paste
should i paste my code?
you should just explain please what exactly you try to do because I still don't understand it
maybe but i did it to use myself
i'm trying to do that
you know plhide?
I asked you what you want to do, you asked me whether I know a certain plugin. So no, I still don't understand what YOU are trying to do, no
here is my code, if this helps: https://paste.md-5.net/ayoyusowuv.java
You will by default only see commands for which you have permissions for anyway
if i ask you that its just to use as example a well known plugin
to explain what i want to do
So you want to...
Blocks tab-completions and commands, that can be configured in the config.yml
Option to allow or block listed commands
Groups that allow or disallow commands and tab-completions
Group inheritance
Group priority
Enable or disable that OPs can bypass blocked commands
OP-Protection
Can be enabled or disabled
Player can't be OP'ed who are not in the list
Non-allowed OP'ed Players who joined will be kicked and deOP'ed
Customize the /pl message
?
Why not just use that plugin
I really don't get what your actual question is
umm just edit the plugin.jar?
if the player has the permission to execute that command (like litebans.ban)
it bypasses the blocking system
but that makes no sense. then it won't do anything
players cant execute commands without the perm ission anyway
that's what permissions are for
So you basically just want to replace the no permission message
of course
if i use the .contains() method on a list of strings, will it check if there's a string in the list that matches the value or if one of the strings in the list contains the value?
player can't execute staff cmds
the strings must be equals()
but
If you have a list "johnny" and "tom" and you do list.contains("john") -> false
staff can't execute staff commands either
ok awesome
Just give staff your own permission to bypass
and if i would whitelist staff commands we will be at start point
I don't get it, maybe I'm too stupid
i don't want from a trainee to see all commands and plugins
then just dont give trainees permissions to those commands...
I don't understand what they're trying to do in the first place
are u stupid or something?
No
I don't know if I've misunderstood, but shouldn't I just modify the plugin.jar that includes the command and block it through sender?
No one knows what you want
I doubt it, maybe your explanation just sucks hard
or you're the only smart one here, might also be possible, although I highly doubt that too because otherwise you wouldnt ask here
anyone have experience with ProtocolLib?
Yes
bruh why are you calling me in DMs now @umbral bear ?
accept my request
lol no
Lnaoooo
dude
Just explain what you want here
Expecting someone to be your personal support person is bad
i tried 4 times
now tell me when i said that
Its culturally bad to call people without asking
this is a help channel though
yeah, more referring to the calling the dev, haha
Well you didn't do it well enough
a dev is not a god
You kept asking if we knew a certain plugin
i don't know how to do it
Do you want the command to be invisible to anyone other than the staff?
just stop writing with ppl that dont can explain their problem good or at least understand your help ^^
Well then that's unfortunate for you
no one wants to be on voice for support requests
What difference does it nake
thats bad news bears
if you cant articulate your issue over text, you should rethink hosting a server
If you can't explain here, how come you can in vc
can i ask my questions now
just join pls
ask ahead
๐
I don't think I will
You can always ask. If the channel is busy create a thread
Lmao
what are you afraid of?
lmao
your mouth breathing on the mic? haha
You wasting my time
?kick @dawn phoenix inappropriate behavior
Done. That felt good.
you're wasting mine
Lmao
rip
GalaKrond, ask away
Yo how would i send a textmessage in chat so it shows more text when i hover over it
https://paste.md-5.net/emeqeguxoz.java
This initializeSentry never works and never modifies variables. and never send message in console
you will have to invoke the method spigot() on your player object then use Player.Spigot::sendMessage
(which takes a component so check out bungeecord chat api)
?jd-bcc
alr found on google
I suppose I have a question myself
Let's say I've got a vector (let's say players look vector)
well you literally called me on discord
How do I apply a vector force relative to the player look vector
oh vector math ๐
Mhm
and we are trying to help, but they can't explain their problem and then tell people trying to help they are stupid for not understanding their "question"
i hate vector
better ping me than to cast insults back
wh owas that? what did they say? i was showering D:
yeah I didn't really insult imho, I just said his explanation sucked
but yeah I just won't engange in this discussion any further ๐ it's the best solution
yeah well, I didn't mean you but some other guy decided to be a dick towards this guy
๐
isn't there a method to get the player's looking vector?
tbf
when the code runs, no entities will be loaded in principle
only thing I can contribute to vectors and looking at something is this ๐
https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/de/jeff_media/jefflib/VectorUtils.java
so I just think the way you're trying to achieve something is poorly implemented galakrond
Yes there is
But that's not what I want
so?
please just stop calling or DMing me
explain your problem here so people can understand, then I am sure someone can help
i stopped the first time i did call you
I want to apply let's say a 45 degree force not relative to global coordinates, but to the player coordinates, so the direction the player is looking is "north"
God i hate my life
same
you want the player to "turn"?
oh no wait I get it
well, regardless, what are you actually trying to do GalaKrond (not how)
you want the player e.g. to be moved X blocks to their right for example
my problem is that i want to get other plugin's permission by giving the command name
We've already awnsered this multiple times though
Bukkit.getPluginCommand("someCOmmand").getPermission()
Basically yes, but not blocks, just like a .setVelocity to their right for example
i know
yeah I understand. Sorry no idea, I suck at math since my school time ended lol
so where's the problem? that was what you were asking
Yea, not a problem
but it returns null
because the other plugin didnt register a permission for that command
so it has no permission
svssoliny a good way to explain a problem is by first saying what the problem is, then what you tried, and concretize with an example or such
i checked the spigot.yml and i found the permissions
and with citizens it worked
I highly doubt that spigot.yml will contain any plugin's permissions
it will not
are you talking about plugin.yml instead?
Probably and Citizens just registered their perms properly... some other plugin hasn't
That won't help
Some people just check if sender.hasPermission, instead of just using the plugin.yml
commands:
someCommand:
permission: you.can.get.this.permission.via.the.api
permissions:
someOtherPermission:
description: You cannot get this permission from the command because it was not associated to the command
it returns null
LuckPerms also cannot magically know what permissions belong to a plugin
Why not >:((
there is just no way to do that if your plugins do not properly register their commands/permissions
LuckPerms != Jesus ๐ฆ
and also i need the permission name
you cannot
Blasphemy
Hi, ยฟhow you doing?, is there someone who can offer me support for something in 1.8?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
^THIS is blasphemy @worldly ingot
lol
scnr
You can get those permissions though btw. plugin.getDescription().getPermissions(), it's just not super pretty
They're not associated with commands either, so ye
you have to understand this:
Either a plugin properly tells bukkit "permission XY belongs to command ABC". If they don't, how should ANYONE know those permission and command belong together?
it is just not possible
That also assumes the plugin defined them
When the server is on again, I need to apply the sentryTask.runTaskTimer(LivingEntity entity) to all Entity 'sentry'
well any permission can be used with ::hasPermission so sadge
did u realize you use runTask

yeah but they need to get some permission from some 3rd party plugin that didn't properly register it, and there simply is no way to do that
because it's just not possible
yeah, poop plugin
yeah lol
You could scan the bytecode for permission checks ๐ง
btw there is a poop plugin on spigot. whenever you eat something, it spawns coco beans at the player's butt
it's just init so i need it one time when server turned on
Ah yes olivo 200 IQ
Big brain boi
I really don't can see over this
initializeSentry initializeSentry = new initializeSentry();
like PLEASE stop doing that
I guess you could lazily fetch permissions passed through CommandSender::hasPermission by injecting a delegate altho not just worth the trouble
it hurts everyone's eyes
but what if the checked permission is actually a bypass permission? ๐

or if the plugin only checks permission when !player.isOp()
I am trying to serialize armor content and inventory contents on config, but armor contents is not serializing so it throw npe when i try to deserialize it
we have been beaten
just only serialize nonnull objects
Could you show the code
ss?
new initSentry().runTask(this);
How about this
anyone know how to fix, I've set my project sdk to java 16 and its still not working
- Write a tag into their PDC
- On ChunkLoadEvent -> get all Entities in that chunk and check their PDC and add them to the task if tag is present
- On WorldLoadEvent -> get loaded chunks and do the same
- onEnable -> get loaded worlds -> get laoded chunks -> do the same
- On ChunkUnloadEvent -> get all Entities in that chunk and check their PDC and remove them from the task if tag is present
- Do the same on WorldUnload
- Do the same on onDisable just to be sure
- Listen to EntitiyDeathEvent and EntityDespawnEvent for removal from the task
- When you spawn them for the first time also tag them and add them to the task
do you actually run java 16 to compile?
ah no
?paste Copy and paste the code in to a paste
ok
you must compile with java 16+ ๐
ah alright, thank you ๐
np ๐
Project Structure -> set java to version 16+
Ok god i will try tommorrow its fucking 1/1 4:00 AM i sleep Bye guys
It's nice seeing 7smile7 occasionally tripping in here to drop some concise yet comprehensive guides to people ๐
And in gradle.build
ooh you're already in 2022
ya
always has been
shit
must feel like a completly different year where he lives O.o
well okay now I know what to expect! have a good night lol
Thanks
ah you're going to need more null checks
or kotlin ๐
It is
But next time send the full stack trace pls as the whole trace could lead to a different cause
Hey, i've installed java 16 and I'm still getting this issue, anyone know whats wrong?
Yeah gameHandler is null
I still don't understand this : I want to be able to display someone's IP (for ban-evading reasons)... But I want to do it discretley by using a hoverable text event. but it doesn't seem to work! I can't figure out why... but there are always errors. Can someone send a snippet of code so i can see how to do it?
Have you told it to use the Java16 jdk?
well print it before running your Event
there is a good chance that your static singleton is not set at the point you isntanciate your listener class
I've set the project to java 16.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
O: pengu!
Used that
still doesn't work
i know what you mean, but the thing is when i try to serialize armor content and inventory content, armor content seems to be null and i had armor while creating the kit
Show code
or is it inside spigot
and i know that
Uh i removed code after it didn't work
Show some code and errors then we can give some advise ๐
We don't know how you're serializing or deserializing
but there MUST be something that knows that
Nope that does literally the same thing
Try passing GameHandler as an argument via your SumoListener constructor.
This is then called dependency injection.
Not really
i put all the code related with it in the pastebin
oh wait
like a permission plugin or something
No
?paste
Wrong import
what do I import?
so?
Do ChatColor.RED.asBungee()
Import the md5 one lol
it's definitely impossibile?
You need the other ChatColor. The one from md5 chat
oh ty
@tame shoal
:D
The only way you can know is to read the bytecode of every plugin. Don't do that...
nothing is impossible
IK
How are your command and permission present?
If they are not in the plugin.yml then nobody knows how to sow them together unless you do it yourself
i'm not masochist
I'm making an ingame version if tebexs store using http requests to get packages and category information from their site, problem is, their http requests take about 1-1.5ish seconds each. Would it be a better idea to load all of the category, package etc information in an object and refresh it every say 30 seconds on an async thread, or leave it as it is where the http requests to get information are sent when needed? (might be slightly out of date vs UI latency)
here it is, sorry, i thought i put it.
so
Good. Now take the easy way out and type the things directly in to a config or smth.
is there a guide for making commands
Is there a way to blow up an end crystal without using NMS?
can i dm you?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Hm doing it async with a CompletableFuture then syncing back with the main thread takes too long (unresponsive UI)?
I would just put a AsyncLoadingCache from the Caffeine library between the UI and the request then set the data timeout to 30s or so.
@lost matrix ?
Create a thread ;D
yo, i have another question. When i teleport a player, it gives me this message. Is there a way to disable it? or to edit it maybe
You're the one sending it? If not maybe mention what plugin
What plugin shows you this message?
its the plugin i programmed lol
Then remove the message sending
i didnt do it
Then do it?
no, i didnt actually send any message
Something is sending the message
Then what plugin sends a message?
we all are dumb lol
it's actually a requirement to join this discord
And if you don't meet it yet, you will soon ;)
why is choco here then
that gives emotion
he is impossibly smart
then he must be banned
someone ping conclure pls
it doesn't say how to send the message
How can I send a title?
sending a msg ?
player.sendMessage()
Doesn't work
if player.sendMessage("md_5") will not work we are all lost
Just says that in chat
thats a different thing ^^
component.create()
Show the whole code pls
idk if im done
no it creates a component
wait
?paste
?
player-sendTitle ?
commandsender probably
uhhhhh
please use cmdS.spigot
alr
but you can check if(cmdS instanceof Player)
yeah u can
wdym
cmdS.spigot shows up as error... I might be stupid lol
cmds.spigot().sendMessage(component);
((Player)cmds).spigot()
probably
^
Ah works
where you retrieve the non-bukkit API :)
xd
and how would i reference the chatcomponent
it comes up as
that wierd string i sent earlier
that thing
i need plugin that will make spawners ignore light levels unless a torch is placed directly on it
or if its in direct sunlight is this even possible if so where would i even start
oh is it a component builder?
component.create()
^
How can I make it like send it every minute
BukkitRUnnable
hey!
I have been making a bans system which is kinda going very well except for the fact that im confused about a part that i don't know how I'm going to do it
I'm willing to use MongoDB and it's a little confusing to me of how im gonna make it so it actually removes the ban after x amount of time for example:) would be helpful if someone could help me in this thread
I did it like this but do I put it in a listener or no also if I did something wrong tell me
runnalbe.runTaskTimer
do I put it in the listener or no?
what listener
see I have two java files one is a listener and one is just javaPlugin
it depends on what you want to do with the title
send it every second when a player moves
or joins
or breaks a block
or without a special reson every time
.<.
make spawners work on custom light levels
component.create() ?
yeah that's what I want so if I want that there is no need for the listener right?
just in onEnalbe
wtf is this ... you end the var-assaignment in the second code line
after that you add smth and then you create it ... create returns a object and does not change the ComponentbUILDER
well there was a tutorial exactly for this ... if you would read it before you would know it ^^
AAAh im bad at reading
So is it like this?
?dosc
?docs
yes
?jd
thats for me btw
Do I need to fix these or it will just work
its ok for now
you dont have to worry about those
Oh ok thanks
how would someone create a hoverable message. I don't understand it at all
you can delete BukkitRunable runnable = (BukkitRunnable)
armor stand ๐
...
Oh ok thanks
invisible armor stand with name
Before I did this I got this error
I don't think I fully understand what's going on
It tells you what's wrong ๐
So the runtasktimer is the wrong one?
No your plugin is disabled
could you give some example?
Like i need to create a chat message
where you hover above it it shows something else
If you're wondering why. It's probably an error during onEnable
But what do I put in obEnable
And how would something in main class change an error in my other class
I'm not talking to you?
Oh ok
: (
What's the error this time?
@tame shoal https://www.spigotmc.org/threads/text-base-component.398485/ the endest message can help you
Any suggestions for a cleaner way of checking if a map doesn't contain all needed keys from another map?
if(!Map.entrySet().stream().filter(entry -> !secondMap.containsKey(entry.getKey())).collect(Collectors.toList()).isEmpty())
return;
It worked but I saw that I get this error in the cmd that runs the server so should I worry about it or no?
Sorry if I'm asking alot but I'm new to this so can I know what is the issue
Why do you run 1.14
yeah
Map::entrySet
Set::containsAll
We can't know without the code
Something is null
Maybe because before I join the server right?
and replace .collect(Collectors.toList()).isEmpty())to count()
@stone sinew
Yes
How can I make it just detect anyone in the server and send the title to him
Loop Bukkit#getOnlinePlayers
And what about when the keys aren't the same object? For example map 1 is ItemStack and map 2 is Material.
๐
I mean your method isn't really ideal for different types of maps either?
anyways you could use anyMatch() instead of filter()count() == 0 or filter()collect()isEmpty() I believe
or noneMatch
if(!craftIngredient.getItems().entrySet().stream().filter(entry -> !chestIngredientCounts.containsKey(entry.getKey().getType()))
.collect(Collectors.toList()).isEmpty()) {
return;
}
craftIngredient.getItems() -> Map<ItemStack, Integer>
chestIngredientCounts -> Map<Material, Inetegr>
and you wanted to check if none of the itemstacks materials are contained within the latter map
I did a for loop that does that but then what do I do?
You use sendTitle on the player
Yes. If the materials map doesn't contain all the the itemstack map's types then I want it to return false.
its not that hard to type a '.' :(
I didn't get what you meant by use sendTitle on the player also do I put the for loop outside the run or inside it?
craftIngredient.getItems().keySet().stream().map(ItemStack::getType).map(chestIngredientCounts::get).allMatch(Objects::isNull) maybe @stone sinew
if u wanna make it clean (not considering performance)
It would seem that your programming skills are quite lacking. I highly recommend learning Java before starting with Spigot
Thats longer then the one above lol
?learnjava Here are some good links to get started
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.
yes but its more clear what you're doing, you asked for cleanliness
It's because I didn't learn java I was using python and I just tried this in java today so yeah that's why
True. I usually prefer short code. Longer code doesn't seem as "clean" to me.
Loops exist in Python. You should know how to use an object from it
i like explicit code that strongly outlines what the point is
whether it be short or long
Do you open source your code?
mhm
Thats why
I don't care if others can understand it lol as long as its short and functions exactly how it should, I'm fine with it
yeah but that gets to a point where it could be hard to understand even your own code
so its good to be careful
Thats when I just rewrite it ๐ Gives me something to do.
i did this with my old shop plugin
rewrote it 3 times before abandoning it
My minions-revamped plugin had 4-6 iterations before it. They were never completed xD
I think I figured it out, that's what you meant?
player will never be null
Yes but you really should learn Java
Also avoid assert if you don't know what it does
Yeah
Ok thanks
Uhh that is not true
runs Bukkit.getOnlinePlayers() in async task
in Bukkit.getPlayerExact("dvsdfsdf")
he meant if you run Bukkit.getOnlinePlayers()
Uh ok...
Hello, can anyone give me an actual simple explanation about api-version in plugin.yml? I read the explanation on spigot's website multiple times but it's still gibberish to me
What'd you read?
@worn tundra "This will signal to the server that your plugin has been coded with a specific server version in mind, and that it should not apply any sort of backwards compatibility measures. As a result you will also need to make sure that you have programmed your code to account for reading of older configurations, data, etc... .Each server version can decide how compatibility is achieved, unknown or future versions will prevent the plugin from enabling. As of the 1.14 release, the api-version 1.13 is still allowed - however future versions may drop backwards support based on this version."
This is the official explanation, but practically I don't understand a word
what's the difference if I put 1.13 or 1.18 there?
It's too general
It defines the API-VERSION of the api you are using
you don't need it in your plugin.yml
... I'm talking about how it affects the server
all you need for a functional plugin is Main, Name, Version, Commands
the explanation says nothing about it
Plugin might not work
Someone will give an example of aspectj in a plugin for minecraft? (edit nms)
Another way too general answer ๐ฆ
please explain why
Your plugin will only be able to use the api methods from the version specified in the plugin.yml (Atleast thats what I was told. I could be wrong.)
okay let me tell the full story: I released a plugin that saves items in a config, and I put 1.16 in the api version. People who use 1.12 complain that it throws an exception about BLACK_STAINED_GLASS_PANE not existing - so would changing the API version to 1.13 help?
BLACK_STAINED_GLASS_PANE doesn't exist in 1.12
Its STAINED_GLASS_PANE with a durability of 15.
I got the perfect thing for you
I love how the return dislike link is above your github, in your discord profile
LOL
Can use Xmaterials or make your own like I did
EXACTLY!
Don't need 15+ methods just to get a fucking material
oh wait... I did see XMaterial a lot in the development forum
was it created to solve problems such as mine?
It makes backwards compatibility easier. Atleast with materials lol
basically you create an enum with the different names it could be under
wow
what is your plugin ?
Here is my Versionless Material class. https://pastebin.com/EiKQ4FVB
enum VersionedMaterial {
BLACK_STAINED_GLASS_PANE("STAINED_GLASS_PANE");
private final String[] alternateNames;
VersionedMaterial(String... alternateNames) {
this.alternateNames = alternateNames;
}
}
@echo granite
then u make a method to get the material and store it
i have a world generator plugin i made but i dont know how to load all the worlds when the server starts can someone help me?
You load them teh same way you generate them
If the world exists its loaded. If it doesn;t its created
private Material cache;
public Material getMaterial() {
if (cache != null) {
return cache;
}
for (String name : alternateNames) {
if ((cache = Material.matchMaterial(name)) != null) {
return cache;
}
}
return null;
}
but we use a command for it and ii cant just input it into the plugin each time i make one
nice idea
wait
Thank you, I put a lot of hours to develop it and luckily I have 450 downloads without any advertising ๐
but what is a Bulletin Board ?
pinboard ?
yeah pretty much
ah nice
It's a board where you can post updates on stuff
Do you have an alternative for the word "bulletin"?
hmm i would call it (Job-)News Board or smth like that
or Announcement Board
good luck with mysql support xD
https://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
Its not bound to the shade plugin
It doesn't provide an answer
guys how do i add a subpath to a path in config.yml?
tried searching that, but i havent thing anything
hello:
world:
yes: no
Path:
Sub-Path: "Test"
````getConfig().set("Path.Sub-Path", "Test");`
hello.world.yes
config.set("hello.world.yes", "no")
thats to store "no" in the yes subpath
yes
but if the path doesnt exist?
You mean the default worlds? They always automatically load in
How would i access a class that I haven't imported using reflecton (to store in a hashmap)
You get it by name, so long as it has been loaded by teh ClassLoader
Can i store it using Class.forName() inside of the hashmap?
as i cant import the class itself
You can retrieve the class as an object and store it in the map, yes
oh ok
i meant custom made ones but i just made it so whenever some teleports to them it loads them in using createWorld();
please help
You have to actually to call the createWorld method to load it
ik
It ain't gonna be automatically loaded by your server jar
Unless you change the level name to that world
I have a command (/wtp) which you use 1 argument which is the world name, so if you visit the world, and its unloaded, it loads it cause everytime someone uses wtp it does Bukkit.createWorld(new WorldCreator(arg[0]));
Does that load in every world?
oh i already have a world creator
This will create lag. You should load the worlds in your onEnable
as I said, the page doesn't give an answer
I read it entirely
Is there a way to have the plugin load in every world without me telling it the names in the code then?
Why's the O small u dummy
Wtf are you doing pengu
Why not use a Map<Long, ChunkSnapshot> ???
Then add it to your classpath.
wow it's 7smile7
if you need to use Object just use it instead of object lol
still believe comments are sin?
good code should be self explanatory smh
Yes. Ive taught some CS students about clean code a few months ago and had to read Rober C. Martins book again.
Comments are a sin
yo, its me again lol. i'm now trying to store the name (second argument of the command) and the coordinates in the config file. warps: name: x: -17.045529743215834 y: 71.0 z: -217.36350930724504 the coordinates work but the name inst showing .-.
Add it to the classpath.
So I should comment every single line of code? Got it 7smile. 
Meh. Sure. But then you would have to work with reflections all the time.
Comments are made to just make funny notes
Comments are a sin?
And say // fuck
LOL
yes they are
๐ค
I've written // java is stupid a few times
// We have no idea what this method is doing but if we remove it everything breaks
Do you have the jar you want to use that class in?
how?
Do you use maven or gradle
Just add a system scoped dependency
What plugin do you want to add to your classpath.
Btw how do you compile your project? Because ive
seen SO many ppl writing a pom.xml and then they still
build artifacts.
What really lol
Clean package?
Yes. pom + adding jars to the project and then proceeding to ignore the pom to build artifacts
or just package
can anyone help me 'bout this?
clean install ๐
You're overwriting the name with the section
how can i fix it?
oh silly me lol, thanks!
The value of your "warps.name" path is a ConfigurationSection.
You cant write a String to it and then let it be overwritten by a section.
Either make a list of sections or use your path as name
I dont think he only wants to have one single warp
LET'S GOOO HAPPY NEW YEAR
oh yeah you're right
so how can i do that? i'm new at config files ๐
So
set("warps." + name + ".x", x)
Yeah, that ^
oh thank you so much ^^
public class ringtest implements Listener {
Plugin plugin = MythicUtilities.getPlugin();
@EventHandler
public void RingEffects(PlayerRespawnEvent event) {
Player player = event.getPlayer();
player.sendMessage("Line 18");
new BukkitRunnable(){
@Override
public void run(){
player.sendMessage("Line 23");
}
}.runTaskLater(plugin, 1);
player.sendMessage("Line 26");
}
}
^Listener Class
public class MythicUtilities extends JavaPlugin {
private static MythicUtilities plugin;
@Override
public void onEnable() {
//Commands
ringLoader.load(this);
getCommand("getMat").setExecutor(new getMat());
getCommand("getRingList").setExecutor(new RingList());
getCommand("applyLore").setExecutor(new ApplyLore());
}
public static MythicUtilities getPlugin() {
return plugin;
}
^Main Class
So im not sure as to why the getter isn't working, the console says that plugin is null when attempting to register the bukkitrunnable
The proper way would be to write a Warp class and make it ConfigurationSerializable.
Then write a WarpManager class which contains a Map<String, Warp>
This way you can save/load all your warps with a single
config.set("warps", warpManagerInstance);
You're not setting plugin
you never assign plugin to anything
First line in your onEnable should be the initialisation of your static plugin variable.
or else its null on default
Because otherwise you'll accidentally try to use it before it's set.
You cant initialise it statically as only the spigot classloader is allowed to instantiate JavaPlugin classes.
k thx
If you want it even more early you could init it in your constructor
Oh thats not a bad idea
Why would you need it before then though
onLoad ๐
I didn't even know that was a thing lol
Smh just pass your plugin in the constructor like you do with any other object
yeah be a normal person
or if you want to go extra use guice, dagger or some lib to handle it for you
And also let listener classes be instantiated and registered automatically ๐
@EventClass
public class DeathListener implements Listener {
private final YourPlugin plugin;
@Inject
public DeathListener(YourPlugin plugin) {
this.plugin = plugin;
}
@EventHandler
public void onDeath(PlayerDeathEvent event) {
Player player = event.getPlayer();
PlayerTracker tracker = plugin.getPlayerTracker();
tracker.handleDeaht(player);
}
}
Yep
๐ field depenency injection ๐
Yeah you are right
Yes just classpath scanning
just check if a class implements Listener โ ๏ธ
Thatโd also be an option
But there are people who dont treat Listeners as singletons
so annotation would be safer
in your onEnable ๐
Not really auto then :p
wooosh
Iโll woosh you
oh dear i has been wooshed
My first idea was having a custom class that extends JavaPlugin
But people extending that would still have to make sure they call super() in their onEnable
guys, is there a way to convert a string (GRASS_BLOCK) to a Material type?
plenty of static methods in the Material class for you
i tried to google them on google but i didnt find anything helpful..
use your IDE to help you
please help
Material.valueOf?
yep i tried that but didnt actually work
you need to provide more context
maybe i'm using that wrongly
I quoted my original message where the context is lol