#development
1 messages ยท Page 5 of 1
GCs walk along references reachable from the GC root, so unreachable circular references don't matter
alright, good to know
Any Ideas how to code cosmetic armor?
Resource packs?
custom model data for armor
with resourcepack
No I mean that you wear a gold chestplate but a diamond chestplate is shown to other players (not that the armor has a different texture)
you would have to make the client desync somehow and show gold chestplate in the inventory but its diamond armor
Packets, Sensaicraft
So I should use Protocollib as dependency and then look for a packet which sets armor?
yes
also need to cancel base minecraft packets as well that change armor
how can I stop players from putting any item in their off hand
public void onClick(InventoryClickEvent e) {
if(e.getClickedInventory() instanceof PlayerInventory) {
if(e.getClick().equals(ClickType.SWAP_OFFHAND)) {
e.setCancelled(true);
}
if(e.getRawSlot() == 40) {
e.setCancelled(true);
}
}
}```
Do you have any tips how i would detect if the packet was sent by base minecraft or if it was sent by me?
click & swap hand event, cancel those
Or refer to old combat plugins
I would like some feedback if this is actually caching data or what. It doesn't lag at all it used to crash my server with my old code. https://github.com/Williambriggs1/RandomThings
I cancelled the swaphandevent but im struggling on InventoryClickEvent
I believe that the getRawSlot id for offhand is 45. 40 is the getSlot id
oh
https://www.spigotmc.org/wiki/raw-slot-ids/
all the slot numbers you have ever dreamed of
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
thanks
amogus
it worked
Idk why they change the slot numbers so often
hi
Hello i want to get the endercrystal class through reflections. In EntityType enum there is a method named getEntityClass(). Is there a way to use the getEntityClass() method through the ENDER_CRYSTAL field ? ```
Class<?> entityClass = ClassUtils.getEntityClass("EntityType");
Field crystalField = entityClass.getField("ENDER_CRYSTAL");
final Location location = getRandomSpawn();
if (location == null || powerups.contains(location)) return;```how can i repeat `getRandomSpawn()` until `powerups.contains(location)` equals `false`? and also make it stop trying after X times (so that it doesnt loop forever)
either a while loop, or a for loop with the desired amount of threshold loops
also cancel playerswaphanditemsevent
that blocks people from switching to offhand through the hotkey
Anyone know how to use the gradle bnd plugin to build a bundle I can then run in OSGi? It seems (from https://www.baeldung.com/osgi) that's it's really simple with the maven-bundle-plugin, but since this obviously doesn't exist on gradle I'm stuck with https://github.com/bndtools/bnd/blob/master/gradle-plugins/README.md . gradle bundle seems to execute fine, but then I can't load the bundle with karaf using either bundle:install com.example/example/1.0 or bundle:install mvn:com.example/example/1.0. I'm assuming this is because karaf doesn't know where to look for the bundle or I haven't published the bundle to maven local? I suppose my question is, why is this (seemingly) so much harder in gradle, and what am I doing wrong? My build.gradle is here https://hastebin.com/ijapuqeruk.gradle
so i have Location locationA and List<Location> locations, how can i find the closest location to locationA from locations?
d;spigot Location#distanceSquared
public double distanceSquared(@NotNull Location o)
throws IllegalArgumentException```
Get the squared distance between this location and another.
the distance
o - The other location
IllegalArgumentException - for differing worlds
d;jdk Collections#min
public static T min(Collection coll, Comparator comp)
throws ClassCastException, NoSuchElementException```
Returns the minimum element of the given collection, according to the order induced by the specified comparator. All elements in the collection must be mutually comparable by the specified comparator (that is, comp.compare(e1, e2) must not throw a ClassCastException for any elements e1 and e2 in the collection).
This method iterates over the entire collection, hence it requires time proportional to the size of the collection.
the minimum element of the given collection, according to the specified comparator.
coll - the collection whose minimum element is to be determined.
comp - the comparator with which to determine the minimum element. A null value indicates that the elements' natural ordering should be used.
ClassCastException - if the collection contains elements that are not mutually comparable using the specified comparator.
NoSuchElementException - if the collection is empty.
ty
how can i make an item spawn at a location without having it have an offset?
cause currently, i have to teleport the item after like a second to make sure it stays at the center of the block
d;World#dropItem
@NotNull
Item dropItem(@NotNull Location location, @NotNull ItemStack item)```
Drops an item at the specified Location
ItemDrop entity created as a result of this method
location - Location to drop the item
item - ItemStack to drop
This should make it stay at that location
nope, still has an X/Y offset
Welp
Great!
Anyone know how to turn a single module project into a multi module project in intelliJ without everything exploding?
I'd like to turn
https://github.com/Fredthedoggy/FredHunt
into a repo with Common, Spigot, and Fabric
and yes, I understand I'll need to abstract a bunch for common, but that's fine
whenever I've tried though, IntelliJ always gets mad at me mixing Java versions, and tries to run fabric on Java 11
Uhhhh
make sure the pom.xml is set to java 8 in the modules too
or if it happens again, show the error
It's worked fine for me so maybe you forgot to specify the versions in the modules? ๐คท
also the module names should be lowercase I think
wait really?
it isn't necessary but it's convention
ye
oh, my other issue is what should the main spigot class be, for example?
since rn it's me.fredthedoggy.fredhunt.FredHunt
etc.fredhunt.fabric.etc
but do I do me.fredthedoggy.fredhunt.spigot.FredHunt?
yea thats what i do
๐
Make sure the pom.xml is turned into build.gradle.kts
๐
I believe you do yes
if (event.getModifiedType() != PotionEffectType.INVISIBILITY) {
Bukkit.broadcastMessage(event.getModifiedType().toString());
Bukkit.broadcastMessage(PotionEffectType.INVISIBILITY.toString());
return;
}```this (the `if` statement) keeps returning `true` even tho they are equal: https://srnyx.has.rocks/java_wRgK9iFUC4.png
d;Spigot PotionEffectType
public abstract class PotionEffectType
extends Object
implements Keyed```
PotionEffectType has 1 extensions, 1 implementations, 1 all implementations, 1 sub classes, 17 methods, and 32 fields.
Represents a type of potion and its effect on an entity.
That's not an enum, so you'll want .equals instead of ==
what is it?
It's an object
A non-enum class which instead uses static variables
with a bunch of static members to grab things like you're doing
members might be the wrong word
Idk the terminology
โ๏ธ
ah alr, ty
is members correct!?
I think members are for non static
didn't know that until now either
ยฏ_(ใ)_/ยฏ
you should never need ==, since .equals works on enums too, so it's easier to just use Object#equals and never run into that sort of issue
primitives
yea its just more visually noticeable
that's not a good reason to use ==
Auto boxing ๐ ๐
but yeah, you're right I guess
but like who checks primatives
๐ฅฒ
((Integer) 1).equals(2)
```ez
does that work?
idk how autoboxing works
kotlin ๐
Auto Boxing just makes it work iirc
well 1.equals(2) won't work
so like Int == Int would convert to int == int
so I'm wondering if casting will cause classcastexception
or if it'll automatically work
๐คท
public static Integer valueOf(int i)```
Returns an Integer instance representing the specified int value. If a new Integer instance is not required, this method should generally be used in preference to the constructor Integer(int), as this method is likely to yield significantly better space and time performance by caching frequently requested values. This method will always cache values in the range -128 to 127, inclusive, and may cache other values outside of this range.
1.5
an Integer instance representing i.
i - an int value.
there we go
hey dkim, have you made a project with modules before?
mine is with gradle too lol
anyway, want to turn mine into a multi platform project ๐ ๐
I keep doing dumb stuff & making it not work
just like make the modules exist
not moving stuff to a common module, that part's easy
Unfortunately I think the only open sourced project I have is Bedwars which is outdated and doesn't use kts
here it is though https://github.com/dkim19375/Bedwars
I'd recommend using kts though
okay you win
for the buildscript
kts it is
lmfao
Root module: https://pastes.dev/YGdWIDjORV
Plugin module: https://pastes.dev/j5CCPKDpbr
settings.gradle.kts: https://pastes.dev/1i6acg9tQK (the maven repo is used for paperdev which I recommend if you're on 1.17 or above ๐)
The root should have minimal dependencies, so I have placeholderapi and triumph config, both of which you probably should only have in the plugin module but I guess I forgot
I unfortunately am still supporting spigot
like a dumb person
so no paperdev for me
oh, also 1.16
Ah alr ๐ฅฒ
I forgot about spigot, I haven't made public plugins in a long while
but ye u can use spigot api
https://bstats.org/plugin/bukkit/FredHunt/11552 Spigot is only 25%
that's pretty good
oooooooh wow
paper was only like 52% last time I saw
๐
Oh
pretty similar
oh globally paper is 55.7%
wow it matches up really well
It's almost as if proportions were proportional!
but I mean 50 servers vs the global 187391
well, there are sketchy things with low number graphs like that
like those 6 servers with purpur are probably all on my network
๐
well, 2-3 on my network, my test server, a youtuber's events server I manage, and another test server of mine
Yes, proportions scale ๐ฎ
@lyric gyro @dusky harness what's the best programming language
Scala
So tldr; 50% of programmers like kotlin, and the other 50% like Scala
proportions scale ๐ฎ
๐ ๐
Kotlin took a few things from Scala but it doesn't even take the cool things
๐ฅด
Woww
what does scala have
i only saw it like 2 times so i dont remember
are you telling me that a small percentage of a population is generally representative of a large percentage of a population?!?!
okay
๐
But does scala work on most/all java code
it's a JVM lang, so I sure hope so
"on java"?
it's pretty hardcore OOP/functional lol
if for ex u were trying to make a spigot plugin
Oh
it has very good interop with Java
Yeah
scala is the gateway drug of FP
it's not pure enough to be difficult or incompatible with java but has just enough to get you into it
i mean even like Streams and Options are gateway drugs into FP
or at least into monads
vavr pausechamp
unfortunately, too barely
Main:
private final NamespacedKey potionKey = new NamespacedKey(this, "reaping_potion");
public NamespacedKey getPotionKey() { return potionKey; }
Command:
PersistentDataContainer reapingpotionPDC = potionMeta.getPersistentDataContainer();
reapingpotionPDC.set(plugin.getPotionKey(), PersistentDataType.STRING, potionMeta.getDisplayName());
potion.setItemMeta(potionMeta);
Listener:
PersistentDataContainer container = event.getItem().getItemMeta().getPersistentDataContainer();
if (!container.has(plugin.getPotionKey(), PersistentDataType.STRING)) {
event.getPlayer().sendMessage("work4");
return;
}
So I'm a little confused on this every single time I right click the item it sends work4 and I'm not sure why it is anyone have a clue why?
Might be bc Iโm on my phone but could you paste it on hastebin or similar? Hard to read
I would investigate what the item does have in pdc
is there any video guide to learn compliling plugins?
what IDE/program are you using?
(what program did you use to create your plugin)
It depends on the program or the tool used, so there can't really be a video showing it in general
None, i need to complile a plugin to fix minor bug, dev is taking very long like its been 3 month
never used any IDE/programs
so i guess which is best IDE for new comers?
It depends if they used maven or gradle or neither
seems like maven
you do not need an IDE to compile a plugin
usually
since they usually have something called a build tool
if not then you'd probably want an IDE
can you send the source?
if it's maven then you do mvn clean package in command prompt
(Make sure to change the dir to the project directory - ex cd C:\Cool Project)
yep its maven
https://maven.apache.org/download.cgi <- if it says mvn not found, download apache-maven-3.8.6-bin.zip
in line 62 i need to remove that +5 dmg its causing bows to do very high damage by default
rather than vanilla
welp i tried... gonna see if some other dev can do it
if (args[0] == "help") { //this doesnt work
// but args[0].equalsIgnoreCase("help") works
player.sendMessage("Help message!");
return true;
}
guys, what's the difference of == and equalsIgnoreCase()?
use args[0].equalsIgnoreCase("help")
i mean why == not work
ok, im little confusing
== compares instances
while equals compares contents
Two differences
== checks for exact equals
args[0] and "help" are not the same instance, so this returns false
However, for example java String a = "test"; String b = a; a == b will return true because it's the exact same instance
equalsIgnoreCase also ignores caps, so test is equal ignore case TeSt
thanks
thank you
is it possible to return an "empty" ChatColor?
basically a ChatColor that does nothing
what do you need it for
Especially in the BlockFromToEvent, does anyone know how to replace a crop's drops? As there is no setDrops method and I can't cancel the event as it would prevent water from flowing.
Additionally, as soon as Block#getDrops() is called- the block drops are made so I can't set to air before, otherwise there are no drops and setting after gives me double. (normal drops and the drops I want).
I would think you'd just set it to not drop items and drop them yourself
Check if blockbreakevent get's called if it's broken from water
Negative, it doesn't
But I don't want to change the type/amount of items, just the item names and lores.
Well you could potentially change them when the player picks them up if you can't before that
Unless, you spawn new ones and delete the old ones
How'd I force despawn them since getDrops is a itemstack and not item?
For context, I need to label crops based on how they are harvested/made. (Eg. Player, water, piston, etc)
Only two categories though, organic and inorganic. Inorganic is basically anything other than by the player.
Either you're missing something simple, or there's no easy way and you're gonna have to go use a hacky wa
y
im sure you can modify the drops befofe they are spawned as item entities
How do you change what the maven-publish plugin actually publishes? Atm it just compiles my code and publishes that, but how can I change it to publish the result of another task? I've tried adding artifact <task> but that just runs the task and doesn't publish anything
You're trying to publish a fat jar? Aka shadow
Trying to publish a bundle made from bnd
No idea what bnd is but normally it's a good idea to publish the main jar and let every dependency be transitive
But if you want to change it, the artifact should work, I know shadow has a "special" artifact for it, bnd I am not sure
Bnd is the only gradle plugin I could find that produces bundles for use in OSGi. To run those bundles though, they need to be installed into maven local, which is what I'm trying to do
help
if (e.isLeftClick() || e.isRightClick()) {
if (e.getRawSlot() == 5) {
if (player.getInventory().getHelmet() == null) {
if (e.getCurrentItem() != null) {
if (e.getCurrentItem().hasItemMeta()) {
if (e.getCurrentItem().getItemMeta().hasDisplayName()) {
if (e.getCurrentItem().getItemMeta().getDisplayName().contains("ยงfLeaflet Hat")) {
ItemStack newItem = e.getCurrentItem();
player.getInventory().setHelmet(newItem);
Bukkit.getServer().getPluginManager().callEvent(new ArmorEquipEvent(player, ArmorEquipEvent.EquipMethod.PICK_DROP, ArmorType.HELMET, null, newItem));
}
}
}
}
}
}
}
}```
why does this not work
btw Leaflet Hat is oak leaves
what part of that monstrosity doesn't work as expected?
It doesnt set the Leaflet Hat as player's helmet
how wide is your monitor
wah
might want to return out if not true
rather than this giga chain of ifs
or.. maybe combine them idk
Thanks Matt, no idea why but that suddenly started working so uh, yeah
Though I did have to set an archive classifier, which I didn't really want to do, which might hurt me later
Is there a way to not have it publish the compiled code too?
If it's java you can just add
java {
withSourcesJar()
}
And it'll publish the sources (normally)
The code's in kotlin, but I just want to publish only the bundle, if that can be done
It seems like otherwise I have to add an archive classifier, which the OSGi tool im using doesn't really like
Is someone here well informed with packets?
ยป Give the helpers some details
ยป Ask suitable questions
ยป Be polite
ยป Wait
I already asked the question multiple times but never really got a useful anwser but again, I try to code it so that some players see other armor then others and i coded it and it also returns the right colors for the Players but ingame Players with the Traitor role have no armor and Players with Innocent Role are all Purple (Detective Role works) Here is my Packet Listener : https://paste.helpch.at/ufijusimed.cs (I have no idea why it doesnยดt work :()
What if you set all three to Color.YELLOW?
So that you can see if this is actually the issue
So basically replace that code with this: https://pastes.dev/DznB84kER2
I'm not sure if this is a packet issue, but I've basically got no ideas
// %lt_color%
if (params.equalsIgnoreCase("color")) {
final ChatColor color = new TeamManager(new PlayerManager(player).getTeam()).getChatColor();
if (color == null) return "";
return color.toString();
}``````java
public ChatColor getChatColor() {
if (team == null) return null;
if (team.equalsIgnoreCase("lthost")) return ChatColor.DARK_RED;
if (team.equalsIgnoreCase("ltred")) return ChatColor.RED;
if (team.equalsIgnoreCase("ltblue")) return ChatColor.BLUE;
return null;
}```
so that instead of passing null, i can pass the empty color
team:
lthost: []
ltblue:
- ee1e3f3e-87c4-4d7e-94b3-9e1f12a94f2c
ltred:
- e907083e-5db6-41fc-9e32-5c4d99a08712```how do i get the keys under `team` (`lthost`, `ltblue`, `ltred`)?
d;ConfigurationSection#getKeys
@NotNull
Set<String> getKeys(boolean deep)```
Gets a set containing all keys in this section.
If deep is set to true, then this will contain all the keys within any child ConfigurationSections (and their children, etc). These will be in a valid path notation for you to use.
If deep is set to false, then this will contain only the keys of any direct children, and not their own children.
Set of keys contained within this ConfigurationSection.
deep - Whether or not to get a deep list, as opposed to a shallow list.
yep just remembered that lmao, ty
Np
how do i display a jobs name with job papi
wrong channel
Anyone know what packet Entity Effect Colors are contained in? I don't see anything here; https://wiki.vg/Protocol#Entity_Effect
public PotionEffect(@NotNull PotionEffectType type, int duration, int amplifier, boolean ambient, boolean particles, boolean icon)```
Creates a potion effect.
type - effect type
duration - measured in ticks, see getDuration()
amplifier - the amplifier, see getAmplifier()
ambient - the ambient status, see isAmbient()
particles - the particle status, see hasParticles()
icon - the icon status, see hasIcon()
d;1.12.2 PotionEffect#PotionEffect
public PotionEffect(PotionEffectTypeย type, intย duration, intย amplifier, booleanย ambient, booleanย particles, Colorย color)```
Creates a potion effect.
type - effect type
duration - measured in ticks, see getDuration()
amplifier - the amplifier, see getAmplifier()
ambient - the ambient status, see isAmbient()
particles - the particle status, see hasParticles()
color - the particle color, see getColor()
I'm looking for the packet
not the method of the potion
since I need to modify it at a packet level
for dumb reasons
Yeah, but I guess it was removed at all ?
but potions still have colors?
void setColor(@Nullable Color color)```
Sets the potion color. A custom potion color will alter the display of the potion in an inventory slot.
color - the color to set
Show where?
Idk, that's from memory
The color is just for the item, nothing much afaik
stuff like this
E.g healing is pink, jump is green
Ah, hm
I just want to make all potions show up gray
so you can't tell what they are
from color
Or maybe you can hide the particles at all?
I was asked expressly to make them gray
Fair
the concept we're pulling off is "anonymous", so you can't figure out who is who
eg. all armor is iron
all names are "Player"
skins are a specific person
and enchantments are hidden
but being able to say, oh the person with strength will make it too easy to differentiate people, while no potion particles will make it so you can't tell anyone has potions at all
https://wiki.vg/Protocol#Particle_2 what about this?
I see minecraft:effect, but no colors associated
Second particle, sorry
https://wiki.vg/Protocol#World_Event Data Int Extra data for certain events, see below.
that's when the potion is splashed, right?
like the splash potion itself
not the player who radiates the effect
Yup, sounds fair
kinda seem to work, but I tried setting it to zero and all particles dissapeared
trying with a real color now
Smh fred ๐คฃ
still not working
and ofcourse lingering potions keep working, and keep their normal color
I give up
But lingering is something different
It creates an area, not just some particles when it is used
I don't see anything useful there
btw this is created by lingering potions https://wiki.vg/Entity_metadata#Area_Effect_Cloud
mhm
oh damn
what am i doing wrong? https://paste.srnyx.xyz/sugemavile.java
its still sending a normally formatted msg
could it be because im using LPC as well?
i would remove lpc
that worked, how can i make them work together?
idk what you're doing here, but try changing your listener priority? see if lpc has an api?
or lpc's listener priority
how can i change listener priority? never done it before
@EventHandler(priority = EventPriority.HIGH)
declaration: package: org.bukkit.event, enum: EventPriority
alright, ty
another problem, the recipients thing isnt working
do i have to set them before i set the msg?
oh wait
i think i have to clear the set first, and then add who i want
if you're setting it manually just make a new list then
don't retrieve the current one
there's no setRecipients, only getRecipients
which is stupid cause it makes it more performance-heavy
i set my listener priority to highest, didnt work
i can probably just remake LPC lmao
ye, usually you don't have 2 chat plugins
was only changing chat for a team chat thing
ah, you could always cancel the event and send messages manually
then it wouldn't go to lpc
yea i had that initially but then discordsrv wasnt getting it
ah
discordsrv has to have an api, no?
might be easy to send message there, ๐คทโโ๏ธ
many options
it does yea, but it'd just be too messy to send each msg manually
ig
if it comes down to it i might do that
but it could arise other issues with other plugins that rely on chat msgs
if it works it works 
only gotta code it once
i mean, what do you really use lpc for
and how hard would THAT be to do
literally just chat
not hard at all
literally just have to copy the code i already have
BUT, i was thinking of switching to a more advanced chat plugin like venturechat so that i could have moderation stuff
๐ญ
just make venture chat
๐คทโโ๏ธ
i mean its open source...
if you're gonna use another chat plugin, send messages manually I think is the best
or play around with priorities and see if you can get something
another issue with sending manually is that venturechat wouldnt detect them which means no moderation for that msg
ic
ill just remake parts of venturechat that i need
public void onInventoryClick(InventoryClickEvent event) {
if (!event.getInventory().equals(inv)) return;
event.setCancelled(true);
final ItemStack clickedItem = event.getCurrentItem();
if (clickedItem == null || clickedItem.getType().isAir()) return;
final Player p = (Player) event.getWhoClicked();
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "" + p + " - " + ChatColor.YELLOW + "Clicked the slot" + event.getRawSlot());
}
so this fires I tested it with a send message but it doesn't get past the first if statement anyone have a clue why
Use InventoryHolder and then check if the inventory's holder is an instanceof your custom holder
Trying to figure out some system to have for favicons that supports multiple platforms...
Right now I support spigot, paper, bungeecord and velocity. All platforms except spigot allow the usage of a BufferedImage for the favicon.
Spigot uses a CompressedImage, since I use ProtocolLib there, which accepts a Base64 encoded String, (normal?) image string or a byte array...
So right now, my most difficult part is to figure out a system that allows me to turn an image into some form of data that I could use accross all platforms without much work in the end.... Any ideas?
Actually. CompressedImage accepts an InputStream, which could be good...
Well, what's your inv variable
Hello I should use player.getUniqueId() even for cracked players?(it'll never change ?)
Yes
how can I get the power level of a target block?
d;AnaloguePowerable#getPower
int getPower()```
Gets the value of the 'power' property.
the 'power' value
AnaloguePowerable powerable = (AnaloguePowerable) block; I hope this works
d;Material%TARGET
public static final Material TARGET```
BlockData: AnaloguePowerable
I got it from here btw
thanks
Hello guys, i wanna make the folder to save player data
Should i name the file by username or UUID?
My friend told me should use player's name because its shorter so it'll be faster but i've seen many plugins use UUID
save by uuid if you want to allow people to change their names and still have their data
its shorter so it'll be faster
This is untrue btw
can u explain why?, i thought it needs to loop over the file name to find correct UUID?
thank you
UUID's are hashed, so length is not a factor
:bruh:
Operating systems and file systems are made by people far smarter than that
thats one way to explain lmao
i thought if they change their name, the UUID also change right?
got it, thank you
only true for offline servers
that's a good one
on online servers, uuid is bound to the account
UUID = Unique User ID 
Well, any file name string really, not specifically UUIDs
Indexing is wild
well yes, but since the question was a comparison between flat string and uuid
also look into database solutions instead of using file system for it
unless if you want people to be able to manually edit the files
Now I want to read whitepapers about different file systems and disk formats 
I need to resist the urge
Ok thank you, i'll try to learn how to work with sql, im kinda new haha
Thanks yall for the answers
sqlite is a good option if you want the plugin to work without any external databases
Will take a look at it after few more plugins, thanks
is there anyway to set glow color without using teams?
do it and share knowledge ๐
thereโs probably a way to do it with packets
In the end you do need to use teams, even if you don't register them on the server's scoreboard, you need to send team information to the client, since it's based on the player's team colour
imma try using glowapi
makes sense
is there a way to create for example 1.16 world with 1.19.2 server jar
no
or at least not without using a custom fork and spend countless man-hours rolling back the chunk, world and generation systems to how it was like in 1.16, and everything that depends on it ยฏ_(ใ)_/ยฏ
or a custom ChunkGenerator that literally implements the old generation but like, good luck lol
oh god
i think it wouldn't be that hard but i don't really want to deal with conflicts every single time
its a nightmare
maybe i can create a custom world generator
well actually purpose is that i don't want the new underground levels
like the negative coordinates
It might be easier to do that with data packs
i couldn't find anything useful for "disabling it"
But I know literally nothing about those so uh yeah
yeah so me
start server on 1.16, pregenerate tons of chunks, switch to 1.19
i kinda need to reset the world frequently
min height? how
and what about mountains?
it'd still generate 1.17+ terrain
well only underground would fix my problem
Not over the max world height ๐
Set the min world height.
You can change those with data packs, but I mean it would still use the new generation patterns, just with different heights and blocks
how do i add this plugin as a dependency? all it says in the wiki is "Add eGlow as a dependency"
https://github.com/MrGraycat/eGlow/wiki/Developer-API#getting-started
Spigot eGlow plugin. Contribute to MrGraycat/eGlow development by creating an account on GitHub.
guys, how to add variable to string quotes like this "my name is {name}"?
can i do that?
?
i mean i can i print a string like this
String name = "Jayce"
System.out.printl("my name is {name}");
i don't know what its called
java doesn't have patterns / string interpolation
instead of this
String name = "Jayce"
System.out.printl("my name is " + name);
Ok got it, thank you very much
you could use String#format or printf
or .replace("{name}", name) (you'd have to make a string tho)
got it
what's the context?
IntelliJ or gradle seems bugged for me, if I compile any (gradle) project 1 to 3 times it wont include changes if I compile it again
Updated gradle and IntelliJ and it's still there
Only fix I've found is to fully restart my pc
try to run gradle clean build
or if you use shadow, gradle clean shadowJar
I always use that
Otherwise it just fucks up
^^ still and issue, any help would be appropriated!
hi, im using rayTrace and i want it to shoot into the air (as far as the rayTrace maxDistance, so the getHitPosition is basically just 30 blocks in front of the player's eyes) if the RayTraceResult is null, how can i do that?
nevermind figured it out:
player.getEyeLocation().getDirection().multiply(Main.config.getInt("gun.distance.max")).toLocation(player.getWorld());
Is possible to deserialize a custom object from the root of the config using bukkit's config system? all methods require a path =/
no

this didnt work, think cause of the multiply thing
whats the correct way to do what im trying to do?
d;MemorySection#getSerializable
@Nullable
T getSerializable(@NotNull String path, @NotNull Class clazz)```
Gets the requested ConfigurationSerializable object at the given path. If the Object does not exist but a default value has been specified, this will return the default value. If the Object does not exist and no default value was specified, this will return null.
Requested ConfigurationSerializable object
path - the path to the object.
clazz - the type of ConfigurationSerializable
does this work only if an object was previously serialized at the path? How do I deserialize an object trough the methods/constructor mentioned here ๐
d;ConfigurationSerializable
public interface ConfigurationSerializable```
ConfigurationSerializable has 24 sub interfaces, 10 implementing classes, and 1 methods.
Represents an object that may be serialized.
These objects MUST implement one of the following, in addition to the methods as defined by this interface:
- A static method "deserialize" that accepts a single
Map<String,Object> and returns the class. - A static method "valueOf" that accepts a single
Map<String,Object> and returns...
This description has been shortened as it was too long.
the deserialize method isn't meant to be used by the developer
and if it works if it was only serialized at that path - probably not, but depends on how the deserialize method is implemented
probably not, but depends on how the deserialize method is implemented
well, is not called rn, so I assume it is used only if it finds the==: path.to.Classthing
I think that is used when deserializing only when it's inside of another object
(you have a ConfigurationSerializable inside of the map returned by serialize)
aight
well, is not called rn
Are you sure? Since that's how spigot deserializes custom objects
yes, I am
but the config doesn't contain a serialized object, so that's might be the problem
oh
Also, I found out you can access the root using "getRoot()" LOL
Hey guys, im trying to upset in mongo with this code, but for some reason i have almost 500 documents when there should only be 2... so its not upsertting
code:
Gson gson = new Gson();
String json = gson.toJson(empire).trim();
main.getEmpireCollection().replaceOne(Filters.eq("id", empire.getName()), Document.parse(json), new UpdateOptions().upsert(true));
}```
figured it out: player.getEyeLocation().toVector().add(player.getEyeLocation().getDirection().multiply(Main.config.getInt("gun.distance.max"))).toLocation(player.getWorld());
i have a sorted (highest int to lowest) Map<Player, Integer>, how can i get a Player based on their "place" (ex: 1st, 2nd, 3rd)
Is the integer their place?
no its how many points they have, but i figured it out anyways
this is how i did it: https://paste.srnyx.xyz/lasehuqoqo.java
I don't think Concurrent map save the order, does it?
ok just switched sorted to LinkedHashMap
I have (believe it or not) never worked with Chunks before, so I have some questions:
I'm actually trying so remove a ~150ms scan off the main thread, this scan involves a lot of block comparisons, getting its State (for like comparing Sign text) and stuff. I read that ChunkSnapshot is an "immutable copy" of Chunk, but I have no idea how reliable that is, and still, is the method Chunk#getChunkSnapshot thread safe by itself?
There are also 3 variants to get a chunk from the world:
getChunkAtgetChunkAtAsyncgetChunkAtAsyncUrgently
Almost all chunks I'll get are loaded already (but not all), and I know what range of blocks I'll need to access async (I have the minimum and maximum points of the area, which might surpass the size of a single Chunk), which method would make more sense (I'm using Kotlin and have access to Coroutines)?
Also, how do you guys handle these cases were you might need to access blocks from multiple chunks at once (like in intersection of chunks)? Is there a native abstraction in Paper for a "region" (that can range from 1 to n chunk snapshots)?
Does ChunkSnapshot even keep the block NBT data?
I read that
ChunkSnapshotis an "immutable copy" ofChunk
Yes, that is true
is the method
Chunk#getChunkSnapshotthread safe by itself?
No, you must call it on the server thread, then jump to another thread to scan it however you like, the ChunkSnapshot itself, being immutable, is inherently thread safe after you get hold of it
There are also 3 variants to get a chunk from the world:
getChunkAtgetChunkAtAsyncgetChunkAtAsyncUrgently
[...]
which method would make more sense
Just gCAA will be fine if you are unsure whether they are loaded or not, the urgent variant is more useful for stuff like spawning entities and such, you still need to call it on the server thread, get the snapshot and jump to another thread
how do you guys handle these cases were you might need to access blocks from multiple chunks at once (like in intersection of chunks)?
No other way than just calling the methodsyou can do some fancy maths to get the chunk coordinates for the blocks you need (
chunkX = blockX >> 4, obvs same for z)
Is there a native abstraction in Paper for a "region" (that can range from 1 to n chunk snapshots)?
No
Does
ChunkSnapshoteven keep the block NBT data?
I'm not sure, if it has methods like getBlockState/getState (not getBlock followed by getState) then yes, if not then no
it has getBlockData, probably not useful to get Sign texts I guess...
lame
I'm pretty sure BoundingBox has a method that returns chunk chords inside the points.
is copying NBT data from blocks so slow that it is worth to not do so?
I mean, they are already loading the chunk and copying the block type, why not also copy the NBT data from the block while on it?
You might have to play around with different methods and see what's right for you.
Depending how many chunks your server loads at a time and other factors play huge parts in deciding what methods to use.
Hey guys, world's newest Minecraft Plugin developer here (I started today hehe)
And I wanted to know how can I make so that Spectral Arrows explode on impact rather than outlining who you've hit
So they are Explosive and not Spectral
This is for a minigame I am developing with my friends
What do I have to do
I don't really know my way around Intellij that much
Is it as complicated as it sounds?
Also, the minigame we're making is like a wave of mobs that you have to kill to go to the next wave
We have to place the mobs manually for now, but I want to randomly generate these waves
So it gets progressively harder
And I want the mobs to spawn in a fixed location. Is that possible?
I believe it is, I mean, what's impossible with Java after all but I want to be sure
And how do I develop a wave system?
I have a lot of work to do and I don't know how to do it just yet, I need a lot of help.
These were a lot of questions but I need help
Really hope y'all don't mind helping a beginner!
Any java/coding experience?
I know HTML and a little bit of Python
I'm picking up Java now and I feel like I'm getting the hang of it
I have zero experience but it's not hard. Not at all
(Even tho I barely started lol)
?learn-java
Online Courses:
Online courses are also great for learning java. Some websites that offer them are:
- Coursera - Free unless you want a certificate
- PluralSight - Great courses from what I've seen. Mostly Paid
- Udemy - Never used them myself but they seem to all or at least most be paid.
My first ever course was one from Coursera. - I can say it was pretty good at introducing me to the programming world as a whole not just java.
Oracle Docs:
Oracle docs can help a lot at learning and understanding java:
- Start with this,
- Breeze through this (skipping stuff that doesn't seem relevant like bitwise operators),
- Hit this.
They're the first three from this larger thing which you should definitely go through overall. But those three should be enough for slightly better understanding of what is happening here without feeling like a huge time sink.
That one is a small part of this larger site wherein "Essential Java Classes" and "Collections" also have good useful stuff
Other services:
Some other cool services that will help you learn java are:
As you can see there are plenty of good ways to learn as long as you're willing to invest the time. Have fun learning!
few useful things here
Almost everybody here will recommend at least jumping into java itself and learning at least the basics before heading into a plugin
from personal experience I started by watching a youtube tutorial on how to make a plugin and didn't even realize how bad the code was
Is everything I asked possible though?
^^. My first time I tried plugin development back in 2014 or 2015 I skipped learning Java and it was hell trying to get more in-depth with plugins.
Well what I want to know is
How do I practice not learn
I have no clue how to practice a programming language
how can you practice without knowing
I know I need to learn but how do I practice
well you have an IDE, intellij
now you gotta learn how to make something runnable
a main method
Also, what java course in Coursera is good?
I have no clue sadly, I didn't write the FAQ
there's a few intros to java
I'd recommend checking out some of the syllabuses
It literally asks me for paying information when I try to start a course
Yeah we should change channels, we aren't on topic here
That might be a recent change. Can look into updating the response.
ah, free 7 day trial then $49/mo
That's gotta be a somewhat recent change. Will look into it.
Can i change the color of raindrops with spigot api?
no, rainfall is a texture, can only change from a texture pack
If you can find a place to learn Java (YouTube or something idk), afterwards CodedRed makes pretty cool basic tutorials for Minecraft plug-in development
If you feel that you really need a from the ground up Java to plug-in development there is mineacademy.
Though not free, it teaches basics of Java, and plug-in development from beginner to some pretty advanced stuff. I never finished it because Iโm a bad student and wanted to branch into my own things lol, but sometimes I go back and learn something new. Link https://mineacademy.org/project-orion
๐คฎ
thanks
just watch enough yt videos and go through enough trial and error and you'll be fineeeee
yes it's not that complex to start learning
just start from anywhere
be passionate and you will find your way by yourself
what's the event name for when you sound a goat horn
i wanted to make it so horns are like ultimate abilities
you get healing or more resistance or speed etc when you sound them
and how do i increase the delay
also
how do i make the drowned not suffocate when they aren't in water?
and attack other mobs, not players
because i want to make a horn that spawns a horde of drowneds to help you kill the mobs in the minigame im making
the horn i want to use is specifically that one that sounds like a submarine or boat horn
i would assume playerinteractevent
and when it comes to making the mobs you spawn attack other mobs i think that requires nms to modify the mob's goals as afaik theres no way to do so using just the spigot/bukkit api
well there is a option to disable this thing
i guess only disabling it will just fix my problem
I don't think that's what you're going after
That's for chunks that have been generated before 1.19 when upgrading to 1.19
isn't there an option in world setting for min height? I mean, World has a method for this
Oh?
I found something
This guy teached how to turn mobs into allies
Creepers, Zombies, etc
But
I still need to know what's the event when you sound a horn
Because I can't use playerinteractevent
yeah but it does need nms
fuck
that makes sense actually
im having trouble downloading nms
can someone help me
i couldn't find anything related with that in forums
and searched for a while in javadoc
why cant I send images here
You won't be able to upload images here directly to avoid spam, so please use https://imgur.com/upload or similar service to upload images/screenshots.
Okay
Is InventoryClickEvent the only way to do something when a player complete a trade?
did you run buildtools for 1.19.2?
I did for 1.19
also you need to tell it to use maven local
how do I do that
can I just erase the .2 at the end?
good question. I have no idea how to add the maven local repository on maven. just on gradle xD
your creating a plugin for 1.19.0?
also you dont have to afaik
you just change it to spigot in the pom.xml
I don't trust
It's red, I don't think it will work
you change it to spigot and then click the maven icon to reload
yeah
its not red anymore
I just erased the .2
and It became white
So I already added Maven local repository
well yeah cus youve ran buildtools on 1.19 and not 1.19.2
Im stupid lmao I even have the folder open
to make your life easier you could use remapped mojang so your not dealing with a() b() etc
do I need to restart Intellij?
why would you?
Yeah I just did that
Nothing happened
It's indexing
If that means anything
oh wait
now it does recognise the nms commands
thanks for your help mate
but I have another question
what is maven
and why is it important
uhh how else are you gunna compile your code?
yk, your setup to use maven to compile
it's a compiler?
yes
no
oh God
well maven converts stuff from .java to .class and creates a jar thats useable, i would call that a compiler
hmmm
like gradle
except that its not the one compiling stuff
its a project management tool is the best way to explain
it's importing the command from net.minecraft.world, not net.minecraft.server, should I worry or it's the same thing?
the code isn't red or anything
they are not the same thing
the command?
EntityCreature
yeah that
but it's not importing from net.minecraft.server
it's importing from net.minecraft.world
will this make a difference?
yes because thats where the class is located
everything isnt located in net.minecraft.server anymore
they refactored everything ages ago
if you are new to programming, i would stay away from nms stuff personally
I'm hardcore
until you know at least basic class structure
I started math with logarithms and then I learnt how to add
its up to you, but its going to make it more complex than it should be
since you need to deal with casting etc
but will it make a difference or not?
yes it will.
fuck
what can I do to solve this?
its not a "problem"
it depends on the context
do you need EntityCreature class?
if yes, continue if not.. why are you getting that class
well I think I do
what are you trying to do exactly
Well my idea is taking those horns that were added in minecraft 1.18
and make so it when you sound them, you will release a powerful ability
kind of like a ultimate attack you know
why do you need nms for that?
and one of them specifically
spigot library is sufficient
summons a horde of drowneds
that will attack other mobs (its part of the minigame)
and be your pets for a little while
afaik you cannot modify a mob's goals with the spigot api only
so nms would be required
or atleast thats how i see it
yeah, you need to create a custom entity
not to ruin your enthusiasm lets do it this way so its not too overwhelming for you
start from the easy tasks:
detect if they have the horn (maybe in hand)
change the horn data (its name, lore, make it shiny etc)
remove the horn, add cooldown
^ try making these first, none of them require nms
if you are new, its going to be hard
Bump
not really
dont expect to do it immediately
mhm
but once you are comfortable with that much, you can start looking into nms as well, but its still a big jump
especially if you want to support multiple versions
just start
for ai yes
i wouldve thought it would be EntityDrowned
entitycreature is the superclass no?
apparently it is
EntityCreature - EntityMonster - EntityDrowned
in this order
each extending the one before
I see
so it would be EntityMonster
actually, entitycreature (pathfindermob) is a superclass of all monsters and animals
or atleast going off screamingsandles
i highly recommend you code using mapped and deobf version
of nms if you are developing for 1.18
you can use paperdevbundle for it
with gradle
makes your life quite a bit easier honestly
or you can add md5's plugin to your pom.xml, add <classifier>remapped-mojang</classifier> to your spigot dependancy in the pom.xml after you have added the --remapped flag to your buildtools start script
so I have to extend EntityMonster first?
do the other stuff first before you get into the nms stuff
you need to learn some basic java first its really not a good idea to jump straight into nms and ai
okay, get to a point where you can do this without much effort
btw
The first plugin I made (a plugin that welcomes and says bye to you when you enter or leave the server) isn't working
share the code and we can check
I followed the tutorial exactly and it worked for the dude but not for me
copy and pasting code isnt a good way to learn tbh
dont follow tutorials exactly, you kinda need to try and fail until you dont anymore
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class HelloWorlderListener implements Listener {
@EventHandler
public void onLeave (PlayerQuitEvent e){
Player player = e.getPlayer();
e.setQuitMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + player.getDisplayName() + ChatColor.RED + " Saiu do servidor :(... Volte sempre!" );
}
@EventHandler
public void onJoin (PlayerJoinEvent e){
Player player = e.getPlayer();
e.setJoinMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + player.getDisplayName() + ChatColor.GREEN + " Entrou no servidor! :D Divirta-se!");
}
}```
what is the main class
also, for future reference
import org.bukkit.plugin.java.JavaPlugin;
public final class HelloWorlder extends JavaPlugin {
@Override
public void onEnable() {
// Plugin startup logic
}
@Override
public void onDisable() {
// Plugin shutdown logic
getServer().getPluginManager().registerEvents(new HelloWorlderListener(),this);
}
}
// monki brain moment
you should start naming your packages
this?
properly
hm
helloworder.helloworder while is creative, is not good
tell me, what do you see here
Well, first it's extending the JavaPlugin
why are you registering your listener in the onDisable method?
you want your logic to start onenable and your stuff to exit ondisable
i'm not
@Override
public void onDisable() {
// Plugin shutdown logic
getServer().getPluginManager().registerEvents(new HelloWorlderListener(),this);
}
The text formation on Discord is different for some reason
no wait
It isn't
Is that why isn't it working?
yes
you only tell spigot when your plugin is disabling
aka when your server is shutting down usually
ik I was just learning how to create a project
So I need to put this in OnEnable?
yes
yes, just think about it in order
when my plugin enables, tell spigot to message my plugin when an event happens
is what you are doing there
import org.bukkit.plugin.java.JavaPlugin;
public final class HelloWorlder extends JavaPlugin {
@Override
public void onEnable() {
getServer().getPluginManager().registerEvents(new HelloWorlderListener(),this);
// Plugin startup logic
}
@Override
public void onDisable() {
// Plugin shutdown logic
}```
So now is it correct?
Like that?
yes
you click the green arrow
there should be a button for it on the top right
like that
you click the build option
or you can click the green arrow if its automatically been put there
mine doesnt look like this
I just clicked build project
now what do I do
dont you have a maven button the left side of intellij?
right you mean i think?
yes I do
But mine doesnt look like this
yes right
then click the maven button
play button is for running it
on the right there should be a tab
with " maven" on it
do you see Run Configurations?
double click it
nothing happened
post a ss of your maven tab
yeah what now
what do you see
run, debug, edit, delete
nah
sorry
im stupid
you mean the green arrow next to it
so you dont see anything like this?
no
you see this?
yes
click the little down pointing arrow
click edit configurations
add new configuration
in Run add clean package
make sure working directory is your project's directory
brb
back
are you still there?
we hired a new internet and i had to recieve the guy who will install it
anyways
everything is already there @proud pebble
clean package, working directory
what now
Ok
and then click the little arrow again and click the configuration you just made
then you should beable to click the green arrow
yes
i still cant run that one
but I already did run the other green arrow
next to the maven thing with the down arrow
it should let you run it
thats next to debug
the green arrow here?
yes
in your project on the left, do you see a target folder?>
ok thats right
windows explorer
now you should beable to stick that jar in your plugins folder and use it
i'm not the one using the plugin
it's for a server my friends are making
thanks for your help again
you are surely a highly helpful human being
i do try
what was the actual name of "zoom-in" as action in intellij
uh it's just "increase font size"
is commands.<command>.usage required in plugin.yml?
no
does anyone know why shadow is failing to shade this
java.lang.NoSuchMethodError: 'net.kyori.adventure.text.Component me.aki.apexapi.common.util.ColorUtil.colorize(java.lang.String)'
they are in dependencies (and their methods show up properly)
its failing to relocate too it seems
Are you building with shadowJar?
yes
everything else relocates properly
for some reason net.kyori doesnt though
and it lacks the minimessage as well so im kinda baffled
Can you show your entire build script?
Hmm it looks correct, it might be something to do with paperweight and shadow compatibility stuff, not exactly sure though
also interesting that you add kotlin 1.7 but shade std for 1.5 
ah, i just copy pasted from an old project for the versions
maybe a weird interaction with extension functions?
colorize extends String maybe thats messing with either paperweight or shadow
nah, its an interaction with paperweight i think since its integrated in paper maybe they exclude it by default
how do I make it so that the plugin checks what item the player just used
?
@merry knoll
sorry for ping
used?
sumtin like this
public void arrowHit(ProjectileHitEvent event) {
Projectile spectralArrow = event.getEntity();
if (spectralArrow instanceof SpectralArrow) {
World world = spectralArrow.getWorld();
Location location= spectralArrow.getLocation();
world.createExplosion(location, 2);
}```
but since it isn't a projectile i want
(i want a consumable item)
how do i do it
do what exactly?
check if the item the player used is the correct one
actually, why do you want it
when you say correct one, what would a correct one be?
then why did you post something relating to a spectal arrow then?
playerinteractevent
I said "something like this"
Projectile spectralArrow = event.getEntity();
this line of code specifically
projectile hit event is not at all similar
instead of projectile what do i put




you can do some fancy maths to get the chunk coordinates for the blocks you need (