#help-development
1 messages ¡ Page 2044 of 1
European keyboards don't have it
or at least Italian ones don't
idk if they're different in other EU nations
do you have an alt gr key?
yes
then you have easy access to the tilde and backtick keys đ
Add a Cortana voice command for it đ¤Ą
oh I foudn it
its alt gr + Ăš
I was looking at the wrong layout from MS
well accordingly
for you its alt code 60
as well
weird your laptop keyboard isn't following the typical layout though
wonder if it requires the function key to be used too
nope i tried it as well
lol
Which Euro Keyboard are you using?
fn key lights up with red the keys i can use with fn
Italian, but appaently doesn't follow standard Italian keyboard layouts
If you have the accent grave (If that is the accent I think it is) you need to Press it twice in Order to get two backticks
That File will Take forever to Download with 16 kbits/s
There is a reason I often shoot very much in the dark
And the download failed. I cease to understand how https is so unreliable
Like, FTP is so much faster and reliable (If you increase the timeout)
lol
technically could increase the timeout for https
in firefox for example
network.http.keep-alive.timeout 115 is the default you could increase it
same with websockets
chrome probably has similar setting somewhere
but I don't know it since that isn't my go to browser
am I the only one who ALWAYS has problems wit jitpack?
what do you need to know about it?
when you remove some unused imports and now you have to recommit 20% of the whole codebase lol
package de.jeff_media.angelchest;
/**
* This is the 100th class added to the original AngelChest source code, NOT including all the shaded libraries etc
*
* It's useless and has been added on 30th June 2019 at 12:50 CEST
*
* The total number of files contained in AngelChest.jar at this time was 1923, of which 1633 were .class files.
*/
public class Class100 {
}
bruh
bruh
thanks imma do that
no u dont

I also recommend this https://github.com/Jaimss/terrible-plugin
does this already exist in the standard libs?
public class Pair<A, B>
{
public A first;
public B second;
public Pair(A first, B second)
{
super();
this.first = first;
this.second = second;
}
}
seems abit silly to declare a pair
also can the plugin somehow detect this line from its plugin.yml ```yml
api-version: 1.18
(to auto disable itself if versions dont match cause i use nms methods)
sometimes it's very handy
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/plugin/PluginDescriptionFile.html#getAPIVersion() this exists
declaration: package: org.bukkit.plugin, class: PluginDescriptionFile
but to detect the NMS version, you need a bit reflection
I always do sth like this:
if(nms) {
final String packageName = JeffLib.class.getPackage().getName();
final String internalsName = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
try {
//abstractNmsHandler = (AbstractNMSHandler) Class.forName(packageName + ".internal.nms." + internalsName + ".NMSHandler").newInstance();
abstractNmsHandler = (AbstractNMSHandler) Class.forName(packageName + ".internal.nms." + internalsName + ".NMSHandler").getDeclaredConstructor().newInstance();
} catch (final ClassNotFoundException | InstantiationException | IllegalAccessException | ClassCastException | NoSuchMethodException | InvocationTargetException exception) {
plugin.getLogger().warning("The included JeffLib version (" + version + ") does not fully support the Minecraft version you are currently running: " + internalsName);
exception.printStackTrace();
}
}
now "internalsName" is e.g. "v1_18_R2"
hehe teye
cause i wanna avoid nms as much as possible
but since i plan a plugin for custom entities that injects its entities into the server
version mismatch could crash things
what MC version are you on?
because if it's 1.17+ you HAVE to use the remapped jar for custom entities, otherwise it won't compile. But you should be using remapped anyway đ
Remapped makes things much easier
how so
it just complicated it for me
to import it
because i didnt know of the change
otherwise it seems pmuch similar to me
How is a(), b(), c() simillar to coolMethodName(). All you really need to do is copy paste remap config in to your pom and you're good to go
Takes less than 5min
so it took the vanilla obfuscating out
with remapped, you can basically code sth once for 1.17.1, then compile exactly the same code against 1.18.2 mappings and it'll still work in 99% of cases
hm
what's the regex for 'all non numeral characters' ?
no
i want to extract the number from a string
wait
\d does numbers
not not numbers
hello id like some help with getting 1.18.2 plugin development started [idk if im doing it right]
i downloaded the buildtools.jar that i made a bat
java -jar BuildTools.jar --rev 1.18.2 now im just waiting is this right?
it depends. do you need to access NMS code?
I once wrote a tiny tutorial on how to get started with IntelliJ + maven + spigot-api: https://blog.jeff-media.com/how-to-create-your-first-minecraft-plugin-using-the-spigot-api-and-maven/
um idk what nms code means, im just familiar with how 1.16.5 does it all i really need is the jar that you add to dependences
then you don't need to worry about NMS
but anyway, I highly suggest you to use maven. it might seem a bit complicated at first, but it actually makes everything much easier
my blog post explains everything you need to do to get a working maven setup
oh
is this normal for /data get @p ?
yes
the green part you see is the discovered recipes etc, the second half is mainly their inventory
no, the creative inventory is 100% client sided
um could i still get help with getting the jar file for dependences the build tools stopped running and the spigot-1.18.2.jar doesnt work
oh wait, it actually does include it
huh
but you can't really rely on it
pdc contains book pages
yes sure
well, not really PDC. the book pages are inside an NBT tag
but PDC basically IS NBT
ah i see
it's simply an interface to access it using spigot API instead of NMS
imma assume getinventory interfaces with PDC then
wdym?
well if the inventory is stored in the PDC
ah note taken
check out the 6lth line from the bottom
everything inside BukkitValues is the data you get from player.getPersistentDataContainer()
is there no way to make 1.18.2 plugins without maven?
gradle
um
thats just the spigot api
Heya guys quick question. Do you know any lib that helps me build JSON messages?
Adventure
how would I get it?
Isn't that a paper thing?
You can shade it in to your plugin if you want it
Uhm, ok great ty
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
oh thanks
if i need to transleate a list with color codes in config do i need to have it a spesial place?
anyone know a good tutorial on world gen? i tried the one on the bukkit fandom but its old and outdated
can you send me a link
Hello world
Cancelling EntityChangeBlockEvent seems to remove Falling Blocks, is that correct behaviour?
i need a lib idea
how can i find all entities in a radius around a location? Is my only option to spawn in an invisible entity and use the getNear function (alternative to iterating through every entity in the world and checking their location)?
update: get all entities in a chunk and iterate through those
World has a getNearbyEntities() method
that being said, that method iterates through all entities in that world to see which ones are close enough to the location specified. You wont get around that I believe
yeah i was gonna say that
can i do a for (a : aset; b : bset) in some way/form? I have two sets i need to iterate through and perform an operation on each of the entry pairs of the sets (they have guaranteed the same length)
also does null count as duplicate entry in a set?
nested loo[p
loop
for each a in aset, loop through b in b set
or make a wrapper class
ah not what i meant
i need to perform an operation on every pair in the set per index so to speak
also i just realized i need to use ArrayList
you can get 2 iterators
for (a : b) is just syntatic sugar
@smoky oak
Iterator<...> asetIter = aset.iterator();
Iterator<...> bsetIter = bset.iterator();
while (asetIter.hasNext() && bsetIter.hasNext()) {
var aItem = asetIter.next();
var bItem = bsetIter.next();
}
``` something like this
fucking ugly but it works
idk for sure im doing the order right
one sec
isnt that the complicated equivalent of java for(int i = aset.length()){ var aI = aset.get(i); var bI = bset.get(i); }
where's the difference?
Set<...> isnt ordered it doesnt have a get(int) method right
Sets can't get duplicate entries though?
oh ok
which might be in the same chunk
I thought u meant that sets can
as such a set for the location.getChunk.getEntities() might have duplicates
also does a location point to the corner of a block with the lowest coords or to the middle of it?
block location is an int i think
which does not answer the question
How would this have duplicates
box = new BoundingBox();
box.resize(l.getX()-.5,l.getY()+.5,l.getZ()-.5,l.getX()+.5,l.getY()+1.5,l.getZ()+.5);
reason i ask is bc im unsure if i have to use 1.0 instead of 0.5 here
You add 0.5 to each to get the middle
List of locations around which to check, list of Entity[] in the chunk the location is in
if two in same chunk
dupe
Ah, so youâre checking chunks multiple times and combining them into one aggregate collection
I see
it's the only solution i found so far
List<BoundingBox> pset = new ArrayList<>();
List<Entity[]> eset = new ArrayList<>();
BoundingBox box;
for(Block b : blockList){
if(b.getType() == Material.WAXED_COPPER_BLOCK){
l = b.getLocation();
box = new BoundingBox();
box.resize(l.getX(),l.getY()+1,l.getZ(),l.getX()+1,l.getY()+2,l.getZ()+1);
pset.add(box);
eset.add(l.getChunk().getEntities());
}
}
Yeah thatâs not a bad solution, it just wasnât clear from your original explanation that two could occur in the same chunk at once
Whoa whoa whoa
Why are you adding arrays to it
Why not just have a List<Entity> and stick them all in that
bc Chunk::getEntities() returns Entity[]
might be a solution
If all youâre going to do with that array later is iterate through it you might as well
this looks disgusting but i guess it works
Set<ItemStack> r_set = new HashSet<>();
for(BoundingBox b : bset){
for(Entity e : eset){
if(e instanceof ItemStack && b.contains(e.getLocation().toVector())){
r_set.add((ItemStack) e);
}
}
}
return r_set.toArray(new ItemStack[0]);```
Bro
an entity cant exist twice
normally
looks disgusting because of how you did it
no but the array returned from Chunk::getEntities() can be the same if it's called in the same chunk twice
what is rset
set of ItemStack[] array to be returned before conversion
done that way to make sure i dont get an arrayIndexOutOfBoundsException
what does it do
store all entities found in the defined bounding boxes
Set<ItemStack> entitiesFound = new HashSet<>();
for(BoundingBox boundingBox : boundingBoxes){
for(Entity entityEntry : entities){
if(entityEntry instanceof ItemStack && boundingBox.contains(entityEntry.getLocation().toVector()))
entitiesFound.add((ItemStack) entityEntry);
}
}
return entitiesFound.toArray(new ItemStack[0]);```
Yep
why convert it to an array
Why do you care if theyâre in the chunks twice if the end result is a set
That will eliminate duplicates anyway
integers cant be half, so i think it would be in the corner
actually due to the fact the bounding boxes cant overlap, the duplicates would have in both iterations of the code only been added once to the return set
also for some reason it doesnt throw an error
yet
Thereâs no error because youâre checking for entity instanceof ItemStack
Which will always return false
So it never goes any further
ah
ic
if(e instanceof Item && b.contains(e.getLocation().toVector())){
r_set.add(((Item) e).getItemStack());```, then?
yep
why are you doing b.contains
if they're in the collection of entities they were in a bounding box
you don't need to check it again
right?
it's not boundingBox.getEntities but location.getEntities
the b.contains is to make sure the entities are inside the bounding box and not just in the same chunk as it
oh you're not using the bounding box to filter the entities before this?
im doing the filter here
declaration: package: org.bukkit, interface: World
declaration: package: org.bukkit, interface: World
use those
I've been specifically told not to use them because they iterate through all entities in that world
also since when the fuck are entities considered dupilcates when the only difference betwen is the location
unless you're envisioning having 100000000 entities in the world or something this shouldn't be a sizeable difference
wait when did spigot create a util class for bounding boxes?
ÂŻ_(ă)_/ÂŻ
seems pog
well then imma replace that set with a list
@smoky oak i just ran the numbers with a quick test program
if your world has
500000 entities currently loaded in
which btw would freeze your server anyway
the time to check them all against 25 bounding boxes is about 234 milliseconds
How to check if Inventory is not a Chest Inventory?
I'm going to take a look at it then
from InventoryCloseEvent
plus you can use the Predicate one to only return Items
my method either returns duplicates or, when using a list instead of a set, removes some entities
Whatever you set it to though its a chest ui if no type is not specified
ok. thanks
i wanna make a plugin now where you can make potions recharge their use either through doing damage to mobs or gaining xp
is that feasible?
much like the mending enchantment ig
@EventHandler(ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) {
Profile profile = Profile.getByUuid(event.getPlayer().getUniqueId());
Match match = profile.getMatch();
if (event.getPlayer().getLocation().getBlock().getType() == Material.WATER) {
if(match.getKit().getName().equalsIgnoreCase("Sumo")) {
event.getPlayer().setHealth(0);
event.getPlayer().spigot().respawn();
}
}
}
why is that not working
if(match.getKit().getName().equalsIgnoreCase("Sumo")) {
this line is working
i tested
You should test event.getTo() not the players location
ok
hmm
if (event.getTo().getBlock().getType() == Material.WATER) {
if(match.getKit().getName().equalsIgnoreCase("Sumo")) {
event.getPlayer().setHealth(0);
event.getPlayer().spigot().respawn();
}
}
}
like that?
yes, that will trigger when you step into water
kk
^
Might want to check for the water before you get the profile aswell
nvm
beat me to it
yes, always early exit in teh move event if you can
well didn't worked
i tested it but didn't worked :C
That's not because of that lol
..
Getting data from Offline Players
C:\Program Files\Java\jdk1.8.0_321\bin\java.exe -jar BuildTools.jar --rev 1.8.3 What should I add to run java 8 ?
can you completely make your own enchantments using only a plugin?
Basically yeah
great
is there a player property or function that allows you to make them âwetâ all the time
Altho youâd have to in principle add custom lore for displayable visibility in regards to the client
wym by wet?
specifically so they donât get burnt or have riptide effects
(so they can fly during the day basically)
((with a trident))
weird sounding question but idk
You can do all of that
pog
im having a difficult time trying to figure out where to split up my plugin features
you can also use my plugin eliteenchantments and code your own effect
like i could either make a large conglomerate plugin that incorporates all the features i need for my server
or i could split it up tediously into multiple plugins
It's best to make a core plugin with small features and then separate plugins for large features ie. enchants, events etc.
cool
That way if something breaks you don't need to disable your whole plugin with all the features only the plugin that is broken
I mean in spigot it doesnât impact that much how you like to isolate features into jars tho
yeah but i just want to be neat basically
also a lot of the features im making i donât see anywhere else and i might wanna publicize them
but iâm not gonna do that for just a very niche plugin that incorporates all these weird features into one package
Well in enterprise or more professional environments you might wanna extract modules that may change for fragile reasons into separate ones/jars such that the entire system doesnât have to recompile everytime a binary incompatibility change takes place
yeah
i mean iâve literally never made a plugin before so i donât know what itâs like updating through minecraftâs changes
Yeah, got a lot of fun ahead of you then
lol
i should look into mcmmo
although what iâve seen of it i donât really like all that much
Is mcmmoâs source good?
but it might be fun to have
It's not too bad if you are only working on plugins for your own server
mhm
Ngl if you want to look at some good code to learn from... hate to say it since he is ugly but Auxilor plugins code
But yeah since you did wanna code enchants even looking at sth like splodgeboxs or auxilors enchant plugin could enhance your understandings possibly
lmfao
cool
Auxilors code is probably good enough
My code isn't public but hopefully soon will be đ¤
Last time I looked some of the design choices in his lib was questionable although nothing youâd have to worry about pricedown
Ah
coming from c++ to java is there anything i should really know, like am i allowed to just jump from cpp to java as a cheat or should i just learn the whole lang
c++ is pretty similar but there are a lot of differences in practises etc.
Shouldn't be too hard to learn Java tho for you
Or well you still have it with Unsafe and VarHandle to some extent
But like the gc will handle memory for you
right
Like itâs genuinely hard to achieve a memory leak if you think enough whilst coding
lol
iâll try to learn the language in general though ig because ik learning a language for the express purpose of a single project rarely goes well
like itâs better to familiarize yourself with the whole environment
itâs like ppl that donât know c++ that ask to learn how to make game hacks from me
Idk
Some people do fairly well when working on sth whilst learning the language
Others donât
mhm
iâm just hasted by how the server is currently up and running and i have so many ideas but canât apply them all in time
But if you came far in cpp (like even multithreading, templates and object orientation) Java will most likely be a piece of cake for you
ok good
itâs just annoying having to detour so far from brainstorming new gameplay ideas
takes so long to implement stuff
currently everythings running in the server using only datapacks lmfao
Hehe yeah well I tend to use libraries
and it works but some stuff is missing
what general libs do you recommend
So usually doesnât take that long for me, altho as they say there are no zero cost abstractions
In the start none
But have a look at GitHub repositories such as awesome-java and awesome-minecraft
Alright good luck (>:
yes
I hate noteblockapi
Header files are optional 
File file = new File("mySchem.schematic");
Vector pos1 = new Vector(loc1.getX(),loc1.getY(),loc1.getZ());
Vector pos2 = new Vector(loc2.getX(),loc2.getY(),loc2.getZ());
World world = new BukkitWorld(loc1.getWorld());
CuboidRegion region = new CuboidRegion(world, pos1, pos2);
can someone help me?, I want to save a world edit selection to a schematic file, this is because I want to save copies of certain places to be able to paste them later (It's for a minigame) I've been looking for days how to do it and the ways I found don't work and in the world edit discord do not support 1.8, maybe some of you know
Im using world edit api and 1.8 version
Time to update đ
Time to stop acting like this
Not really, updating is always a fantastic option! đ
Hi, I'm trying to detect when an item is being burnt by lava, here is my code:
@EventHandler
public void onEntityDamage(EntityDamageEvent event){
Entity entity = event.getEntity();
if(entity instanceof Item && event.getCause() == EntityDamageEvent.DamageCause.LAVA)
{
Bukkit.broadcastMessage("burnt");
}
}
But because the item is being damaged twice this event fires twice, any idea on how to fix this?
If you only want it to fire once save the UUID to a Set and don't do anything if the Set contains the UUID
Alternativly only do stuff if it's in the Set depending on what you want
Oh that's smart
I'll do that, thanks! :D
If an item takes damage once, it's impossible for it to survive right?
Well yea
And if multiple items will get burnt at the same time will it add it to the same list? Or is it like every user has it's own list
Or every time the event runs or whatever
That would depend on what you are actually trying to do
If I just add the id of the item to a list every time it's being damaged with the event
Then another item is being damaged
Will it be the same list? or does it create a new one in the memory?
Also if I check a value in the config every time this event fires
Will this be intensive for the server?
does someone have exp with deserializing inventories from player dats?
to view the inventories of offline players
When I have InventoryClickEvent and action is HOTBAR_SWAP, how can I get two items that are swapped?
Will this work on both lava and fire?
for example when i have stick on slot 1 inventory and on slot 2 I have diamond, when I hover over stick and press 2 on keyboard items get swapped, but when I use e.getCursor() + "\n" + e.getCurrentItem() it returns ItemStack{AIR x 0} ItemStack{STICK x 1}
so my question is how can I get both items that are swapped
Will someone help me?
you can try inventoryview, however, what you want is mostly clientside
What can I do with inventoryView
Is getServerInfo case sensitive?
iirc yes
How can I open a book for player in 1.12.2? got a solution
i was having the same idea but i feel like having additional files for one and the same thing does make things more fragile
like ofc i can serialize it from the object in memory
but i was thinking of accessing the "real" inventory directly from the players file
and write to that
you can also use something like prism or coreprotect - all that data would be in the database
prism
Hi, do you know if EntityShootBowEvent will be triggered for pillager crossbow shoot?
?tas
Hello! How I can create an empty ConfigurationSection object?
Simply create a "yamlconfiguration" object, or what I need to do?
ConfigurationSection::createSection exists
oh.
really? that was too easy... thx!
well
you do have some other options
but I'd stick with createSection
for instance you could pass a new MemorySection() or simply a new MemoryConfiguration()
anyone got a good tutorial for world gen? i tried the one on the bukkit fandom but its outdated
Should Player.getInventory().remove() remove 1 item from a stack if it's amount is more than 1? or should it just remove the whole stack regardless of the amount
it will remove all matching stacks
I see, how do I remove 1 item from the stack then?
I will try that, thanks :D
Oh, setting the amount to 0 is the same as removing the item, I see
Anyways, this works now thanks for the help :D
đ
is LootGenerateEvent the callback that fires when opening villager/dungeon etc chests?
BROOO
WTF
NO
use removeItem
uuuuuuuuuuummmmmmmmm........
does anyone know why in the world it seems impossible for bukkit to give me two item instances as long as they're duplicates of each other?
I set up a scan that tells me the items over a block, but this scan does NOT work once i throw down items with the same type & stack size?????
code is basically this (with a check if it's in a bounding box):
Collection<ItemStack> ent_col = new HashSet<>();
for(Entity e : allEntitiesInWorld){
if(e instanceof Item)
ent_col.add(((Item) e).getItemStack());
}
print(toMaterialString(ent_col));
And the following happens:
[1x Amethyst block] -> AMETHYST_BLOCK
[1x Amethyst block][1x Copper block] -> AMETHYST_BLOCK+COPPER_BLOCK
[1x Amethyst block][2x Amethyst block] -> AMETHYST_BLOCK+AMETHYST_BLOCK
and here's the dumb part:
[1x Amethyst block][1x Amethyst block] -> AMETHYST_BLOCK
the fuck???
HashSet requires unique elements.
dont items have location?
Item does, but ItemStack nope
urgh
^
anyone?
thats pretty restrictive imo
how would you remove 1 item from a stack
that method removes as much as it can find of the same type & amount
oh is the signature of the Set#add method add(Object) instead of add(E) to make you able to add objects which extend E but arent cast already?
for Set its add(E) tho for map its put(K,Object) iirc
this is a thread, not a tutorial
but for example map:
V remove(Object key);
boolean containsKey(Object key);
yes
to avoid casting?
thats nice, it addresses what you think your problems is with the tutorial are
oh i thought the person who wrote this drank to much
even if i can get the tree populator to work, idk how to make it so it creates a new world and idk how to make it customizable
then perhaps you shouldnt be doing it?
not knowing something = shouldnt do it?
maybe, try getting one of those 3 things to work first?
it won't help
probably not
making bread so you have sliced bread to make a sandwich is never a good idea
i dont like new versions pvp
OCM
6 million pvp plugins and none of them work đ
meh
i can pvp without a plugin
i cant pvp
i think i will try cloning the world
sorry god
dont worry i will train you
good
anyone?
"no one can help" or no one sees it as a good use of thier time?
both
i sure someone might if you paid them
most of those are 1.12-ish no?
yeah - I generally only see them when someone runs curseforge
classes i'd think you could handle via luckperms tracks, races would be more difficult if it goes beyond factions
pretty large design undertaking and probably why no good ones are out there or maintained at current release
put no sarcasm in those last posts
hahaha werent you all about yourself a short while ago?
Well that's basically impossible
write down a list, put it on a map and include space for forks/features to ignore until your done your main list
you will never satisfy everyone and to go out of your way to support legacy items is not worth it
then you have special cases to put in your feature requests to ignore until the core is done
you will eventually come to the conclusion that some requests are stupid or impossible
one hopes so, however you still want your core to be stable and maintainable
I'd say most important thing with big projects is to get stuff done, doesn't have to be perfect the first time but make sure you progress, else you'll get rather demotivated hastily
measurable stuff done!
From personal experience I've worked with talented people, but (some of them) pay too much attention to insignificant details like "Oh you use singleton here, must refactor :))))", which of course makes sense but it slows the rest of the team down enormously, well Idk if you're working with some1 now but you get the gist of it I hope
(Well this doesnt go without saying that paying attention to details isn't always bad, but yeah, find a balance :^))
if you know how to use them, gantt charts are valuable for visualizing that type of issue
Hey,
my PlayerInteractEvent somehow gets fired twice, even after I checked for event.getHand() == EquipmentSlot.HAND. This is my code:
event.setCancelled(true); if (item == null) return; if(event.getHand() == null) return; if (event.getHand().equals(EquipmentSlot.HAND)) { if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { int itemSlot = player.getInventory().getHeldItemSlot(); if (itemSlot == 0) { //code } } }
you have two hands ...
Yes, but the offhand is EquipmentSlot.OFF_HAND
If I wanted to add, for example, a "COMMON" or "RARE" or "EPIC", etc. tag into an item when crafted (so adding that tag when crafting vanilla items), would I need to override all vanilla crafts and replace them with my own "custom" recipe, just to add those tags, or is there a better way?
Like an event or something that fires when I craft, and then, with the help of a HashMap, I can just come in and set the tag to the item
Represents an event that is called when a player interacts with an object or air, potentially fired once for each hand. The hand can be determined using getHand().
you know what hand you want, are you cancelling the other one?
Thanks!
event.setCancelled(true);
if (item == null) return;
if(event.getHand() == null) return;
if (event.getHand().equals(EquipmentSlot.HAND)) {
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
int itemSlot = player.getInventory().getHeldItemSlot();
if (itemSlot == 0) {
// Code
}
}
}
As you can see in the code block, I checked for event.getHand().equals(EquipmentSlot.HAND)
no need for equals
Okay, but still calls two times. But only, if I look directly down. When looking at another block or in the air, its fine
interact event?
Yes
for each hand
make sure you didnt register it twice btw
I didnt, I already checked
And there is always a golden pressure plate beneath me, when this event is called. Maybe this helps
I think it has to do with hat, because it always calls twice when I look at the pressureplate. When I look at the pixel on the edge of the pressure plate, where just the block beneath is, then its fine
I would say do a quick console output and check, not sure what you have would cancel both events. As EquipmentSlot[] is an array it might still be valid if you dont remove the HAND enum
There is no MAIN_HAND, only HAND and OFF_HAND
yea i just realized
ah
do event.getHand() == EquipmentSlot.HAND instead of .equals
might be the issue
And as I said it works perfectly when looking on any block/air except when looking down on the pressure plate
wait, on a pressureplate?
Yes
maybe the game triggers the event twice since its a redstone component?
Standing on a pressure plate is a playerinteractevent hmm
so the hand interacts with the pressureplate and the pressure plate interacts with the hand
And is there a way to fix this?
check if your on a pressure plate and suppress one. however before that make sure it doent happen on a regular block
it shouldnt
what do you mean by supress one?
check if you are interacting with a pressure plate and choose which one to ignore and which one to handle it
So i can basically check if the Action is PHYSICAL?
mmm i think you will also have the same issue with buttons and sculk sensors
ANd if so, return
anyone else here hating regex too?
yeah one of the action types might work
if(event.getAction() == Action.PHYSICAL) return; does not help
you would want to do the opposite
PHYSICAL
Stepping onto or into a block (Ass-pressure) Examples: Jumping on soil Standing on pressure plate Triggering redstone ore Triggering tripwire
Well, my event should only trigger if it's not the Physical one, but the right clicking
unless what you are doing is supposed to be on the pressure plate
do you knows a Discord bot plugin that displays the status and player count of a Minecraft server in the sidebar?
okay so you want not PHYSICAL
but I return at the end, so the next code doesnt get executed?
Yea your right
your test above should return, I never trust it to do that though
Although I would do if action != Right hand refurn
why does this not work?
replaceFirst("~ /.*"+separator+"(.*)/","");```
it's supposed to cut off every slash in the file string but the string returns unmodified
its a habit and code rule for certain types of programming, there should only ever be one return and always at the end.
How do you assign it
i read the file location in
anyway, drop in a comment to make sure which event you are handling and responding to
imma try something else
It's all about the PlayerInteractEvent
aha
String name = s.getType().getName();
name = name.substring(name.lastIndexOf(separator+1),name.length()-4);```
no regex necessary
yes, but check your conditions
I already checked them and have no clue, and I already sent them in here
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return; also doesnt help
are you firing in both conditions or just one?
Only when the hand is the main hand
i had a similar problem and dbuged it with https://pastecord.com/icelizacop.java
that works as expected
if that fires twice then you are registering the event twice
give me lib ideas
I don't really know the difference between the different sever types, like paper, bukkit and spigot so if I give someone a plugin I coded in spigot should it work no matter what his server type is or do I need to do something?
But not for Java, thereâs no reason not to trust a return statement in Java lol
spigot plugins work in bukkit and paper, except if you use .spigot() functions i think
but paper will always work with spigot
I see, is there a server type that wont work with my plugin?
What if the extension is longer or shorter than 4
depends if you share your code or not
Spigot plugins are fine with paper servers
paper plugins are not fine with spigot servers
what type
luckily i only have to deal with one type of extension atm
alternatively i use indexOf(".")
What are you talking about? Thereâs nothing wrong with a return statement
if its in paper it might not
Is there more than paper,spigot and bukkit?
forge
yeah but theyre uncommon
randomly buried returns results in random issues - when someone else uses the code
@crude loom a Bukkit plugin works for Bukkit, Spigot, Paper, whatever is downstream from Paper, etc. A spigot plugin is guaranteed to work for anything spigot or later, and may work for bukkit. And so on and so on and so on
Sounds like your methods are too long. And the returns arenât ârandomâ, theyâre specific exit conditions that should be documented
Ah, and if the server version is Forge then it would be coding in an entirely different environment right?
Forge and spigot are totally unrelated yes
too short if anything
If theyâre short then it should be apparent where the returns are, and the exit conditions should be documented
i agree
An early return is no different from throwing everything inside one big if statement, it just makes the indenting more annoying
Ah I see, thanks!
Maybe one of the Files functions could help you out
Which is harder to read:
if (a != null) {
if (a.b() != null) {
if (!a.b().c()) {
//stuff
}
}
}
Or
if (a == null) return;
if (a.b() == null ) return;
if (!a.b().c()) return;
//stuff
Files::newDirectoryStream or perhaps Files::walkFileTree zacken
Correct
well, most compilers do compile down to the former iirc
mostly due to performance but yeah
But thatâs not for the human to read
Lol
It also gets compiled to bytecode, but that doesnât mean our actual source should be a bunch of bytecode
yeah
n yeah File::listFiles is probably fine for your case zacken altho not particularly scalable
nullable operators when
never
Optional can help you out instead (with a bunch of flatMaps)
I literally gave you two reliable api methods but sure
a?.b?.c() looks a lot cleaner than Optional.ofNullable(a).map(a::b).map(b::c).orElse(null)
i personally use
dunno what the difference is between flatmap and map tho

basically
(M<T>, T -> M<R>) -> M<R> is a monad
or in Java
class M<T> {
public <R> M<R> flatMap(M<T> this, Function<T,M<R>> function) {
//TODO
}
}```
M<T> this can be removed so
class M<T> {
public <R> M<R> flatMap(Function<T,M<R>> function) {
//TODO
}
}```
simply
map is just
(M<T>, T -> R) -> M<R>
lol thats not simple
so <R> M<R> map(M<T> this, Function<T,R> function) instead
basically flatMap is a computation builder, whilst map is not
ye
im makin a plugin where a user can select where they want to respawn after death
is anyone ever using that lol
how should i go about making a "limbo" world or thing so that i can prompt them and receive their answer
yes
there are Optional religious people
because they simply believe touching null is too low level for Java
isnt that a kind of disease? đ¤
i believe even satan is afraid of doing that
lol
myeah
well it wouldn't be bad if Java added null chain operator
but its probably low priority
How does the plugin know what is the correct usage and when to send the message of wrong usage from the plugin.yml?
might be added in jdk 69 or sth
kek
cuz they scarcely add newer features such as those
they mostly observe other languages and how those features are seen upon by respective language developers
Hey ,
does anyone have a site / support to learn how to use APIs between plugins? and learn what an "api" is? ^^
cause they want to add necessary and non rushed features (where there have been proper theory around it), unlike a certain language Kot...
lin..
I don't
well I dont think thats possible with plugin yml
just the usage
but thats for /help
so in reality you would need to manually prompt a given command sender the appropriate messages
hmm I mean apis from other plugins is just code where you're only exposed to an abstraction
not much different from normal code
learning them takes time as they are all a bit different in terms of design and depending on what the api is for
basically it's just being able to add events from other plugins to my plugins?
there's no general way to suddenly fully unlock knowledge for every api that presently exists in this world
hmm
to some extent
... can you access other plugin handlers ?
but like an api is a very foggy term
what sort of handlers?
think they mean custom event classes provided by other plugins
event handlers?
event handlers in this case
As in event listeners or the event handler list in an event class?
Bukkit::createWorld which takes a WorldCreator, so look at that if you wanna create a world
okok , thanks :p
i think i'll just jump into it and see what happens haha
might be worth doing it eagerly, as soon as the server starts since creating a world can lag a bit
Tasic thing is, a mere Java class alone can be seen as an "API" from the view of other classes
either; seems like a bad idea allowing an unassociated plugin to commander another plugin
It could be useful so not that bad of an idea - just depends on the circumstance
that is true also
Do you want to spoonfeed a block change to a specific block logging plugin? This is one way to do it without using their API
But it should be possible to do
@ivory sleet hey if im trying to keep a json in memory for quick access of a lot of data moving arround consantly, is it better to use normal json for example:
https://pastecord.com/viqahisaqo.cs that would generate the image, or learn gson and use that instead?
those are not normal
but mainly those
they are not contained within the java library itselfg
those are from a dependency
what is the name of that dependency?
anyhow yes I would strongly encourage learning gson, or jackson or moshi, those three are the ones most devs out there use in fact
so being knowledgable in those particular three wont harm you
com.google.gson.JsonObject
thats gson
you're just using an arguably legacy way of dealing with the json tree structure
and by any chance do you know which one i should use if i want a lot of data moving around efficiently?
otherwise im gonna google a few things
When using saveResource("example.yml", true/false);
What does the true/false do ?
replace eixsting
Liver failure
Constant state of failing liver
igh thanks
Or is it kidneys
poor vitamin and lack of exercise creating a storage of uric acid - ideally the whites of your eyes should have a blue tinge
My personal favourite for json parsing is org.json:json. But I am sure a lot disapprove here
it be kidneys and their condition if their eyes are yellow would indicate jaundice
oh, your just a mongrel đ
not aware of any health related things to iris color other than cataracts - oh and glacuoma
someone will still think you are pretty
...
ah you are one of the rare people then
So if there is for example
one:
test: false
two:
test: false
in the file thats already created, it wont replace them, but if it has new content thats not there, it'll add it, right?
no
it will overwrite the existing file if the parameter is set to true
and if it's false, it will say "could not save resource asd.yml"
Aha, understood.
only good use-case scenario is restoring to defaults if the file is invalid
but there are much better ways to do it
But can you like compare them somehow ?
you can read from the file, are you expecting them to be different?
What is the common way to show the user the list of the plugin's commands and syntaxes?
what are you trying to do?
make a help command that shows all commands? đ
doccumentation and a wiki?
Yeah that works, thanks!
Yeah but I meant more for the common server user
yeah you can dump em in the plugin.yml or use annotations
Wait but the help commands shows the description and usage of the command
How do I show the syntax?
what is a file pom.xml in plugins opensources ? i can add repository and dependency inside
comments of the response
it's telling maven how to build the project etc
sorry if i'm super dumb but i'm trying to learn đ
What do you mean?
If for example some values are not the same, replace them and keep the rest of the content.
Or would it be better to use a database for things such as creating mines and stuff?
ok so this is where I add the dependencies and libraries of my api or libs?
yeah
basically ur configuration file that maven uses to turn your project into a jar file
simplest terms
sender.sendMessage("Contributors are currently: " + plugin.getDescription().getContributors()); etc
Ah, and this I do where?
https://www.spigotmc.org/wiki/create-a-simple-command/ unless you want to use annotations, then its different
its a part of spigot
i currently am playing with using annotations now
I have a library for annotations to register everything 
yes it generates it's own plugin.yml looks like this for commands @Command(name = "contributor", desc = "Contributor Command", aliases = {"SAcontributor"}, permission = "QuadArrows.contributor", permissionMessage = "You do not have permission!", usage = "Only returns authors")
then you only need your CommandExecutor
..
i originally thought it might be that way too
//ab.addField("Cannot Retrieve Online Players..", "", true);
ab.addField(p.getDisplayName(), "", true);
}
else {
ab.addField("Cannot Retrieve Online Players..", "", true);
}``` in this code
oracle seems to have had other ideas
oracle?
Integer.parseInt(String.valueOf(1))
don't worry, it's commented out
when someone playing in my server like if 1 or more than 1 player is playing its sending embed message
but if no one playing its not sending any message
should i use this?
lol no
nonono
lol
annotations is at the base an oracle thing
what are you even doing
Yes, but nothing prevents you from acctually doing it like proposed
::isEmpty kek
It's not an oracle limitation but a plugin-annotations limitation
what should i do .-.
::isEmpty
Are you sure that the lines of code are called when there are no players online?
ok
Also beware that getOnlinePlayers can be inaccurate in some conditions
yes maybe cause when 1 player is playing its sending exact embed message i wanted
but when the player is less than one or noone playing its not sending any message
when?
Player being dead for example
ah
It makes sense given that there is no player entity, but under some circumstances it can be an issue
is possible to kick the person from the server if he refuses costum resource pack download
So you are not sure?
no
Just throw a few sysouts at it and check if it is called
trying this if (Bukkit.getOnlinePlayers().size() == 0)
1.18 has this natively
its a server option if i recall
ok
still same
are you sure this is called?
Maybe #isEmpty() might make more sense
It's not of relevancy
I forget what data type Bukkit.getOnlinePlayers() returns tho
Player most likely
Yeah but is it an array of players or List?
@fallen sandal Actually, could you just send the whole code?
Yeah then you can use #isEmpty()
mm
wait
and they were never seen again
why not just add/subtract from a scoreboard objective?
my internet sucks
Then using discord may not be the wisest choice
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.entities.MessageChannel;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.awt.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import static org.bukkit.Bukkit.getServer;
public class getonlineplayers extends ListenerAdapter {
@Override
public void onMessageReceived(MessageReceivedEvent event) {
if (event.getAuthor().equals(event.getJDA().getSelfUser())) return;
Message msg = event.getMessage();
if (msg.getContentRaw().equals("!onplayers"))
{
MessageChannel channel = event.getChannel();
for (Player p : Bukkit.getOnlinePlayers()) {
EmbedBuilder ab = new EmbedBuilder(); //Creates the embed.
String logo = "https://swapnocraft.com/favicon.ico";
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
Date date = new Date();
ab.setTitle("Swapno Online Players");
ab.setColor(Color.decode("#00aaff"));
if (Bukkit.getOnlinePlayers().size() == 0) {
ab.addField("No one Playing..", "", true);
}
else {
ab.addField(p.getDisplayName(), "", true);
}
ab.setFooter("Developed With Love By Akash :) " + formatter.format(date), logo);
event.getTextChannel().sendMessageEmbeds(ab.build()).queue();
}
}
}
}```
my dc was glitched lol
what
Your Bukkit.getOnlinePlayers().size() == 0 is called for every online player
yes
And if there are no online players?
ab.addField("No one Playing..", "", true);?
its in the for loop
Nope! It will never get called
ah
Are we allowed to limit the amount of IPs a plug-in can be used on?
I want to try and prevent paid plugins from being leaked, but am not 100% sure if spigot allows for this.
Whilst this is not going to stop everyone, it may stop people that donât understand Java very well
leakers will just remove that code
you can listen for InventoryClickEvent and InventoryDragEvent
cant i use else in anyway? .-
thats probably what is you are looking for
You can, just outside your for loop
I know they will, more looking to stop people sharing between friends
Could perhaps render plugin versions more than x versions out of date useless to slow the spread of leakers
so i tried moshi and gson, i dont fully understand whats going on and the docs and not that clear i think, so is using the legacy version of gson that bad? its my easiest option
I always say. Show me a plugin that has some anti-copy prevention and I'll show you a cracked plugin lol
it would be for a beta version of the server, so not that much usage
nah not bad
mm i think im gonna use that
but how to define the value of Player p outside the loop
if (players.isEmpty()) {
// Empty!
} else {
for (Player p : players) {
}
}
Would be how I would do it
ok
Unless you want to send that JDA message for every online player
At which point you just need to move the if statement over the for loop
if (players.isEmpty()) {
// Empty!
} else for (Player p : players) {
}```kekw
else for 
Incompatible types. Found: 'org.bukkit.entity.Player', required: 'java.lang.String'
oh god
that looks so cursed
I can of sth like else var x = 1; also
holy crap
ew
okay so
i had changed some stuff and made like the old one
// Empty!
ab.addField("No one Playing..", "", true);
} else {
for (Player p : Bukkit.getOnlinePlayers()) {
ab.addField(p.getDisplayName(), "", true);
}
}```
and its working what i wanted
thanks for help :))
how to add a potion effect to a monster please ?
Does anybody know how can I use javax.annotation classes? I'm using Intellij IDEA but it doesn't recognize the availability of these classes via maven dependency and the imports are shown as unavailable. How can I fix it?
thank !
thats a thing?
ye because you dont need brackets for an if else
o
if (true) { doSomething(); }
if (true)
doSomething();```
if (true)
doSomething();
else try doSomeException();
catch (Exception e) {}```
would probably work
spaces
good
without is horrible
yes exactly
Ctrl Alt L
doesnt do anything
formats the current file
Is it possible to have text both bold and underlined in a written book?
I have tried ChatColor.UNDERLINE + ChatColor.BOLD, but Java does not like that.
or call toString explicitly
That worked. Thanks!
i have a problem with an event etting called twice
can someone send me the ' thing cuz idk how to do it on italian keyboard?
so i send the code
xDDD
is there an event that triggers when a sound is played or when a player hears a sound?
mhh, i don't think so
never heard of it
also, would be quite difficult to manage
imagine that in a whole server like everything plays a sound, imagine mananing that xD
even if you had an event like this you wouldn't be able to detect what made it for the all things that makes sounds
what do you need it for?
I want to make a challenge for myself to hear all minecraft sounds
do you know if something like this exists in modded?
wait what
and you would to make like that every time a sound is played, you get a warning?
something like that?
@,@
well every time a new sound is played its checked off the list
oh
i don't think there is a way to do that
i also checked the event folder of bukkit do be 100% sure and there is no event for this
Forge has a client sound event
thanks for checking anyway
ok, onto forge then. thanks
hm
can you send me the ' thing

