#help-development
1 messages · Page 498 of 1
I don’t think my build files have ever broken
Gradle is a funny experiment
Run „gradle init“ in your project folder
Gradle even complains about „deprecated features“ about a build file it itself created one minute ago
Gradle is a fucking joke lol
Nobody was ever supposed to use it
everyone can test it out yourself, just do this:
gradle init (in any folder, complete the steps)
then gradle build
it's gonna complain about itself
gradle be like "er hmmmm I just created this file 20 seconds ago. but erm... not sure.... might be broken tomorrow. not sure yet (shrug)"
Select the middle square.
What's the image dimensions?
Probably at least the size of your monitor. It covers the whole IDE with the image.
Ehhh, I don't really do DMs
I just cloned a repo that's using gradle. brb, I'll only have a smoke, take a shit, and go to rehab again, I'll be here again 2 weeks. Maybe gradle's done then
Alex, you need anger management at this point
ikr? maybe I could open an issue on gradle's GH and maybe it even gets answered... in 2 years
You could try using this one. It's a little over 2K in resolution.
can I implement InventoryHolder or is that still deprecated?
wdym
while you can, in theory, do it, you shouldn't. what's the purpose, anyway?
People use it to identify their custom inventories
yeah ik, I even do that myself in old plugins
but one day, choco told me "DON'T TO IT" lol
Smh, people out here not realizing they can just do instance comparisons on their inventories.
tbh, how are people supposed to know that?
anyone got an idea why my server suddenly doesnt recognize my plugin? ive done it a hundret times made the plugin yml main class everything but it doesnt work
what are other possible reason
s
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
Send logs
as i said. my server doesnt recognize it. there is no logs nothing.
it just completly ignores it
Is this a local server?
?paste your log
Is there any nice nosql databases like sqlite I pretty much don't want to have to go through the pain of mapping nosql patterns to sql
Mongo?
Mongo isn't serverless
or wait actually i did find something but its on the top before all other plugins begin to load
Kind of but also quering json would just be wild
I thought slapping together some random json query thing would be hacky as fuck
No it's case sensitive
ok then i know whats wrong

?paste
Either one of those objects could be null.
?paste
what's "admingui" line 22?
also use proper class names pls
the screenshot i send
this is the base it is refeering to
p.openinventory
either "p" is null, or "gui" is null, or "gui.getventory()" is null
what was the problem?
this thing at the very end
ah yes lol
x)
can you use the constructor of the main class?
private val configManager: ConfigManager,
private val tableManager: TableManager,
private val hikariCP: HikariCP
) : JavaPlugin() {```
and should i be using stuff like HIkariCP(this) or give it a variable? (for dependency injection)
what is that?
Kotlin moment
why do you use that?
Why would you need constructor of main class
Just handle everything in onEnable lol
i have come to my senses
is there a website that lists changes between paper api and spigot api?
or maybe even a list like "this was now added to spigot api"?
View the Bukkit, CraftBukkit and Spigot changelog.
how did you get banned on paper lol
by violating their rules, obv
yes sure, but what exactly?
I was in a phase of drinking. I had some discussions with staff, IIRC. I didn't say anything bad. But then I sent the following song, and somehow staff considered this "fat shaming": https://soundcloud.com/le-crochet/fucking-a-fat-girl-burning-testicles?utm_source=clipboard&utm_medium=text&utm_campaign=social_sharing
they ignored the fact that every eminem song is like "yo you didnt pay enough for the drugs you bought from me, I will now shoot you!!!!!" yeah idk people are weird sometimes. The song isn't even about fat shaming, btw.
Hängst du schon am Haken? Knusprig Paniert und JEFF & Jefferson ergeben zusammen: Le Crochet!
but discussing my paper ban is not sth we should do here
why is there a utm on this link LMAO
wait nevermind i read it wrong
it just shows where the clicks come from
that song isn't even good, btw. I got way better songs on soundcloud lmao
lol I am german too, I understand, why did this get you banned?
¯_(ツ)_/¯
every rap song has much "worse" lyrics
I kow. I did appeal my ban once, but nobody ever answered
Yes
This is why we stick with spigot api for spigot plugins
how can i get a quat from an euler angle in joml
Hi! Having trouble while trying to put NMS on my spigot plugin. I removed the - api in the pom.xml file but nothing changed (I didn't even get an error...). I'm on intellij idea and I used an idea plugin to create the project. Any idea about how to fix it? (sorry if my English sucks)
Have you run buildtools
The plugin just build everything and I don't get any dependency errors (at least for the spigot api) so I think it did
if you havent directly ran it you most likely havent
?bt or you can run this if ur on windws
Then should I recreate a plugin manually?
no you can still use that you just need to run buildtools once
OK thx will try it tomorrow
how could i check if an item is stackable, like ender pearls, arrows, end crystals, etc? this is for a set amount gui, but the item to change amount is unknow, i check if item.material is block or item.material is edible but i want to allow other stackable items
Material#getMaxStackSize
I'm trying to register an event that triggers whenever somebody eats a specific food item with a name
whenever I eat the item in-game is doesn't do anything
print the display name and compare it to Enchanted.format result
System.out
why does this return unknown server
lol don;t show too much code
I believe you may have got the answer there chap
Just substring from index 2
😢 This day and age anyone can get dementia even a server, really shows you no one is safe
Then you’ll have a known server
can you tell me how
he was joking :P
oh
I prefer the substring method but this works too I supose
I completely forgot about it.
The substring went straight over my head. 3 in the morning.
I know that scoreboard teams are the ones that manage the colors for glowing effects
But I'm having issues with other plugins affecting my plugins glow colors because of it
What's a possible workaround/
Hey, is there a way to use the Player Command packet through ProtocolLib, or will I have to use NMS for that?
Why would you want to use the packet?
I want to run something when a player sends the Leave Bed packet, which is contained in Player Command. I want the packet instead of the method because I need it to be when they specifically click the leave bed button
I'm not sure I follow, what do you mean?
Why packets over the API?
Why would you use the packet for leaving a bed over the spigot event?
Its because I want specifically when and only when the use the Leave Bed button, instead of being forced out by the server. The event method does not let me do that.
Does the time change before or after they exit?
Before I believe
Even though it seems like after on the client
I could be wrong though
I'll go a bit more in depth with what my goal is. I'm trying to make it so that players can sleep during the day, so I need to edit how the bed leave event works, basically setting it to always be cancelled unless they use the Bed Leave button to leave it.
By "sleep during the day" I assume you mean sleep through the day?
Do you want it so that sleeping during the night still passes the night?
Yes
I do have the Harbor plugin installed, which changes how sleeping through the night works, but I do not believe this changes that much with my goal.
declaration: package: org.bukkit.entity, interface: HumanEntity
There you go, there's your solution vis packets
what does that do?
sorry idk what to say that dosen't sounds aggressive
not trying to
Your problem
rude
anyways how does that solve their problem?
they want to detect when someone clicks the leave bed button
not make the player leave the bed
I guess that he simply wants to simulate a day and night schedule using schedulers
Essentially, I'm trying to cancel the BedLeave event unless it is caused by the player clicking the bed leave button, which is why I need the packet.
Looks like the API needs an update imo
To include a boolean for Leave Bed being pressed
yeah maybe
Otherwise you could listen for https://jd.papermc.io/paper/1.16/io/papermc/paper/event/player/PlayerDeepSleepEvent.html and check whether that hasn't been called before the bed leave event
declaration: package: io.papermc.paper.event.player, class: PlayerDeepSleepEvent
Shouldn't matter if it's just for you personally, I guess
that is true
It does if they don’t want to use paper like a lot of people lol
I'd say that likely more than 80% use paper
i do use paper as of now, but my main concern is if i switch to something else later on
Plenty of people don’t, due to the quality control issues paper has had in the past
I guess the odds are less likely than the NMS code breaking because of an update
lol true
I see, the issue lies in the lack of check/care on the server side for if it was the server or client waking up the player
yeah that does seem to be the root issue of this
those variable names hurt to look at
obfuscated
yeah, but my statement still stands
hmm
oh i dont believe the deep sleep check will help me, since when it is day the player is immediately kicked out of the bed
I'll still give it a try tho
Just check if they send a stop sleep packet
If they do, let them leave
Otherwise, keep them in the bed
Yeah, for now that's the only solution
and now we're back to the original question
.
I’ll check and see if I can find it for you
Much appreciated
I think it may be CLIENT_COMMAND @late pumice
client command is a separate thing from player command according to the protocol page
and when experimenting on my own i did try client command, it didnt work
it just seems as if the ProtocolLib devs just didnt import player command
Time to open a spigot issue on it
Well the lack of ability to discern between a player cancelling or the server cancelling something would be something of somewhat importance
canceling this only will cancel skipping to night, but sleeping in day still kicks you out of bed
I am trying to make players receive many hits from lava so that it would almost instantly kill them but somehow they just get hit like normally instead of being hit like 20 times a second. What am I doing wrong here?
public void inLava(EntityDamageEvent event)
{
if (event.getEntity() instanceof Player && event.getCause().equals(EntityDamageEvent.DamageCause.LAVA))
{
Player player = (Player) event.getEntity();
player.setNoDamageTicks(0);
}
}```
Event hasn't finished yet so no damage is not yet set
wdym?
you are calling player.setNoDamageTicks(0); in teh event, but the event has not finished so it's already at 0 and will be overwritten when the event ends
runTask and set it in there
thank you
I got a question
I'm currently building a item like this
public ItemStack build(String customId) {
itemStack.setItemMeta(itemMeta);
NbtWrapper<?> nbt = NbtFactory.fromItemTag(itemStack);
NbtFactory.setItemTag(itemStack, NbtFactory.asCompound(nbt).put("ct-identifier", customId));
return itemStack;
}
Using protcolib
It results in a Caused by: java.lang.IllegalArgumentException: Stack must be a CraftItemStack.
Do I have really need to use reflection to create a new constructor of CraftItemStack?
where is your itemStack variable?
It's being built above
private ItemStack itemStack;
public static ItemStack getCustomItem(String string) {
CItems a = instance.lookupItem(string);
if(a == null) return null;
return ItemStackBuilder.of(a.getMaterial())
.setDisplayName(a.getDisplayName())
.setLore(a.getLore())
.setUnbreakable(a.isUnbreakable())
.addEnchantment(a.getEnchantments())
.addItemFlags(a.getItemFlags())
.build(a.getCustomID());
}
so yes minecraft ItemStack
So I need minecraft ItemStack?
So I need to use reflection to get it right?
which line is throwing the error?
NbtFactory.setItemTag(itemStack, NbtFactory.asCompound(nbt).put("ct-identifier", customId));
This one
This one too
NbtWrapper<?> nbt = NbtFactory.fromItemTag(itemStack);
any reason you cant use pdc?
Well, I'm limited to using protocollib
so i do need to use CBM?
or whatever it was
shh gotta write reflection ig
you could use a real simple util
sec
as you are not really going down to NMS just CB
yes
?paste
add one to get the method you need https://paste.md-5.net/imumenusug.java
Alrigt
I need some help understanding this
Using ProtocolLib:
ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(this, PacketType.Play.Server.SCOREBOARD_TEAM) {}
To listen to the packet
final PacketContainer packet = event.getPacket();
This contains the packet data. What layer does it actually contain from the wiki link
Like, the wiki link has field names and types. How does this actually work
ItemStack leggings = new ItemStack(Material.LEATHER_BOOTS)
"ItemStack cannot be resolved to a type"
There is no import option
that comes up in the error prompt
for the class
you've got spigot as a dependency?
Yes
Have you tried restarting the IDE? I find that works sometimes
Still not working
?paste
I don't know enough eclipse to help
im guessing that isnt in a method
.
You have an error at the top of the page to
So how do i fix?
probably importing the wrong thing
?paste the class
@remote swallow
its in a method but you dont have an import for it
Weird thing is that ecplies usually recommends one
press CTRL+SHIFT+O
whats the importing directory
WHAT IS THIS WIZARDRY
Anyone know about packets help my messages above please 😦
Its fixed
Is playerinteractevent not intercepted?
I been reading the wiki:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/PlayerInventory.html
I cant tell where you find the setHelment method, like how do you set the helment, on the left it says void
declaration: package: org.bukkit.inventory, interface: PlayerInventory
I dont really know how to read the wiki
player.getInventory().setHelmet(...
It's searchable
it needs to say void since its a setter...
MMultiple of the same item
like 4 arrows
Actually ima check the forums
new ItemStack(Material material, int amount)
How do you store a players inventory then re-add all the contents
how can I modify existing vanilla commands? for example take the vanilla fill command and modify so the max area you can set is 20
You could listen for the command preprocess event
There are getContents and setContents methods
yes do that. @ all the users. man some people are so entitled
Hey,
what is the best option to create a "custom block"? So the block i want to create should be a barrel or a chest and when u open it, it should trigger something, like "Hello world" in the consol.
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Bukkit.broadcastMessage(e.getEntity().getKiller().getName() + " won the fight against " + e.getEntity().getName());
^ this should broadcast right
Hello, I'm trying to cancel splash potion damage to potion thrower, so basically if you throw a harming potion you don't get damaged, only other players do, and I can't get thing working, any ideas on what methods to use, also It has to be a specific potion, for example if you throw healing potion u get healed, but if you throw harming you dont get harmed only other players do.
@EventHandler
public void onDmg(EntityDamageByEntityEvent e) {
if (e.getEntityType() != EntityType.PLAYER) return;
if (e.getDamager().getType() != EntityType.SPLASH_POTION) return;
Map<UUID, ThrownPotion> thrownpotion = FFASystem.getMain().getPotions();
Player p = (Player) e.getEntity();
if (thrownpotion.containsKey(p.getUniqueId())) {
if (thrownpotion.get(p.getUniqueId()) == (ThrownPotion) e.getEntity()) {
e.setCancelled(true);
}
}
}
}
any ideas what im doing wrong
{
Bukkit.broadcastMessage(e.getEntity().getKiller().getName() + " won the fight against " + e.getEntity().getName());
if (e.getEntity().getUniqueId().equals(Bukkit.getPlayer(firstPlayer).getUniqueId())) {
e.getEntity().getInventory().setContents(playerinv2);
e.getEntity().getKiller().getInventory().setContents(playerinv);
} else if (e.getEntity().getUniqueId().equals(Bukkit.getPlayer(SecondPlayer).getUniqueId())){
e.getEntity().getInventory().setContents(playerinv);
e.getEntity().getKiller().getInventory().setContents(playerinv2);
}
}```
The message isnt being broadcast in chat
variables bruh
private UUID SecondPlayer = null;
private ItemStack[] playerinv = null;
//private HashMap<Player, ItemStack[]> itemhash = null;
private ItemStack[] playerinv2 = null;```
secondPlayer and firstPlayer is defined later onwards
it isnt null for long
I dotn think
ItemStack[] cant be null
💀
Thats also redefined later
Because another event sets player 1 and player 2
two people clicking on a sign
Oh wait
I registered the entire class its located in
that means all the event fcuntions are registered right?
The issue is the fact Bukkit.broadcast aint working
it isnt event outputting a error, i think it aint even running
idk
Have you registered the event?
I registered the class its kept it, that registered the other two events
Bukkit.getPluginManager().registerEvents(signEvent, this);
SIgn events is the name of the class
ima send you my code
I got to go to dinner, ill be back
I will tidy up my code later
dont you need "new signEvent?"
getServer().getPluginManager().registerEvents(new BlockPlace(), plugin);
Thats how i do it
He already created instance earlier
Hate to do this and yes i sorta looked on google, is there a way to write a line inside a .yml?
from something being activated
YamlConfiguration#set
more so talking about like adding a line
mm
not 100% what ur saying but sorta am lmao
new to java ¯_(ツ)_/¯
moved from skript 💀
good
mm yeah skript was just to easy and also getting out of hand
making auctionhouses in skript isnt fun 😭
i despise skript
lmao
For example if you do set("smth", 30),if smth: 30 already exist, it will just change value, if not, new line will be added
Your best friend will be NullPointerExeption
if its only that
dam alr
I created the instance earlier
idk whats the issue. no errors
Do not make plugin with one class
lmao im not that dumb
im more of learning files
ik guis, lists, all that
i made a public plugin alr
which ppl love lmao
how do i convice a skript lover to stop loving it and learn java
lmfao just say
And do not use yaml as player data
skript doesnt work
mmm i was just gonna make it UUID: price
Enough to use hashmap
You said that want to learn Collections?
igs
ill just show you this, red is the real dumb guy
does his name start with a j and end with a r
idfk
kekw
ik way to many ppl
he is the most unoriginal person ive ever met
man if u saw my dms ud wanna die
literally every server he has ever made is a really shit copy of anotherone
own 3 big servers + develop on like 10 big servers lmfao
every single servers
Is anyone available, this is my question, the one I'm replying ti
theres been like 10
lol what server did he copy
justbox lol
YamlConfiguration#set(UUID, price);
i can 100% promise i dont have lightskies files 💀
lmfao
little curious
so if i wanted to do that
Mh holding most of your traffic thats not good.
itd be setting tho
not really
minehut is so dog shit now
it is
literally no one clicks on a random server
im creating servers off minehut now
like a year ago everyone was
advertising is the best way
yeah
Wydm
the only servers that im on that actually get constant players are ones hosted with an actual host
yeah i use bloom
Like player has own bounty?
bloom is best
@viscid ginkgo
m
i was gonna do seperate files for each player
but im not that advanced yet
like for my spawner plugin i used pdc instead
Create configsection of player uuid and set uuid: price
like make a list?
whats your average amount of players
mm like 130-200
but recently
its been dead
☠️
might be a bit laggy if its 1 file per
mm yeah idk
you could use a yaml file or json for it, yaml is easier to start with
back
faegyuigrae db
isnt that hard?
only thing thats good about skript is theres more docs 👎
You need to learn little but of sql and use JOOQ as typesafe sql.
if you dont even know sql structure why would you use a mapping framework
Skript vars just yaml
arent skript variables stored in .csv files
I remember .csv files back in 2019 when I was into Skript
wait no
yeah it is
Oh I thought it stores vars in yaml
variables.csv
you can store data in yaml files
but its mainly blocking the main thread
while writing
so some addons are needed
to fix this afaik
Does anyone know why it aint broadcasting?
yeah, but skript uses .save() each time something is written from skript
that's dumb
and some addons were developed to mitigate this issue
maybe its fixed rn, idk i havent developed anything for skript in years
last thing i developed on skript were snippets for skunity of how to retrieve client's version via ViaVersions API using skript-mirror addon
Add @fresh templetHandler
Ok
Hello, I'm trying to cancel splash potion damage to potion thrower, so basically if you throw a harming potion you don't get damaged, only other players do, and I can't get thing working, any ideas on what methods to use, also It has to be a specific potion, for example if you throw healing potion u get healed, but if you throw harming you dont get harmed only other players do.
@EventHandler
public void onDmg(EntityDamageByEntityEvent e) {
if (e.getEntityType() != EntityType.PLAYER) return;
if (e.getDamager().getType() != EntityType.SPLASH_POTION) return;
Map<UUID, ThrownPotion> thrownpotion = FFASystem.getMain().getPotions();
Player p = (Player) e.getEntity();
if (thrownpotion.containsKey(p.getUniqueId())) {
if (thrownpotion.get(p.getUniqueId()) == (ThrownPotion) e.getEntity()) {
e.setCancelled(true);
}
}
}
}
Sorry that I had to reupload this 3 times, it's just really important and I can't seem to figure this out, I really need to fix this ASAP.
what's the problem with your current code?
btw you shuold not use == to compare entities
but equals()
It doesn't cancel the event to the potion owner/thrower
try to use .equals() instead of == for the comparison
declaration: package: org.bukkit.event.entity, class: PotionSplashEvent
aight
May be more useful for what you’re trying to do
you also don't have to save the thrower in a map, you can just use getThrower() or getShooter() or sth like that
I tried all related events and I made sure it's perfect
but yet nothing worked
you haven't made sure it's perfect
you use a useless map, you do the comparison wrong, you use bad variable names, ...
I did not make this one
that won't allow them to only remove the effect to one player, though
Yes it will
how?
If they set the intensity for that player to 0 it removes them
Yeah I wasn’t positive on how to do it so I checked the source lol
I knew there must be a way
should I use potionsplashevent?
Yes you should
Check if the potion is harmful, if it is, set the intensity to 0 for the potion’s thrower
aight thanks mate lemme try this out
Ik thanks
👍
How do you check if a player has a item with a specific name
itreate through all contents of their inventory
check item meta
Hey Alex, I tried doing this and it still didn't work, any ideas?
@EventHandler
public void onPot(PotionSplashEvent e) {
if (e.getPotion().getShooter() == null) return;
if (e.getPotion().getShooter() instanceof Player) {
e.getPotion().getEffects().forEach(potionEffect -> {
if (potionEffect.getType() == PotionEffectType.HARM || potionEffect.getType() == PotionEffectType.POISON) {
e.setIntensity((Player) e.getPotion().getShooter(), 0);
}
});
}
}
}
Have you tried any debug?
wait lemme try
I am serializing ItemStacks within a json file.
Do you recommend that I transform ItemStacks to JSON or use Base64?
I'd go with json
imo base64
That would just make it a pain to edit
Ye it didn't send anything
Well, it's a Market Auctions Plugin
No need to edit (?)
Show us your debug
((Player) e.getPotion().getShooter()).sendMessage("0");
Well, it's for a customer, not for me
@EventHandler
public void onPot(PotionSplashEvent e) {
if (e.getPotion().getShooter() == null) return;
if (e.getPotion().getShooter() instanceof Player) {
e.getPotion().getEffects().forEach(potionEffect -> {
if (potionEffect.getType() == PotionEffectType.HARM || potionEffect.getType() == PotionEffectType.POISON) {
e.setIntensity((Player) e.getPotion().getShooter(), 0);
((Player) e.getPotion().getShooter()).sendMessage("0");
}
});
}
}
Would it be more efficient?
I don't see why it matters? Did they explicitly state json storage?
Yeah databases would be better since that's exactly what they were made for
Add more debug so we can see where it’s failing
And you have registered this listener right?
And you can have multiple servers
aight
And sell items between them
If they said json they probably want you to store the item as json
ye
Of course, if SQLite were more optimized, it's my duty to ask what they think.
However, I think it can get messy to manage the deadlines of items for sale. After 24h they should expire. With JSON I'm getting comfortable parsing each item, getting TimeStamp and then checking if 24h have passed and introducing them into a Cache Caffeine since the items can be requested multiple times.
The performance of SQLite I assume is worse than working with a Cache<long, JSONObject> of Caffeine
@EventHandler
public void onPot(PotionSplashEvent e) {
if (e.getPotion().getShooter() == null) return;
((Player) e.getPotion().getShooter()).sendMessage("line 26");
if (e.getPotion().getShooter() instanceof Player) {
((Player) e.getPotion().getShooter()).sendMessage("line 28");
e.getPotion().getEffects().forEach(potionEffect -> {
((Player) e.getPotion().getShooter()).sendMessage("line 30");
if (potionEffect.getType() == PotionEffectType.HARM || potionEffect.getType() == PotionEffectType.POISON) {
((Player) e.getPotion().getShooter()).sendMessage("line 32");
e.setIntensity((Player) e.getPotion().getShooter(), 0);
}
});
}
}
}
it's failing at:
if (potionEffect.getType() == PotionEffectType.HARM || potionEffect.getType() == PotionEffectType.POISON) {
You'd just load what you want from the database
So print out what the type is
OH
Never mind I remember now
You have to compare potion effect types with equals
The problem with JSON is that you have to load the entire thing
It’s not an enum
if (potionEffect.getType().equals(PotionEffectType.HARM) || potionEffect.getType().equals(PotionEffectType.POISON)) {
like this?
It worked
How can I load (from SQLite) only the items that have a timestamp between the current time and the next 23 hours and 59 minutes? Is it more efficient to store the result in a cache, or is it unnecessary since the items will be displayed in an inventory GUI?
lemme test if it damages other players
How do you check if a player is dead? Other than events, I have a on death event set a timer, that will respawn the player when the timer runs out, I dotn want to respawn the player if they respawned
Thank you alex, it works like a charm
isDead
Send me the docs
declaration: package: org.bukkit.entity, interface: Entity
is it player#isDead
it’s literally Player#isDead
java.lang.ClassCastException: class org.bukkit.potion.PotionEffectTypeWrapper cannot be cast to class java.util.Map (org.bukkit.potion.PotionEffectTypeWrapper is in unnamed module of loader java.net.URLClassLoader @421faab1; java.util.Map is in module java.base of loader 'bootstrap')
What are you trying to do
One sec
Why are you casting that
I suspect they aren’t intentionally doing it, it’s some library they’re using
Or them using eclipse
Which likes to recommend random and non-functioning casts as quick fix
I have another issue, that issue does nto really matter since the end goal still happens
What?
java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Player.getUniqueId()" because the return value of "org.bukkit.Bukkit.getPlayer(java.util.UUID)" is null
{
Player killer = e.getEntity().getKiller();
Bukkit.getScheduler().runTaskLater(this.instance, () -> {
if (e.getEntity().isDead()) {
e.getEntity().spigot().respawn();
}
Bukkit.getServer().broadcastMessage(e.getEntity().getKiller().getName() + " won the fight against " + e.getEntity().getName() + " the loser will get their items instantly or in a min");
if (e.getEntity().getUniqueId().equals(Bukkit.getPlayer(firstPlayer).getUniqueId())) {
e.getEntity().getInventory().setContents(playerinv2);
killer.getInventory().setContents(playerinv);
} else if (e.getEntity().getUniqueId().equals(Bukkit.getPlayer(SecondPlayer).getUniqueId())){
e.getEntity().getInventory().setContents(playerinv);
killer.getInventory().setContents(playerinv2);
}
}, 1200);
}```
A: the broadcast is not working
B: I get that error
player is null
Oh the broadcast is workking,just to the console
Whats the broadcast method to the server?
show the whole error message
Hello, I am currently developing a simple plugin to change names. So, the problem is that when I call the PLAYER_INFO packet (via the method below), the name doesn't change in the sender player list (but it works after a re-login), but it changes in others. How do I fix this? Do I have to send a "trigger" packet myself? If so, what type of packet?
This is my PacketListener:
protocolManager.addPacketListener(new PacketAdapter(this, PacketType.Play.Server.PLAYER_INFO) {
@Override
public void onPacketSending(PacketEvent event) {
PacketContainer packet = event.getPacket();
if (MinecraftVersion.FEATURE_PREVIEW_UPDATE.atOrAbove() ?
!packet.getPlayerInfoActions().read(0).contains(EnumWrappers.PlayerInfoAction.ADD_PLAYER) :
packet.getPlayerInfoAction().read(0) != EnumWrappers.PlayerInfoAction.ADD_PLAYER) return;
getLogger().info("Packet received! The packet: " + packet);
int index = MinecraftVersion.FEATURE_PREVIEW_UPDATE.atOrAbove() ? 1 : 0;
List<PlayerInfoData> playerInfoDataList = packet.getPlayerInfoDataLists().read(index);
List<PlayerInfoData> newPlayerInfoDataList = new ArrayList<>();
for (PlayerInfoData playerInfoData : playerInfoDataList) {
Player player = event.getPlayer().getServer().getPlayer(playerInfoData.getProfile().getUUID());
if (playerInfoData.getProfile() == null || player == null) {
newPlayerInfoDataList.add(playerInfoData);
continue;
}
// get name
// update profile
// add new profile in newPlayerInfoDataList
}
packet.getPlayerInfoDataLists().write(index, newPlayerInfoDataList);
}
});
And this is the method by which I trigger PLAYER_INFO
for (Player onlinePlayer : Bukkit.getOnlinePlayers) {
onlinePlayer.hidePlayer(this, player);
onlinePlayer.showPlayer(this, player);
}
Ok
Remove the player info and add it again
Oh I send the wrong error message
at com.onutillities.SignEvents.lambda$onDeath$2(SignEvents.java:135) ~[onutillities-1.0.jar:?]
at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.4.jar:git-Paper-519]
at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[paper-1.19.4.jar:git-Paper-519]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1483) ~[paper-1.19.4.jar:git-Paper-519]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:447) ~[paper-1.19.4.jar:git-Paper-519]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1397) ~[paper-1.19.4.jar:git-Paper-519]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1174) ~[paper-1.19.4.jar:git-Paper-519]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:320) ~[paper-1.19.4.jar:git-Paper-519]
at java.lang.Thread.run(Thread.java:833) ~[?:?]```
{
Player killer = e.getEntity().getKiller();
Bukkit.getScheduler().runTaskLater(this.instance, () -> {
if (e.getEntity().isDead()) {
e.getEntity().spigot().respawn();
}
Bukkit.getServer().broadcastMessage(e.getEntity().getKiller().getName() + " won the fight against " + e.getEntity().getName() + " the loser will get their items instantly or in a min");
if (e.getEntity().getUniqueId().equals(Bukkit.getPlayer(firstPlayer).getUniqueId())) {
e.getEntity().getInventory().setContents(playerinv2);
killer.getInventory().setContents(playerinv);
} else if (e.getEntity().getUniqueId().equals(Bukkit.getPlayer(SecondPlayer).getUniqueId())){
e.getEntity().getInventory().setContents(playerinv);
killer.getInventory().setContents(playerinv2);
}
}, 1200);
}```
There you go. It says what's wrong
?paste
SignEvents line 135
if(entity.getKiller() == null) {
return;
}
Use paste ;/
Need help with my timber plugin. How can I get this to break logs from the ground to the leaves? I tried to set the do while to !value which froze my server and setting it to value breaks only 2 logs public void timber(Block block) { do { block = block.getRelative(0,1,0); block.breakNaturally(); } while ( logs.contains(block.getType()) ); /* for(int y = 0; y < 10; ++y) { if( logs.contains(block.getRelative(0, y, 0).getType()) ) { block.getRelative(0,y,0).breakNaturally(); } } */ }
I know, that is what I got from that. You see the for loop, I did had that at first but I remembered trees can be different sizes
Ok so my friend just killed me in server
but the killer thing aint logging
the event
something aint working
the evnt is running
but killer is coming as null
Probably because when you call .getKiller() (during the event), the server does not consider the event achieved so the player is not currently dead
It will be
So the killer is not set
It will be set after the event
So how can i get the killer in that event? If you look at the code, i made sure the player respawned. do I need to gett he killer after the player respawns
getKiller is always a player
Ima add the instanceof statement
Maybe in the task that is run on the next tick, the Killer will be set
yes
This? @remote swallow
Should I get the killer after the player respawns
or just a tick after
get killer is either gonna be a player or null in the event
Oh, I get it! So I can do this without the PacketListener? Just check if 'onlinePlayer' is the sender, if so, send removePacket, otherwise just use Player#hidePlayer. And the same with addPacket and Player#showPlayer, right?
Idk how long the killer remains in the player "data"
Otherwise, if you want to listen to "A player kill another player" you can use EntityDamageByEntityEvent
I meant the remove and add PlayerInfoActions
Is that specific to player inflicted player deaths?
emphasis of deaths
not damage
You can check if the damage will be > to the entity that receive the damage
I image the event counts mobs too?
Then, the entity will die and the event will have both not null Target and Killer
Yep, but you can check if the entity is a player
Also, im assuming that I can check if the health are == 0 or < 1
Yep, you can always get the health of an entity
An entity is considered dead is its health is < 0
Or <= 0*
I get it. But you see, if I just use PLAYER_INFO_REMOVE and then ADD_PLAYER, the name above the sender's head will not be updated. So I use Player#hidePlayer and Player#showPlayer to update the player. I was wondering if there might be some other way to do this (update the player).
I can also use entity.isDead?
in a damage event
Also how do I convert a entity object to player
can I cast ti?
first check if its actually player
and after that cast
or just instanceof pattern matching
you can cast it, or you can use other methods to obtain the player object without casting
since all entities have a UUID, you could do Bukkit.getPlayer(UUID)
e.getEntity().spigot().respawn();
}```
Respawn is not a method for the e
on the damage event
seems really redundant
it is generally more appropriate to use methods without casting, but its acceptable to cast as well as long as you do your checks properly
it removes the need for a check if its a player as the method would return a player if it really is
why would you iterate over list of online players again just to find player with specific uuid, when you infact already have that object
assuming instance is checked
why would you iterate if you have an entity object?
Bukkit.getPlayer(UUID) iterates over online players
pretty sure it has an internal map
^^
How do I get the size of each tree?
yap, my bad, Bukkit.getPlayer(name) iterates
still seems weird to do Bukkit.getPlayer(entity.getUUID) over (Player) entity
brr
probably because everyone does the casting because its acceptable and no one complains about it 😛
Yah just
if (!(entity instanceof Player player)) {
return;
}
player.doStuff()
but all I said was it was just more acceptable to do the non-casting route if its available because in general this should ensure that everything works at least that is what conventions say
but no one is opposed to the casting XD
anyway, is there way to see nms source code on spigot stash other then those weird patches
{
Player killer = Bukkit.getPlayer(e.getDamager().getUniqueId());
Player dier = Bukkit.getPlayer(e.getEntity().getUniqueId());
if(e.getEntity().isDead()) {
Bukkit.getScheduler().runTaskLater(this.instance, () -> {
if (dier.isDead()) {
dier.spigot().respawn();
}
Bukkit.getServer().broadcastMessage(killer.getName() + " won the fight against " + dier.getName() + " the loser will get their items instantly or in a min");
if (dier.getUniqueId().equals(Bukkit.getPlayer(firstPlayer).getUniqueId())) {
dier.getInventory().setContents(playerinv2);
killer.getInventory().setContents(playerinv);
} else if (dier.getUniqueId().equals(Bukkit.getPlayer(SecondPlayer).getUniqueId())){
dier.getInventory().setContents(playerinv);
killer.getInventory().setContents(playerinv2);
}
}, 1200);
}```
Ima try this
Btw
load it up sources in your IDE
builtools gives you the repos in their full source form without the patches view
cool, thanks
in regards to stash, only have patches view unfortunately for the server
Bukkit.getServer().broadcastMessage(killer.getName() + " won the fight against " + dier.getName() + " the loser will get their items instantly or in a min");
Only logs to the console
is there a method that logs to all pllayers in the server
well the server for the most part logs a lot of stuff
however in regards to plugins
it is up to the plugin to log to console any information they want to be shown in the logs
I mean im fine with it going to the console
I just want it to log to chat
broadcast messages show up in log because they are part of the chat
will i have to loop over all players
oh, it aint appearing in chat for me
it should
its a broadcast
if the broadcast isn't showing up, then make sure that your client doesn't have some setting turned off I guess
otherwise you have some kind of error in your broadcast in which case your server log should have some kind of error in there
why do you call #getServer on bukkit, try Bukkit.broadcastMessage()
I tried that. hmm. ima try again
?paste
Use instanceof instead of the Bukkit.getPlayer method. It's faster and safer https://paste.md-5.net/potiyominu.java
What's returned when I use GetDurability on an item that has no durability?
sometimes im wondering what im doing
Do you mean ItemStack#getDurability ?
yes
Deprecated since 1.13 :/
Is there any way to see the RAM usage of an individual plugin?
Look at the Damageable interface
declaration: package: org.bukkit.inventory.meta, interface: Damageable
Get the ItemMeta from the ItemStack and then check if it's damageable with (meta instanceof Damageable)
just make sure to import correct Damageable interface, its common mistake to import one from entity package
thank you
there are two Damageable with the exact same name?
yes
someone has to explain me how it finds a ; at index 2: @define c ed ; 2
without more to go on can't really tell you
it could be the way your code is designed
index doesn't necessarily refer to its place in a string
its c++ anyways but ye
hi ! Just achieved to add NMS to my project, the problem is... it is still obfuscated
?nms
seems like buildtools doesn't find the maven repository, is there a way to specify it using args ?
nms is not in any maven repo
not true
read the link I sent to properly access nms with mappiings
ok nms is not in any legal repo
"Maven does not exist, downloading. Please wait."
still alive somehow
bruh somehow if (size_t commentIdx = it->find(';', 1) != std::string::npos) {} makes commentIdx 1 or 2 sometimes
splitting it into two lines worrks
looks like if (size_t commentIdx = it->find(';', 1); commentIdx != std::string::npos) {} is the syntax
at com.onutillities.SignEvents.lambda$onEntityDamageByEntity$2(SignEvents.java:141) ~[onutillities-1.0.jar:?]
at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.19.4.jar:git-Paper-519]
at org.bukkit.craftbukkit.v1_19_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[paper-1.19.4.jar:git-Paper-519]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1483) ~[paper-1.19.4.jar:git-Paper-519]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:447) ~[paper-1.19.4.jar:git-Paper-519]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1397) ~[paper-1.19.4.jar:git-Paper-519]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1174) ~[paper-1.19.4.jar:git-Paper-519]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:320) ~[paper-1.19.4.jar:git-Paper-519]
at java.lang.Thread.run(Thread.java:833) ~[?:?]```
because the return value of "org.bukkit.Bukkit.getPlayer(java.util.UUID)" is null
One sec
what would that mean huh
that player is not online
me being sarcastic
Well duh, but given the code, and the fact I had my friend hit me in game
It should work
use getOfflinePlayer if they are not online
wha Bukkit.getPlayer(e.getDamager().getUniqueId());
My friend hit me ingame
The person who hit me
their uuid
then fetched them from the server
because the entity object you get from the event lacks a bunch of class;s
cast entity to Player after checking
your event is running when ANY entity is damaged. your error is beciase it fired for a non player
THe player entity gained from the casting lacks some stuff
wha
you need a player, then cast it
if (e.getDamager() instanceof Player player) { player.stuff() }
Either way the damager/killer is registered as null
Ok ima try again tommorow
thats the spirit 💀
I need to test one more thing
its late
...
1:15 am
Wow, timezones are weird
5 minutes sleep feels good enough
i somehow needed less sleep today cuz i normally have to go to college
ig im used to it
then sleeping in the weekend till 10 am 💀
Why don't you have to go to college today?
idk its some kind of free day
they should've done it tmrw, 3 hours networking practice smh
im probably insulting elgarl now
no clue how
arent you the networking guy
I was for a few years. Not much I've not done 🙂
didn't work, it is still obfuscated
then you did it wrong
that tutorial is quite simple
don;t manually import spigot
use maven to handle dependencies
run buildtools
with --remapped
then it's pretty much copy/pase into your pom
the problem is buildtools doesn't put the dependencies in the maven repository like it should do (and like said in your link)
you need to read and follow the links
damn plugins
which dependencies are you referring to?
spigot
yeah lets not specify if you mean api or server
server
its in the buildtools directory where it says spigot
you can manually install it if you want
not that hard to do
tried to do it and ended with the obfuscated code
then you are obviously doing something wrong
but I think I did it wrong will search on google
and didn't read something
List out your steps.
the post gives you everything you need
not sure what google is going to do
Walk us through what you did exactly
unless you simply are unable to read
but, you don't need the server jar to necessarily be in the repo
as long as maven can find it and it is appropriately defined, then do everything the post says
to include following links
To be fair, build tools is wonky sometimes.
maybe I am dumb (i suck at maven), but why do I get multiple root tags error when I follow the link's instructions ?
in pom.xml
Show us what you did
?paste your Pom as well
did it
because you are copy and pasting assuming its the entire config
when it really is just a section you should add
not sure where in the post it says this is the pom and nothing else or you should copy this over your entire pom
oh fuck im really dumb
Hello
so I just need to replace the build and the dependencies
What is the event for obsidian forming
(i need the location of the water and lava that formed it)
you shouldn't need to replace anything, rather just add and ensure you don't have duplicate tags for build and the sorts
I think it’s the BlockFormEvent either that or it’s the BlockFromToEvent
Timber plugin lag, wow. Huge chunk of trees clearedTPS from last 1m, 5m, 15m: 19.73, 19.91, 19.97Need help locking it to one tree, instead of over 15 trees
Think that’s a #help-server question.
Unless you have code
I made the plugin so yes, I have the code
Mb, share away.
block.breakNaturally();
// Leaves
if( leaves.contains(block.getRelative(-1,0,0).getType()) ) { this.timber(block.getRelative(-1,0,0)); }
if( leaves.contains(block.getRelative(1,0,0).getType()) ) { this.timber(block.getRelative(1,0,0)); }
if( leaves.contains(block.getRelative(0,-1,0).getType()) ) { this.timber(block.getRelative(0,-1,0)); }
if( leaves.contains(block.getRelative(0,1,0).getType()) ) { this.timber(block.getRelative(0,1,0)); }
if( leaves.contains(block.getRelative(0,0,-1).getType()) ) { this.timber(block.getRelative(0,0,-1)); }
if( leaves.contains(block.getRelative(0,0,1).getType()) ) { this.timber(block.getRelative(0,0,1)); }
// Logs
if( logs.contains(block.getRelative(0,-1,0).getType()) ) { this.timber(block.getRelative(0,-1,0)); }
if( logs.contains(block.getRelative(0,1,0).getType()) ) { this.timber(block.getRelative(0,1,0)); }
if( logs.contains(block.getRelative(1,0,0).getType()) ) { this.timber(block.getRelative(1,0,0)); }
if( logs.contains(block.getRelative(-1,0,0).getType()) ) { this.timber(block.getRelative(-1,0,0)); }
if( logs.contains(block.getRelative(0,0,1).getType()) ) { this.timber(block.getRelative(0,0,1)); }
if( logs.contains(block.getRelative(0,0,-1).getType()) ) { this.timber(block.getRelative(0,0,-1)); }
}```
Where are you calling that method?
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer(); Block block = event.getBlock(); Inventory inv = player.getInventory();
ItemStack item = player.getInventory().getItemInMainHand(); ItemMeta meta = item.getItemMeta();
ItemStack powerItem = new ItemStack(Material.COAL);
if( !(axe.isItemValid(item) && logs.contains(block.getType())) ) { return; }
DataContainer container = new DataContainer(meta); Power power = new Power(meta);
if( power.has(100) ) {
axe.timber(block); power.remove(100);
int powerPercentage = container.integerGet("Power.Current") * 100 / container.integerGet("Power.Max");
if( container.booleanGet("Feature.AutoFuel") && powerPercentage < 5 && inv.containsAtLeast(powerItem, 2) ) {
power.add(200); inv.removeItem(powerItem);
}
axe.updateItem(item,meta); item.setItemMeta(meta);
} else {
event.setCancelled(true);
}
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(
ChatColor.AQUA+"[Timber Axe] "+ChatColor.GRAY+"Power: "+
ChatColor.WHITE+(container.integerGet("Power.Current") * 100 / container.integerGet("Power.Max"))+"%"
));
}```
Command Output on kill dropsKilled 650 entities
I’m assuming that you broke one block and any trees that were connected got broke along with the first one?
Yes, that is my issue. I need it to break only one tree
Then you’ll probably have to change your checks. I think that #breakNaturally() calls the BlockBreakEvent so you have yourself an interesting loop.
You could try just setting the block to air and then spawning the items it would normally drop.
can you be more specific
i cant get the water and lava made in BlockFormEvent
Try the other event then.
BlockFromTpEvent
To*
Or smth like that
How should i use it
?jd-s
Take a look st it
if to is lava?
Try to make the logic urself
already cancelled
It’s be more like if from is lava, but ya know
I stole this source code from another plugin. It was breakChain(World world, int x, int y, int z), so its what the author did
Well, can’t really blame you too much. There is no real easy way to determine a tree. However that method looks like it would only ever work on small oak and small birch trees.
Provided it’s used correctly
Or trees that don't connect to each other. Like in the Plains biome. Dark Forest biome generated 640+ entities. Trying to copy EpicTimber is a task
You could redo your approach entirely and just recursively trace the tree up to a certain point.
I don't know how I can do it, that is what I need help with
You got the timber function
I’m not at my computer so I can’t really give and quick examples.
hi all. really basic problem regarding java, not bukkit, i have a command declared in another class but i need to pass through a variable. how do I do this?
the best way is to first remove leaves
then, go back and detect all the logs that are in the air
and then get the ones that are connected to the ground
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
that is not what i need
It gets the trees from all connected leaves. I just killed over 2k of drops
The way you described it, it is
not sure what that has to do with what I said
once you are certain you identified a tree, in an area around it, remove all the leaves in the air, then the logs not connected to anything
and then the base
kind of, but not exactly, i was asking more about import rather than this.
i can if they are public
You can't lol
I tried searching on how to detect a tree but there is no results I can find. The leaves removal is what connects all the logs
it sucks, but i can
xd
I sense static abuse
Well, I didn't consider that
public abuse
?learnjava I would say
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.
Tf are you on about?
idfk intellij did something for me
Show code
if it has 2-3 logs sticking up from the ground, search another 5 blocks and around
if there is leaves it is most likely a tree
then, you just remove the leaves, I am aware the leaves connect the logs but you are removing anyways
You could probably get real convoluted by checking block type and creating methods for each wood type.
this helps in identifying the floating logs so you don't accidentally continue and kill all your trees that are next to each other
ide broke for a second, it was just visually showing it as working
Let me see
alternatively
if you have leaf decay enabled
just remove all logs floating in the air
server will automatically remove extra leaves for you
I think that’s what MCMMO did in its early days.
Is this how I can travel up the tree? public void timber(Block block) { do { block = block.getRelative(0,1,0); block.breakNaturally(); } while ( logs.contains(block.getRelative(0,1,0).getType()) ); }
well you are going to need to specify some constraints that you believe are acceptable when satisfied is a tree
so you could say, if there is 3 blocks of wood in a single line, and then some leaves
around it
at the top
if those conditions are met you can start removing the logs around it and the trunk
once logs are gone, if leaf decay is enabled on the server the leaves will disappear over time on their own
if leaf decay is disabled, you will have to remove the leaves in a pre-determined area
is that not like a state of the leaves or logs or whatever?
whether they are natural
but you need the constraints so it doesn't just like start killing all your trees XD
I want to remove the leaves as well, I love EpicTimber but it does multiple items that you normally don't get. That is why I started the plugin. Also, I had a function set up before but it removed leaves from other trees as well
what is the player damage event?
There is
excuse my bad phrasing
EntityDamageEvent > Check if the entity is an instance of a player and continue from there.
If you want to get the damager, use the EntityDamageByEntityEvent
took me 2 days for a simple preprocessor 💀
yep did this, this is good right? or might it have issues