#help-development
1 messages ยท Page 379 of 1
a bukkit discord exists?
ye
people still use bukkit to develop plugins?
Lol , just heard that discord exists
.
oh weird
wt
easy autocomplete
dont think u can link discords mate haha
haha
you can yes
DFS with compressed Tries works so good on autocompletion
ohh they blocked the term get bukkit
Atleast i used to sent many times the papi discord
ohh yeah haha
haha
nop, they blocked uris
also they removed the help commands from bot
?bing
Bing your question before asking it:
https://www.bing.com/
Google your question before asking it:
https://www.google.com/
?firefox
bing 
agree, ๐คข
?yahoo
Yahoo your question before asking it:
https://search.yahoo.com/
LOL
?opera
๐ญ anyone know where I can atleast go to fix my issue, havent been able to compile in weeks now
do you guys name packages in plural or singular form?
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
like utils or util
utils
utilities
for me
java uses util afaik
asked a little bit ago
they do
technically whatever you want but than you get yelled at by 4 big guys
oh right, just realized
that discord name sounds from somewhere
is there a way to make an hashmap return the values by their "added" order?
HashMap doesnt keep order of values added
you gotta make a array whenever you add it
well, i kinda knew that
kinda sounds like ur looking for a queue
just asking in case there was some function that does make it happen
if not, all good
i will just make an arraylist of the order of keys i want and then display them
oh right, not being rude i suggest reading about different java collecitons if you want to learn more about them
LinkedHashMap should do it if u need a hashmap
There are many types, for example HashMap, HashSet, ArrayList, Queue, etc
even in CPP we have std::string iterators
LMFAOOOO my first message
why java does not have those wtf
oh ok, ty. will look into linked hashmaps then
use the char array
Also give some time to read about all JAva colelctions in general, is pretty useful to learn about them
I've been compiling with that profile for years, havent had any issues till now
i know how java works, just not sure about every single small detail
No no, i mean all the collections types
I didnt mean whole java
never before needed to have a linked hashmap compared to an hashmap
knowing many collection types is a pretty big part of java tho
choosing the right collection is a big part for performance for example
is there a player right click event?
interact
PlayerInteractEvent, then filter for rightclick
The event fires once for both hands afaik so just make sure its the hand you want ๐
The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.
For example, only executing code if the main hand was used:
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
return; // do not progress past this point |
}
// provide functionality
}
whoa
okay
thank you
if (event.getHand() == EquipmentSlot.HAND) { // * if the hand used is the main hand:
oh wait that code did what I wanted ill just copy that lol
does minecraft server uses only one thread?
does minecraft server uses only one core?
'return' is unnecessary as the last statement in a 'void' method
is that a glich?
or just should I put else{
uh oh , i think i made the hashmap but i get lots of errors
no u probably just dont have any code after the return statement (yet)
u should look into tutorials on how to code java
return at the end with nothing below is useless
this said return
ye
so ill remove the return
idk whats hard to understand its very simple
guys wish me luck
i wish u luck
cooldown
i tihnk this will work
it did not
well can i see what ur doing? ๐
yeah
coding on your phone might be easier ๐
lol nope
or that
?paste
bruh
i would love to buy raspberry pi
but I am too much fearful to look at my bank account lmao
i usually just take the chair but eh
i mean they not that expensive right?
idk tbh
good joke
just use your old pc if u have
how to correctly center scoreboard entries? https://i.imgur.com/YoVQEKz.png
what does ultimate does on intellij
energy bills go brrr
im a student
i pay bills
im a student
quick question thats not for the gui, plugin.getConfig().getStringList("Bans").add(event.getEntity().getUniqueId() + "");
doesnt add it to the config
tbh ur better off just buying a 2 dollar server from pebblehost or something
oh wait I prob have to savei t
yah, but sending the jar is like hell for me
reruning the server takes more time than on pc
why dont you vscode. its working fine if you are not working with gradle
i coudlnt set it up
why
didnt work
lol my client + 1gb ram server uses my 95% ram
it works now bro Thanks alot!
but ofcourse ๐
but now i need to learn from my code, i mostly copied the hasmap stuff
now that u understand it i could show u a little util i made ages ago
maybe it will be usefull to u
yeah it can be i will read it
the idea may sound stupid but using a python script or something to monitor file updates and upload it to ftp server automaticly is an option too lol
basically when I add the players uuid to a strnig list in the config it doesnt work. anyone know why?
thats would be good
55 155 170
i know python enough to make something like that
it worked with a arraylist idk why it aint workign with a stringlist
ur getting the string list @wary topaz
?
when modifying that list it does not modify the file
u gotta get the list
modify the list
ohhh
set the list
arent u using default config?
Thanks alot for help everyone im going off for today
ur alrdy doing getConfig lol
so why aint it working
pretty sure u have to do something like saveDefaultConfig in onenable or somethn
public void onEnable() {
// Plugin startup logic
saveDefaultConfig();
new everything(this);
}```
never rlly worked with this config system from bukkit
already done
well then it should be loaded fine
is it because im doing saveconfig and not savedegfaultconfig in the everything class?
i mean i dont think adding to getStringList () response will work
ye told him that here
i added a "" so it thinks its a string
isn't it just a new object, why would it update config
show ur new code
bruh its the same
what did you want me to do?
List someList = getList
//modifyList
config.setStringlist(bla, list);
saveconfig
setStringlist is not a thing
is it not?
nah
is weak hashmap good for caching things?
yes
FileConfiguration cfg = plugin.getConfig();
ArrayList<String> abc = cfg.getStringList("thing");
abc.add("test");
cfg.set("thing", abc);
saveConfig();
try this
Hello everyone,
List<String> abc = cfg.getStringList("Bans");
abc.remove(p2.getUniqueId() + "");
plugin.saveConfig();
plugin.getConfig().getStringList("Bans").remove(p2.getUniqueId() + "");
plugin.saveConfig();
queueforfix.add(p2.getUniqueId());```
hi
i changed it to a list
cause a stringlist aint a array
list is immutable afaik
why u saving twice now
immutable means you cant change it
oh i was gonna delete that one
Incompatible types. Found: 'java.util.List<java.lang.String>', required: 'java.util.ArrayList<java.lang.String>'
I had a question about some plugins I have. Any plugin that has a gui does not work all of a sudden. For example, when using my /shop plugin I am able to keep the items that pop up instead of going to the pages. This is happening with all my guis. Is there an easy fix for this?
what version spigot u use
1.19.2
check your clickevent for yoru inventory
okay i will
What is the point of squaring the distance before comparing it. Is it to ensure no negative numbers if you get what I mean?
then don't answer lmfao
Why this two task eaving doing the same exact thing and working in the same exact why one is throwing and error for the forEach loop? https://paste.md-5.net/xodimesasu.cs
^
the top one could probably throw it as well
u should use #removeIf instead of foreach
unless thats a hashmap isnt it
found this snippet from the CraftBukkit implementation. ```java
Entity nearestHitEntity = null;
RayTraceResult nearestHitResult = null;
double nearestDistanceSq = Double.MAX_VALUE;
for (Entity entity : entities) {
BoundingBox boundingBox = entity.getBoundingBox().expand(raySize);
RayTraceResult hitResult = boundingBox.rayTrace(startPos, direction, maxDistance);
if (hitResult != null) {
double distanceSq = startPos.distanceSquared(hitResult.getHitPosition());
if (distanceSq < nearestDistanceSq) {
nearestHitEntity = entity;
nearestHitResult = hitResult;
nearestDistanceSq = distanceSq;
}
}
}
No it isn't
no
its easier to calculate squared value
than taking a square roots
square roots are a bit expensive
Can you give me an example on how to use it, the last time i tried it didn't work so i don't know what i did wrong
what collection are you using?
but why would you need to compare the distance squared instead of just comparing it as is?
its a nifty hack that you can use whenever you dont need the actual distance
A Map
its faster to check squared value than square root one
because of negatives?
yea map does not have removeIf
but you wouldnt need to get the square root? you could just compare as is?
distance is
sqrt((x2-x1)^2+(y2-y1)^2) right
the thing is you dont need to take a square root
to detect how distant he is
he can take the square root on his calculator
and make a value defined to the square
How should i fix it?
distanceSquared = 9
if (distanceSquared == 9)
is faster than
if (sqrt(distanceSquared) == 3)
its a hack
ooh. because location.distance() uses square root?
yes
but you see
if you need real distance this wouldnt work
because your returned value is squared
its just a way to bypass square root calculations
yes but for comparing its perfect?
yes
Map<Block, Long> map = getmap;
Iterator<Block> iterator = map.keySet().iterator();
while (iterator.hasNext()) {
// ur conditions
iterator.remove(); // remove the entry
}
using a iterator should fix it
cuz you are doing concurrent modification
anyone know how I can change the angle on a spawn entity with protocollib? I can't seem to work it out, it mentions a float but I am unsure whether that is what I actually want?
Please i need your help im fucking stucked, trying to make a cusotm menu editable i cant code the proper logic for it
register your listener?
to speed up calculations by avoiding Math.sqrt()
its not even annotated with @EventHandler ๐
eh well it happens
Server#getPluginManager().registerEvents(JavaPlugin, Listener);
take jree fava lessons from me
(checkmybio)
what is the raySize argument in World#rayTraceEntities?
is it the "thickness of the ray"?
?jd-s RayTraceResult
wish that worked like that
wasn't there a fucntion which did this thing
not that i know of
oh i see
and ?jd-s
I dont think the answer I am looking for is in the result class?
^ ?
should be World
my bad
?jd-b
?jd-bc
ez
Found this in the docs: raySize - entity bounding boxes will be uniformly expanded (or shrinked) by this value before doing collision checks
but I dont really get what its supposed to mean
idk test this
smth like ray thickness
its a multiplication factor of the box size?
so it can hit bounding boxes
even if the point is missing
niice lol
alright but would it not be more efficient to just make the ray bigger?
there is no real ray
Check the observer pattern.
I know
so no
oh wait nvm whoops
so in theory the "ray" is infinitely thin right?'
and calculate for each ray
yes
i mean at that point isnt expanding the box way more efficient?
i feel like thats not all that expensive
is raytracing and raycasting the same thing?
if you have a thin ray
Nah
you need to calculate new point for each ray vector
whats the difference
using sin and cos
Watch youtube
and then check if this exact ray hit anything
not really the answer I was looking for
Nobody gonna give deep info
cuz thin ray is a cone
this is a pretty good explaination
but why is the method called rayTrace then. Its not recursive?
i have no idea
its a bit confusing
welp, thats one way to confuse the developers
probably just due to alot of people thinking its the exact same thing
Raytracing is technicaly a foton(light)
no, how?
or maybe cuz rayTrace() is using recursion, but not related to the picture
just to move the point 0.00001 xyz and check if it finally hit something
and if distance reached the limit, return null
Like light can be reflected.
is it really that accurate?
seems like a good way to crash ur server to me
well, raytrace should have distance
so method doesn't endlessly repeat
and some kind of length
Yes, but its not necessarily the same thing
on which the point moves each recursion step
well still
like if you are on 0,0,0 and looking forward, and raytrace
I checked the implementation and it turns out the ray is actually a boundingbox
its called that cause its called that
hello md5
hi md_5
kinda small ig
i mean good point eh
can you send a link/screenshot
i usually used like 9999% weirder formula
to get the target
lemme find
from the CraftBukkit implementation:
@Override
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, Predicate<Entity> filter) {
Validate.notNull(start, "Start location is null!");
Validate.isTrue(this.equals(start.getWorld()), "Start location is from different world!");
start.checkFinite();
Validate.notNull(direction, "Direction is null!");
direction.checkFinite();
Validate.isTrue(direction.lengthSquared() > 0, "Direction's magnitude is 0!");
if (maxDistance < 0.0D) {
return null;
}
Vector startPos = start.toVector();
Vector dir = direction.clone().normalize().multiply(maxDistance);
BoundingBox aabb = BoundingBox.of(startPos, startPos).expandDirectional(dir).expand(raySize);
Collection<Entity> entities = this.getNearbyEntities(aabb, filter);
Entity nearestHitEntity = null;
RayTraceResult nearestHitResult = null;
double nearestDistanceSq = Double.MAX_VALUE;
for (Entity entity : entities) {
BoundingBox boundingBox = entity.getBoundingBox().expand(raySize);
RayTraceResult hitResult = boundingBox.rayTrace(startPos, direction, maxDistance);
if (hitResult != null) {
double distanceSq = startPos.distanceSquared(hitResult.getHitPosition());
if (distanceSq < nearestDistanceSq) {
nearestHitEntity = entity;
nearestHitResult = hitResult;
nearestDistanceSq = distanceSq;
}
}
}
return (nearestHitEntity == null) ? null : new RayTraceResult(nearestHitResult.getHitPosition(), nearestHitEntity, nearestHitResult.getHitBlockFace());
}
this one with dot
but changed to entity
and target location to
entity location + entityHeight/2
so perfectly the middle
this is probably more effective though no?
idk, never tested
efficient sorry
only used dot
depends on ur needs
tho this dot > 0.99D
Is making a cone
so if you are trying to get entity in like 200 blocks away
you can hit several entities
yes
where the point is your eye
and dot is the circle
it is
and how is that makign a cone?
you use .dot()
which is simply checking how close the point is to the target point
and as long as the target can stand higher/lower, to the left and to the right
the search area is circular
cuz distance is measured with sqrt(x^2 + y^2)
aha thanks
well iirc the dot does this
just gives you a double representing distance
if you set it to 0.01, it will be very precise
Please i need an explanation why my optional is not getting present, if the menu inventory is exactly the same
Im using the next codes
@EventHandler
public void onMenuClick(MenuClickEvent event) {
Player player = event.getPlayer();
Optional<Menu> optional = previews.getPreview(event.getMenu());
if (optional.isPresent()) {
Menu menu = optional.get();
player.sendMessage("[Editor] Editing menu " + menu.getTitle());
if (!player.hasPermission("escaparate.preview.edit")) return;
menu.set(event.getSlot(), new Button(event.getItem())).update();
player.sendMessage("[MenuClick] Menu " + menu.getTitle() + " has been updated!");
return;
}
event.setCancelled(true);
}
public Optional<Menu> getPreview(Menu menu) {
return getPreviews().stream()
.map(preview -> new Menu(config.getString("Menus.Editor").replace("%display%", preview.getDisplay()), config.getInt("Menus.Rows")).set(preview.getContent()).update())
.filter(preview -> preview.getInventory().equals(menu.getInventory()))
.findAny();
}
lez go
mafs be like
List<BanEntry> list = (List<BanEntry>) event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries();
How can I convert tihis to a array list?
mafs?
ArrayList<BanEntry> list = event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries();
Incompatible types. Found: 'java.util.Set<org.bukkit.BanEntry>', required: 'java.util.ArrayList<org.bukkit.BanEntry>'
aah
oh that's a set
yaeh
.toList()?
var arrlist = new ArrayList<BanEntry>(event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries());
ArrayList<BanEntry> list = (ArrayList<BanEntry>) event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries().stream().toList();
tf is var
new ArrayList<>(whatever)
java 13 ig
So im having issues with my code, because is cancelling the event. While it must be joining inside the optional is present
what is this?
Dynamic variable?
no it's not
So how?
ok
for (int i = 0; i < list.size(); i++) {
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD,1);
ItemMeta playerHeadMeta = playerHead.getItemMeta();
playerHeadMeta.setDisplayName(list.get(i).getDisplayName);
}```
Cannot resolve symbol 'getDisplayName'
it doesnt?
can you get player from ban entry?
forEach((player) -> {}) instead
How can it get the name than
event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries().forEach(e -> {
// your code
});
mm no
you can use an enhanced for loop
I hate List#forEach
It's pretty much worse in every single way
How can I do that?
for(Object whatever : myCollection)
alr
or yeah, use ^^^
ty
i only love it when you can use a method reference
I use List#forEach() idk why hate.
cuz imlusion
wait what is the object "whatever"?
its a name...
variable name
It's a for loop wrapper that forces you to create an anonymous class
you gotta make sure your collection is not null and you can't modify external variables
Inventory bannedplayers = Bukkit.createInventory(event.getPlayer(),45,ChatColor.BLUE + "List of banned players!");
var list = new ArrayList<>(event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries());
for (Object whatever : list) {
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD,1);
ItemMeta playerHeadMeta = playerHead.getItemMeta();
// playerHeadMeta.setDisplayName(list.get(i).getTarget());
}
}```
and yes this is for debug ill add the item later
wait what
you are not creating an anonymous class with that
Please learn java
you are
???
lambdas are anonymous classes
public void onClickReviveToken(PlayerInteractEvent event) {
if (event.getHand() == EquipmentSlot.HAND) {
Inventory bannedplayers = Bukkit.createInventory(event.getPlayer(),45,ChatColor.BLUE + "List of banned players!");
var list = new ArrayList<>(event.getPlayer().getServer().getBanList(BanList.Type.NAME).getBanEntries());
for (Object whatever : list) {
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD,1);
ItemMeta playerHeadMeta = playerHead.getItemMeta();
}
}
}```
isn't that an anonymous fucntion?
cuz anon classes have new everytime
oh i see
sorry
() -> {
...
}
is the same as
new Runnable() {
@Override
public void run() {
...
}
};
Player::remove is the same as new Consumer<Player>() { void accept(Player player) { player.remove(); } }
only if you have
method(new Runnable() {
})
Ah yes, syntax sugar.
but yeah i just read oracle documentation
a lambda compiles down to the same thing as an anomymous class
nope
just invokedynamic stuff
they're more compact to write but compiles to the same
Vector startPos = player.getEyeLocation().toVector();
Vector dir = player.getEyeLocation().getDirection().normalize().multiply(8);
BoundingBox ray = BoundingBox.of(startPos, startPos).expandDirectional(dir);
Collection<Entity> entities = player.getWorld().getNearbyEntities(ray);
``` will this collection be sorted from first to last entity?
Does bungeecord plugins, works on velocity?
50/50
What does that mean?
50% work 50% wont
No
I've use default JDBC driver than use any sql libs.
this uses jdbc underneath ??
Yea english still broken ๐ฆ
but makes tables n all for me
anyone know if World#getNearbyEntities is sorted in some way?
Are you planning in future use annotations over Class properties to create table model?
hah, well just checking if there is time to be saved
check stash
Test it
Please i need help, for some annoying reason my menus are not matching, but i dont find the reason!!!!
@EventHandler
public void onMenuClick(MenuClickEvent event) {
Player player = event.getPlayer();
previews.getPreviews().forEach(preview -> {
Menu menu = new Menu(config.getString("Menus.Editor").replace( "%display%", preview.getDisplay()), config.getInt("Menus.Rows"));
menu.set(preview.getContent()).update();
if (!menu.getInventory().equals(event.getMenu().getInventory())) {
player.sendMessage("[Editor] Menus doesn't match");
return;
}
menu.set(event.getSlot(), new Button(event.getItem())).update();
player.sendMessage("[Editor] Menu " + event.getMenu().getTitle() + " has been updated");
});
event.setCancelled(true);
}
For some reason, my code is cancelling menu edition in all the menus, when must no cancel it on editor menu
uhh
I cant find the reasons tho, i know its something to menu comparing. But the menus have the same title, same rows and same items, so it must be not returning
Because this return is not related to onMenuClick but to forEach lamnda function
oh that makes more sense know
instead of foreach(preview ->{}) try for(var preview : previews.getPreviews())
right
How would i check if a string is an item?
Why?
ive found the isItem(), but cant get it to work...
Sign shop
Hmn
Sorry if this is a stupid question, but what would happen if the server crashes / closes during a scheduling?
An exceptions is throw, telling you that the schedule id: x couldnt be run
So if I make it so that when I mine a stone block, and I set the stone to bedrock for 10 seconds when broken, would the block still be bedrock when the server opens.
Save on shutdown
Collection<BanEntry> bannedPlayers = allBaned();
Iterator var11 = (new ArrayList(bannedPlayers).iterator());```
What's wrong with my iterator?
public static Collection<BanEntry> allBaned() {
return Bukkit.getBanList(BanList.Type.NAME).getBanEntries();
}
What are you trying to do?
Make a gui with all the banned players
Just use a for loop???
I doubt you should be making an inv with the player as a holder
the getbanentries returns a list
Yeah
You can use one anyway
How would I implement it?
No one knows this?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
;-;
I actually agree with Nazar here. I prefer writing raw SQL. I feel like I have more control and abstraction libraries always feel far clunkier. I refuse to use ORMs too. I hate them with a passion.
What does string is an item mean
I want to check if the string is an item, like in adminshop/signshop
If you know what i mean
What string
A line on the sign
A line on a sign
You can match the string to the material enum
If you want to check whether or not it's a valid material, you can use Material#matchMaterial(String) and check if it's not null
Ohhh, use get or match material, witch ever throws an exception on none found or check for null
Then do an additional Material#isItem() check to make sure
Aaarh okay i see thanks
Same issue, for some fkg reaon none of them are matching
List<BanEntry> banEntries = new ArrayList<>(Bukkit.getBanList(BanList.Type.NAME).getBanEntries());
for (int i = 0; i < ; i++) {
ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD);
ItemMeta playerHeadMeta = playerHead.getItemMeta();
playerHeadMeta.setDisplayName(banEntries.get(i).getTarget());
}```
Instead of gettarget, How can I make it return a display name?
is it possible to make a plugin that stops operators from doing commands?
Yes, listen t CommandPreProcessEvent and get the sender, check is operator
so i can stop admin abuse
yes
Oh god
How about
You add a permission plugin
ebic ebic dont you dare
What does get target return
Are u currently busy?
Hover over it
For some reason im looping over all the previews i currently have, and none of the inventory are matching, not matter if they have the same content, title and size, Im really messed right now
Could you show us the code?
Well... you need to match them differently. Not by .equals()
For this i need a list of materials or am i stupid here?
is it 46?
For example:
Map<Preview, Menu>
should't be return instead of continue?
N * 5 will always end with 0 or 5
Material is an enum with that method
right owuld test that
In which case you dont need to iterate anymore
yeah you are right
If there is more code after the loop that should run i think it should be break
Arh okay
But i have the same issue
Because i dont know the previre obj neither
๐ค
The MenuClickEvent should contain the Menu that has been clicked. Otherwise this event is useless.
oh im a stupid
You are right
Hahaha
Collection<Entity> collectionEntities = player.getWorld().getNearbyEntities(ray);
ArrayList<Entity> entities = new ArrayList<>(collectionEntities);
Collections.sort(entities);
``` intellij is yelling at me saying `reason: no instance(s) of type variable(s) T exist so that Entity conforms to Comparable<? super T>` is it actually a problem?
You need to define by which property you want to sort your entities. Sort by health, by distance to an object, etc.
For that you need to implement a Comparator<Entity> and pass it to the sort method besides the List.
The implementation can be an anonymous class.
Do I just return a number value that they are to be sorted by?
Here is an example which sorts the list by the height of each entity:
List<Entity> entityList = new ArrayList<>();
Comparator<Entity> heightComparator = new Comparator<Entity>() {
@Override
public int compare(Entity e1, Entity e2) {
return Double.compare(e1.getHeight(), e2.getHeight());
}
};
entityList.sort(heightComparator);
This is a simplification:
Comparator<Entity> heightComparator = (e1, e2) -> Double.compare(e1.getHeight(), e2.getHeight());
And this is the most compact way (But harder to read):
Comparator<Entity> heightComparator = Comparator.comparingDouble(Entity::getHeight);
Yes. Sorts happen by ints returned by this method:
@Override
public int compare(Entity e1, Entity e2) {
return ...;
}
return 0 -> objects are equal
return negative -> e1 is below e2
return positive -> e1 is above e2
What sorting algorithm is that?
is there better more optimalized way to repeat string x times? @Override public TextBuilder repeat(String text, int length) { for (; length> 0; length--) { builder.append(text); } return this; }
Should not be important to you.
This approach can be applied to any sorting algorithm.
But it uses some form of quicksort.
Just looked it up: Uses mergesort
Native arrays use dual pivot quicksort since java 8
Interesting they also change the sort algorithms based on the size of the underlying array.
Anyways that should be irrelevant here. Any sorting algorithm will do just fine.
Yes
public TextBuilder repeat(String text, int length)
{
builder.append(text.repeat(length);
return this;
}
thx
How can i check if my custom config is empty? I need to create starting sections, when it's created first time
Get values and check for isEmpty
is there a a way to implement a URL returned valued inside an async?
Example:
private String returnedValue(String url) {
new BukkitRunnable() {
@Override
public void run() {
return new URL(url);
}
}.runTaskAsynchronously(PluginMainClass.getInstance());
}```
i dont want an URL connection to lag the server
if not, i have a way to do what i want without that
just curious
You can do it in a new thread
Creating a new URL does not lag anything. If this opened a connection then it would be a side effect in a constructor.
That would be really bad.
its to get the texture of a players skin
I would use a CompletableFuture for that
Let me think if there is an easier way.
But CF is basically the gold standard for such a thing
@brave sparrow didn't you say you were working on a jar loader?
Yep
Example i just made up:
public void tellPlayerHisKills(Player player) {
UUID playerId = player.getUniqueId();
CompletableFuture<Integer> future = requestKillsFromDatabase(playerId);
future.thenAccept(kills -> player.sendMessage("You have %d kills.".formatted(kills)));
}
public CompletableFuture<Integer> requestKillsFromDatabase(UUID playerId) {
return CompletableFuture.supplyAsync(() -> loadKills(playerId));
}
private int loadKills(UUID playerId) {
// some DB action...
return kills;
}
Smile, i have been 1h more checking and same fucking issue
I dont udnerstand the reaosn and im getting up to rage about fucking api
Show your whole mess pls
yess thanks!!
thanks a lot ๐ค
https://paste.md-5.net/vovaxokare.java - Main listener
https://paste.md-5.net/itixeqehaj.java - Handler
For some reason, literally none of the menu works now
All this shit happens becaue i havent code my own and custom api
Never write getters or setters for any collections or other data structures
Thats No. 1
Okay. Is it just for loading a jar or does it do other things?
right, i just want to fix this, and then refactor code
Anyways lets see what we got here
right really thanks man i have been whole afternoon with this shity๐
Also i forget these code, where i create the editing menu
Its prety simple hat i need to do, but cant figure the right logic
Btw the standard for this:
if (!optional.isPresent()) return;
Is this:
if (optional.isEmpty()) return;
Because fucking menus doesnt have a way for tracking them
Still reading
what stashrepo is the implementation of the thing that calls PlayerInteractAtEntity event?
bukkit
Im really confused about menus
I dont know why they didnt add a fucking traccking system, something like a unique id or name for traccking
but the implementation is craftbukkit some place?
This is the implementation
where in the code is the event called?
Im still trying to put the pieces together. There is a lot of very weird code here...
Like this
wtf?
Where do you even add your menu and preview in the map?
On the edit command
I need more code. Is this on github?
If you have such a method:
Then you should never, ever create a Preview somewhere else.
Same goes for Menu
Those need to be removed
i want to test quickly my base classes for my command api
is there any way to use onCommand
to listen for all commands
?
its only for a temporary checking to see how my dispatching abstract classes work
or should i listen to event?
Not sure what that even means...
there is an event
Alright? And you want to do what with this?
commands require to get commandexecutor set
is there any dirty way to make this work for all the commands/inputs
without registering it
via getCommand()
Yeah, dont do that. Listen for the CommandPreprocessEvent
ik, im just testing my abstract classes too see how internal my custom dispatching work
before i would begin to properly integrate it into bukkit plugin
what about using MockBukkit framework for unit tests?
usually for tests u probably just wna unit tests ur own components, and then integration tests which mockbukkit could help with
" internal my custom dispatching work" by this I understand own components with custom logic
i have divided my gradle into two subprojects
core and bukkit
to separate bukkit and generic logic apart
i have designed simple classes inside core subproject
and i want to do simple impl for bukkit for it
anyone know how PlayerInteractEvent.getClickedPosition() is calculated?
does core project use classes such as Player or its pure java?
Pure
I didnt use any interfaces regarding the bukkit api
even if u use stuff like Player
just mockito or mock urself
unless u need greater emulation of the impl of Player
in which its almost an integration test, thus mockbukkit :>
sadly there is not framework now for integration tests with bukkit ;< I hope someone create it
what's mini? I can't find that one in google
thanks
I guess that's even better, seems to be easier to use in CI\CD
Right, and what should i use so?
mutators and accessors
right, but that wont fix my issue
I need more code then
i managed it to work on bukkit
but its so raw and codesmelly rn
it doesnt support tab completion and other neat stuff im going to implement in the future
anyone know how to add support for vault permissions?
Itโs for dynamically loading extensions to plugins from standalone jars or from other plugins
I've made Jar loader myself too
all you need is some reflections to instanciate the main class
and URLClassloader to achieve that
What more code? Can you specific more?
Busy right now. Trying to get multi block objects for this working and its a bit complicated...
hmnn right
I will have to fix this shit in my own so, because i need to finish it haha
But thanks
anyone know the vault support discord
cant figure out how to add vault permissions to my plugin
like make a new permission provider or whatever
oh and don't use Vault#has to test permissions, as all that does is query Bukkit. Use Vault#playerHas
it tells you straight on Vault github how to use it
vaultapi or vault
api
Does someone have an idea? 
Yeah itโs not all that hard to do
Iโm just making sure it has a decent API
It's probably better to send relevant code
anyone know why it wont convert the enchant to the vanilla name correctly?
code https://paste.md-5.net/worivagufu.js
log https://paste.md-5.net/oserutawox.css
?
patient! This is a community all people helping are volunteers, so you cant expect instant help
Sorry if sound rude, but that the reality of asking for help in community discords
Sorry my bad! not my intention to come across like that
This line Enchantment enchantment = Enchantment.getByKey(NamespacedKey.minecraft(enchantmentKey.toLowerCase())); is not finding an entry for durability under the minecraft namespace
thank you, i've switched up how i'm saving the enchantment name
using getKey().getKey() instead of getName()
sorted thanks
getKey().getkey() ???
yes
getKey and getName are each part of the Keyed
Weird convention
just all depends how he wants entries in his data to look
tbh i'd rather just the vanilla enchant name without 'minecraft:'
which getKey().getKey() gives
I finally moved to a menu api, but i till cant fix the issues related to the menu editor and preview, for some fkg reason im till able to modify both of the menu, or not being able to modify any of them
Menu api currently using: https://triumphteam.dev/library/triumph-gui
Current code im using: https://paste.md-5.net/kafipibuqo.java
Its really weird this issue
And i have read their docs and all some seems correctly
Starting from that menus title are differnet, so there instantly the inventory objects are not the same to be overriten each other
when i typing Material.item then cpu usage is 100% help me

๐ค
Also, is Material.item a thing?
Material.OAK_DOOR, Material.AIR , etc every item
That cant lang the sever
Also you never gived any test, rather nothing
To see us what or how did you even ge ttha conclusion
I think he's talking about his IDE, not the server.
oh righ
yes ide
how can i solve this problem?
CPU limiter?
There's no reason it should be using that much
just let it happen
yes there is, the Material class is a fuck
Sure but not to max a cpu
all fun and games until you do a new Player()
Oh have you tried that, it broken servers with that thing
They are not spgiot modules
In that example specific, they are maven modules
Buth you java modules and gradle or maven modules, they are for different things
Now choco can give you a better explanation
When you have a module-info.java file you're dealing with Java 9+'s Jigsaw modules, which Bukkit doesn't support (nor does it really need to)
so choco, the way to go are maven or gradle modules
I see them every once and awhile on github
they using maven or gradle modules
In your example, they are built over maven modules
But you can do the same for gradle too
Oh didnt know, that bukkit didnt support Jisawg modules. Now i have learnt something new
Yeah, Maven & Gradle modules are a completely different concept. They're pretty much just subprojects
Some fast questio nnone related, what event should i use for allowing items to get moved in custom inventory ?
Like would work an editor
InventoryClickEvent? ... Not much else you can do
Hmn
I tried but didnt sucess
I now moved to menu api haha
So i skip all that issues
Triumph?
decent choice
Now just need to fix the issue with the editor menu
Because items are not being aved
So i need to listen to click event right?
What are you trying to do in the first place?
Allow the menu to being modfied
Like you will do with a kit editor, where they provide you the kit and you can move the things, etc
Ok but for this you need to know if this is viable for this GUI library.
Do you need a live update of the gui changes on other opened views or
do you only need the changes to apply when the gui is opened the next time?
All works perfect, the issue is with saving back the edited items into the preview object
Final code, i just written to test
Update the preview on the close event. Not every time someone clicks around.
oh ok
but how i would know the items on close event?
nothing im an idiot
I just need to get the gui items and save it back
Omg why the inventory is not a fucking hash map
๐ก
What? What would the key be?
Map<slot, itemstack> ๐ค
So an array. Just worse.
why an array?
now i have to do an ugly for int, to get the itemstack ๐
getContent() returns an ItemStack[]
Which works exactly like a Map<Slot, ItemStack> would work.
yes but [] is not complete as Map is, if we compare map already allow to get them by key

Alright you got something in mind. Youll manage
but right the logic is true?
I need to get the inventory content on close, that we can agree tru?
Yes
Oh i didnt lose anything. Worked 3.5h on both my projects. Thats my daily goal.
oh pretty nice
Once i finish this i would fast start with the menu api, so then i dont depend on 3rd parties and dont have this isuses
Oh yes. This sounds like a Verano idea...
hahaha
I really like how people laught at me but i dont care because once everything works well, then i will laught haha
Why do people make fun of Verano?
I mean, what's wrong with doing your own library?
I always asked my self that question but must be because of my actitue
Yeah it would be better using custom libraries
Take as an example Imliussion he has many custom libraries, and none laught at him
bro what
why ain't this working
whoops
my main pom: https://pastebin.com/JH70FuZ0
my 2nd pom: https://pastebin.com/uk2F5Ghu
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
You should write a gui library first. You will have giant mess and be confused again if you first write a use case with another library.
What do you mean by "select"
First of all: The parent project should not have any code in it
huh?
Delete the src folder in your top project
in the API module? or the bottom one
yeah i was going to point that, the parent project should not contain any code
This is how the top level structure of a multi module project should look like:
okay so, how would all of this work? Sorry for being that guy but like how would the plugin work without an src in the main path
Let me explain with a structure
ty

