#help-development
1 messages · Page 787 of 1
As I understand it, you need to change its state to the desired one during placement so that the texture of the block changes?
states are like changes, and with changes means a way to convey that visually. Not all states are visually represented
therefore you can make use of them, even more so when there is unused states to be used 🙂
hm this cool i gess
but I guess the states are strictly limited
spawnerBlock with an entity, is it just a block or also an entity?
I heard ItemAdder uses them
for textures
its a block
but also an item if its in the eventory
you mean listening to it?
or you mean when its thrown?
its async because netty threads you know
So it's invoked from the netty threads?
what?
yes
the event is called from a network thread not the games main thread
hence your logic in your listeners for AsyncPreLoginEvent is invoked on the respective network thread too
I just asked whether it was one or many threads
implementation detail
for most server implementations, multiple threads are used tho
you can block the pre login event just fine if that is what you are asking
other players should be able to connect just fine
it depends on how many netty threads there are, by default there is 4
so you can in theory have that event fire at the same time 4 times
but its one of the few events as lynx said that actually happens outside of the game loop
I'm asking whether I'm working in a multi-threaded environment
Given that there is a main game thread and at least one netty thread, yes
I already got the answer
perfect
"yes"
If I recall correctly they aren't only if comparing user to virtual threads
virtual threads aren't really a thing in the JVM yet, iirc they are still in preview ?
oh wait no
they were finalised in 21
What
Wait
Then how come
A server have like 52 java threads
With only having like 16 physical ones
what
platform threads can exceed the core count ?
its just that the OS scheduler deals with them
instead of the JVM itself (which is the case for virtual threads)
I really don't know whether you're asking or being annoyed
(not that plain java threads are typical OS threads, more of a JVM implementation detail as to what it ends up being)
The OS has a scheduling strategy which lets the pyhsical threads work on any OS threads + the OS itself.
Sometimes this means the physical thread actually jumps between two os threads every few micros/nanos for just
one or two instructions (At least in real time operating systems). Each windows, linux and mac have different strategies.
But you could in theory start 100 threads in java which are all handled by a single physical core if your OS and/or jvm impl suck.
the reason its still advantagious to create multiple threads in that case is because of blocking operations which halt the thread meaning it isnt scheduled so other threads have more resources to do their work
no it isn't
gasps
with all the plugins you have doing blocking IO in that event that would massively increase the ping of 1/n of your player base lol
n being the number of Netty threads
I mean it isn't run on a netty thread...
The auth threads are still network threads
stop the flame
the server thread is also a network thread if I perform network ops on it
There you go
:yesyes:
now you think correctly
phew
auth threads are just network threads to the mojang services 
But wouldn't jumping so often between threads be strictly inefficient?

your thread not running because something else is is also surprisingly inefficient
it wildly depends on the kernel every how many cycles it switches processes
and what strategy etc
even for Linux they seem to use a new scheduler every few versions lmao
something has to support my e-cores 
how can I use interact entities?
interact entities?
What do you want to use them for
There is an event iirc
found it
I want to know how to spawn them, move them, read what entities are inside of them, remove them
You spawn, move, and remove them just like any other entity
As for reading what's inside them, you can use entity.getBoundingBox with world.getNearbyEntities
what type of data is bounding box?
BoundingBox
yeah but how do I extract entities inside that bounding box?
Yes
it has a BoundingBox overload
And one of the options you can pass to it is a bounding box
so it gets the "nearby entities in the world" that are insidethe bounding box
whats that?
yes
Method overloading in java is a feature that allows a class to have more than one method with the same name, but with different parameters.
first time im hearing it
Is it possible to get others minecraft server data like player count maybe? For example I know a server with ip play.minecraft.net and I wanted to get the player count of that server, is that possible?
Yeah
there should be a couple of libs out there that do pings for you
Alright, I think I can use this right? https://mcstatus.io/
Probably?
All you need to do is send a query packet to the server and read the response
Could make a quick api for that ig, But I assume one exists already
I could just use PlaceholderAPI Pinger placeholders smh.
Thanks for the help anyway guys!
i try find note block texture but i have just 1 texture
but how i undestand note block has 800+ textures
Is there a way to change max players at runtime?
in your resource pack. you add them
every change to teh NotBlock Meta makes it a different block, as far as your resource pack knows
if so, then logically they should not add up
were
if you place a noteblock and change it's values you geta different texture
but when you change the itemStack it stops stacking with the main itemStack and if noteBlock works like that it shouldn’t stack when dropped
you change when you place
Wait I have a sample
does this mean there will be 800+ note Blocks in the inventory?
Here's a sample noteblock file for a resource pack
what?
I'm confused when you put a block it doesn't store information inside itself. And that means the drop will be normal standrard item
when you break a block you get back it's default block
yea
no matter if you changed it when placing
I forgot that the block does not store information (
I mean, the states are the information in this case
although it would be great if this was added
What if BlockBreakEvent -> if brokenBlock.getMetadata()... -> blockItem.getItemStack()...
You could but metadata isn't persistent
There is block PDC, but in this case you can just use the states to identify the block
I know command blocks can store nbt while in the inventory
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
That one?
Probably idk
By the way, persistentDataContainer is not persistent, right? This means that the data from the chunk pdc must be stored somewhere
Idk why you don't just use the state as a unique identifier
the library from that link about customBlock must store data somewhere, but how does it do this if the data is not constant
It is
It stores it in chunk pdc
PDC (Persistent Data Container) is persistent, it just stores stuff in the chunk pdc, as chunks, worlds, entities (including block/tile entities) and items can have pdc
It stores it as nbt data
Metadata = not persistent
Pdc = persistent
Yes
The only case where storing stuff in metadata is acceptable is when you don't need it to persist
Wha-
He’s nonnative it seems
i not eng
I under stand
how much here eng?
Do you mean much
yes
I am not english, but i did have english at high levels in school
I am not english, but I accidentally learnt it once
Worse than french?
French is also a plague
agreed
Still a plague
bro literally wants to go back to latin apparently
erm 🤓 old German, actually, not Latin
hiya, im currently using this code:
fun createFakePlayer(name: String, displayName: Component, uuid: UUID): Player? {
val packet = PacketContainer(PacketType.Play.Server.PLAYER_INFO)
// Set the parameters
packet.modifier.writeDefaults()
val profile = WrappedGameProfile(uuid, name)
packet.playerInfoDataLists.write( // error is appearing here
0,
listOf(
PlayerInfoData(
profile,
0,
EnumWrappers.NativeGameMode.SPECTATOR,
WrappedChatComponent.fromText(name)
)
)
)
packet.playerInfoAction.write(0, EnumWrappers.PlayerInfoAction.ADD_PLAYER)
// Send the packet to all players
for (player in Bukkit.getOnlinePlayers()) {
MCInfinite.protocolManager!!.sendServerPacket(player, packet)
}
// Get the player
val player = Bukkit.getPlayer(uuid)
player?.displayName(displayName)
return player
}```
and getting this error: ```
Caused by: java.lang.ClassCastException: Cannot cast java.util.ArrayList to java.util.EnumSet
at java.lang.Class.cast(Class.java:3889) ~[?:?]
at com.comphenix.protocol.reflect.accessors.DefaultFieldAccessor.set(DefaultFieldAccessor.java:41) ~[ProtocolLib.jar:?]
... 23 more```
(protocollib)
BENADRYL!!!
is there any way to specifically disallow comments passing a certain character limit in IntelliJ, currently I hard wrap at 120 characters for code, but I want it to be shorter for comments
Hi, if I want to teleport a player to the nearest safe place within maybe 9x9 blocks and if that example is slabs, stairs, etc. then the player should be teleported to the nearest place correctly how can I do it?
You need to pass an EnumSet of wrapped actions and a List of wrapped entries
So example that the player is teleported correctly when slab like this
ok so packet.playerInfoAction.write(0, EnumSet.of(EnumWrappers.PlayerInfoAction.ADD_PLAYER)) doesn't work because it needs an int and a EnumWrappers.PlayerInfoAction
@lost matrix
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO);
Set<EnumWrappers.PlayerInfoAction> actions = EnumSet.of(
EnumWrappers.PlayerInfoAction.ADD_PLAYER,
EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE,
EnumWrappers.PlayerInfoAction.UPDATE_LATENCY,
EnumWrappers.PlayerInfoAction.UPDATE_DISPLAY_NAME
);
packet.getPlayerInfoActions().write(0, actions);
// You got this part already
WrappedGameProfile profile = new WrappedGameProfile(UUID.randomUUID(), "Bob");
List<PlayerInfoData> playerInfoDataList = List.of(
new PlayerInfoData(profile, 0, EnumWrappers.NativeGameMode.SURVIVAL, null)
);
packet.getPlayerInfoDataLists().write(0, playerInfoDataList);
ill try
still the same error
error occurs in this line: packet.playerInfoDataLists.write(0, playerInfoDataList)
Which plib version?
v5.1.0
Server version?
1.20.1
so not writing the playerinfo?
Write the info after writing the actions
please someone go on #help-server sorry but i really need
somebody delete that
thats what I've been doing
Show which line exactly throws the exception again pls
.
Yeah no idea why it doesnt work for you then...
this is so frustrating
hi, has anyone here already configured Plan Analytics on an https domain name with nginx?
how i can add an attribute "String" in an item?
private static String getRomanNumeral(int number) {
if (number <= 0 || number > 3999) {
throw new IllegalArgumentException("Il numero deve essere compreso tra 1 e 3999");
}
String[] romanSymbols = {"I", "IV", "V", "IX", "X", "XL", "L", "XC", "C", "CD", "D", "CM", "M"};
int[] arabicValues = {1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000};
StringBuilder result = new StringBuilder();
int i = arabicValues.length - 1;
while (number > 0) {
if (number >= arabicValues[i]) {
result.append(romanSymbols[i]);
number -= arabicValues[i];
} else {
i--;
}
}
return result.toString();
}
how i can optimize it?
(by cache he means make it a constant)
My display entity seems to remove it's render before the chunk that it is positioned on is out of render distance. View range (from display entity) and simulation distance (from server properties) and Entity-tracking-range (from spigot.yml) all seem to not fix the issue.
Is there any other setting I am missing?
Oh did not know that, thought it would use packets so it could track stuff off the main thread, that explains the higher performance costs of it compared to others.
is anyone here familiar with bungeecord messaging because for some reason mine stopped working after migrating my server
Hello, Ye Sparten does Use More Resources than other Anti-Cheats and Can't detect as much as others
I even think they didn't fixed the 3+ block vanilla Step yet
Yeah, I know, I had, well not the best experience with it, I switched to smth else already, but it's still surprising me that he does not use packets.
public class IntegerToRoman {
public static void main(String[] args) {
int number = 1000;
String romanNumeral = intToRoman(number);
System.out.println(number + " in Roman numerals is " + romanNumeral);
}
public static String intToRoman(int number) {
String[] romanNumerals = {"M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"};
int[] values = {1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1};
String romanNumeral = "";
for (int i = 0; i < values.length; i++) {
while (number >= values[i]) {
romanNumeral += romanNumerals[i];
number -= values[i];
}
}
return romanNumeral;
}
}
k
?
No, The Spartan Developer already wrote a message in this Chat explaining that he was Very Young as he created Spartan and gained alot of experience over the years, Still recoding Spartan to an Packet Based Anti-Cheat is too much work for him and consumes too much time he don't has
yea
is anyone here familiar with bungeecord messaging because for some reason mine stopped working after migrating my server
Didn't he publish a speech that indicates that this was his main source of income for many years and is now even selling 2.0 based on a Patreon sub? Well sounds like BS to me.
I actaully don't know, I think Minecraft Anti-Cheats can be very profitable because there are not Many Good Solutions but a high demand, Many Server Owners don't know what they should do
migrating from what to what ?
i just set up my dedicated server slightly differently on the backend
now for some reason bungee messages not getting through
That's what I mean, sounds like a BS excuse of why it can't be rewritten.
mhh, Maybe a Networking issue
there are so little because they are simply INCREDIBLY difficult to make
I think it might have to do with the ip's of the server changing or something
i mean not even servers like hypixel have a working one
3 year old clients still bypass it
Its not that hard, You just need to have good Ideas and than its easy
Im working on a own Anti-Cheat but don't have really time for that :C
That's not how shit works
if its not that hard do it xd
if you manage to make a good one
you will make hella bank
good luck man
mhh thanks, Your welcome to try make an Anti-Cheat too: https://gist.github.com/Snowiiii/2c306f3e8926bc7fb8acaaa8c3c105d7
what event runs when u middle click a block in creative
InventoryCreativeEvent
did you fix that?
any ideas on how to minimize tps drops from hoppers/tileentities?
paper
not much more you can do i believe
well id rather not have to do that but I see the point
I alr added a tile entity limit for like 1k per chunk
its a last resort for somone actually trying to lag the server
but some farms need hoppers
ye i plan on it really soon
use the block feature ad soon as it drops below 15tps
Isn’t there a tick limiter for hoppers
Also. Don’t crosspost in 4 places wtf
believe me nothing is worse then the luckperms disclrd
lol
my server with 60 members answers faster
I am gonna block every single person who crossposts from now on
reasonable
fr
nope. ..
if I want to spawn Interaction entity in x,y,z location and set it to be 1x1x2 rectangle, would it's length be equally distributed in that center?
or would it count the length from a corner like that?
Entities spawn by corners
Shouldn't have to cast if you use the fancy spawn method
fancy spawn method ftw
Hello, i have made a plugin long time ago with some friends and now tried to use it again, tho when starting it i get this error:
java.lang.NoClassDefFoundError: de/tr7zw/nbtapi/NBTItem
at de.xxxxxxxxx.xxxxx.Main.onEnable(Main.java:88) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:266) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:342) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:480) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_20_R2.CraftServer.enablePlugin(CraftServer.java:548) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
at org.bukkit.craftbukkit.v1_20_R2.CraftServer.enablePlugins(CraftServer.java:462) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:577) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:400) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:250) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:954) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:298) ~[spigot-1.20.2-R0.1-SNAPSHOT.jar:3936-Spigot-dba3cdc-5a2d905]
at java.lang.Thread.run(Thread.java:840) ~[?:?]
Caused by: java.lang.ClassNotFoundException: de.tr7zw.nbtapi.NBTItem
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:160) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:112) ~[spigot-api-1.20.2-R0.1-SNAPSHOT.jar:?]
at ....
Does someone maybe have an idea on why this is not working?
Missing/outdated NBTapi
hi is there a way to set a specific line of a text display
i have a lot of characters to put into a text display but if i do it all at once the client disconnects
it is in my build path. I tried v 2.12.1 and v 2.10.0 (which has worked a year ago)
You casted Interaction to LivingEntity
Which won't work since Interaction isn't a LivingEntity
but im getting interaction
Not all entities are living entities
setDirection
Thanks this worked :)
How big can a minecraft world be? I'm kinda of curious right now if its plausible to use an Int2Object map in my situation by instead of having a 1d array with 3 entries I could pack all of the coordinates together using bit shifting and use that as the map key otherwise I'll prob just go with the array
well I've heard its around 30,000,000 in practically as there is a world border there
yea
Pretty fucking big
there does seem to be one at 30m blocks
but it can be removed
if one would like that
i see no reason the world coulnt be bigger than that
Oh u difn’t mean size?
is there still glitches and stuff where you can't place blocks and stuff after that, I remember there always being weird quirks with removing it
mainly need to know as I'm making a plugin that relies on world coordinates for keeping track of certain structures and this is a super rare edge case, but I gotta know
yea
I wonder is it realistic to do a Long2ObjectMap than use bit shifting to shift the 3 ints together still?
is there a way?
do multiple text displays then maybe?
time to replan I think then
how can I check if a certain entity UUID is already stored in this ArrayList?
#containsKey
i mean, they're cheap af
like that?
its not what I wanted
I want to see if it has THAT particular entity UUID in here
i mean, if you are going to end up getting that list. its the same
else, contains is fine
https://wiki.vg/Entity_metadata#Text_Display it does appear to be one thing
problem is that entity is added to ArrayList despite me saying in code that if it's been added it shouldnt be added 2nd time
computeIfAbsent is redudant here
You are checking if the map has the entity as a key
Not the list
Also, you could use a set to avoid duplicates
I was told to use it like that
first value is player UUID
second value is ArrayList of entitiy UUIDs
I want to check if ArrayList of that specific player contains that entity UUID already
but idk how to work in nested lists
map.get(playerUUID).contains(entityUUID)
as coll suggested you probably want to use Set there
instead of list
why
since there is no point in having duplicates
and if you arent gonna have duplicates, sets are the way to go
Hello, is there any way to spawn a lightning and not affect the player who spawned it (I explain?), I have a code that spawns a lightning and affects nearby entities in a limit, but I have already tried several alternatives and still doing damage, the code is as follows:
player.getWorld().strikeLightning(player.getTargetBlock(null, 100).getLocation());
int radius = Main.getInstance().skills.getInt("lightning.radius");
double damage = Main.getInstance().skills.getDouble("lightning.damage");
player.getWorld().getNearbyEntities(player.getLocation(), radius, radius, radius)
.stream()
.forEach(entity -> {
if (entity instanceof Player && entity != player) {
ChatUtil.console("PLAYER DAMAGED BY A LIGHTNING: " + ((Player) entity).getName());
((Player) entity).damage(damage);
((Player) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 200, 2));
}
}
);
strikeLightningEffect
so Set cant store duplicates by default?
No duplicates, plus contains is much faster on Set then on ArrayList
bro plzzz help my es ku el no work'
myeskuel
ur what
mysql
my es ku el
I wouldnt need to use contains tbh
if I had a set
dont' try to confuse the people helping you kinda idiotic
cuz no duplicates
i want interate potgrekuql
???xd
they are talking to crackma im pretty sure
thank u bro
wait how do I add one Entity UUID to Set in to this kind of Map
well you need to computeIfAbsent it, since there won't be a set entry for that uuid
Why do you use a concurrenthashmap
yeah to insert a set for a player you mean
was about to ask this
since Entities can't really be accessed via asynchronous threads
idk it was like that in another code
xdddddddddddd
please know the data structures you are using
do u know what they are for
but it works worse for your case
then they just need a better server 🤷
how do I compute if absent with list
yeah
wdym
same as u did with list ?
like its -> with ArrayList
wait so why do you need computeifabsent
thats not a good enough reason to add it
.
I dont even know how you want to add stuff to your sets
thats what I am literally asking about
yeah they were talking about when you dont have a player id in the map yet
yeah and I dont have them
eh
its like that for ArrayList
how is it for Set
how to do it for Set
its what I am asking for
not how to computeifabsent for set
or a concurrentHasSet if you like those 😛
What is this master piece of a lambda abusive ArrayList with one entry in a map if absent?
Just curios
???
For resource pack dev, how tf do I center my model in blockbench so that the arrow is accurately on the position I want it to be?
what arrow
I use displayentities to simulate projectiles
when spawning it without resourcepack, it's centered on the vector where I want it to be
when I use the resourcepack, the model is off in position
oh, idk sorry
well I was told to do it like that
so I just did it
no worries^^
I just saw that snipped and where wondering what you try to code with that piece of art? Just my curiosity.
a plugin probably
yeah i would also assume they are making a plugin
well judging by your tone you are rather looking to mock someone so im not going to answer that
I hope you realize what this code does, right?
It ain't wrong if you're sure that's how it should be done
it makes playerUUID and adds this EntityUUID to list
Fine, Fine, you are right.
But what ever that is, rather create a common class to hold the data structure than running multiple maps what use UUIDs, it's just redundant.
and then just adds them if PlayerUUID exists
I guess
it works like that at least
Yeah it creates, places and returns an ArrayList
But the creation only takes places for when it's absent
which makes sense
Otherwise it just returns the existing list
Yes
But you understand why that works, right?
but yeah I do agree with sirbro that it would be beter to create a class for a player that has these sets and stuff rather than creating a bunch of maps
how many of these maps do you have
why when doing abilityStand.getLocation().setDirection(player.getLocation().getDirection()); armorstands are always on one specific direction?
even when I switch my looking direction
well what does getDirection return
That is not how
direction?
Locations work
They just return a separate object/a snapshot
Of the entity's position
ArmorStand#teleport
player location holds teh bodys location/facing
player getEyeLocation returns the head location/facing
right, I just had to look it up to make sure xD
yep use teleport
setDirection will only adjust teh Location object which is a clone
Location is always a snapshot that does not change the original holder's location
No
Because as I'm saying
why?
you cna but nothing changes xD
its literally same thing
its not the same
armorstand.getLocation returns a clone, so modifying it will not affect teh stand
It's not.
All locations do that
getLocation, setDirection, then teleport the stand to the modified location
so stupid
🤷
Cloning is not stupid, is necessary in an API, since Java passes by reference except of primitives, you would end up in hell, passing references via API.
when you have repeated something like 3+ times, its time to approach it differently
annoying for who exactly
you
I dont feel annoyed
tahts because you dont know any better
what do you suggest then, if you know better
Because 3x map or list lookups, resizes etc. operations will consume a lot more time/load than just creating one class object what holds the data structure in a single map or list, as I said
But what do I know
and what, it would sit in that class and it would do exactly same stuff
so whats the difference
you only have to get your "player" object once
The difference is, that one list or map holding the data class's object is more performant than x lists or maps just holding a part of it and also cleaner code.
because it would just be a List<PlayerLists> for a lack of a better name
which also means it will scale better when you decide to add more maps
how can you use a config.yml file to change different attributes of a gui (rows, lore, items, etc.)
i'm new to java its quite confusing
well those are 2 seperate things
first one being how don you read from a config file
and the second part being how do I change attributes of a gui
by which I assume you mean some way to create a gui from a config file
List<playerUUID, ListOfLists<List1, List2, List3...>>?
yes essentially
I just want it to store spawned Armor Stands, Interactions (that I use as hitboxes) and Enemies standing in those Interactions
ArmorStands for animation purposes
Interactions for mechanics
which works like that rn
and it just works fine
anyone thats in it gets damage as long as they are living entity and not armorstand
if those are the only 3 lists youll ever need its probably fine
whats teh confusing part
idk if those are the only 3
like
I want to make those 3 by each ability separately
so that they wouldnt get mashed together
you said its confusing
like 3 lists for this ability, 3 for that etc.
thank you for volunteering ig
so that I wouldnt remove armorstands / interactions / use hit enemies by something else by accident
I would reccomend to start out creating a menu hardcoding it into a class
Just forget what I wrote, your experience with Java is not nearly big enough yet, would just mess up your code atm. just keep your lists, no offense.
and then devise some kind of format that would work for creating a menu on the fly
I already made several manager classes
lol
I just wanted to see how to use interactions properly
I didnt think that Id need 3 separate lists
so I should make a class that would create, remove and edit such playeruuid nested lists?
I am trying to figure out how to make it so that everyone in a server says a random number from 0-9 or gets messaged a random number either or I am confused though how I would do that would I make a for loop and grab all the players then for each player it goes through the loop? Im still newish to coding so sorry if its a easy solution - I did the random number generator already
Bukkit.getOnlinePlayers().forEach(p -> p.sendMessage("random: " + new Random().nextInt(10)));
Thanks
Just make a variable for that Random
var friendlyByteBuf = new PacketDataSerializer(Unpooled.buffer());
friendlyByteBuf.c(id);
friendlyByteBuf.writeDouble(loc.getX());
friendlyByteBuf.writeDouble(loc.getY());
friendlyByteBuf.writeDouble(loc.getZ());
friendlyByteBuf.writeFloat(loc.getYaw());
friendlyByteBuf.writeFloat(loc.getPitch());
var EntityTeleport = new PacketPlayOutEntityTeleport(friendlyByteBuf);
// send packet
am i missing something obvious?
I mean, look at how the constructor reads the bytebuf
wait so what should I use instead of this CocurrentHashMap?
HashMap lol
I got a really weird copyright question. I've made a plugin for someone else, and their co-hoster fuckin stole it lol
https://github.com/Thatundeadperson/ReachSMP
can i
a) tell github to take it down, and will it happen?
b) get him for copyright violation?
he also posted it on spigot.
https://www.spigotmc.org/resources/reach.113507/
@worldly ingot can you take that down, please?
side note it is on my private github if needed for evidence
whats the difference in them
CHM can work in concurrent environments
with a slight overhead
i.e. you can use it from multiple threads at a time
A concurrent hash map has build in locking mechanics so it can be used async (multi threaded), you will not need that using the regular Bukkit/Spigot api.
how?
im not using any apis tho
CMH is also useful if you modify it while iterating
decompile the packet class
you are inherently using the spigot api
If you modify while iterating, create an Iterator, do not abuse a concurrent hashmap.
Wha?
i don't even know how to acces it
How do you iterate without an iterator?
I love ReentrantLock's!
Meh, CHM does not use those
CHM doesn't actually lock a lot, if at all
Quesiton do I have to make that a seperate class since I keep getting the error can't resolve symbol bukkit if I do not NEVERMIND import spelt wrong
Well CHM does lock quite often actually but these locks are not worth speaking about
For, forech, stream, whatever is available for the given data type, not talking of what it is using internally.
And they are only required for resizing bucks and stuff
Nevermind my import was spelt wrong
@vagrant stratus can you take this down?
for - iterator
foreach - iterator
stream - iterator but fancy
iterator - iterator
be patient
Yeah they just use synchronized blocks
how can I send an empty resource pack to the player so it unloads the previous one?
le shrug
Even my relatively lock-free ConcurrentInt62Set uses locks: https://github.com/Starloader-project/stianloader-concurrent/blob/main/src/main/java/org/stianloader/concurrent/ConcurrentInt62Set.java#L88-L100.
But I never really found a use for reentrant locks in Data structures
For me it generally me "My PC is turned on - if it isn't a thursday it is likely that I will respond soon"
thats what the yellow is for tho?
Well uh, I don't bother manually setting that flag
just set it always to away
I have a few people that I know personally that have set their status to always be offline
Well, whatever it uses internally, you will need to access the iterators methods to perform operations safely while iterating, otherwise ConcurrentModificationException and than of course you could also use a concurrent map what might not be necessary by using the first approach, but it most likely does not matter.
Which is just pain for me since I cannot really be "well, at this point you probably read it"
what packet lib should I use for 1.20+, since protocollib doesnt support 1.20+
The whole point of CHM is that CMEs are impossible
Almost no concurrent datastructures will throw CMEs
is there a way to make a player run a command like sudo or do you just grab there name and make the server run a command for them?
That is the point of using them
Why would you care if single thread and clean code, but ok
Uhh sory stupid question, i cannot remember what programm to use to access a storage from my hosted server. i got the ip, port, username and password.
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Player.html#performCommand(java.lang.String) its useful to look at docs
declaration: package: org.bukkit.entity, interface: Player
depends on what service you want to access lol
Because you just won't bother? It's less to worry about, has a much smaller fuck-up risk and less lines of code for basically the same performance outside of hot code
the storage where backups and all the minecraft server files lay
what approach should I take if I want to make GUI that would display unlock progress for a player based on what level (not in-game experience level, but just some arbitrary made level mechanic) they practically achieved?
you are probablly refering to FTP service, hence i like FileZilla for it
Also, modification while iterating can sometimes be a little more than plain removal of objects - for example what if you need to add or replace objects?
AHH yes filezilla was it yesss thanks lol. Just randomly forgot the name of it
Isn't that illegal is many countries?
Question for performCommand - Does the player need to have perms to perform the command or will the server force them to perform it
Yeah, fine, I admit it might has it's advantages
he in north carolina
single state consent
only matters to who is recording it
i know american law well enough to know hes in the clear
So yes, it is illegal.
i assume they still need permission
Probably not considered blackmail, so not completely bad but still.
Ya same thats going to be hard to figure out
fair
Ill just maybe make the server run the command then and target the player then
I think we misunderstood each other. Whatever
I was referring that extortion might not be completely fine, which they did by offering a ransom payment
Yeah that blatant act I disregard
and now hes like 'pay me to take it down'
I would think that "the whole point" is thread safety and atomicity 🤔 but sure
How can I detect when an item is added to the players inventory?
(I know there is a InventoryPickupItemEvent, but this only works for item pick ups, not for item changes if obtained from a chest or /give)
You’d have to check every tick
There is no event that covers all changes to an inventory
I just downloaded the plugin lombok for intellij and after trying to import it to the project I was previously workong on I get cannt resolve symbol lombok
What build system do you use
Windows 11
Maven, gradle etc.
Maven sorry
Did you setup the compiler plugin in there properly?
I am pretty sure give me a minute
All I know is that I have Kotlin and Lumbok which is all I thought I needed to download to use it
Do i need t o set something up or get sometihng else?
Wait I know what I did wrong
I didnt put it in my pom file
How to set items in the loom?
What is the best way to mysql? In plugins
The same with other inventories
No its not like that
Can someone help me with plugin messaging?
Is this right? https://pastebin.com/igMEMAux
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.
Yes it is? If not you'll need to explain more about what you're doing
I want to use my custom channel for this
I am trying to set item to the loom. Loom is full client side and you can not just use setItem to set item
loom is not full client side
Yea
Then please
Provide me a code
When you use setitem
try InventoryView#setItem
W8
I'm currently working on a PR for bukkit based soley around Inventories and InventoryView's I have been testing it quite frequently and such behavior has been identified as both possible and executable by a plugin
I can assure you, with 100% confidence, the loom inventory is not fully client sided and it is possible to set Items within it
How InventoryView?
Inventory battleInventory = Bukkit.createInventory(null, InventoryType.LOOM);
battleInventory.setItem(0, currentBanner);
battleInventory.setItem(1, dye);
return battleInventory;
createInventory does not work as intended
you can't use that method
you'll need to use NMS until my PR is merged
if you're using paper api paper has a HumanEntity#openLoom method iirc
Create LOOM INVENTORY in nms?
kind of yeah
Spigot
I am having troubles adding project lombok to my pom file(Maven) I can not just copy and paste it because of "multiple root tags" anyone know why
then NMS will be required here
How to create it XD?
are you using mojang mappings
?nms
yes mappings are absolutely necessary now adays
obfuscated makes this process much harder
I am used to NMS but i have been using mappings but i have not been coding plugins for a long period of time XD
just lmk when you have mapping set up
👍
okay this might be a second to type out
What's the diffrence
its just a GUI vs command line only
Nah i'll use the full version
World#rayTraceEntities does not include Displays?
I have been trying to add Lombok to my project however even after installing the plugins and trying to copy and paste the new pom lines to maven it does not work does anyone know if I am missing a step?
Player player; // we assume we have a player
CraftPlayer craftPlayer = (CraftPlayer) player;
// Convert to NMS player
ServerPlayer nmsPlayer = craftPlayer.getHandle();
int nextCounter = nmsPlayer.nextContainerCounter(); // this is an ID that can be sent to the client so it knows what is going on
final ContainerLoom loomContianer = MenuType.LOOM.create(nextCounter, nmsPlayer.getInventory()); // this creates our loom
// Bukkit handles a lot of the work for us so our job here is pretty much done
// This gives an InventoryView! remember this can only be created by the player you made that NMS container with, otherwise errors will occur.
InventoryView view = loomContainer.getBukktitView();
// now we can do edits if we want
Inventory inventory = view.getInventory();
inventory.setItem(0, new ItemStack(Material.BLUE_BANNER));
// now we can finally open the view
player.openInventory(view);
@green plaza hopefully this explains everything if you have errrors lmk
uhm its a small compiler optimization that will usually just get done automatically I just do it out of habit
you really don't need to use it in this case
sheeshers, ik this is completely unrelated but heyo- first time I've seen you outside of sku
doing alright lime? been a while
Ik i don't have to but i am just curious why ppl do that
Also heard few times that it boost performance a little bit
final just means you aren't going to reassign it, I do it for clarity
yeah, but the compiler automatically does it, when coding its not really something you need to be cognisent of
I don't come here. I'm just here to complain that Spigot forgot to include Displays in rayTraceEntities.
But JDK has to use more bit's to mark that's it's final soo how is that boosting performance XD?
lmao, u sure it's not counted? I'd think it'd count anything that's an entity
// Paper Method
result = origin.rayTraceEntities(targetBlockDistance, ignoreBlocks)
// Tried Spigot too, always null.
result = origin.getWorld().rayTraceEntities(origin.getEyeLocation(), location.getDirection(), targetBlockDistance, 0.0D, entity -> !entity.equals(origin));
Works fine for a single pixel of an armour stand 120 blocks away. Not a block display right in front of me.
dont' know a lot about jvm so who knows
honestly people mainly use it for immutability purposes and cleanliness
I have a question
@golden lava check if the Display entity is revealed with World#getNearbyEntities
(checking source rn and it seems that ray trace also uses that method)
private void getLoomInventory(Player player, ItemStack dye) {
CraftPlayer craftPlayer = (CraftPlayer) player;
// Convert to NMS player
ServerPlayer nmsPlayer = craftPlayer.getHandle();
int nextCounter = nmsPlayer.nextContainerCounter(); // this is an ID that can be sent to the client so it knows what is going on
final LoomMenu loomContianer = MenuType.LOOM.create(nextCounter, nmsPlayer.getInventory()); // this creates our loom
// Bukkit handles a lot of the work for us so our job here is pretty much done
// This gives an InventoryView! remember this can only be created by the player you made that NMS container with, otherwise errors will occur.
InventoryView view = loomContianer.getBukkitView();
// now we can do edits if we want
Inventory inventory = view.getInventory();
inventory.setItem(0, currentBanner);
inventory.setItem(1, dye);
// now we can finally open the view
player.openInventory(view);
}
Inventory inventory = view.getInventory(); -> here it pokes me for int for method getInventory
Does it matter for loom?
oh yeah use getTopInventory
my bhad
If that works i'll suck your toes
please don't 💀
Haha
Unless 1.17 changes something that 1.19.4 has with inventories it'll work and that prospect scares me
I don't think so. Packet implementations are quiet the same
Please tell me how to create component
So i can set this gui a title
oh yeah the title lol
do you want a custom name
or just the normal one
Okok
CraftChatMessage#fromStringOrNull
this is why we need Inventory PR
What is inventory pr?
my pr to add all of this to api <3
@golden lava display entities have a hitbox size of 0, so the ray can’t hit them
HOWEVER you can use the double argument of the method to increase the size of all hitboxes so you can hit them
it adds API to bukkit, and implementation to craftbukkit
this makes a lot of sense honestly
Ok, so then why does this default to 0.0D https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/src/main/java/org/bukkit/craftbukkit/CraftWorld.java#871
why shouldn't it? Why would it arbitrarily expand hitboxes unless you're attempting to do something special?
so e.g. it would look like this within the API subject to change
Player player;
LoomView loom = MenuType.LOOM.create(player, "The Title");
player.openInventory(loom);
Because by default it shouldn’t expand hitboxes?
But then it's not including Displays, an Entity.
Yeah well displays are special and have that 0 size hitbox
Mojang basically wanted them to be excluded from ray traces so they don’t block anything
I would like to recommend changing that default or including that to the JavaDoc of the method.
definitely don't change the default, but it should be logged in the JavaDoc ngl
will remind u tomorrow at this time
Ideally someone can make a jira issue for it
fr ^
well im definitely not doing that xd
This is why we can’t have nice things
cuz coll messes everything up 
@river oracle i have custom InventoryHolder, any chance to implement this to this loom?
This Holder just holds every click event's etc and don't want to implement it manually
ahhh Holder's shouldn't be used like that let me send you a better way to do it
pretty sure you'd need to use patches to get holders to work anyways
e.g. forking spigot
I am using it as it is being shown here
Something similar to this
But more complicated
as long as you're not using actual InventoryHolder's you can kind of cheat here lol its gonna be hacky though since you can't do patches
just get the Inventory from the InventoryView and store it
should I make manager class for custom GUIs made with inventories?
or can I get away with making each by hand?
Some kind of manager is usually good
Using a class which inherits InventoryHolder is good too :)
like making an inventory with X rows filled with certain items as background and custom name set and then changing separate objects by hand based on what I'd want?
whats that?
Then one more question cuz i am lazy asf. What event is being trigered when player complete loom crafting?
No clue
declaration: package: org.bukkit.event.inventory, class: CraftItemEvent
I want to make some kind of interactable skill tree / stat upgrade tree within GUI for each player
Nope as always InventoryClick wave his hand
so that it could fill inventory items with visual representation based on readings from player's config
like if he's got that upgrade or not etc.
I am coding an invitation system, the sent invitation should be deleted after a while. Should I use Bukkit Scheduler or BukkitExecutor or something else?
Use a scheduler along with timestamps
Store a timestamp for when the invite should expire a check them every once in a while using a repeating task
Will I check all invitations at the same time in the scheduler? But this may cause some invitations not to be deleted in time.
Why would they not be deleted in time
Will I define a specific scheduler for each object?
Nah you can just use one to check them all
In this case, invitations that do not disappear at the right time appear.
if you are using mysql it can do this for you btw
CREATE EVENT clearExpired
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 MINUTES
DO
UPDATE table SET status=0
WHERE status <> 0
AND TIMESTAMPDIFF(SECONDS, NOW(),table.timestamp)>120;
/* OR */
CREATE EVENT clearExpired
ON SCHEDULE AT CURRENT_TIMESTAMP + INTERVAL 2 MINUTES
DO
DELETE FROM table
WHERE TIMESTAMPDIFF(SECONDS, NOW(),table.timestamp)>120;
mysql has events that are handy to use 🙂
expiring rows/columns are one of those things
so let mysql clean them up for you instead of wasting resources 😛
oh wow this is fucking neat
I offer mysql and sqlite support to the user. There is also the possibility of using sqlite. Also, I do not plan to write the invitations to the database, I can keep them in memory, it is not important data, they can be lost when the server is shut down.
well, options 😉
?
For example, a scheduler ran every 5 minutes and then an invitation was created that had to be deleted after 1 minute. This invitation will be deleted the next time the scheduler runs, that is, after 5 minutes.
glad someone might find it useful 😛
Is it a good idea to store custom experience points and levels like combat experience from hypixel in player configs?
Or should I think of other way?
So make it check every 10 or 20 seconds
sounds like you should use a database!
Use a db
also in case you don't need permanent storage, mysql does have memory only DB's
don't worry there are plenty of choices, MongoDB, SQLIte, MySQL, Postgress!!!!
(You should probably just use SQLite)
so lets say someone wants to use mysql like you said you offer support for, the plugin could run more optimally by not having to store such info in memory when the DB server can do that for them
i want to make a code for each player online assign them a random number than message them that number any ideas on the for each player online since thats where I am struggling
as well as handle expiring stuff
and then just have your code do the whole in memory scheduling if sqlite is being used since SQLite is just binary file storage
Im pretty sure I was told to keep using configs
So when do I use config and when database
only because in terms of ease the API already provides you stuff, where as using a DB you need to create your own methods and the sorts to do this, aside from the fact you are stubborn in learning java stuff 😛
You literally advised me to not take half measurements and you did sell me half measurement
Which means that majority of my work goes to scrap
I didn't sell you a half measure o.O
What can possibly happen if I use config for that
you can use a config if you want, but yaml starts to bog down once you start hitting like a few hundred to thousand config options, and if you want to use a yaml like structure still you option would be to move to just storing pure json instead and then from there you would have no choice but to move to binary storage if what you are storing keeps getting larger, and then from binary storage you would need to look at a proper DB server. But DB servers like mysql don't take up much resources so sometimes it might just be best to start with a DB to begin with if you expect to be storing a lot of data and more so if that data needs to persist or is needed elsehwere.
Yeah just check more often
Comparing time stamps is a cheap operation
Question I am wondering how would I give everyone a random number then do something with that random number? Would I need a array For Example, 1 = diamonds 2 = dirt and every player gets a 1 or 2
well why not 0 and 1?
then you could use a boolean if you wanted
Java has api methods for using Random with a range as well
so your range would just be 2
and you would check if the random number provided is either a 0 or a 1 🙂
I know how to use random with range its just how would every player get there numer and ther eitem
Just check if all the players have 0 or 1 with a statement and give them the items?
So in that case how do I make database
And how do I read it
depends which data base flavor you want
?
most of the time comes down to preference
I dont have a preference
Well just like programming languages, there is different kinds of DB's
Idk something that works?
well they all work of course
All my work is now for shit so ill have to start from zero
however, some have limits while others are tailored to more specific things
I want something to store custom enemies, weapons, playerstats etc.
well this is part of learning and overall part of development sometimes. Not everything works out perfectly in one go
sometimes you learn what you were doing is just not good enough
For which you told me to use configs for
so you just start again
I don't recall me being the one specifically for you to use configs, just that you are not willing to learn
since you don't want to learn proper stuff, easier to just direct you to something already provided
continuing with not learning proper stuff, using a DB isn't going to make that better and you will in fact make things worse potentially as using DB's are not as forgiving as the API is
I dont consider that kind of attitude, namely "heres a half measurement now fuck off" on a help channel apropiate
It doesnt work that way
the support most receive here as well as the educating would typically cost you a hefty penny for, but we freely do it and we are not paid either nor does anyone pay for this support
Since when money determines how important your opinion on a matter is
would this assign everyone a random number if so there seems to be a error Bukkit.getOnlinePlayers().forEach(new Random().nextInt(10);
Well, we are not obligated to provide support nor do you have a right to it either. We have no obligations to really do much of anything, but we still provide support because we want to. You are free to not like it, but we are free to not like those wanting support as well. It is a two way street type deal. You refuse consistently to not learn appropriate basics, methods, and conventions to the point it makes it difficult to provide you support on stuff you ask about because you lack the understanding required.
well this sets your range to 10
0-10
Yes it does however would it give everyone a number or no?
well 0-9 actually
true
possibly, but I probably wouldn't use new random for everyone though
I am a new coder sorry I am struggling with this XD
I would create 1 random object, and just call nextInt() every time
and then assign a number it provides
wait so create a integer then make it generate a random number then do 1 player then continue?
calling new Random() if you have a large enough players would actually lag your server since its a taxing process to generate randoms 😛
its going to be like 5-10 players
And in the end makes you look very unprofessional if you resort to giving poor quality answers
whether I am professional or not here makes little difference. Spigot isn't my employer so the opinions have no meaning for me
its not hard do you store players in a list already?
I would probably use a hashmap
Oh god
So what database do I use
The h word
whatever you want, I'd go with SQLITE or something
Before I say anything, I would like to request a lawyer
Do i also need to make management classes
Can they be static
Learn, look it up on youtube or something, this is java!
Hashmap <UUID, Integer> randomsMap = new HashMap<>(Bukkit.getOnlinePlayers().size())
Random randomNum = new Random();
for (int assignNum : Bukkit.getOnlinePlayers().size()) {
randomsMap.put((players UUID), randomNum.nextInt());
}
Thank you
its not complete as you will need to figure out how to get players UUID's and put them in
or just use player names since its only used when they are on anyways
Mhm
!!!!
Frsoty thanks you your very nice and Ima go try to code this now
Have a great day/night
notice I store the random object and not make a bunch of random objects 😛
always avoid if you can in making new randoms, its one of few objects that will cause you issues later down the road lmao
Oks
Do i just make connection to db at server enable and keep it like that
You usually connect to the db once, or create a db pool so it can swap around connections when sending multiple queries.
weeeee
Whats a pool
There are some things where we can't really tell you because its dependent mainly on you. What you prefer, what you know, what kind of data and how much data, does it need to persist or not etc. If you want a DB for learning purposes either go with sqlite or mysql as there is plenty of resources and tutorials online to guide you in the appropriate direction to learn about this. There is more to DB's then just using them, such as setting the DB tables up properly etc IE their structure and the sorts.
A pool is basically multiple database connections, it basically allows parallel queries to the database without exhausting the single connection
not sure if I was correct there
learning proper DB management is like a whole course in of itself just fyi
