#help-development
1 messages · Page 1427 of 1
this should be pinned imo
md_5 needs to add a ?pdc
^ or that
pinning shit is too much work for the maintainers to handle
i guess
it involves like clicking stuff and shit
but... why don't you just return Collections.emptyList()?
because thats where the <eval> is
what
oh, are you trying to output the result of the evaluation as the tab completion?
no
then i'm confused lol
o.O So just return that. I don't understand the cancelling in the event part
that needs brigadier though
so you dont tabcomplete <expr>
Ohhhh but you don't want them to actually hit tab to auto complete <expr>
or. well. i guess that works
homemade version
okay okay, i gotcha now lol
ngl I thought that event was called when a plugin returned its tab completion results
yikes
uhhh
I have a produce Method in an object, and it has to be executed sync, but when I have lots of objects on my world, it starts to lag, is there a way to make it "async" somehow?
well show us what this produce method is
and also
how many times will it be executed?
and also what does it do
if it does something like world modifications, dont do that async
is this world modification?
yeah no
spawns an item
cant do anything
oh
i meant more like
getting rid of blocks
that type of stuff
holy
Is there a reason why you dont cache those config values?
yes
don't have to change much code
🤣
and further more, these objects are like... not static...
wow
this code is the example of a mess
To be fair configs are already cached
I would disagree..
holy shit that code
if you say it is a mess.. well then idk what to say.
Im not a fan of the one-line if statements
because for me it is very readable.
you think that is... readable?
thats not readable lmao
how would you make it better?
where do we start
have you ever heard of oop
or delegation
or just in general, writing code that does not repeat your self
lots of repetition going on
I personally would create seperate methods that get the config values
Instead of all that magic
holy jesus.. the more i look at it the more i realize
i will make a list if you want.
No, I am not exaggerating
this is legit a fuckmess
then do me a list then
Alright
I feel like all of those config calls should be cached when the machine object is created
Its very hard to read
what is this plugin again?
Idk
😂
which is an achievement
nice
I think its fine
thanks for the achievement
Its just the extreme amount of config calls
mostly that
- Use better delegation/separate some of the logic in actual methods so you can actually see the logic better. To anyone else reading that code that is not anywhere readable.
- Start naming your damn methods better. What the hell does "produce" mean. It could mean produceItemStack, or some other shit. and also don't name your method simply "data()". Yeah that's a big no no.
- The biggest one. Use your damn variables. Store your instance, the config, as one variable instead of using like some getter method 1 quadrillion items.
- You are repeating a ton of code. And I mean a ton. Store some shit like the config reading in some methods.
- As what Martoph said, cache the config values such that you will use those instead of retreiving from the config. The ton of hashing shit going on... That is why it's causing a ton of lag. Instead, make some schedualed task to automatically update the values when necessary.
- You should be using dependency injection here. It avoids situations like these such that it creates too much coupling. But at least store it in a damn variable man.
the last one, is kinda optional
and is debated
myeah, though it's still pretty slow
Yeah
Its just a lot of hashing going on
as it does map lookups for every .
still pretty slow
I disagree
it only starts to lag when the count of objects reaches an abnormal amount
like 1k
??
this is false
lmao
you should be already conserving resources
Slow doesnt mean lag immediately
a map's performance doesn't depend on its size
that is the whole point of a hash backed map
the map performs consistently regardless of the number of entries in it, as long as the hash function is good enough
Regardless, just rewrite this whole segment lmao
which means it performs just as slow with 3 entries in it as it would with 3,000,000
someone explain what dependency injection is i never understood that concept lol
as far as I know.... Bukkit uses SnakeYAML and you cannot retrieve something from the io directly.
it stores into a map with the values etc etc etc.
I meant hashing
but that is still slow if you do that like a quadrillion times
like what you are doing
lmao
IdentityHashMap tho fast as fuck
and you are querying keys with several .'s like three dozen times
that adds up to like two hundred fucking map queries
Your machine object needs more fields
as I said, the object itself does not mean anything, the object is a representation of the data on my other file.
🤦
omfg
get the variables from the config before its created and pass it to the object
Okay listen to us
WE ARE TELLING YOU WHAT YOU WANTED but you wont listen to us and just argue about it
We are developers. You come to ask and now you just come to argue with us?
I gave you a full list of improvements that can be done
as I said, you are doing several hundreds of map lookups just to get some values that could 100% be cached
now go apply them, or rewrite that code segment with those 6 things in mind
several fucking hundreds
not "just a few"
not "just a few dozen"
several fucking hundreds
yeah I'm leaving this chat like a rocket launching to orbit
thats nice
have fun
We tried lol
you may come back if you are a Chinese rocket
Must be a woman 😛
LOL
so like women are smart tho
how long have you been doing java Jadss
women are prolly like 5x more mature than men
they play dumb but they're smart lowkey
mhm
Of course they are, they know everything.
yea
lol
they know what a dick looks like at 7th grade. We don't even know what their thingmabob look like until sex
/s
sus
nope im a virgin
realy loving the sexism happening
conclure im a virgin
how long have all of you been doing Java I want to get a total time here lol
6 years idk
uh revirgination
ive been doing java for like 2-3 years?
around that
also my first actual enterprise language
16 years so far
i take seriously
lmao
lol
17
you come from kotlin?
from javascript
lol ye
6 years and I'm still shit at it lol
same
same
still stuck with yucky leaky abstraction
really shows how complex a language is
yeah
I only learnt how to use lambdas like 3 months ago
Lambdas were in java 8 i think
Yea
ye
They dont usually teach it in school
ive been doing lambdas since march 18th, 2014
its faster than anonymous classes tho from what i heard
wonder if thats intentional or not
ye
My school's i.t teaches basic python and that's it
and it doesnt make sense cause it doesnt use new
same
my teacher says python is by definition the best language
lambda:
their lambdas are absolutely disgusting
Yea show him the kids from my class lmao
I wish lamdas were faster
aren't they dynamically invoked or smtng
they are faster than anonymous classes
Ah
yeah imagine if they were
I only use streams for stuff that i do once
pretty sure there is like an ide plugin that converts streams to imperative for loops
😬
oo nice
yeah it kind of trips over the same pitfalls as lombok
and also doing stuff like parallel shit would be hard
it kinda just does stuff and 🤷🏿♀️
if we would only have 1 cpu, technically parallel streams wouldn't be parallel just concurrent, amirite?
1 cpu? or 1 cpu core
Speaking of school btw, I hate being that one kid that "knows computers so they can fix everything"
Is it possible to rename @EventHandler?
I want to create warps with undying totem animation, i created items with custom model data
when player teleports to warp i want it to trigger Totem Of Undying with Custom Model Data: 2
with PacketPlayOutEntityStatus packet how can i do it?
The annotation? no
Because one is for the team, the other is for the kit gui
i mean method
thanks
For a moment I was afraid it would work like an override
uh technically yes if you implemented your custom EventExecutor
like the annot
anyone know something about this?
yes, you can rename the event handler
the method name does not matter
nobody is forcing your click event handler to be called "onClick"
that is just a convention
you can call it "onClickThisShit" or "onScrewedYourMom"
or just "fuck"
the only two things that matter are
- the EventHandler annotation
- exactly one parameter that extends Event
how can i make a try catch and send a message with the class name like
me.paradis.main.testclass.name
player.sendMessage(String.valueOf(e.getClass())); returns the error name
like null
not the name
You know class.getName exists?
you want this.getClass, e.getClass would be the exception class
yes this
thanks
hey, what's the correct way of setting the contents of an inventory holder going from a Block object?
I was trying to cast BlockState to InventoryHolder but it ain't too happy about that
do I actually have to handle chests as chests, furnaces as furnaces and so on?
Uh I'm pretty sure they can be cast
hm that's what I thought as well, especially since they're passing on the instanceof check
let me try again
If they're passing the instance of then they'll definitely work
private void fullBlockRestore(Block block) {
BlockState blockState = detonatedBlocks.get(block);
blockState.setBlockData(blockState.getBlockData());
if (blockState instanceof InventoryHolder)
((InventoryHolder) block.getState()).getInventory().setContents(((InventoryHolder) blockState).getInventory().getContents());
detonatedBlocks.remove(block);
}
am I missing something obvious?
[21:58:14 WARN]: [EliteMobs] Task #16969 for EliteMobs v7.3.0 generated an exception
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState cannot be cast to class org.bukkit.inventory.InventoryHolder (org.bukkit.craftbukkit.v1_16_R3.block.CraftBlockState and org.bukkit.inventory.InventoryHolder are in unnamed module of loader 'app')
at com.magmaguy.elitemobs.explosionregen.Explosion.fullBlockRestore(Explosion.java:73) ~[?:?]
at com.magmaguy.elitemobs.explosionregen.Explosion.access$000(Explosion.java:20) ~[?:?]
at com.magmaguy.elitemobs.explosionregen.Explosion$1.run(Explosion.java:62) ~[?:?]
You're not instanceofing the same thing you're casting
detonatedBlocks.get(block) and block.getState() mght be different
is just having the data not enough?
^ cause you don't call .update first
Also the set is redundant
which one?
You're setting the data to the data
oh the instanceof?
Just call .update(force)
you know I did wonder why it was that copying the data wasn't doing a more in-depth copy
thanks for the help
In fact all your code is redundant
Delete it all except for . update (force=true)
That'll restore the inventory without any extra code
Need the true
also need to modify block and not the blockstate lol
hm well that partially worked but the inventory contents aren't getting restored
if you are updaing from a BlockState using update you will wipe the inventory. If you are applying BlockData you should not need an update
hm
Hey - is there a better way to get an item name? Right now I'm using this line: player.getInventory().getItemInMainHand().getType().toString(), although that returns it in a less than ideal format
thats the Material
I know, I'm just not sure how I would go about making it show in a more user friendly way & that's what I'm asking about
Ah, will read that. Thanks a bunch
well I figured out the issue, it's never an insteadof inventoryholder for some reason
the plot thickens
?paste show code
line 110 never triggers
fyi
though I am exploding and regenerating chests just fine, inventories aside
check for instanceof Container
that does trigger
cast to Container and getContents()
yeah switching over now
but wait, isn't this for Block objects
what happens if I try to do it to BlockData?
which is what I was storing
why are you calling them all blockState if its BlockData?
sorry
I am storing blockstate
but I was copying block data
since afaik you can't copy blockstate
thats my regen code https://paste.md-5.net/devemunura.cs
I set type, set BlockData, then I add the inventory
if you have a BlockState you can get the inventory from it
notice I add the inventory after the block has been set with .update(true);
fyi I'm pretty sure your set type there is extraneous
its not
if you don;t set the type it will thrown an MC error/warning in console about the wrong block type
it doesn;t error out as such, but it warns of wrong block types adn it says it will try to fix it
like [19:06:20 ERROR]: Block at 227, 38, -931 is Block{minecraft:stone} but has net.minecraft.server.v1_14_R1.TileEntityStructure@527ce791. Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.
hm
you may not have to fill your inventory after as you are using BlockState. So long as you set type and data, then update it shoudl work.
I store my inventory separate so I do it after.
anyway good luck I'm off
if (event.getClickedInventory() instanceof PlayerInventory) {
for (String i : plugin.getConfig().getConfigurationSection("blocks.").getKeys(false)) {
plugin.getLogger().log(Level.SEVERE, i);
}
It only prints one
Not sure why
remove the period after blocks
Same thing
maybe try debugging with info instead of severe? idk
It shouldnt matter
Since its being looped
wait
nvm the config file fucked
it never saved after i hit save'
wierd
fucking notepad
🤷♂️
is there a good way to get the spawn reason of an existing entity? not using CreatureSpawnEvent
you're supposed to do that
hmm
it seems to be resetting it
@dusty herald it seems to be resetting the config on server restart
It has saveConfig() on onDisable()
try removing it
ok
@dusty herald is this not suposed to be in ondisable?
public void onDisable() {
this.data.saveConfig();
this.saveConfig();
}
Ok
@sage swift
help mw
if(event.getClickedInventory() instanceof PlayerInventory) return;
where do i put the !
to do the opposite check
outside of the parentheses
nope
see if you can figure that riddle out
This might work
if (!(event.getClickedInventory() instanceof PlayerInventory)) return;
Np <33
lüp
The keys are things like NETHERITE_INGOT
bruh momento
How do i check if any of these
ItemStack[] items = event.getClickedInventory().getContents();
are these
getConfig().getConfigurationSection("blocks").getKeys(false)
@quaint mantle
Yes
I'm bad at events
its just
getting a itemstack array
and checking if any of the blocks line up with a different list
lüp
How can I pass in chat api components to an item's lore? Right now in spigot we have ItemMeta.setlore(List<String> lines) thats it. How could I use perhaps Bukkit, CraftBukkit or nms to achieve this? This is achieveable with minecraft commands, for example: /minecraft:give @p stick{display:{Lore:[{"color":"red","text":"stick"}]}}
i obviously dont know what this is, so if you would like to contribute to the conversation please do. If your just going to post things that wont help anyone please see yourself out
loop through every item
brigadier maybe?
well it's a set
so you can use Set#contains
Brigadier is for commands
could look into how minecraft processes it
set is not exclusive to spigot
how do i easily look things like this up
Like what does the Set#Contains mean
Im kinda new
Ive gotta ask this question at some point
the pound sign means you call the method on an instance of the object
got it
so you can't just do it statically
Where do i find the documentation for it
I cant find it on the spigot site
declaration: package: org.bukkit.material, class: MaterialData
if you want the big brain one line solution here java Stream.of(evt.getPlayer().getInventory().getContents()) .anyMatch(item -> config.getKeys(false).contains(item.getType().toString()));
Bukkit?
Use IntelliJ for better experience and for TabComplition
Base java api 😔
Okay :((
NetBeans all the way /s
but yeah for your classic loop you'd do something like java boolean found = false; for (ItemStack item : player.getInventory().getContents()) { if (config.getKeys(false).contains(item.getType().toString)) { found = true; break; } }
mobile?
What does getKeys means
null checks?? U can't turn something nullable into an itemstack
also uh that world doesn't exist apparently
yes ik
but how?
i set it
why'd ya cut out the line numbers
if i have yml section: key: bla bla bla key2: bla bla bla key3: something else and i call config.getConfigurationSection("section").getKeys(false) i'll get a Set with "key", "key2", and "key3"
🤷♂️
thanks i think ill use this
give us line numbers, you maniac
i tried to turn something nullable to itemstack?
where
well apparently the world is null Supa
Oh cool
oh sorry
I'm saying null check those matchMaterials
so how am i supposed to check if what the player types matches the enum of a material
.matchmaterial is the comand i found in the docs
pos1.getWorld() is probably null.
I'm saying that matchMaterial is nullable??
uhh yea but does that matter
why tho
I don't think it's matchMaterial
leme check
oh I mean no if you don't care about people inserting false arguments
bep bop bap i am correct 100% of the time so i dont need any null checks
yeah
you madman gecko
if you call .equals() on a null object, it throws an exception
everything on my server runs perfectly
i think a check for null will handle when ppl just enter random strings
yes that is what I am saying to do
but i set both of the Locations variables to block.getLocation
from two blocks
the error is on line 44 and it says getWorld() is null >.>
kinda liek what happens when u left and right click in worldedit with the wand
but it should have worked right?
debug it uwu
yeah
yes
pos1.getworld == null ?
okie i'll do the command before i set the position vars
thats how i created the vars btw
did i do something wrong
thats the default value i guess?
i just figures i'd add a value to it
does the world Lobby exist?
^
it does not
huh..
pog
but the location should be overwritten
that might be your issue bud
i overwritten it
or just world
roger
yeah, it's world
i broadcasted the new value of the Location var
so its updated
:/
😮
its fixed
surprising ly
wait hold up
does this mean the location variable did not get updated?
the issue was that, if a world doesn't exist, Bukkit.getWorld() will return null.
but i overwitten it witha world that DOES exist
i have the code to overwrite it from the beginning :/
well
if you must hardcode it, I guess you don't need to check
but neither of those things are great practices
what if someone wants to use it in another world
what if the default world name isn't "world"
they can just use it
How can I get the name of the advancement in an event
.getName?
lol
but wouldn't the wand's effect only apply in the overworld?
not a thing
i did not design it to be like that
when u left of right click with an item
the pos1 and pos2
get new values
it shows this when I use event.getAdvancement().toString();
from the blcosk u interact with
org.bukkit.craftbukkit.v1_16_R3.advancement.CraftAdvancement@5cfd8b82
XD
this is an example
pos1 and pos2 will ALWAYS be in "world"
you can't set the positions to the nether or the end, ever
what why?
block positions != dimension position
when you use getWorld, you're selecting a dimension
wait blocks don't contain values of their dimension?
nah
getKey()
those are just coordinates of where in the dimension the blocks are
thx
u can see what that does idk what it returns
you can
which one
just use getWorld on the position they're right clicking
pos1.setWorld(bukkit.getworld("blah"))
it should already be available
try get Key getKey
don't use Bukkit.getWorld()
I did EXACTLY that
i set the world twice
for extra reassurance
XD
so when u do block.getPosition
whas wrong with these
XD
well yea i didn't change the code at that part
and how can I make my plugin sends a message to the admins(OP) when there is a new version?
the second line is disposable
disposable
onJoin > check perms > send message
it should be removed
okie
yeah I mean how can I make it check
onJoin > Player#isOp() > send message
k whats wrong with it
i should have overwritten the world right?
with this
PlayerJoinEvent yo
correct
is your command handler for setting positions?
this is when i FIRST made the variables
ah, so that's old
i figured i'd give them a value
yeah, your solution should work now
should i not?
in general, hardcoding a world is a bad idea
well yea but it didn't work before i change the starting value from "lobby" to world
indeed
hardcoding in general is a sin to me
i didn't mean to do that tbh
one question
if you're immediately reassigning the value of pos1, why are you storing it in your command executor?
i did not?
actually, I should probably ask what your intentions are.
What's this code supposed to do?
the two positions are created in the Commands class, then the vairbales are reassigned values in another class
I got this now adventure/arbalistic
record location of blocks
okei thx
damn it so i created the variables here like this
and i gave them value in a different class
but the two position vars are null
why did the edits made in a different class not get passed on
plugin.getLogger().log(Level.WARNING, plugin.getConfig().getConfigurationSection("blocks").getKeys(false).toString());
for some reason
it just logs []
i have triesd with blocks and blocks.
sand:
dirt:
thats the config
show full code and config
public void onEntityDeath(InventoryClickEvent event) {
if (event.getClickedInventory() instanceof PlayerInventory) {
if(!(event.getClickedInventory() instanceof PlayerInventory)) return;
for (ItemStack item : event.getClickedInventory().getContents()) {
if (item == null) continue;
plugin.getLogger().log(Level.WARNING, item.getType().toString());
plugin.getLogger().log(Level.WARNING, plugin.getConfig().getConfigurationSection("blocks").getKeys(false).toString());
if (plugin.getConfig().getConfigurationSection("blocks.").getKeys(false).toString().contains(item.getType().toString())) {
plugin.getLogger().log(Level.WARNING, "aaaaaaa");
}
}
}
}
i need to rename the event lol
why are you converting it to a string?
yes
oh
idk
i thought i had to
it's not a string
ok, well this should work right?
if (plugin.getConfig().getConfigurationSection("blocks.").getKeys(false).toString().contains(item.getType().toString())) {
oh wait
no
how do i do that correctly?
u already checked if the inventory is a player inventory
why is it being checked twice
Idk if i had noticed it sooner i would have removed it lol
i removed the tostring
from the configuration section
leme try it
still no worky
leme try it without the .
nope
How can I check that the advancment is not a recipe?
if (plugin.getConfig().getConfigurationSection("blocks").getKeys(false).contains(item.getType().toString())) {
plugin.getLogger().log(Level.WARNING, "aaaaaaa");
idk whats going wrong here
...
What r u trying to do?
hey, i'm trying to make a simple plugin who prints "niceee" when a player joins, and it has never print "nice" when i joined, and i'm not getting any errors. Can someone help me?
Here is my code:
package com.sfx.mlgrush;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
System.out.println("Niceeee");
}
}
in the console or for the player?
check if the keys of the section "blocks" in my config contain any of the items in the player inventory. item == current item in players inventory
ig for the console
console
🤦
leme get the code4 you
getLogger().log(Level.WARNING, "nice");
getServer().getConsoleSender().sendMessage("nice");
that could also work
@wispy monolith
I don't think that's right
so u want to make a list right?
yea, but i also want them to have the freedom to add numbers
in ur config
so an amount of that item
so sand: 64
i havent added that yet
Im just future-proofing
change it to
block:
- 'sand'
- 'dirt'
But then how would i add the amount
this is how u make lists in ur config.yml
amount of what?
a
but it's in my server folder
¯_(ツ)_/¯
not in the bungeecord folder
package com.sfx.mlgrush;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin implements Listener {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
getServer().getConsoleSender().sendMessage("nice");
}
}
is my code correct
that seems like exactly what i did but with extra steps?
wouldnt sand: 64 be better
YAGNI
don't start implementing something if you don't need it now.
yeah but u can check for the blcok now
... why?
it makes your code more complicated for no reason
yea no thats retardd
it's literally--
it will get confuing and sometimes it can breack something
I know im going to add it
So
Im going to make sure that i dont cause trouble later
please D:
yeah we are just giving u and advice
Yea i will
but if you're not adding it now, it's best not to add that
Well im going to add it as soon as im done with getting the base name of the material done
then ill work on getting the amount of items as well
change nice with ice
that's fair
use the one i sent you
here
as long as you don't release something with a bunch of unused code, it's not really a problem
oh yea
i wouldnt do that lol
@quaint mantle getLogger().log(Level.WARNING, "nice");
anyway
i gotta head off
thanks for the help
👍
anyone can help me
[08:31:00 ERROR]: Could not load 'plugins\mlgrush.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
show ur plugin.yml
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 14 more
[08:31:00 INFO]: Server permissions file permissions.yml is empty, ignoring it
your jar does not contain plugin.yml
but how can I include it
Show ur dircetory
what ide
@quaint mantle
no the left side of your screen thta have ur classes and packages
package explorer ig
move the plugin.yml to src
i'll try
just drag it to it
oof tf
org.bukkit.plugin.InvalidPluginException: java.lang.UnsupportedClassVersionError: com/sfx/mlgrush/Main has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 52.0
i'm trying to change the compiler version but idk how lol
and add an api-version to your plugin.yml
can u join vc?
i'm trying
tf is that now it says that it enabled my plugin, but when i try to join my server it says "failed to login: servers are in maintenance"
i tried restarting my server
did u cahnge the compiler version?
yes
Anyone here ever used Discord JDA? I'm trying to use it in a plugin and I'm getting a lot of exceptions
ok
I did
ok done its working bruh
cool
thanks dude
np
My code works, but whenever I run it it produces like 5+ exceptions like this: java.lang.IllegalStateException: zip file closed
show all the classes u used the jda on
or at least the main class
hello?
?paste
here u can paste your errors code whatever
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
sorry I was editing the pastebin
happens when sendPlayerMessage() is called
error looks like this: https://pastebin.com/JZbTNyL8
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
ok so first u need to Make th JDA
this.jda = JDABuilder.createDefault(token).build();
I have that
if I omit playersWebhook.execute(); then I get no errors
with all the exceptions that u can get
When I have it the code works but spams errors
I forgot to mention I'm using a custom class to send webhooks
I'll send it
What is your plugin trying to do
like a log?
kinda ye
how to make a for loop with each player connected in the server
just make the bot send the stuff to a channel with some events and that's it
for (Player p : Bukkit.getOnlinePlayers()){
...
}
thanks
alr ig that works
but I liked the custom bot names from the webhook
wdym?
like with a webhook I can make the sent from user any name I want and any icon I want
how can i fix this error?
?paste
What does line 30 in de.bitlukas.bitbuild.listener.PlayerInventoryClickListener.onPlayerInventoryClick says
World world = Bukkit.getWorld(worldName);
u can do that with the bot too
oh sorry I mean 20
F
line 20
if(event.getCurrentItem().getItemMeta().getDisplayName().equals("§8» §eSettings") || event.getCurrentItem().getItemMeta().getDisplayName().equals("§8» §aWorlds")){
I've put it in a try catch
c:
event.getCurrentItem() is null i suppose
I would need to make seperate bots tho no?
ok but it's better to don't over complicate stuff
I mean webhooks shouldn't be this hard lol
All of those methods can be null. (getCurrentItem, getItemMeta, getDisplayName) Concider adding null checks before accessing
I FIXED IT
Sending messages causes even more errors 😭
With a try catch :3
huh I really thought it could be null
Aight
or if you didn't set display name, it should be Material name
I wouldn't recommend that concider adding null checks. Try catch is a waste of performance
debug
It's a little server only for me
do like this
private JDA jda;
@Override
public void onEnable() {
try {
this.jda = JDABuilder.createDefault(token).build();
} catch (LoginException e) {
e.printStackTrace();
}
}
public JDA getJDA() {
return this.jda;
}
webhook is easier
yeah
and save performance
My webhooks aren't even related to the JDA but somehow sending a webhook message causes JDA errors? 🤔
?
I'm so confused lol
webhook is http request
ye
remove JDA deps
I'm using HttpsURLConnection to send the webhook but doing so causes an error from JDA
and when u want to get it in another class u just add this
JDA jda = Main.getPlugin(<Main Class>.class).getJDA();
Only using it in 1 class
ok so that is it
u don't need that line
you should show your dependency list
I'm so confused tho bc HttpsURLConnection isn't even related to JDA and JDA throws errors about zip file errors?
.
want the pom.xml?
only <dependencies>
<dependencies>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.1_253</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/JDA-4.2.1_253-withDependencies-min.jar</systemPath>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>```
remove JDA
add the event's and get the info u need and send to the log channel, example:
guys I am using webhooks and a bot so I need JDA and my webhook class 🤦♂️
so
cant remove either
use Hesham's answer
that doesnt use a webhook
ye ik the problem is with the webhook
the problem is JDA
?paste
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
jda.getTextChannelById(ChannelID).sendMessage(event.getPlayer().getName() + " joined the server")
}
ffs I dont want to send the message with JDA I said this already
I want to send a webhook
webhook may be get rate limit
I've said this like 5 times
ok do what ever u want
rate limit doesnt matter
rate limit is the matter
also you are over complicating stuff even using JDA
I already did but I'll send it again
how so?
Hey, I created a command in my plugin but I have a problem because I get this error:
[07:55:51 ERROR]: null
org.bukkit.command.CommandException: Unhandled exception executing command 'dratoggleforplayer' in plugin DontResetAttributes v1.0.0
[..]
Caused by: java.lang.NullPointerException
at me.krystejj.dra.command.ToggleCommand.onCommand(ToggleCommand.java:18) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[patched_1.16.5.jar:git-Paper-642]
... 19 more
this is my command:
public class ToggleCommand implements CommandExecutor {
public ToggleCommand(DontResetAttributes plugin) {
plugin.getCommand("dratoggleforplayer").setExecutor(this);
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
System.out.println(args); //<-------- this causes an error
if (DontResetAttributes.affectedPlayersNames.contains(args[0])) {
DontResetAttributes.affectedPlayersNames.remove(args[0]);
commandSender.sendMessage(
ChatColor.GRAY + "Disabled DontResetAttributes for player " + ChatColor.AQUA + args[0]);
} else {
DontResetAttributes.affectedPlayersNames.add(args[0]);
commandSender
.sendMessage(ChatColor.GRAY + "Enabled DontResetAttributes for player " + ChatColor.AQUA + args[0]);
}
return true;
}
}
sorry for my bad english
I think you dont understand his question