#help-development
1 messages · Page 816 of 1
same way you do it from a terminal
the commands are not different just because its a query
you can use sql scripts btw too
that has basically all the queries to create your DB the way you want
if it doesn't already exist
this is actually the recommended method instead of a bunch of hardcoded queries 😛
public void onArmorStandInteract(PlayerInteractAtEntityEvent event) {
Player p = (Player) event.getPlayer();
ItemStack macchinetta = new ItemStack(Material.PURPUR_BLOCK);
ItemMeta itemMeta = macchinetta.getItemMeta();
itemMeta.setCustomModelData(16);
macchinetta.setItemMeta(itemMeta);
if (p.hasPermission("eternitystaff")) {
if (event.getRightClicked().getType() == EntityType.ARMOR_STAND) {
ArmorStand armorStand = (ArmorStand) event.getRightClicked();
if (armorStand.getEquipment().getHelmet().equals(macchinetta)){
p.sendMessage("Its Working");}
else{
p.sendMessage("Its not working");
}
}
}
}```
why its not working
because you're just making a new item, in context, and then checking if the armor stand is wearing this item
at no point is the armor stand's helmet set to this item
.equals should work as long as the items are identical
.isSimilar is the same but ignores stack size
Neither ignore durability tho
and whose fault is that
If we create two identical objects, == will return false but .equals will return true as long as the two objects' contents are the same
madre
holy..
would there be any difference between broadcasting a message, or sending it to each player in a for loop ?
broadcast also goes to console
Habit 1 - Guard clauses might be applicable here
so no performance difference?
no
I use both
what performance impact are you expecting in terms of sending a message?
weird to think a message would cause such things
How can I ensure my plugin will only start the onEnable() method after another plugin has been 100% initialized?
depend: [OtherPlugin] in plugin.yml
have done that
but my plugin still starts slightly before the other plugin is done executing onenable
i want to create a custom chat system therefore every chat message will be sent in this way
Other plugin onEnable:
At the very end: important method 1
My plugin onEnable:
At the very begining: important method 2 depending on important method 1
1270 ms for find rtp location it's a lot?
Is that the correct name?
ok but I am not sure why you believe sending messages would have some kind of heavy impact
I also recommend learning about chat channels and conversation api as well if you want to make a more decent chat system
plugin.yml of other plugin
how do I parse Entity to ArmorStand?
Just instanceof and cast?
Ok
So long as you are not using NMS
There is code for finding locations, but the thing is that it usually takes more than a second, and I have seen where it takes a maximum of 366 milliseconds. Any optimization ideas? https://paste.md-5.net/eluvozekul.cs
it would be faster to loop all blocks in the region that are in your blockList then add their Location to a Collection and pick a random one
the performance of randomly picking a location until it matches one of your types could take forever
or at least until time runs out
Generally the issue is loading chunks
Also you can speed up the height check by using getHighestBlockAt
What the hell is this
Just generate a random loc
Get the highest block
Add 1 to y
loading chunks could cause bad performance but his issue is line 6
And teleport
Maybe also check how solid it is
he's literally picking a location at random every time
you could try querying the terrain's max height at the location and start checking for solid blocks up from there
Also you can search async if you use a heavy method
And have it fire a synced teleport at completion
also possibly pass the chunk to getSolidLocation and use local block coordinates so it doesnt have to find the chunk for the location every time but that prob wont matter much
what would be the better way to have a leaderboard setup, do i have my 1 map for stored data unsorted then another map that stores leaderboard pos plus uuid or do i sort it when the leaderboard is needed
also true
Depends
On your usage
u could do this by selecting a couple random chunks, taking snapshots and asynchronously checking those for locations
or use nms
Use a tree map 🙂
could be queried every 5 seconds by papi or could be a 40 minute difference between query from command
/\
Even have the whole process be async
could i sort by a method in the value with a tree map
can u take chunk snapshots off the main thread
something like this?
No
You also cannot load chunks async
yeah so maybe just take chunk snapshots on the main thread and do the searching on another thread
I guess, you could also just have one map
would it be better with a hashmap and a treemap
are u loaidng all the data on startup or smth
wouldnt it only put loaded players on the leaderboard
i mean you would expect a leaderboard to include offline people right
yeah
well i dont want to query something from db with papi
Papi completable future support when?
kekw
why do u need papi
so people could show the leaderboard position on a scoreboard or a hologram or whatever
I am trying to detect a Right Click Interaction with a specific item using the held item's displayName to get an object from a HashMap. This works for every item with a normal ColorCode like §a but if displayName has an RGB color and is generated with textComponent.toLegacyText(), the saved name does not match the name from the Interaction Event. Why is that?
ig
u makign a library or like public plugin?
public plugin
kind of, except you can reference a sql file
ah
also the exception you should be catching is SQLException
and not just generic exceptions lol
i need to add bulk queries and indexes to my datastore framework bc i just realized how little it can do
im sensing jankness emerging
Dont use the name or lore of items to detect custom items. Use the items PDC instead.
?pdc
lmo
says access denied
7smiles been here 30 seconds and his head hurts
Ok, I'll work into this, thank you
your credentials are either wrong, or the user in question doesn't have the perms required
seeing as you are using the user test I am going to assume the user doesn't exist
@Inject some memes
At least return a copy of your list...
You animal
i wrote regex just to show u exposed collections
Yeah, ill never get people sabotaging their data integrity like that...
Might as well make your fields public.
you need to log into the DB server as root and create the appropriate user
I recommend creating 2 users one with localhost and the other with 127.0.0.1
so it doesn't matter which you use
or just create 1 user that is allowed access from both domains
either or doesn't matter a whole lot
isnt localhost the same as 127.0.0.1
no
oh tf
ah
but the os will resolve localhost to 127.0.0.1 right
probably even earlir
than the os
some OS's don't have localhost mapped to 127.0.0.1 and thus can fail
interesting
i assumed it would be hardcoded in earlier, like maybe in java but ig not
but mysql doesn't treat hostnames like localhost the same as 127.0.0.1 either even if localhost is mapped appropriately
weird
Which one? Even RTOS has that mapped.
I think ubuntu was one of them, they could have since fixed it and was probably just a bug in their stuff
I haven't used any recent versions of ubuntu to see if its still there, but its not like it bothered me either
I just learned to not rely on localhost meaning loopback address
localhost could be the local ip instead of loopback
there is no standard that says localhost has to map to loopback lol
Bukkit api not can be async
some methods in the api can be used async
u can make a snapshot of a chunk and read from it asynchronously
so if u select like 3 random chunks
and make snapshots of them
then search for a location in those asynchronously
and then once found do Bukkit.getScheduler().runTask(plugin, () -> player.teleport(location))
that would work in theory, unless those chunks are like all ocean
in which case maybe dispatch the process again which sucks but at least it doesnt lag the server
Wat this?
declaration: package: org.bukkit, interface: Chunk
not sure if you could do it via query, but if you can you need to use a user that can create users and modify them and then you have to flush the privileges
typically the root user is all that exists to do this
I don't recommend using the root user though, generally your DB server should already be setup with the appropriate users and permissions before usage
final Random random = new Random();
public void findRandomLocationAsyncThenRun(World world, int range, Consumer<Location> consumer) {
final int CHUNKS = 3;
int rangeInChunks = range / 16;
List<ChunkShapshot> chunks = Stream.generate(() -> world.getChunkAt(random.nextInt(rangeInChunks), random.nextInt(rangeInChunks), /* generate */ true))
.limit(CHUNKS)
.map(Chunk::getChunkSnapshot)
.toList();
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
Location loc = null;
// find location using the chunks list
if (loc == null) {
// restart process with different chunks
Bukkit.getScheduler().runTask(plugin, () -> findRandomLocationAsyncThenRun(world, range, consumer));
} else {
Bukkit.getScheduler().runTask(plugin, () -> consumer.accept(loc));
}
});
}
void someMethod() {
findRandomLocationAsyncThenRun(world, 6400, loc -> player.teleport(loc));
}
shit like sendMessage is just packets
im not sure if thats async doable tho
i dont see a reason why it wouldnt be tho
Yeah
It is
Is there a workaround to create a static method which uses generics?
huh
Static methods can use generics
oh wait generic classes
They just can’t use the generic types specified for the class since they aren’t a part of the class instance
yeah :/
show what you want to do
you need some form of static constructor or what
im following this tutorial
i want the get method to be static
n oyou don't
why would any of those methods be static
you can sure access map even if it isn't static
but not the same filled one?
use Dependency Injection or in your case you can easily just do
MainClassWhatever.getDataHandler()
its a different object
get your api -> get data manager
?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
okay, but isnt dependency injection not clean?
not sure what you mean about not clean
injecting it into every class that needs it doesnt sound fun to me
you don't necessarily need to inject the main plugin instance into the class, but all classes are just objects
you either create the object and hold it somewhere for it to be accessed or you create a new one
you should avoid static if it doesn't need to be static. Anything static can not be GC'ed and stays in memory
one of the caveats of statics
whats GC'ed?
but isnt letting something stay in memory the thing i want, when trying to load the database data into memory?
database data is independent of the objects
Your data depending how its structured could be multiple objects and those objects held in memory
when that data isn't needed which also means the object you will want it to go away
not persist
your connection manager for the database could be static since this object wouldn't be ideal in going away and you don't necessarily want more then one thing controlling your connections
but static isnt a problem when im unloading the player from the static map once its not needed?
it can be because static persisting in memory isn't the only thing that may be bad
it also prevents there being multiple instances
i dont want there to be multiple if the data is the same?
ok, but static isn't dyanmic though
money or something shouldnt be different per player per object
Garbage collected, it's a memory process from the java virtual machine that erases phantom/loose objects whose references aren't used anymore
thanks
okay
I'd recommend googling Garbage Collector theory and studying more, a really interesting topic
Also very helpful when you start working with lower level languages such as C
a very large topic too
Indeed
it could be its own class in my opinion XD
Or just make yourself familiar with the JVM memory model
That will superficially cover GC
I recommend not using static until you learn more about it
so that it doesn't interfere with your stuff in ways you are not expecting
you actually don't need static to make the majority of anything, its just a handy utility to help improve stuff
@wet breach Wheres his code? I cannot follow the thread you lads have
they wanted their get method to be static so that they can access it from other classes
and basically everyone so far said for it to not be static, and then I sent the link for di and that it doesn't just apply for the plugin main instance 😛
and then you appeared in the convo above
XD
Oh okay
but everyone is correct that it shouldn't be static
I mean just make an attribute in your plugin object where the data manager is initialized and access the main manager through your plugin singleton no?
frostalf i know static should be use carefully but in my opinion this data should be singleton because why would there be 2 instances of money data or something
the thing about singleton is that it makes the object only have a single instance. You can have multiple money objects/data per player
making a class a singleton wouldn't help as it would mean all the player objects would have the same data for money
no thats not ture
I mean it's more like if you assign a data manager to a plugin instance, whereas there's a possibility in which a plugin instancr is initialized more than once (which it is for spigot's case code wise, since there can be another allocation), I'd use a class local variable
every player has a object in my design assigned to them, i want this hashmap to be static
you are correct it isn't entirely true but unless you have some method in the singleton that can obtain data dynamically then the data the singleton holds is the same for anything accessing it across the board
i dont really understand, but im sure that every player has its own data in the hashmap
if the player data manager is the singleton the data can be seperate per user
You should differentiate between the ideologies behind what you're trying to solve. If your goal is to make a decorator of a hashmap to store custom data, you should focus on modularity. By making it static, you ensure there only is one decorator and this enforces logic and a specific pattern for users of that map
Which in turn is not modular
And not disconnected from it's usage
in my opinion I would go with a player manager singleton with a wrapper around the player object for custom data
in this manner, you only need to have the player object to access your data
with a centralized place it is held
Yeah but use a WeakMap to not enforce a reference to be kept to the player even tho it may become invalid
Or use the player's uuid (preferred)
if you want, depends how it is all setup really
reason we generally recommend using uuid or avoiding the player object is because many forget to ensure they are removing the objects when players leave
or otherwise known as doing cleanup
again just use the WeakMap
and remove the player on leave to ensure
if you want, its not an inherent need
it should be tho, so the JVM actually enqueues the player instances. It is also recommended by the spigot authors since the underlying entity object can become invalid
or again, use the simpler variant: UUID's
the advantage weakmap would provide over not using it, is ensuring gc happens on it faster
allows you to also have data when players become invalid
if you just use the player object, it still gets gc'ed if nothing is referencing it
i mean as long as a player is kept as a key in an map entry the player instance won't be cleaned, due to the player being directly referenced
unless the player is a specific type of reference
such as WeakReference, or SoftReference if you want to allow JVM to enqueue the referee on memory demand
yes if you don't remove it from a map, which is basically what I am saying in terms of clean up it won't get gc'ed
ah yes
yes everything you said is true in terms of recommendation but its just because we get a lot of people that don't know the proper things so the recommendations just helps them in the long run from running into some weird errors 😛
well weird errors for them anyways
Just do it similar to this:
public final class PlayerData<T> {
private static PlayerData<YourPlayerDataObject> data = new PlayerData();
private final Map<UUID, T> customDataMap = ...;
private PlayerData() { ... }
}
If you do enforce a singleton the generic part is completely unnecessary
yeah ofc haha ^^
@wet breach all good I am just trying to be as accurrate as possible to give the best advices to people, so if they don't understand something they can google it and learn even more (at least that's what helped me a decade ago when i started programming lol)
I think its fair to give ppl options and sometimes let them experience the pros and cons for the different options you may give them
yeah true
as opposed to telling them in advance ^^
i mean afterall we need to make the mistakes to actually learn from them, being told not to do them won't have much of an affect when you're a beginner
yeah, definitely
but id argue its different for advanced people yk
but its always hard to measure how much a person have had experiences in the field with only a couple messages
like when im trying to help here im starting off thinking that the people involved are advanced, since i think thats the median (maybe im wrong)
havent been in this forum for too long
oh it vastly differs,
i guess yh
if gc'ing is your concern, an optimization trick people forget is nulling out objects 😉
gc will remove nulled out objects faster then if they are not
also, another trick to that is you can kind of force a gc to happen if you null out many objects quickly too lol
typically you will want to try to re-use objects though to stick with OOP
but its an optimization for complex code yh
long time ago you were taught to null out objects you were done with, but I don't think they teach that anymore
except for languages like C or CPP
where it is a necessity
yes I agree
all those flags are meant to be used
the JVM is good for a general standpoint
but you should utilize them as each program is actually different and it helps the JVM out instead of guessing
how is it important for c or cpp, never heard about it 🤔
THIS so hard
because C and CPP don't have GC so you have to do your own memory cleanup
the only way you can remove an object in those programs is to null them out
isn't every object cleared when it goes out of scope, as there is no gc
aside from dynamicly allocated objects
isn't every object cleared when it goes out of scope, as there is no gc
no, it stays until something tells it to go away, which is why memory leaks are more common to happen in C or CPP then other languages
because typically somewhere someone forgot to null out an object
so it just got left behind lol
i wouldn't say so, memory leaks are due to bad use of dynamic allocation
std::string &foo() {
std::string bar();
return bar;
}
this will not work
as bar doesn't exist when out of scope
I suppose, but objects left behind are another way, over time the application will consume a lot of memory if its not cleaning up appropriately
even in Java you could technically go out of scope of the memory that GC handles commonly. Anything done using native methods for example GC doesn't handle, but most of this happens with JNI related things or if you use unsafe and manually make buffers in memory.
and the exception to either of these two is memory mapping files
you have to differentiate where the objects are allocated. Heap or stack? It plays an important role since a so-called stack frame is allocated for each block / method invocation. The stack pointer tells you where the current last object and next object will be allocated. Objects saved on the heap go through the OS, thus the heap is way slower (!) than stack allocation (also cache misses come into play but thats a different topic). For C/C++ the developers have the responsibility to free memory for heap objects. There are so-called smart pointers which have a reference count and free heap allocated objects automatically when they go out of scope.
so to actually answer your question: objects allocated on stack are automatically cleared; heap allocated objects not.
haven't i said unless dynamiclly allocated ?
.
(... didnt see that ...)
well aparx provided a more thorough answer for those that don't understand
nice job 🙂
that is exactly what i said, no need to nullify objects on stack, just free ones from heap
I think we were talking about Java, no?
well to free them you null them out unless this has changed
in Java every object (actually: non primitive) is allocated on the heap
nah we started talk about cpp
ah okay
it gets more complicated when u use langs like java, which now has virtual threads, gen zgc etc, ugh barely wanna think about all the stack and onheap managament that is done
gen zgc is extremely op
there was a language (forgot the name) that claimed to have like crazy stats on GCing
haskell maybe
yeah
i have no history with haskell so cannot comment on that :/
always fun to learn this of a language that claims stuff
yeah didnt know it was possible for a language to falsely advertise important design choices
Haskell's computation model is very different from that of conventional mutable languages. Data immutability forces us to produce a lot of temporary data but it also helps to collect this garbage rapidly. The trick is that immutable data NEVER points to younger values. Indeed, younger values don't yet exist at the time when an old value is created, so it cannot be pointed to from scratch. And since values are never modified, neither can it be pointed to later. This is the key property of immutable data.
This greatly simplifies garbage collection (GC). At anytime we can scan the last values created and free those that are not pointed to from the same set (of course, real roots of live values hierarchy are live in the stack). It is how things work: by default, GHC uses generational GC. New data are allocated in 512kb "nursery". Once it's exhausted, "minor GC" occurs - it scans the nursery and frees unused values. Or, to be exact, it copies live values to the main memory area. The fewer values that survive - the less work to do. If you have, for example, a recursive algorithm that quickly filled the nursery with generations of its induction variables - only the last generation of the variables will survive and be copied to main memory, the rest will be not even touched! So it has a counter-intuitive behavior: the larger percent of your values are garbage - the faster it works.
well I think of them as mutually exclusive tools/ideas rather
its an oop concept (I think, correct me if im wrong) and its making me mad sometimes
dont really have strict hate nor love towards one or the other
I mean sometimes mutability is just needed depending on language and other functional requirements by the means of optimizing a design or perhaps speed
yeah
i mean always allocating new objects to "mutate" a single attribute is really costly and unnecessary. It comes down to the paradigm you use
yeah
I think structs as in cpp is a great thing
whereas you have restrictions but can group closely related attributes
but working with a language like Java that enforces you to use OOP is just... yeah...
yeah, procedural programming is something many prefer to traditional object oriented programming
I love Java for it's adversity but yh idk
yup correct
well you could do functional programming in java if you wanted
I mean you see Java adapting it more and more
but java has sort of (like many other langs) gone over to a more modern approach
esp since java also allows for easier use of the data oriented programming style nowadays
and the functional bit also :^)
okay but now we talk javascript lmfao
if we talk about data objects
lets talk about JSON
xD
the simplicity is crazy
json is so overrated
but comes at a cost
the only thing I hate about json is the fact that it can have infinite arrays of arrays
well yesnt
which is weird and there isn't really a way to know when you reach the end of a multi-dimensional array except just looping until you encounter no more arrays
i mean java has made major steps towards letting devs step in that direction of paradigm
yh i mean the new JDK versions are all great imo
from java 8 onwards they made good changes
slow, but qualitative changes
yea
oh that reminds me, I think next weekend I should work on a lib for unix sockets 🤔
rather have them overthink everything 100x than do a breaking change down the road for their stupidity for committing too quick
i prefer that to kotlin tho, just pushing new features as soon as possible almost
still don't know how I am going to implement that for spigot and bungee though
lmao
and well for things like REST apis we now have graphql, (yes there are still some issues w/ it but hey, its cool)
idk I can definitely see why people prefer kotlin over Java, but not for me. I am personally so familiar with Java code and prefer that
hell been programming 10+ years with java
well I just think kotlin is a harder tool imo
why switch huh
the only thing I have gathered from those using kotlin is the whole null thing
nullability yeah
which I don't really have an issue in terms of null lmao
kotlin gives away ton more features, it becomes hard to know which of them one should use, code can become very messy and unreadable with kotlin rather hastily
well there was a time where i only programmed in typescript with complex generics, coming to java again was a pain simply due to the nullability
but typescript is type erased anyways
so can't really compare that
type erasure
is
in java
;-;
well u have reifiable and non reifiable types, but still
yeah
loops alone are so weird for the trained java eye
it seems like unnecessary object allocations
but it probably isn't
also the dumb interoperability
since the compiler handles all the underlying tasks
i mean interop is cool and all
but coroutines 🤑
its just that it wasnt semantically designed in a good way
may i say something, we kinda got off topic guys
true
altho virtual threads :)
drifted away slightly
coroutines even cooler with loom
yea aparx, true, well as long as this channel covers the more programming talk its rather fine
ig
I think there would be a lot of hinderance if this wasn't the case in java
if it didn't exist polypmorphism would be more complex
since they wanna touch on completely non type erased generic types
OwO?
also, because of type erasure generics don't incure overhead at runtime either
well I mean, project valhalla
true
i mean there is some info retained
like for reflection purposes
Value Objects, introducing class instances that lack identity
Flattened Heap Layouts for Value Objects, supporting null-free flattened storage
Enhanced Primitive Boxing, allowing primitives to be treated more like objects
Null-Restricted and Nullable Types, providing language support for managing nulls
Parametric JVM, preserving and optimizing generic class and method parameterizations at runtime
@young knoll
in regards to this, type erasure helps generate bridge methods to preserve polymorphism in extended generic types
hence it would probably be more complex if we didn't have type erasure
yea
Should I use abstract classes as a way of preconditions or no
idk if u need abstract classes for that
what's the best way to do this
to do what, now?
handle all those runtime exceptions
I mean dont u just throw those in the implementation class?
ok
this is also one of javas weaknesses
since u're in principle specifying implementation details in the javadoc by mentioning the cases of which an exception will yield
so yeah, prob just have some conditions in the impl class :>
a.k.a. a contract?
lol
like, if it's detailed in the documentation it's contract, not impl detail, e.g. "throws NPE if param1 is null"
how could I handle a join system message for factions where a player could request to join a faction and someone of high ranking from said faction could accept?
Like if the leader did /faction requests chat prompts would pop up with this format
NAME [Accept] [Decline]
And you could click on the different parts to handle said actions
ive def seen it before but not sure what that's called
ClickEvent in a TextComponent
is there a way to pass in the name it's associated with as a parameter
i see
looking at the reverse situation, how could one handle invites to every player from a faction leader inviting them to join? Even if said player was offline
provided a player name
hello there, could anybody tell me what I have to do to change the level verbosity of my plugin logger so that records with that level are actually printed out? Changing the logger's level to ALL does not have any affect
logger.setLevel(Level.ALL);
The above did not work, I assume it's due to the handlers?
How can I rotate a mob using its yaw value
you have to register handlers for the levels that are not tracked
Is there no way to get Shapeless with a specific amount of ingredient?
Like 10 obsidian; 5 nether star -> bedrock
Recipes aren’t designed to have stacked ingredients
So it's only possible with shapedrecipe?
Yes
but it only works with shapedrecipe
Yeah like I said it’s not designed for that
Is it possible to remove the necessary items when crafting? I mean there are no bugs in the process
Like, when craft with 11 obsidian and 5 nether star, remove 10 obsidian and 5 nether star
You can try with the CraftItemEvent
Working, thank you 👍
any nerds in here that might have some ideas of how i could add config updation to this https://github.com/The-Epic/ebiclib/tree/master/ebiclib-core/src/main/java/xyz/epicebic/ebiclib/config its pretty much just an annotated config but idk what a good way to do it would be, im already guessing ill need a version for it but im stuck on the part of actually adding it to something, bc i doubt adding an @Update("version", old, new) would be very good if there was 90 of them but i could probably just compact the conversion, but im welcome to any ideas
idk exactly what you're trying to achieve. Allowance for different "schema" versions? If you want to have variable arguments just use an array in @Update, no?
I suppose it depends on if you want something to happen ?
btw this is a perfect opportunity to promote my library
yee
thast what i do to everybodys dms
I ignore my DM's
so would the @Update be the better method of it?
Looks cool 👍
depends what you wanna achieve really
Hey guys I need help with something weird.
So I have a factory that allocates an item (or in this case an implementation of the factory that returns the below item).
@ConfigMapping
@Document("Item used to leave a match")
@SuppressWarnings("deprecation")
private ItemWrapper leave = ItemBuilder
.builder(Material.INK_SACK)
.damage(DyeColor.RED.getDyeData())
.lore("§8Click to leave this match")
.name("§cLeave")
.enchants(Map.of(Enchantment.LUCK, 2))
.flags(ItemFlag.HIDE_ENCHANTS)
.wrap();
The item material that was initially given to the player differs from the material of the item when the player interacts with it.
The ItemWrapper is a simple and tested wrapper around an itemstack to add some custom serialization onto it, it does not affect the item itself.
The material of the item when it was created and set into the player's inventory: LEGACY_INK_SACK x 1 and when interacted with RED_DYE x 1. This is a huge problem for me, since I am using a Set with weak itemstacks to register game items allocated.~~ Trying to create a custom hashcode would result in the reference not being weak anymore. So any ideas or fixes?~~
Update: I figured out it is simply due to the versions and will just use IdentityHashMap as the underlying map for my set to use referencial equality instead of object equality
you forgot api-version in plugin.yml
and .damage isn't 1.13+ api
yeah
oh thanks a lot
what exactly would you want
ah yeah it is open source
there's a prod ready release but it's still early development
btw. is there any public data about what versions are used the most? When planning out projects I am always worried about users not being able to use my plugin since I still think legacy versions are used often, nah?
bstats has some, but < 1.13 is like 10-15%
i run BuildTools with --remapped tag and have net.minecraft.server.network.PlayerConnection
what version
did you use the remapped-mojang jar
how would i apply color to an ink sac in 1.13+? Or is there any thread for it?
there is no color, each color is a different item
is your dependency 1.13+
no its not
its not for this
its just a library I use
Is it possible to not nest in for loops, as a return statement stops the loop (correct me if im wrong)?
Huh?
use a break?
You can use continue and break if that is the question
Labels are also a thing, though not liked by many
call me stupid but i just dont find red_dye, im on 1.13.2-R01
im not giving up til i find it!!
Xd
red_dye not dye
make sure spigot is the top dependency
?jd-s
it may be being overwritten by another dependency
Yeah red dye exists: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html#RED_DYE
mhnn
i checked it, no library exports a dependency
and i have spigot as a top dependency
I think this is an IDE thing
ima reset my caches and some other stuff
If anything, kill all transitive deps
I thought break was a switch case thing?
it also is
Nope, break means "break away from the current bracket context"
So you can have
{
break; //dead code
}
// Alive code
label: {
{
break label;
}
// Dead code
}
continue works only for loops though
Which basically means "redo the given scope"
Though it will reevaluate the condition (though idk if that is the case for do-while loops)
mhn after invalidating caches, deleting dependencies still doesn't work, I cannot even compile Material.class this is 100% an IDE error
decompile*
well restarts do nothing
well for some reason 1.13 does not work, but 1.14 works, so Ima use this as a dependency
You dont have to decompile anything there. You have access to all sources.
So gui general gui; I need to get something created preferably in C because I don't have an environment setup to play with Java, I don't think intellij would open a gui after compiling. I just need a direction to start this I never worked with gui but I need to make a program in 6 days utilizing them
I haven't even read the source material for this yet but it's based on all languages and not structured towards anything so I can figure it out in any language. They want pseudocode but I'm giving them real code it's the last big project of this course so want to go above and beyond.. I'll check those out thanks
depends what you need a GUI for
good luck making one in C though I guess
I can actually tell you let me look at it
It's based on this (keep in mind I don't want answers just guidance)
Draw a customer-input screen for a utility company. What information should be
captured? In what order should the fields appear? Keep in mind that
programmers would need to know database structure for their screens to be
useful.
programmers generally shouldn't need to know database structures, this is why DB Administration is a thing of its own
it is the job of a DBA to ensure the programmers don't need to worry about the structure just the information in how to obtain the data they need or how to store it
They want to teach you a little bit of everything this course branches out in multiple directions, everyone in the college has to do this course if they are doing anything IT related
I guess doesn't change the facts though
as far as customer input screen goes, this is a screen for the customer?
or a screen to display customer related stuff?
That's part of it it's purposely vague it says this and then underneath says give a hierarchy chart and pseudocode or flowchart after answering the questions
interesting
So far I've aced every programming task each week I don't p!an on this week being any different just first time I don't know how to do anything in advanced
does a json lookup from an api website cause lag? whenever I do it my server has insane lag spikes
I'll make it async rn to see if it helps
on teh main thread it's bad
Ok
Yes. Any IO creates horrible lag.
You have to realize that your code blocks other plugins and the entire minecraft server.
A tick has 50ms. A web request can take several 100ms. This means you block the game for a very long times, causing lag.
also what does IO stand for
https://www.spigotmc.org/threads/guide-to-async-io.623371/
This could help
input output
yes I read that when I was working on my plugin that uses coreprotect API
From the post ^
what do I replace "this" with if it isn't in my main class?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
ok thanks
Does something like drawRectangle() work in Minecraft? Where would this image be placed? In the game or on the screen
no
drawRectangle would be a rendering method. The server has no render
No it's animation I'm learning very vague concepts that don't work in every language
well minecraft is rather limited in it's GUI stuff
you have:
- Resource pack overlays
- Boss bars
- Title cards
- scoreboard
- Inventory GUIS
and thats about it
If you wanted to add stuff this is where modding comes in? Instead of plugins
Primitives are usually drawn by using the GPU. The most common approach is a wrapper for OpenGL bindings.
It can be really complicated. Swing from Java has some nice utility methods for drawing on a canvas. For C it can be a bit more tricky.
Yes
Appreciate the info, was going to mess with it in Minecraft but I've never touched mods before, and not ready to do complicated things
yesnt, you can do a LOT with resource packs + plugins
depends on what ur doing tbh
Actionbar also
Can be manipulated to an extent
Have a goal over break to create a GUI that plays an animation nothing big but stuff I never touched before (not inside Minecraft, another language)
ehh did I do it right? (heesewhois is the main class)
and the async task is in a different class
iirc you need the instance of your main class, not a new one
asking me to insert new
yea cuz that isnt your instance
thats your class constructor without new
you have to either cache your main instance or get it via PluginManager
Looking at my options looks like I want c++ with Qt to accomplish this, and I want Python with tkinter
ima just ask chatgpt
Ah, right, my bad
Anyone know how could I check which velocity proxy a player is connecting from?
I have a dual proxy setup
How could I import my HashMap from class A to class B?
I cant seem to figure it out, chatgpt doesnt say
Or I dont understand what its saying
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
PS: You should never transfer maps (or any other collection) between classes
Never make them public, never create getters or setters for them
so I should transfer my command to my class with the hashmap?
No you should create one manager class which holds this hashmap. Then write proper methods to manager this map.
In the end you can pass around your manager class and use its methods.
Here is an example
public class PlayerDataManager {
private final Map<UUID, PlayerDataStorage> playerDataStorageMap = new HashMap<>();
public PlayerDataStorage getPlayerDataStorage(UUID uuid) {
return this.playerDataStorageMap.get(uuid);
}
public void addPlayerDataStorage(PlayerDataStorage data) {
this.playerDataStorageMap.put(data.getUUID(), playerDataStorage);
}
public void removePlayerDataStorage(UUID uuid) {
this.playerDataStorageMap.remove(uuid);
}
}
public class PlayerDataListener implements Listener {
private final PlayerDataManager playerDataManager;
public PlayerDataListener(PlayerDataManager playerDataManager) {
this.playerDataManager = playerDataManager;
}
@EventHandler
public void onJoin(PlayerJoinEvent event) {
PlayerDataStorage data = new PlayerDataStorage(event.getPlayer().getUniqueId());
this.playerDataManager.addPlayerDataStorage(data);
}
@EventHandler
public void onQuit(PlayerQuitEvent event) {
this.playerDataManager.removePlayerDataStorage(event.getPlayer().getUniqueId());
}
}
is it possible to remove item from the server?
like what i need to do? check many events and remove item?
like from looting, trades and other?
Mates, I'm new to the NMS development, and I am trying to conditionally remove the carved pumpkin's blurred screen effect by following a trail in the thread below.
I built the Bukkit, CraftBukkit, and Spigot-Server and imported all the libraries, but I still can't find the ClientboundContainerSetSlotPacket like the image below.
I think I have missed something really important, such as deprecation. It would be really helpful to get some tips to get out of this disaster. many thanks
?nms
Also as stated in that thread you're probably better off making a resourcepack
k i think ima just have the http lookup everytime I do the command instead of trying to understand this hashmap between classes stuff
The only way to remove the pumpkin overlay is to make the client think that there isn't a carved pumpkin in that slot
its async surely it wont cause lag
go for the hashmap, it'll be a good learning experience
true
exactly. so I wanted to intercept the packet to make the client believes that there is a wearable helmet instead of a carved pumpkin in a user's helmet slot.
I would probably go for protocollib instead of nms for this
I thought that the resourcepack method is impossible to "conditionally" display its blurring effect isn't it?
rly sorry I am new to controlling the packet flows but can you give more explanation for your opinion?
any1 know what I did wrong here? its throwing a stacktrace
ProtocolLib can listen for incoming and outgoing packets. Those packets can be modified or even removed from the pipeline.
But maybe start explaining your entire idea because there might be a better approach.
You are not passing anything to your constructor. Which means you replace pluginInstance with the object in itself (Which is always null ofc)
You cant magically pull an instance of your JavaPlugin out of thin air. You need to give it to your class when creating an instance of it.
I made a plugin with some helmet apparels that can be held as like other items in minecraft, such as a carved pumpkin.
but the current problem is that since the apparels are inherited from a carved pumpkin so it keep displays a blurring screen for players.
ok so I tried fixing it but now another error occurred
and I wanted to hide its blurring screen basd on customModelData value
ok thanks
anyway maybe i should consider this option seriously after I try a little more with the current one I'm doing now. this nms really killing me
You can just remove the pumpkin overlay in your resourcepack
yeah but doesn't it removes the overlay from a carved pumpkin either? I wanted to remove it only from the hats I made.
Yeah thats not really gonna happen. The player wont see his own apparel anymore, which is kinda meh.
https://imgur.com/a/Sxv1yHr
what a temptation.
How do I kick a player async?
Because a forced connection close
Does not allow for a custom feedback message
why do you need to kick a player asynchronously
kicking doesn't damage server performance that much lol
making it async probably makes you worse off xD
Just wondering
Probably not
Cuz I'm operating on another thread already
And need to sync the kick
just resync for the kick
BukkitScheduler#runTask it'll kick them the next tick
.
I know, those are basics
this is such a micro-optimization you're going in a super round about way to do something simple for maybe if at all a marginal gain in performance
But it disallows custom feedback
Can someone please help me, so my problem is that i have opened another eclipse project in intellij, and after i have closed that and opened a new one all the depencyes are at the other projects location. How do i fix that so i dosent be at the same location?
I have an example here, all the locations are like this: D:\clients\minecraft\abaac\workspace\jars\versions\1.8.8\1.8.8.jar but it should be: D:\clients\minecraft\FC-1.8\workspace\jars\versions\1.8.8\1.8.8.jar, and it is also like that with every other dependency with mcp (the abaac is the earlier project i wrote about)
Can someone help me fix this error?
https://pastebin.com/Yd9wHiwy it's with mcp
jesus maven clean re-install solved the problem. thanks everyone.
What does the key mean in PDCs? can I just set it to random text or what exactly does it mean
It’s your identifier for that key
so like a password or something?
Its like a mapping. Key -> Value
If you want to get the value back you would “need” the key. So sure a password
Except it’s not a secret
so more like a username
Sure it’s a key
also can I not store stuff like UUID or Player in the PDC?
UUID -> Yes
Player -> You should not
You can store pretty much anything in a PDC to be honest. You just need the right PDC type.
cause this doesnt work
Because spigot doesnt have such a PDC type. You would have to either use a String or create your own type.
I guess I'll convert the UUID to string
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
do I need to install some plugin for it to work or no?
or is the repository and dependency fine
Just a dependency u need to shade
ok thanks it works
can I make this code asynchronous? So that the player waits and it does not affect the server ? - https://paste.md-5.net/obumihekuh.cs
But then, is there any point in asynchrony if you need to wait until the location is received?
I mean, instead of async you can just spread this over multiple ticks
ok and how could I delete a PDC? Set it to null (would that work)?
wdym
like, if you only want to load e.g. one chunk per tick.
Do one check per tick
lemme find smiles post
PDC#remove means you can remove a PDC from another PDC
?workdist

skill issue
?workdistro
lets goo
Ok I assume this will remove all of the PDC related to the thing and I dont need to specify the type?
do you mean getting locations in the background?
yea if you previously stored a PDC in dataContainer under the key key
that method would remove that inner PDC from the dataContainer
You should generally not compare objects with ==. This compares their memory addresses. Use .equals() instead
2 months later
that shit is bound to break fast
magic
Man be magicing
Oops! all singletons
Merry lynxmas
Merry Milesmas
Doesn't work as well
feels like your fault tbh
Can anyone help on how to just send basic chat messages in 1.20.1? Or at least how to use component builders for it?
Player#spigot()#sendMessage to send components
new ComponentBuilder() for a new component builder
More component methods coming soon ™️
ComponentBuilder builder = new ComponentBuilder();
This requires importing a couple dozen methods
I'll update it when 1.20.3 drops if I have time
Importing isn't a big deal xD
I smell paper
Correct
And that is an INCORRECT ANSWER
I assumed there wasn't much of a difference?
Much difference
There's too much of a difference
Yes
Well, they should
But paper plugins don't work on spigot
Oh ok
But paper is kinda... Paper
thats not an actual answer
its just that paper added a lot of extra stuff, making it very hard for us to suggest the right thing to do
Well, there is a chance a spigot plugin may not work on paper for whatever paper reason
Nein sir no breaking changes yet
so if you are planning to just develop for paper, you should use their server as they know more of whats going on
Is it possible that one of the patches paper does to vanilla could somehow change the behaviour of a spigot plugin?
Paper also behaves differently in certain situations. If you dev on Spigot we can help. If you dev on Paper we can;t be certain an issue is not caused by Paper. So advise is to dev on spigot to get help here.
If you rely on some bug yeah but that's on you for relying on a bug for your plugins function
Well, there are some bugs that are considered features by players or mojang ig
Should I register my NamespaceKey inside or outside of the event/command?
Yes somethings behave differently in Paper, like entities through portals.
Oh what
I mean paper does a lot of optimizations so that shouldnt be surprising
Does anyone have an idea why player.isBlocking() doesn't return true even if the player is blocking with a shield?
Did I hear someone saying Paper?
It should but it's worth noting that it only returns true if the shield is fully up
isHandRaised() will return true even if the player only just recently clicked block, but it takes like 0.5 seconds before isBlocking() will actually return true
How can I change this to a annotation which checks it all for me:
MenuRows menuRows;
try {
menuRows = MenuRows.valueOf(rows);
} catch (IllegalArgumentException exception) {
this.logger.warning("Rows for \"" + menuName + "\" menu is invalid!");
return null;
}```
To this:
```java
@Catch(exception = IllegalArgumentException.class)
@Log("Rows for \"" + menuName + "\" menu is invalid!")
MenuRows menuRows = MenuRows.valueOf(rows);```

You don't have to use annotations for everything :(
I want to check if that enum exists
Can't you like check things before
@WritePluginALLInAnnotations```
You'd have to write an annotation processor which is fun
Annotations are evil
why? they look so cool
You get over that quickly
Only sometimes
Java was meant for TVs and you're writing plugins in it
Annotations are devilish
Can you guys help please instead talking what Java was made for?
Anyways you'll need an annotation processor iirc you can do this with a maven or gradle plugin or just a jar file idealistically it searches for your annotations and replaces it with code
Beyond that no one here will be of much help seeing as annotation proccessors aren't an easy ask
And most people here probably do programming as a hobby, probably
Bobby
Google “annotation processor java” or smth
Fuck
I mean, the help here is "don't write custom annotation processors"
programming as a hobby is no excuse to know nothing
A excuse to not know annotation processors tho
well the excuse would be that I have never tried something like this so I wouldnt know how to do it
whether it is my job or not
Yes
An annotation itself cant do anything. Annotations are simply meta information you can give to components.
What is your general idea on what this Annotation is supposed to solve.
Like, why would I write an annotation processor if everything works without annotations
Given you can implement pretty much this exact same concept in like, an interface and a static method
annotation processor is just the wrong tool for the job
Just instead of try/catching the enum to check if that enum exists, do a quick annotation on variable to do that for me.
I mean, you can google annotation processors
and go down that path
its a complete waste of your time
This can be done with a fromString method that returns null with a preconditions statement
You're way over thinking this
Btw this looks like local variable, afaik you can't annotate that
why cant you write a simple function for this though
Hm. Do you want to generate code based on your annotations or do you want another class to read over your fields and
check properties based on annotations?
Huh why isnt the target file being created when I package the plugin?
hmm weird
it is there I checked
ok i restarted it its back now
What is the event for removing items from an armour stand (and adding)? I tried this and didnt work (the DataType.UUID is definitely true)
and a print or something does not show up?
I want to generate code based on my annotations
I think you have to use EntityInteractAtEntityEvent
iirc
Alright, then you need to write an annotation processor. If you are pretty motivated and have some free time, then you might be able to get this
running in 1-2 weeks. Otherwise it will def take longer. So be prepared.
Are you serious? 2 weeks? for a simple annotation?
Annotations are literally not meant to generate code
you are trying to abuse a system that is there for pure metadata for code generation
they are not macros if you come from a language that has those
*If you have a lot of experience with java
Otherwise i can assure you that it will take longer
I mean I don't know how to do that. It seems hard to create. Is there any source on github for me to get inspired or something so I can write it easier?
yea really don't look at lombok 
oh, lombok! I actually use lombok on my every single project.

What's the matter with it?
the codebase is terribly complex
I wouldnt say its a mess. It is just really a lot.
sound slike spaghetti code
it does a LOT, if you have 0 idea on annotation processors, lombok is not the project to learn from
follow some bare bone guide
or
write a single damn helper function that does this whole thing for you 
lol
Yeah i also feel like an annotation processor would be completely wasted on checking if an enum value exists...
I thought It would be cool if I use an annotation for a variable instead of try/catching it, however, I might regret now. try/catch exceptions are kinda messy and its syntax is so boring tbh.
Don't even use try catch here this can be done without it if you make your own custom fromString method
One example:
public static <T extends Enum<T>> T getSafeEnumValue(Class<T> enumClass, String name) {
try {
return Enum.valueOf(enumClass, name.toUpperCase());
} catch (IllegalArgumentException e) {
// Do whatever you want here, like logging the wrong name.
return enumClass.getEnumConstants()[0];
}
}
Particle particle = getSafeEnumValue(Particle.class, "test");
but the method itself still uses try/catch
When i right click a pig it gets executed, but when I right click an armour stand it doesnt
Are armour stands not entities or something?
Don't use valueOf for implementation 🔥🔥
then what to use?
Try the PlayerInteractEvent
Cannot use getRightClicked then
Idk how your enum is set up but a switch with a default seems desirable here
Hello there , iam trying to remove an arena by its uuid from the map
[15:56:14 ERROR]: Error occurred while disabling game v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: null
at org.skywars.core.sync.JedisServerSync.messageServerClose(JedisServerSync.java:94) ~[?:?]
at org.skywars.game.Game.onDisable(Game.java:143) ~[?:?]
use event#getType() instead of event#getRightClicked()
exactly what I did
this is my jedis part of the code
JedisServerSync.java line 94 pls
but it can't be null cuz its already there ..
Ik
i already added it .-.
sorry but that would be a bad idea as well because everytime I add a new type I have to add it into switch too.
Use a registry then
What do you mean?
I don't have time In class atm sry
okay
Doesnt look like line 94 to me
each server is represented by a new random uuid each time a server restart :
its , i deleted some empty lines
everything is working just fine , my only problem now is
it does not decress this by 1
when a server close
any ideas?
do i need to send a hset?
starting with server uuid?
https://java-design-patterns.com/patterns/registry/#explanation this is a basic outline of what you should kinda do though its a simple example
Intent Stores the objects of a single class and provide a global point of access to them. Similar to Multiton pattern, only difference is that in a registry there is no restriction on the number of objects. Explanation In Plain Words Registry is a well-known object that other objects can use to find common objects and services.
just note you don't need a concurrent map in most cases
What you need to do is show us an exception and the corresponding code to it.
when a server close decrese by 1 :
I believe, is just better to create a simple method and use it.
anyone know why i cant import my other plugin?
run mvn install when you build your other plugin
Have you installed it
gochu thx
Hello I have a question which version do I use to minecraft 1.16.5 thx you
1.16.5
I would go with 11 but it supports up to 16
Okay but I saw that's recommended to use Java 8 that's true ?
no
Okay thx you so I think that I will use Java 11 or newer
how can i check if a location is above ground
other then checking the blocks above it
cause
getHighestYat
thx
if the Y is above your Y then there is a block above you
hi , was able to figure out what's wrong :
on what object do i call that
can it be that bcz its in another thread?
wtf is going on with my llamas
they always walk straight in some direction for no reason
i have a class spawmning all kinds of mobs
and llamas are the only ones behaving weird
You smell so they are leaving
sometimes they also just spin in circles
nno
no nms involved
i only put an invisible wolf ontop of em
um, tamed or wild?
no theyx arent they arent running away
they are walkiung ina straight line
from where they are spawned
no matter if theres a wall
or i move
they will get stuck and dont care
change the mob from a wolf to a pig or chicken
try it to see if their behavior changes
is their any other mob with a behaviour similar to a wolf?
like attack uppon being attacked
holy shit theres many
never realized
but now that i think about it makes sense
Hey How can I get title of inventory in event InventoryClickEvent
don't compare inventories by name
how can I compare it so ?
compare by instance
okay
I'll assume you are making a UI?
Yes I use Bukkit.createInventory
store the instance when you create the inventory
then compare to it when the player clicks
create static inventoryy if possible and compare them after
if (yourInventory == clickedInventory)
okay
