#help-development
1 messages · Page 974 of 1
Can’t I do it like this?
Edited
no
you return null if there is no user
that method should always return a String even if LP bombs out
It's a String method hence it needs to always return a String value
and you never translate the prefix
This comes in the PlayerJoinEvent
no
Look at the code here
you do this in the getFormattedName method, you have no use for teh player join event
all your code in the player join event is useless
all you need is your getFormattedName method and use it in your chat event
So do I need to delete the playerjoinevent?
Hey elgarl if you've got any interest :p
yeah
so it looks more random
I'm not sure how to do this
This is (somehow) my first time messing with particle effects
you can see them bounce up first before falling
It's kinda goofy right now considering I was just doing particles at the feet before
the rain doesn;t look bad, but it's velocity is also off, same as the snow
Yeah if it was randomized it'd look better
zero on x and z and try a negative y when spawning
you only want a slight random in the downward velocity on teh particle
no x and z movement
no
setDisplayName accepts a null display name to reset
Egitto is correct here
player.spawnParticle(SeasonsList.Seasons.WINTER.getParticleEffect(), player.getLocation().getX(), y, player.getLocation().getZ(), 512, 0, -1, 0);
Like this?
No, he should not be setting Display name at all
Or the other way around?
he's creating a chat formatting plugin. he shoudl not be going anywhere near display name
give it a try
lets find out haha
https://gyazo.com/604a6ce0263813126b22cfd31121be52
Well that's not what we wanted lol
I'm pretty sure the values I changed were not velocity rather density
they are the random position across x/z
right
I thought you were doign individual particles not 512 with random location
you will not get it to look any better using a single emitter
hmm
So then should I redesign the runnable as well as the particle spawning method to handle individual particle spawns to try and get it looking better?
It's just world#hasStorm/setStorm
rain/snow dependant on player location; temperature
yep
Also custom effects are cooler
I guess you don;t want that
Individual particle spawns sound difficult in the way I'm trying to...
Should I define a region of sorts around the player for the particles to randomly spawn in?
I'd define a radius
gotcha
And the runnable, how frequently should this be ran to handle the random spawning
perhaps just have to test and figure something out?
however fast it needs to look good 🙂
more emitters per tick to make the rain heavier
you could do it async if you swith to packets
actually, try it async as particles literally just send a packet
That was what I thought so
Is there more manipulation to be done to the particles given I switch to packets?
no
would require custom texturepacks
gross
mhm
you can color some if they already exist in different colors
but u cant create colours that do not exist in the base game
nope
Hmm well that's disappointing
Alright so final notes are basically:
Define a radius around the player,
Handle individual particle spawns,
And update runnables to make the particles look good
Oh hey do you guys have any suggestions for custom effects applied to players when a specific season is active?
When instantiating a new WorldCreator is it possible to set a size of the world? I know you can set a world border but that still generates the chunks outside of the border and I'm using the World#vanillaBiomeProvider() to get the BiomeProvider but then because that can detect biomes in ungenerated chunks, it means that it can detect biomes outside of the world border, which I don't want. The goal I'm trying to achieve is find the nearest biomes.
I was previously using World#locateNearestBiome() and iterating through a list of biomes, but that's not particularly optimised.
Hello, how can I get the total available modificable surface using LimitedRegion#getBuffer?
because for 48*48 it returns 16, so do I need to multiply by 3 or something like that?
(getBuffer * 2) + 15
okayyy thanks 😄
hmm
15 as zero indexed
oh, you dont actually mean area
in x and in z basically
as in the unit, you mean area as in the region
yeah
a random coordinate between the min available and the max available in x and z
is it good or did I miss something?
https://paste.md-5.net/votorefohe.java
should I use a minus before the rest for the low in randomBtw?
no
why are you multiplying by 3?
the buffer is a value added to either side of the chunk
I do not understand your line 8
if you are spawning somethign or setting a Block in a populator you shoudl not use teh buffer at all, unless you are creating a multi block structure
oh yeah I forgot to edit this line
so between 0 and buffer?
You forgot here at the end of the if statement a {} or ;
Which one do I need to use?
I didn;t forget anything, its a split line conditional
@eternal oxide like this?
https://paste.md-5.net/pulasoxuce.java
yes
why do you put ; instead of '
age
oh no wait
littel finger is too bent to reach ' reliably
now?
I forgot to put *16 so it was returning the chunk coordinate
not the coordinate of the first pos of the chunk
okay then why do you put little instead of littel 😜
typing too quick
age, brain is too old to keep my fingers in sequence 😛
okay :>
how old are you
lets just say, I remember the 60's
you travelled in time??
I cannot tell if you are being sarcastic 😳
true
Nope. I remember punch cards to program.
Elgar it's not the 1980s anymore
can you tell a pretty famous band from this period? (about rock)
Please, no spigot developer is over 40 years old
Well frostalf and alex are two exceptions, they are like 80 at this point
🤣
Elgar is 😉
alex is a baby though.
Elgar is over 40????
I find that insanely hard to believe for some reason
Bruh
he's my dad..
you can almost add another 20 years on that
there is no shot
If I find one message of yours containing gen-z slang, all your claims are void
I can vouch for him
he's older than 29th June 2012
lol, I had paid my mortgage by then 🙂
slight smile is such a
md joined discord in 2016, subtract 13 years so that he's of legal age to have joined discord at that period of time, means he was born at least in 2003
specific emoji
Any solutions for this?
he's at least 30
Prove it
how do you know I didn't cheat discord
I know I did
he said it some time iirc
because you're a cube.
what's wrong here
you are not actually using the method. you need yoru async chat
AsyncPlayerChatEvent?
yes
istg if the next paste i see has that method inside async chat event im gonna scream
Why lol
because its a basic issue that you should know how to resolve before starting spigot
after some research and years of learning in speaking in english and walking, I came to this conclusion and I think there is something wrong, any idea?
https://paste.md-5.net/ukirotugow.java
add your chat event to https://paste.md-5.net/uwamoragag.java
Sure
ok because you ned to subtract getBuffer
But what should I write in my chat event?
Substract it with what?
use setFormat
(getLimitedRegion().getBuffer() * 2) + 15 - getLimitedRegion().getBuffer()
that will give you relative coord
I've gone through the https://en.wikipedia.org/wiki/List_of_Generation_Z_slang and confirmed that ElgarL does not in fact use gen z slang except for a "bruh" from time to time
haha you been searching
did you find where he said he might even be a grandad
Additionally he says this a couple of times
🌞
I guess I believe him now lol
I'll go do my homework I have 36 minutes before the lesson starts
Great grandad
when did that happen
why are you here then
shoudl I be in a home?
he wants to stay hip with the kids
Okay thanks
Was this referred to me?
elgar when you perish can I have your retirement fund
yes
.<
wow
Of first pos I think
🙂 indeed
elgarl whats your favourite supermarket
Being old I hate them all.
Lol
you seem like a holland and barret kinda person
You prefer the first farmer in your area?
And no gastronomy?
:)
he would never help me anymore after what I've said
No that's a joke, I ate a British meal this week and it was really good
So I wrote
this is slightly wrong. the range is -getBuffer to (15 + getBuffer) So a total of (getBuffer * 2) + 15
A shepherd's pie
Okay I see thanks 😄
I'll try that after eating
public void ChatEvent(AsyncPlayerChatEvent event) { String format = event.setFormat(); }
What should come inside the brackets of setFormat?
you shoudl getFormat() then replace what you need
you forgot the annotation also follow java conventions :p
Don't usually use that
then setFormat
Just set the message
setting format is better
They told me to use it
setting the message can cause issues from other plugins modifying
however as you are just cancelign the event and sending yrou own chat you don;t need getFormat/setFormat
Rly, isn't it easier to just set it yourself?
I don’t even know what to write inside the AsyncPlayerChatEvent
The username is still white
Even tho I’m in a LuckPerms group where I have a prefix of &c
something likejava String format = event.getFormat(); format = format.replace("%1", getFormattedName(event.getPlayer())); event.setFormat(format);
https://paste.md-5.net/uwamoragag.java Elgarl gave me this code, and I should add to it an AsyncPlayerChatEvent
he returns in his if nest
prefix + player.getDisplayName is what you have to return
avoid that
some weird plugins (essentials) likes to modify display name and might add the prefix to that and it then breaks
What does the %1 represent?
Didn't think of that
thats where MC would normally place the player name
Why do you think Essentials is weird?
essentials just is
Oh ok
aka ?tas
You could also cancel the event and then just send Bukkit.getPlayers().for each(player -> player.sendMessage(getPlayerName() + ": " + event.getMessage()));
And that didn't work?
it did but the rest of his code was broken so he still had no prefix 🙂
Ah
I'm surprised I managed to remember that
Lambda is epic tho
may as well broadcast if sending to all
True
?tas
are you sure you replaced the jar on your server?
It's not at all, you just know absolutely nothing about java
it may just be %s not %1s
So instead of %1 I should write %s?
So this might be the problem why it doesn’t work
Is it possible that the problem is cause by the other classes?
no
i told you a million times
learn java
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
Im learning
Ok so
AAAAAH
no still nothing
Doesn’t work
okay thanks, so I came to that conclusion, it's now time to try and SEEE
I knew is was something close
So it wasn’t %s but %1$s?
yes
How would u do that? And where should I write it?
._.
no need now, just use that string
...
show code
All the plugin or only chat listener?
just chat
@eternal oxide, I get a "Bound must be positive" exception, logical when using nextInt, so, should I use another method to generate a random or is there a trick?
https://paste.md-5.net/noxaribozu.java
that looks fine
What does it look like in game
you shoudl be using the max value when getting a random, then minus the buffer to adjust it
Like this
okay thanks
do you register your listener?
Yes in my main class
then I can only guess you didn;t update teh jar on your server
the code is fine
you are doing something wrong when updating your server
stop the server before changing the jar
74, 75... 🎶
drop the file in here
Spigot builds on SnakeYaml
^
makes no difference
Elgarl asked for it
I told him to
how is it 950 KB?
came to that, let's try
Is it a lot?
yes
yes
Idk I also tested it as it was
Shading Kyori is fine
you have two HoverListeners
Exclude the annotations tho
Where
Jar size doesn't matter unless you're dead set on uploading to spigot then you need to be under 5mbs
Why did they set a limit
ooh so they're stingy
oh nm, I'm reading it wrong
You're getting a free service though you have 0 room to complain
HAHAHA yeah
Does it work with u?
but thats your issue, you are cancelling the chat event in your HoverListener
So what’s the solution?
don;t cancel
Just modify the message
you are preventing the listener from running that sets your prefix
So I should setCancelled False?
Just delete event.setCancelled(true);?
yes, and instead setMessage
Exactly!
event.setMessage((BaseComponent) comp);
Which?
just use event.setMessage
Delete all
instead event.setMessage((BaseComponent) comp);
ah text only
no
And what’s the solution to this error?
Uhm I am trying to save player stats to a YML file, such as their kills, their bounty and their name. This is my main class (pay attetion to the last EventHandler):
https://paste.md-5.net/izawuvakuf.cs
And this is the PlayerDataHandler which is responsible for saving these stats to a file:
https://paste.md-5.net/ceguhotisi.cpp
However, when I kill someone, the plugin doesn't create any file on its folder as it should. Am I missing something?
he just said
good question. I've not used hover events
Text only? Wdym
you can;t use setMessage as it only accepts a String
the only way to send with components is to use sendMessage
So event.sendMessage((BaseComponent)comp);?
no
you are being a pain as you are doing hover and format in the same event in different listeners
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
How do I divide them then?
you actually need to combine them
Combine the listeners?
I'll check it out, thank you!
yes
Ok ill copy paste and let’s see what I get
when using Components you can;t apply them back to the AsyncChatEvent
so you do have to cancel and send the formatted message yourself
isn't AsyncChatEvent paper
And I'm pretty sure you can
the method's just poorly named
not in Spigot
AsyncChatEvent is paper
He's using AsyncPlayerChatEvent
AsyncPlayerChatEvent is spigot
Omg it’s so difficult to put them together
nah it's quite simple
yeah its likely beyond your level of java
Nah it’s not that, it’s just I’m scared I break something
breakign is good, best way to learn
bro it took you this long to realize?
This entire project is beyond it
He should apply that in learning java instead imo
So like this?
What packets does bungeecord send to inform the player about a server change?
one sec
plugin might have not been initialised
take a look at that
a single chat event
using your code
but the formatted name I showed you
Should this be in the HoverListener or in an part listener class?
Should I delete it?
No ok
I understood
But
What should i do with the event.setMessage?
I haven't checked any of that hover code so I'm assuming its working
nothing
I literally gave you the whole method
Yes
You are infact not. You have yet to discover the difference between a string and an integer. If you wouldve done yet so much to watch a simple video for first time coders that would already have doubled the knowledge you contain about java
Should I delete the ChatListener?
What the other
I have ChatListener, here is where I coded the get formatted, HoverListener, and now ChatEvent
HoverListener? But then I’ll not have hovermessages
If I hover on top of an username
I give up https://paste.md-5.net/oxukokivad.java That is ALL you need
Should I then keep the HoverListener?
no
Does it get prefixes from LuckPerms?
?tas
this needs to be Plugin not JavaPlugin
I sent the correct code so its just your imports
ah that needs to be HoverInfo not JavaPlugin
has to be HoverInfo as he has a method in there for getLP
registerEvents take 2 params btw
ah yeah i see
also true
registerEvents(new ChatListener(this), this);
yes
yea
Let’s try it
I would say, it works
Thanks, but I got a problem
If I’m an user, I don’t have any prefixes so it’s null
And it can’t be translated
then add a check for null before teh translate
just do if (prefix == null) prefix = "";
before the translate
can getPrefix() in LP return null?
Is that a question?
I don;t use LP so no idea if that method can return null
@rapid vigil is a master in LP

Should I just write this one?
.
great question
Uh no
Listen to incoming bungeecord messages
That's a completely different question
I wanted to see source code where the events are instantiated but my intellij refuses to search library files
?stash
It just claims "No usages in All Places"
no bungee
It's a little complex
In short the client's always in a "play" state
But the handshake process is copied, send to the original server up until the login phase, bossbars are removed etc
What about encryption
Given we're using the original handshake I'm pretty sure packets should be encrypted the same way
Since this just means Handshake and LoginInStart were copied
I mean encryption begin
Packet
Isn't that part of the handshake
nvm I'm a clown and don't know how the encryption part works
afaik there is no encryption between the server and the proxy
yes
Backend <-> Proxy is not
Hello, I get a "Bound must be positive" exception when chunkCoordinateType is <= 0, how can I fix that please?
https://paste.md-5.net/ezapopudog.java
if you are using chunk relative its 0-15
I'm using buffer relative, but well I don't understand how to make it works
if its a Limited region with buffer then its world relative
No
I want the first pos usable, and the last one
relative to the world
using getBuffer
usable wher?
in the limited region?
yeah
show how you are accessing the region
using populate in BlockPopulator
then you should not be going anywhere near teh buffer
you should stay within the chunk
so, buffer and chunk are the same?
no
(here is my entire code logic if you want https://paste.md-5.net/oqipaponic.java)
then chunkj is the "chunk" you are populating. The buffer is a measurement of distance around the chunk which "shoudl" be loaded and available if you need to create a structure outside the chunk boundaries
okay so it's what I understood
@echo basalt https://wiki.vg/Protocol_Encryption this is the verification scheme
Yeah you are just populating blocks, so 0 to 15
Are only the two packets from here copied and sent?
like this?java return randomBtw(chunkCoordinateType*limitedRegion.getBuffer(), (chunkCoordinateType*limitedRegion.getBuffer())+15);
no
Handshake and LoginInStart
just 0 to 15
yes, you add that to the chunk *16
and I'll get the entire distance around the chunk which should be loaded and available?
it gets you world relative coords
no
😭
ChunkX * 16 + random (16)
if your type is a X/Z chunk value
logically?
yeah it is
then yes
no]
I don't understand how I can use the buffer in this method if it is not mentionned
ignore there is a buffer
okay
the only part you populate is the chunk itself
as you are placing rocks you do not need the buffer
it's for future structure that might be biggers
when you get to structures come back and ask 🙂
I can also remove my RandomType enum?
yes
okay perfect thank you
Is there a method to stop a player from having their hand/shield raised? Right now I'm removing the shield and giving it back but that seems over the top https://pastes.dev/OuPKHDPfze
Player Interact, check if #isBlocking()
PlayerInteractEvent only triggers once on rightclick, not while holding down
set a very high cooldown on the shield :^)
Yea, you only need to check once
disarm the shield when its clicked
I want to disarm when I hit the player with a custom attack, I can give the shield a cooldown and play the sound but the shield stays up with a cooldown if you don't release your mouse
uhh sure player.setCooldown(Material.SHIELD, Integer.MAX_VALUE);
i mean the game does set a cooldown when you do a hit with the axe while they're blocking
to prevent it from being used
that's kinda the intended way
yeah, I want to do the same but for my own attack
yeah that works, but the shield stays up in "blocking mode" so if you don't release your mouse it doesn't matter
in vanilla when you get hit with an axe the shield gets a cooldown AND goes down
I want to recreate that
and I was wondering if there is a method to 'unraise' the players hand
possibly set swimming twice
forcing them to any animation wher the shield drops even if only for 1 tick
player.setSwimming(!player.isSwimming())
twice
I'll give this a try thanks
or
have you tried setItemInUseTicks
no idea if it would work on a shield but try setting to 0 or 1
setItemInUseTicks(int)' is deprecated since version 1.20.4 and marked for removal
not in spigot
it is in my IDE
minecraft calls stopUsingItem(), i don't think spigot has api for that
but a certain downstream fork does
You are not using spigot
I'm using bukkit spigot and paper together
it may be deprecated in paper. Its not in Spigot
everythign is deprecated in paper
oh you're right, weird I can't choose between using the paper and spigot method
for most methods and classes I can choose between spigot paper and bukkit but the paper overwrites the spigot one so as long as I have paper API i probably can't
that won't work, shields don't really have a "remaining use time", as opposed to e.g. potions, there is some extra logic the server runs to force the shield down (in n.m.w.e.LivingEntity#stopUsingItem())
wdym "overwrites"?
the spigot api is still there
its both org.bukkit.entity.LivingEntity
marked for removal methods give errors for me
deprecated gives warning
yeah but I can't compile with an error
a warning is not an error
red is an error, yellow is a warning. Deprecated gives a warning, marked for removal gives an error
it's red in your ide because it's deprecated for removal
javac will compile it fine
it will warn you, but it will compile
the fact it's red is your ide configuration
You are depending on paper in your pom
oh you're right, I thought compile would always fail if I had an error
you could even add teh spigot dependency above the paper dependency
then you'd have both API and still be able to support paper, without crazy warnings
IntelliJ is very confusing then
IDE error != compile time error (sometimes)
Most often it is but you can configure anything to be an IDE error
And you can disable the checks altogether
Javac will not care about your ide warning preferences
welp java.lang.NoSuchMethodError: 'void org.bukkit.entity.Player.setItemInUseTicks(int)
it doesn't work anyway so it's fine I'll try something else
Must be a version mismatch
that method is fairly recent, yes
well I am on 1.20.4 and it says deprecated since 1.20.4 so
If paper devs got a dollar for every time they've deprecated a method they'd be swimming in money
, run buildtools and get the latest 1.20.4 build
that method works on spigot if you're running the version it was added in
in the versions it didn't exist it won't work because it didn't exist
idk how to run buildtools but it doesn't matter cause what I need is a stopUsingItem() method but it probably doesn't exist
?bt
use the gui
won't hurt to learn
damn
not much learning required, too
you just need to run one command and you have the server jar ready to run
turns out I already have it on my pc cause I addes NMS once
run it again
lool
you are not running the latest build, that method does exist on the latest build
create own
latest or experimental
guess I'm experimental rn
same...
experimental is features that are not ready for prod or are for end user testing
ok then im not experimental
oo so it IS gonna be a thing after all
i thought it would be like waaaay down the line
😳
Ooo
Hello, how can i make a part of a message clickable link? For example: Welcome to the server! Visit our [discord-link] and our [website-link].
Hello I trying to update an item inside a player inventory but I don't find a solution can you help me ?
Current code:
if(player.getInventory().getItemInMainHand().equals(countablePickaxe())){
ItemStack itemStack = countablePickaxe();
ItemMeta itemMeta = itemStack.getItemMeta();
for(int i = 0; i < itemMeta.lore().size(); i++){
List<Component> lore = itemStack.lore();
if(lore.get(i).toString().contains("§fNombre de blocs cassé:")){
int utilisation = Integer.valueOf(String.valueOf((TextComponent) lore.get(0)).replaceAll("[^\\d]", ""));
lore.set(0, Component.text(((TextComponent) lore.get(0)).content().replaceAll("-?\\d+", utilisation + 1 + "")));
itemMeta.lore(lore);
itemStack.setItemMeta(itemMeta);
player.updateInventory();
}
}
}
also that's the Paper API
You'll probably get better help in the Paper discord
Yep I know but I think that can be laggy cause that happen when I break a block with a pickaxe
what is that ?
?pdc
i mean it's not like you have a choice, and it's not like getting the meta and getting the lore isn't expensive already lol
but, as pointed out, use pdc for storing custom data, not lore
Hello! Why enchantment isn't adding to the item
private ItemStack createEffectItem(Material material, String displayName, List<String> lore, String effect, Player player) {
ItemStack itemStack = new ItemStack(material);
ItemMeta meta = itemStack.getItemMeta();
if (meta != null) {
meta.setDisplayName(color(displayName));
if (effect != null && effect.equals(getSelectedEffect(player))) {
meta.setLore(lore.stream().map(Utils::color).collect(Collectors.toList()));
itemStack.addUnsafeEnchantment(Enchantment.KNOCKBACK, 1);
// meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
}
itemStack.setItemMeta(meta);
}
return itemStack;
}
okk thx 🙂
oh, thanks
Also, fun fact, fairly certain List has a replaceAll() method which you could use instead of a Stream
Obviously it mutates the List you pass in, but yeah
meta.setLore(lore.replaceAll(Utils::color))
im not sure thats a very fun fact
this doesn't compile, replaceAll doesn't return the list 🤓
IT DOESN'T!?
that's stupid
java is stupid
i hate java
i'm becoming a haskell developer
based
chocskell when
@austere cove initiate him
you need to teach me some day how to properly use hasell
I have a severe skill issue
imagine
color <$> lore
instead of #replaceAll(...)
I take it back. I'm becoming a PHP dev
lore.colourme
is the <$> an apply method
functor application
ah, is it multiple symbols or is it literally just <$>
its the infix equivalent of fmap
flatmap is more like a monadic bind
functor
fmap :: (a -> b) -> f a -> f b
where a, b are types and f is a functor type
So for a list w elements of type a and a function a -> b, fmap returns a list w elements of type b
There are also other functors in the stdlib, like Maybe, Either etc
I found an alternative solution if anyone else ever has a similar problem to me:
val regionAccessor = world as RegionAccessor
val foundBiomes: MutableSet<Biome> = mutableSetOf()
val maxBiomes = 10
var x = world.spawnLocation.blockX / 16
var z = world.spawnLocation.blockZ / 16
var dx = 0
var dz = -1
spiralLoop@ for (i in 0..(50 * 50)) {
if (-50 / 2 < x && x <= 50 / 2 && -50 / 2 < z && z <= 50 / 2) {
val chunkToBlockX = x * 16
val chunkToBlockZ = z * 16
val chunkBiome = regionAccessor.getBiome(chunkToBlockX, world.spawnLocation.blockY, chunkToBlockZ)
if (foundBiomes.none { it.key == chunkBiome.key }) {
foundBiomes.add(chunkBiome)
}
if (foundBiomes.size >= maxBiomes) {
break@spiralLoop
}
}
if (x == z || (x < 0 && x == -z) || (x > 0 && x == 1 - z)) {
val temp = dx
dx = -dz
dz = temp
}
x += dx
z += dz
}
Hope this helps another dev sometime eventually!
ooooo kotlin
It might not be the best approach but it works in a subsecond timeframe so I'll take it!
monadic bind is similar but not quite.
Say you have an optional type in Java, and you want to apply a function that also returns an optional. fmap would essentially get u an Optional<Optional<Type>>
A monadic bind does what you're looking for:
(>>=) :: m a -> (a -> m b) -> m b
also functors and applicative types can be defined by monad application:
fmap f x = x >>= return . f
pure = return
mfab <*> ma = mfab >>= (\ fab -> ma >>= (return . fab))
🙏
PotionMeta meta = (PotionMeta) customDrink.getItemMeta();
meta.setColor(Color.LIME);
meta.clearCustomEffects();
customDrink.setItemMeta(meta);```
Hi, I am trying to create addon for slimefun that displays recipes for Brewery addon in Slimefun menu. Can someone please help me to remove "No Effects" lore from potions? I just couldn't find it in meta.
Yo
try give it the hide potion effects item flag
where javadoc smh
?jd
Phone cbf
I have the commandsender filtered to players so
use send message still
So name#Sendmessage("message")?
no
Name = player
ye
its a javadoc notation, we use it to show you need an instance
as it can be confused with static if a dot is used
i mean if you used javadoc notation you should use it for all methods indiscriminately :p
and fields
ruh roh
ruh roh raggy
I am trying to make a plugin that stores player stats on a YML file. The stats I want to save for now are the kill count, their bounty and their name. I want to make a separate file for each user. I have tried with the wiki entry that explains how to use custom config files, but none were generated. This is my code now, and it won't generate either when I kill my friend (for now, I only want to store kills per user):
Main: https://hastebin.skyra.pw/uxubuxisur.java
When I kill someone, no file is generated on the plugin folder, which is hosted on our server. What am I missing? I already tried three different ways before this one and none were working.
File#createNewFile iirc
how do i remove 10 raw cod named "idk" and 15 chicken named "idk" from the player's inventory, if the player doesn't have 10 raw cod then it removes nothing same with chicken (test items)
You don't seem to register your listener
(int) playerData.get("kills.amount"); could be playerData.getInt("kills.amount");
Everything else wrong with the code, smile seems to be currently writing about
I'll let him do the job
i believe i need to copy the player's inventory into an array and loop through that
thanks. Didn't even know these flags exist 😄 Thanks again
Some notes on style convention for java:
- Variables in lower camel case:
Num_veces->numVeces - Generally english is the preferred language for methods and variables.
- Dont use single letter variables like
e(this goes for any programming language) - Dont name your class something ambiguous like
Main
It is very important, that you dont run IO on the games main thread. Hard drives are very very slow compared to ram.
So if an event occurs, and you start writing data to disk, then the entire game has to wait for your IO to finish. This
will cause massive lag in absolutely no time.
Bind your data to scopes:
When a player joins -> Load the data from Disk to RAM
When the player quits -> Save the data from RAM to Disk
Nice job Smile. You should be a Discord Helper
he is
woosh
Thanks for pointing that out MissingReports. You'd make a really good Verified
fuck i use "e" for event
icba to type event everything
event or ev ftw
You don't even need to type it out your ide will do it for you lol
sometimes it doesnt if i have a variable that starts with 'e'
skill issue
anyways
thank you for the info
If you want to remove specific items from an Inventory, then you should use the Inventory#removeItem(ItemStack...) method.
It removes items from the inventory based on the isSimilar() check for ItemStacks.
the thing is, if u don't have enough items (it's a shop plugin) i dont want it to still remove whatever u have
and i want it so if u have for example 10 raw cod in 1 slot and 5 cod in another slot it would still work
and if u have 10 cod in one slot and 6 in another it removes 10 then 5 not 10 then 6 cuz all my previous attempts did that
removeItem should be very exact with its amount. I think you used remove() before, which removes all items that match the given ItemStack
^
can i copy the player's inventory and set the player's inventory
That sounds expensive. Why dont you just use containsAtLeast on the Inventory to check if he has enough items
this is hard to explain, i have a rarity system that changes the color of the item name based on the rarity, i could have a common cod (white) and an uncommon cod (lime) and isSimilar iirc checks if the item name is exactly the same color included
containsAtLeast and removeItem as u said use isSimilar
Hmm, i really wanted to add a method which takes a Predicate<ItemStack> as an argument instead of the isSimilar check.
Well, looks like you need to write two util methods then.
cant i just copy removeItem method and change the check to be my custom check instead of writing one from zero
Sure
what implements inventory in craftbukkit
CraftInventory
CraftInventory

thanks
Simply a mere skill issue on your part
Type faster
shit
hi! Guys, do you know some good library to handle opening and get user input from writable book? I need to get a user input from each line
bro "item" and "i" are already defined in the scope and i need to define an itemstack var
tf do i name it
stack
item stack
genius
Just an example i thought about:
public class InventoryUtils {
public static int count(Inventory inventory, Predicate<ItemStack> predicate) {
int count = 0;
for (ItemStack item : inventory) {
if (!predicate.test(item)) {
continue;
}
count += item.getAmount();
}
return count;
}
public static int remove(Inventory inventory, int amount, Predicate<ItemStack> predicate) {
int remaining = amount;
for (ItemStack item : inventory) {
if (!predicate.test(item)) {
continue;
}
if (item.getAmount() <= remaining) {
remaining -= item.getAmount();
item.setAmount(0);
} else {
item.setAmount(item.getAmount() - remaining);
remaining = 0;
}
if (remaining == 0) {
break;
}
}
return amount - remaining;
}
}
would anyone know how to use shadowJar with jitpack? Can't figure it out, i'm getting this error:
😡
You mean how to get mavenplublish working with jitpack? I dont see a correlation to shadowjar here.
like dis?
Eh... 🤨
thats literally craftinventory method
How about you write it in a more generic way so that it can be reused
jitpack works, just whenever i use the artifact it doesn't
ima just use urs then
i need to include all the dependencies in the jitpack source
How can I make a warden not target specific players
Hm, not sure if there is a specific event for that. The Warden itself has a clearAnger(Entity entity) method.
Let me check which methods would be fired for increasing the anger level.
because i need access to them without adding every dependency each time
??
You can't forcibly open a writable book
using ur code
for (ItemStack costItem : cost) {
Predicate<ItemStack> predicate = (stack) -> stack.hasItemMeta && ChatColor.stripColor(stack.getItemMeta.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(costItem.getItemMeta.getDisplayName()));
if (costItem.getAmount() > InventoryUtils.count(inventory, predicate)) {
player.sendMessage("brokie");
return;
}
InventoryUtils.remove(inventory, costItem.getAmount(), predicate)
}```
like dis?
I thihnk a slightly scuffed thing I could do is create a custom warden and override the canTargetEntity method to not allow targetting of a specific entity
also i still dont understand what i can save in a chunks nbt that allows me to respawn an entity from it
cuz i cant save all the entity data
it is not possible to open writable book and get user input?
just use a sign or smth
i would like to use book instead
no
im not like other girls
is there any supported ways to make http requests in bukkit or do i have to use a 3rd party
I mean, bukkit isn't an http client
the jdk does have one however
in the java.net.http package iirc
i was thinking if using a http would cause issues
Or if you like convenience use retrofit
but doing Bukkit.runTask should fix every threading issue
but nobody will say anything if you just use https
i was thinking using okttph doing async callback then soing Bukkit.runTask to handle bukkit related stuff
and the jdk http client has built-in support for asynchronous execution anyway, returning a CompletableFuture
just use java 😄
so the asyncatcher doesnt cause an error
sure but i was thinking if bukkit had anything against doing async outside their scope
Bukkit.runtask is pretty good
not really
aight needed to make sure
why are these the file locations? this is not where the directory is for the server on my pc
/**
* Ensures that the provided file and its directories are created.
*
* @param file the file to defend
* @return the file being defended (ignorable)
*/
@SuppressWarnings("ResultOfMethodCallIgnored")
public static File defendFile(File file) {
try {
File parent = file.getParentFile();
if (!parent.exists()) {
parent.mkdirs();
}
file.createNewFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
return file;
}
this is the defendfile method
do i understand the concept correct that when i pass a primitive wrapped in a Class i pass a reference, and thus i can handle it like a pointer rather than a copy(e.g modifying the value of the wrapped primitive passed as parameter)?
i mean is this the purpose of wrapped primitives?
defend file?
thanks
my defendFile method just wasn't doing what I was expecting
public static void foo(Integer i)
{
i = 5;
}
public static void main(String[] args)
{
Integer i = 1;
System.out.println(i);
foo(i);
System.out.println(i);
}
```because this appears to remain 1
I may be completely wrong but I would assume that the compiler would unbox this into primitives for optimization
what about strings
it shows the same behavior
and theres no primitive char* in java
Good question
It's something else then probably, not sure, will also wait for an answer
public static void foo(String s)
{
s = "LOL";
}
public static void main(String[] args)
{
String s = "Hello World";
System.out.println(s);
foo(s);
System.out.println(s);
}
``` this remains hello world
that kinda defeats the purpose of pass by reference
so it always makes copies?
it copies the "pointer"
i thought it always passes a reference of objects?
then why cant i modify it like shown?
when you reassign an object you reassign the local "pointer", not the underlying object
Oh that's trueeeee
huh