#help-development
1 messages · Page 1095 of 1
I'm still figuring data structures
which one?
yes that would be great
i see ur work practices havent reflected over to your freetime projects
I've got like 4 different half written mechanics and the core is still not up to foundation level
ouch
yeahhhh just means more rewriting in the future hence why i should actually focus on one thing at a time kek
is it java or kotlin?
java ofc
hmm
Kotlin is for goofy goobers
I also just hate the feeling of interpreted langs, I like to read my fields and what not for what they are
not what they could be smh
I mean tbf java is very straight forward which is what I like most about it
myes
i mean the main issue with java is verbosity, though seems like theyve been working their butts of to change it
Ig that's why we make wrappers and abstract shit as much as possible eh?
well java isnt so flexible when it comes to adapting 3rd party libraries
for one lack of distinctive mutable vs immutable types in the std lib
but then also, to create a delegate u have to write a lot of fucking code
I think that depends more on the impl but yeah
well it ends up sucking
for the most part yeah
libraries change after versions and the only reasonable way to protect yourself is to build sand walls of abstraction
Or just don't support ancient technology duh
not like its that easy
Imagine like one of the common libs WE for example without versioning support kek
i mean heck how much code was using finalize()
and then they removed it
well deprecated + removing it
but still, i get why
Well that's a fair point
but its a pain in the ass
I mean I just think a lot of people get used to one thing and for some reason don't want to accept the new thing
Even if it is better this way
yea, but for production and enterprise its understandable that they hate changing too often
instability and distraction
then you have dev communities that love new features
yeah in that regard for sure, but still improvements can always be made
sure, well if you write software for a car at some point you wanna finish, that is when certain criteria are met
if much of the work goes to changing libraries, or other useless stuff well good bye money
As an example, spigot and the benchmark java versions is something I can appreciate from a software
Like I said earlier, I just think people get so used to doing something one way and just don't want to touch a "new/better" way
i mean spigot lacks implementational transparency
but its at the price of keeping the api compatible with older versions of minecraft
Well that's sort of a requirement wouldn't you say?
i mean look at paper for example
they take a more radical approach where transparency with nms layers is what they value
hence the component movements they pulled through with for one
Yeah spigot component support when? Speaking of lynx sent me the pr for that one and I signed the CLA just so I can see the progress kek
I know I've seen a couple completely disregard spigot and only use bungee chat
anyway most prog language communities face it
enterprise vs developers
developers like new features (trendy, enhancing and so on), enterprise like stability
I'm certainly in the middle of that one
I can apprecaite a fair balance between both
if you're a freetime spigot dev, you most likely side as a developer
i mean you may be able to sympathize with the enterprise
but unless you are enterprise, you wont be one nor care enough about them
Yeah that's fair
I still can appreciate a balance though, some things do just have to change for the better and I'm all for learning new shit so either way its a win to me
I either keep doing what I was, or get to learn something new
myea
well java did change a bit
they used to be heavily enterprise favored
now ATLEAST they have schedules to ship features regularly
or well, JEPs
anyway even with all that, I am more of a javascript guy
on skibidi you will
Speaking of the only thing I've done outside of java was use jfx for a notepad application kek
poor soul
Hey man I ended up doing a markdown viewer (plain text but eh cool for the time I did it), and implemented a really non functional minigame
Like the chrome dino game
Oh just remembered I made a calculator module too
kek I have no . button for the calculator
when you see rads code
lol
is there any public placeholder parsing code that supports nesting? everytime i try to make one and make nested placeholders, my pc goes on life support
papi and minimessage that I know of
so with these placeholders:
%placeholder1 test% = whatever
%placeholder2 idk% = test
%placeholder3% = idk
then %placeholder1 %placeholder2 %placeholder3%%% would result in whatever
i dont think papi supports nesting
the only plugin that i can think of with this is probably skript, it does it pretty well tbh
how would i do it with minimessage?
one way that i thought about it, is parsing deepest first
by putting them in a hashmap with their deep level
Actually now that I think about it, minimessage would just parse to a component so I'm not even sure if it does support the nesting
and I haven't really used it enough to know of a workaround
hm
hm indeed
i'm like 99% sure i actually made something similar to that afew years ago on one of those "java challenge websites"
but i can't remember how i did it
God I hope theres a better way
oh wait it's gonna be wayy more complicated than that
there is no closing percentage
what the fuck is that
Simple coding question
honestly one way to do it is "token"'s
like a compiler/interpreter
what if i just
read the string backwards
wouldn't that also parse the deepest first?
reading it backwards would essentially be... the same as reading it forward right?
one way to do it -
check the characters with a for loop,
when a ( is found, add to the count.
when a ) is found, subtract the count.
when the count is 0, that's one of the strings
that's how I see it
yeah i thought of that
the thing is
i want to do to with percentages (it has no closing)
that could be done with O(n) time, where n is the length of the string
hm?
does Entity#setGravity just stop it from falling
yeah
%% -> () doesn't really work is what he's saying
but still allow it to have X-Z motion?
makes it hover
yes pre sure
hope so otherwise im gonna have some jank movement code
loll
btw hi purple
hi nuclear
Would you suggest multi module impl for the core?
I'm really leaning towards it because I hate the current look of the structure
It's just hard because I'll have to refactor a lot to the api module and I keep running into circular dependency issues
Another thing is that I'm just not sure what should actually be implemented in the api module as opposed to like the skyblock / rpg ones
Do you mind sending me an example of the current structure?
Like what?
Well perhaps I'm just not doing it right lol, but basically getting references to my managers and what not
It's still in the process of being organized kek but I feel like you get where I'm coming from
ah
yeah I would usually suggest making it multi-modular, as it does improve your workflow, and makes it easier to manage your project's codebase
That's where I'm having the most trouble currently tbf
Erm when was designing a core so difficult smh
have an api module, which contains all the interfaces, have a common module which contains abstract classes, and the main core functionality.
Then have a skyblock-api module, which contains all the interfaces/abstraction of your skyblock module.
Then a skyblock module which contains all the functionality
and the same goes for rpg
Might be a bit overkill, but it's a nice way to organize things
the skyblock-api module should only depend on the api module. So you need to make sure it's properly abstracted
the skyblock-api module is stuff that could be used for rest api's, for other developers working on other projects for it, etc.
I gotta go look at some larger projects or something cuz jeez I confuse myself
ahaha
So as an example would I implement the islandmanager in the base api or the skyblock api module? I would think the skyblock api but then it raises the question of circular dependency again
wow look at you
basically that's the dependency tree
if this is easier to view
and you see there should be no circular dependency issues there
because api depends on nothing
common depends on api
skyblock-api and rpg-api depends on api only
then skyblock and rpg depends on their own api modules and the common module
So the base api module is doing what exactly?
Am I holding any actual impl there?
Wait I think I am understanding now
Api is just there for my common interfaces and the skyblock / rpg api is for the implementations of said interfaces correct?
holding all the abstractions and interfaces for the common module. Basically if you have a
public interface User<T> {
T getId();
}```
that could be implemented inside of common as
```java
public abstract class AbstractUser<T> implements User<T> {
private final T id;
public AbstractUser(T id) {
this.id = id;
}
@Override
public T getId() {
return this.id;
}
}```
And the skyblock-api could then have -
```java
public interface Island {
User<UUID> getOwner();
IslandMembers getMembers();
}```
might be a bit overkill for your usecase, but it's a good way of structuring imo
Am I correct in this thinking?
skyblock / rpg api could be, depends on the usecase, like it can contain an abstract class implementation of the interface. And then the skyblock / rpg module can then add functionality.
So yea
in a way
I guess just play around until I figure a solid structure...
basically you see here, AbstractUser can't be used by skyblock-api/rpg-api because it's apart of common, that would be properly implemented inside of the respected modules. It can only use User, which is the interface for AbstractUser
You can then create an implementation of AbstractUser inside of skyblock or rpg such as
SkyblockUser / RPGUser
and contain data specific to the gamemode
Well when you put it in those terms, it makes me question how I should structure the actual data classes now, in the sense of the core being hybrid skyblock / rpg this data should be common between the both... which leads to me think I'm gonna have some pretty big data classes
Not really an issue per se, just hurts the readability
Oh I see, yeah you are combining both of them, aren't ya?
yeah
Since RPG is going to be "built off" of skyblock, I would have builders/factories to interact and change how the main skyblock core is going to work
basically binding stuff to skyblock
Kind of ironic being as I always try to write out a plan for impl on my work projects, yet don't for my free time projects kek
This is a bit simplified, I like this
So like -
public class SkyblockItem extends AbstractItem {
...
public /*final (new)*/ void implement() {
// The registering of the item inside of skyblock.
}
public class Builder extends AbstractBuilder<SkyblockItem> {
...
SkyblockItem build() {
return new SkyblockItem(this);
}
}
}```
RPG Code -
```java
SkyblockItem.builder()...build().implement();
something like that
or allow the SkyblockItem class to be extended by other classes, but the implement be a final method to not ruin the functionality
Essentially, as you said just design in a way to allow for "base" implementation as it were, but also rpg mechanics should be able to change the way this implementation works?
so the structure is basically just now
Yep
Hmm ok I'll certainly keep this in mind, I'm gonna focus on the refactoring first before actually implementing anything new kek
thank you purple!
❤️ sleep well!
:)
Hey guys, I've realized that custom items can be used in recipes, is there an easy way to disable it from being used in crafting or do I just use an event for it
I fucking love consolidating 6 concrete classes into a generic class
man I fucking love good API design
I am keeping all my shit in a permanent -SNAPSHOT state until it becomes squeaky clean
0.1-alpha forever
curse of perfectionism
nah but it makes sense when you're changing methods and classes left and right
Half of it is just good practice with type parameters
I spent a good 10 minutes trying to do something really simple
I spent a good 5 minutes debugging if(true) return;
data class N(val: Class<T>) {
val thing: T
}```
records my beloved
I may also scrap this in 2 commits
I haven't touched java java in a while now
okay doesn't matter because you'll benefit from it too
basically
records with FULLY immutable objects
will be translated into just their raw objects
removing the overhead of the class
where did you hear this
JEP-???
LEMME GET IT
JEP-666
@rough ibex
The document is a draft of a Java Enhancement Proposal (JEP) titled "Value Classes and Objects (Preview)" by Dan Smith. It introduces a new feature to the Java platform: value objects. These are class instances that have only final fields and lack object identity, meaning they are distinguished solely by their field values rather than a unique identity.
Key Points:
-
Goals:
- Allow developers to create classes where objects are differentiated only by their field values.
- Migrate existing JDK classes that represent simple values (e.g., Integer) to this model.
- Improve JVM efficiency by allowing it to optimize memory usage for these objects.
-
Non-Goals:
- The proposal does not aim to introduce a struct-like feature, change primitive types, or automatically treat existing classes as value classes.
-
Motivation:
- Object identity is often irrelevant or harmful for simple domain values and leads to confusion and inefficiency. For instance, two objects with the same value may not be equal using the
==operator because they have different identities.
- Object identity is often irrelevant or harmful for simple domain values and leads to confusion and inefficiency. For instance, two objects with the same value may not be equal using the
GPT summary 1/2
-
Implementation:
- Value objects will be instances of value classes, which do not have object identity. These can be optimized by the JVM to improve performance and reduce memory usage.
- Existing classes that avoid identity dependency can easily transition to value classes.
-
Programming with Value Objects:
- Value classes are defined with a
valuemodifier, making their instances value objects. These behave like regular objects but without identity. - Value classes cannot be subclassed, and their fields are implicitly final.
- The proposal includes examples of how to declare and use value classes, such as
ColorandUSDCurrency.
- Value classes are defined with a
-
Construction and Mutation:
- Value classes must ensure that their fields are initialized before any code can observe the new instance, avoiding mutable states during construction.
In summary, this proposal aims to give Java developers the option to create classes without object identity, simplifying the representation of simple values and improving the performance and memory efficiency of Java applications.
GPT summary 2/2
yes I used GPT but whatever
fuck that I'm reading the entire JEP
lmao W
I'm doing the same but yk
saving time
very interesting
Spigot actually gets good perf?
N(1) == N(1)
well, yes but no but I know what youre saying
holy shit Integer[] approaching int[] performance
There is another JEP
that wants to straight up remove boxed types
so you can
List<int>
if it passes
interesting
void main() {
List<int> list = List.of(1, 2, 3);
System.out.println(list);
var random = ThreadLocalRandom.current().nextInt();
list.add(random);
System.out.println(list);
}
Java 23 has all of this except List<int>
also
switch(obj) {
case Point(_, int y) -> y * 2;
default -> 0;
}
yeah _ works for unnamed now iirc
as part of 22
also
instanceof ColoredPoint(Point(_, int y), Color(_, int g, _))
but wait
there is more
instanceof ColoredPoint(Point p, var _)
I got a weird issue, so I'm loading a chat color cosmetic from my config and on load it's in the correct order but when I tried to debug the map, the order is scattered basically.
Here's the code and debug messages https://paste.md-5.net/hiqasediso.cs
The expected order is gray first and orange last.
HashMap is unordered
Don't think they are gonnz enjoy rebuilding the jvm from the ground up
This doesn't typically happening to me, I always got the right order, it's kinda weird.
You may, you may not
HashMap does not guarantee order
If you want order, you wanted LinkedHashMap
which is insertion order
or a TreeMap
Hmm okay, thank you, yeah changing it to LinkedHashMap would work.
Yes it works wonderfully, thank you!
Remember: If you want to ensure order, use a linked collection
is therer anywhere i can find how to like display entities?
does spigot support the new item components introduced in 1.20.6 / 1.21?
Would be kinda cool to have eatable tools (kinda for april fools idea)
they just copying rust match now
yes
does anyone know why i cant DisplayItem in 1.8?
As most things, they do not exist in 1.8
boo hoo too bad
its confusing because other servers have it aswell tho
lie with fleas
what are you on abt
In chat?
no
Are you talking about the display entities added in 1.19.4 then?
oh
that's not even available for 1.8
im just confused on how some 1.8.8 servers have it
they aren't using that class
They're not running 1.8.8
or they're using packet things when they detect a modern client
though this more likely
unless you're trying to copy Hypixel
True, almost
Use Lists if you don't mind having repeated entries.
Use Linked* ONLY if you don't plan to have random access to the collection elements (myCollection.get(2)). In case of almost any Set, retrieving items by index is not an option (I mean, why would you want to, it's not a list)
The thing is that, Linked*, uses "nodes" to store items, which is more "optimized" than the other collections methods, which use an array. The difference is noticeable mostly when the collection gets very huge, but when having random access to the collection elements, the impact is noticeable always.
When using nodes, and retrieving an element in the middle of the collection, the collection must iterate until it reaches the index you provided, or an element matching the provided, unlike in array-based collections, in where you provide the index, and you access the element on the collection array.
- If you want to ensure order, and you don't mind having cloned instances, use an
ArrayList - If you want to ensure order, and you don't want to have cloned instances, use a
LinkedHashSet - If you don't care about order, use any
Setimplementation which is notLinked(unless you plan your collection to have more than 2^31 elements
😭 Yeah fair enough I should've explained better
player.setHealth(Math.max(0, player.getHealth() - 3));
how i make hit damage anim?
without player.daamge
because i need remove same health on all armors
Player#sendHurtAnimation
1.8
ok
player.setHealth(Math.max(0, player.getHealth() - 3));
player.damage(0.000001); @young knoll
ahah
i need help with citizens cuz i want to do it so when i click on the villaga it opens a gui menu i created with deluxe menu but it isnt working can somone help plz
oh how do i do that>
how can i set a item's durability
declaration: package: org.bukkit.inventory.meta, interface: Damageable
damage?!
Hello @drowsy helm ! Today I came across this resource forum: https://www.spigotmc.org/threads/custom-items-made-simple-code-guide.609537/
It's actually a guide on how to create custom items and i need your help.
(Sorry for the ping)
Yeah it’s funny naming
Sure, whats up
I've been thinking on making custom items with components tbh
hmm where should i set it. like ItemStack or ItemMeta?
May I dm you to explain the issue ?
You can cast ItemMeta as damageable
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
ohhh
gimme a sec
can you explain to me how this specific function was implemented?
thanks it work now
Ah I guess I didn’t cover that in the tut
One sec
Dang did I delete the repo lmao
Yeah i cant find that either
stand.getLocation().getBlock() == player.getLocation().getBlock()
block can i compare instances
right?
public void registerListener(Listener... listeners){
for(Listener listener : listeners){
getServer().getPluginManager().registerEvents(listener, this);
}
}
this is all it is
just a method inside the JavaPlugin class to easily pass listeners
yeah that will work
The CustomItemTutorial object instance is about the Main Plugin Class right?
correct
Thank you
thax
when i use reflections api, getSubTypesOf method always returns empty list. i dont know the reason
(reflections 0.10.2)
here is my code.
new Reflections(packageName, new ConfigurationBuilder().addScanners(Scanners.SubTypes.filterResultsBy(s->true)).getSubTypeOf(Test.class)
lmao
https://github.com/MitchGB/CustomItemTutorial
I've re-published the repo if you need to check it out
appreciate it!
how would one access bitbucket? im trying to view a pull request
hi, i am making a minecraft minigame, for now whenever i wanna load a world i copy its folder from the plugins folder to the main server folder to then load it whenever i want the game to startt, this is to ensure that changes made to the world dont get saved, is there a better way of doing this?
create a jira account and sign the cla
?cla
is block metadata persistent?
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
use that instead
how get maxdurability from item
what abt me storing them in a hashmap and then serializing that with java serialization api?
never used that tbf
but sounds like it might work
if somebody can answer this id greatly appreciate it
java serialization api uses reflection
sooo?
item.getType().getMaxDurability(), im not sure yet on 1.21 custom durabilities
how i set durability but no shows on item?
basically i want save a durability from item but no use durabillity vanilla system yk
i dont want show the "durability bar" on item
ToolComponent does not seem to have a get or set max durability yet
though i know 1.21 has that functionality
dont advertise here
fuck off
💀

zero github followers, nobody knows you in the community
If you want to find customers make them want to find you
illusion i lost all my bets
nope never
does bamboo have the same behavior
it keeps growing forever
thats rough bro
you cannot stop bamboo
string above it
i can but not with vanilla means
yk what ill use custom block data, i cba with handling pistons and shit
hi, i am making a minecraft minigame, for now whenever i wanna load a world i copy its folder from the plugins folder to the main server folder to then load it whenever i want the game to startt, this is to ensure that changes made to the world dont get saved, is there a better way of doing this?
use Tags bro
oh wait are there tags for armor?
which tags
its HELMET
im on 1.8
💀
ITEMS_ENCHANTABLE_ARMOR
on contains
big letters
i think no
#name returns the literal enum value name
if i were to be on 1.8, id throw a hypixel move and hard fork spigot 💀
did tags even exist on 1.8
❌
aw dang it
either didnt exist or had almost no tags
.
player#getinventory#removeitem remove item on armor slots?
HOW I REMOVE
ITEM
ON ARMOR SLOTS
stop screaming
you can remove armor slots using getInventory.removeItem
just pass the correct slot numbers
i think its like 36 to 40 or whatever
No it doesnt, PlayerInventories have armor content as well as extra contents.
What are you trying to do?
then why am I able to add an item to slot 36 and have it appear in the boots slot
my unbrekeable method not works with leather items.why?
forget i fixed
public ItemBuilder unbreakable(){
return changeItemMeta(meta -> meta.spigot().setUnbreakable(true));
}
what does changeItemMeta do?
please dont tell me it calls getItemMeta every time right?
calls of course
public ItemBuilder changeItemMeta(Consumer<ItemMeta> consumer){
ItemMeta itemMeta = item.getItemMeta();
consumer.accept(itemMeta);
item.setItemMeta(itemMeta);
return this;
}
but the problem isntm ethod
problem is the leather armor
works on other armors
but leather armor no
maybe colors leather system the problem idk
This is quite expensive for an item builder
yeah thats what I was afraid of haha
atleast just take out the meta and have it as a separate field
how u edit itemmeta then
because getItemMeta is expensive
Like steaf said, allocate an ItemMeta field and initialize it in the constructor
bro i need get lore etc
lore etc its changeable
oh yes
forget
ok
yes
yes and works
and my texture show "bugged item" yk
Why do you call meta.spigot() ?
i call
public ItemBuilder unbreakable() {
return this.changeItemMeta((meta) -> {
meta.spigot().setUnbreakable(true);
});
}
right but why
then run a cmd
?scheduling
thread.sleep(3000)
ty
💀
🤡
And dont do what ola said
HAHAAHA
it didnt pop up anywayt
fyi that will freeze the server
I literally did what he asked
yea
for 3 seconds
how i make unbreakable
.-.
Why dont you simply call meta.setUnbreakable()?
maybe setdurability(type.maxdurability) ?
and solve my problem?
not have meta.setunbreakable
on spigot 1.8
oof
?1.8
Too old! (Click the link to get the exact time)
Soon its gonna be a decade old 🙂
oh yeah it turned 9 2 weeks ago 🥳
Support was dropped almost half a decade ago. But that doesn stop people from wanting support lul
ItemBuilder builder = new ItemBuilder(armor)
.name(color + ArmorGive.getNameByItemStack(armor))
.setLore("", "§7Resistance: " + color + ArmorGive.getDesignResistanceByCategory(armor.getType(), category), durabilityString, color + Category.getName(category) + " Equipment")
.glow(category == Category.MYTHIC);
if (armor.getType() == Material.LEATHER_HELMET || armor.getType() == Material.LEATHER_CHESTPLATE || armor.getType() == Material.LEATHER_LEGGINGS || armor.getType() == Material.LEATHER_BOOTS) {
armor.setDurability(armor.getType().getMaxDurability());
} else {
builder.unbreakable();
}```
unique solutino
use codeblocks
anyways
the point is , like noone knows whats going on with 1.8 since we are like 2 generations past it
so idk why it doesnt work
what is codeblock
have armordurabilitydesincreaseevent something like this?
?codeblock
You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
Becomes:
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {
}
}```
ah there is a command for it
Probably not in 1.8
PlayerDamageItemEvent is a thing
talk about over engineering
Lol
I mean it technically makes sense. Its just expensive.
if (item.getType().name().contains("HELMET") ||
item.getType().name().contains("CHESTPLATE") ||
item.getType().name().contains("LEGGINGS") ||
item.getType().name().contains("BOOTS")) {
event.setCancelled(true);
}
maybe this then
I would simply set the item to unbreakable
its bad design, just flag the state and apply it later if u care about it so much
okay maybe not bad
but like
Sounds like a problem with your ancient version 🤷
I can totally see this being viable
private final ItemStack itemStack = ...;
private final List<Consumer<ItemMeta>> consumerList = new ArrayList<>();
public ItemBuilder apply(Consumer<ItemMeta> consumer) {
consumerList.add(consumer);
return this;
}
public ItemStack build() {
ItemMeta itemMeta = itemStack.getItemMeta();
consumerList.forEach(consumer -> consumer.accept(itemMeta));
itemStack.setItemMeta(itemMeta);
return itemStack;
}
for a builder
viable maybe
but extremely unnecessary
and as said if u truly care about not creating any item metas unless needed
flag it, apply later
How would you flag it
Just have An itembuilder that stores a meta field 🗿
I have never heard about the term "flag"ing for storing an object in a field...
my item builder stores meta changes with consumers similar to what smile showed
Wdym it's "flexible" 💯
flagging is just a higher level term explaining the intent behind the semantics u impose on ur code
this allows any item to do anything with teh meta that isnt covered by the builder
but all things covered by my builder have fields
Items are on my list after inventories good sir
you are one true blessing
Yes, but the semantic meaning of a flag is based in signal logic... thats what confuses me
i mean if u want u can do it literally and store some state in a bit set
but eh, thats just too low level nowadays
you can just have a meta class val and set it on construction then set it on the item one build()
i suppose the confusion is valid
@young knoll gonna ask again :> why was ItemType not fully implemented in 1.21 we waiting for 1.22 now?
Or is there some crossroads
yeah that was teh first suggestion we made haha
idk
Thats my approach as well. I just said that the consumer might be viable as well
I thought you'd know since you got insider status :(
viable but inflexible
I would argue that its more flexible even
not really
its very common to read from builders as well
what
No
in what country
no it isnt
spring
were u born yesterday?
Why do we need to read from an ItemBuilder
it depends
0 benefit
this is about an item stack builder
well say that to all api designers
You just said it for sake of saying it
not really
Really where is the inherit benefit
what does it depend on
then additionally you lose all integrity w using a bunch of consumers
This is clown behavior
its legit not
but inflexible is not the term I would use
what would you use?
Imagine if spigot adds new methods to ItemMeta. The consumer approach doesnt need to be changed. If you have
concrete methods like setAmount(x) then you need to update your builder. The consumer works either way.
(I personally think that methods need names, so having just the consumer method is unclean)
i dont even know
a normal builder wouldn't change as well? or what exactly are you trying to say?
The true question is, how do you handle methods delegating to more specialized instances of ItemMeta, like PotionMeta.
I use a consumer but really it'd be best to just pray ItemStack gets an overhaul so it's not so blegh
The consumer builder is more flexible
how?
Because of the flexibility i just described
yeah that was my reasoning for using a consumer system aside from the commonly used item meta modifications
how do i kill an armorstand entity
.remove()
thank you
a normal builder wouldnt change as well?
you're talking about a non existent flexibility
If the built object gains more properties/functions, and the builder doesnt change, then you break the builder contract.
If you have a consumer of the underlying object, you can simply keep your builder as it is, and call the new methods via the
consumer. It breaks encapsulation, but its def more flexible in that regard.
weird question but does anyone know how to make an armorstand move? like if it could just walk a couple blocks or just move itself a couple blocks
hi, i am making a minecraft minigame, for now whenever i wanna load a world i copy its folder from the plugins folder to the main server folder to then load it whenever i want the game to startt, this is to ensure that changes made to the world dont get saved, is there a better way of doing this?
If the built object gains more properties/functions
entirely depends on what changes are imposed on the actual class, and even then any good lib maintainer should try to keep it somewhat retrocompatible, but sure lets say it does change thus leading to binary imcompatibility, well its a good thing i used the builder, the builder can and should serve as a factory, knowing how to instantiate and prepare the object its going to publish decoupling creation from instantiation to its clients, thus as long as you maintain the builder, even the actual class itself imposes binary incompatibilities you can save yourself by encapsulation and interfacing, that is afterall why we use static factory methods, builders, factories and abstract factories
multiple ways. simplest is just to call .teleport() on it
id like it to like its hard to explain
id like it to move there without teleport
so that the nametag moves
instead of teleports
Like move smoothly?
anyway i did take back that using a bunch of consumers is bad, it has its place probably, its just isnt as flexible or well ideal whatever you wanna call it, especially if you're moving to a layered builder where you pipeline different states and what not (which usually requires to read what wants a change before applying the next)
thank you
Do armorstand.getDirection
Direction.multiply by speed
Location.add direction
Ye
Cuz the direction vector is usually normalized
move a few blocks, then stay
lemme write it in code for u
you dont need to do that haha but thank you
yeeea
hello sir, how come ive never seen you here before
i mean there is no way to get around this somewhere in the code gotta check if u reached the destination
except if u use a lerp method
not necessary tho
because i usually dont chat
By builder is far gone anyways
public class ItemBuilder<SELF extends ItemBuilder<SELF, T>, T extends ItemMeta>
lol
you remind me of someone
i might just use teleport lol
i do?
but that person got kicked, so doubt it was you
if u wanna know what that is we can dm @stuck oar
alr thank you
fucking hell then
nah that dude with a skull pfp with christmas hat, with the long random name
years ago
frost def was very keen on arguments. I remember when he joined and he was very convinced that memory mapped files are a good idea for a region system
i mean..
ah i know who you on about

no thats not me, im not quite as racist as that bloke
yoo guys, if somebody could just tell me if there is a better way id greatly appreciate it :>
*could have an interesting talk about it as well *
oh he might've said weird things but he thought me how to write some proper code lol
Not via vanilla. You need to be very creative with that. Proper approach would be orchestrating multiple servers, and start them when needed.
Loading worlds will always yield some overhead
wait so those big servers have a mini server for each arena in each gamemode?
and those worlds are always loaded
like always
they are o.O
vanilla MC memory maps region files currently. However Mojang implemented a flaw that caused servers to crash when loading them
Big servers have that for sure. They dockerize their environment and orchestrate them with tools like Kuberenetes.
Wouldnt be surprised if they used Graal containers for high accessibility.
i mean if there are only a few chunks, whats the overhead?
All the IO on the main thread. Checking if folders exists, reading the world data (UUID, name etc) from disk.
so is it okay for me to have them always loaded or is it not okay T-T
Depends how much memory you have to spare and how far you plan on scaling
and btw as i said my approach was to copy the selected arena from my plugins folder to the main server folder to make it a temporary world then delete it
but that crashes
my server
ah well ye there begins the flawed design
Your IO should always be done on a different thread.
vanilla MC already does this
regions like chunks? o.O
but a questino tho, if im planning to always have loading my arenas how would i stilll keep this copying thing going on
why are you fourteen years old?
another question is i think its kind of messy for the server implementing the plugin having to place the worlds by hand in the main server folder is there a better way to do this?
You could copy ther worlds into your jar.
Or throw them in a Database and let the plugins request it.
i said to change my name many moons ago, now this server is the only server that still bullies me with it
and no im not 14
Or simply on some of the public server world hosts and then download it from there when the server starts
not specifically, but I have used memory mapping for plenty of other stuff. Like some years ago I helped with a plugin that tracked all blocks that were placed from creative and who placed it. The test conducted was to see how long it took to load up a large amount of data. It took like 6 seconds to load 10 million blocks of information and 3 seconds to save it.
cant mr smile7face do it for you?
You havent renamed yourself to FifteenBrush so i think thats a lie
shame, you could have been a prodigy
tHe VeRiFiEd NaMe
Ah true
ohhh thats a great idea, then i wont have to check if those worlds exist or smthn
of course their name means they have fourteen brushes that they use
that wasn't the right one lmao
Or that they brushed their teeth a total of 14 times in their lives
how did you load and save it?
not sure what you mean
all a memory mapped file is, is just a file that is mapped into memory
The os handles the loading strategy for memory mapped files, no?
pretty much, the only thing you can change is whether or not a conversion takes place
in this instance the file was binary
having the file as binary avoids having the OS do a conversion before loading into memory since all data in memory is binary
I would argue that there is no actual reason for this. A region can be defined with a few bytes.
Keeping 10k regions in memory will maybe hog 40MB in RAM. And nobody has this many regions.
um yeah if the chunks are not modified or you have many empty chunks in the region
vanilla mc adds too much data currently to allow 10k regions to be loaded
im sure u could optimize that
no this was back around 1.7
unfortunate
most definitely
one of the main reasons way back when a chunk could crash a server via books
Ah i was just thinking about regions as in BoundingBoxes
Worlds UUID -> 2 * 64 bits
lower x,y,z -> 3 * 32 bits
higher x,y,z -> 3 * 32 bits
= 224 bits or 28 bytes. Then throw the object header in (make it a record for good measures)
and you'll be more in the kilobytes apartment
was because MC never bothered to check the size of a region file before attempting to load it into memory
sadly that exploit went on for way too long
book filled shulkers go brrr
some of us profited it from it
so, it doesn't bother me
some
yes, I rather have a large pool of customers with little competition then no customers and lots of competition 😉
Was about to say. Frostalf is a server exploiter confirmed.
I don't exploit servers, but I will exploit people's need for something
not sure of which is worse
servers > people
So in my mind this sounds fine
if it keeps the smile up, sounds skibidi enough for me
I think its safe to say I am the capitalist in this discord XD
and then we have Alex who is a lawyer for your tax needs in Germany
are you funding spigot?
no
right
Im more for a technocracy anyways
it funds itself just fine. but even if it doesn't not sure what me funding spigot would even do
MD_5 has been developing spigot long before any donations
and I am pretty sure the current server/web related things are not super costly currently
bet it probably costs something like no more then $500/month
Hm, website + File hosting service + stash server
pretty sure its all one dedi
no more then 2 for purposes of backup I guess
if I remember think all the plugins currently on spigot only takes up like 300gb
don't need an entire server for the files
Hmm, dont you think its decentralized? People access files from all over the world.
and whay happens when the server goes down
that is what cloudflare is fore
its in case of HDD failure, not backup in to route traffic
I mean you could set it up like that, but I wouldn't unless it was necessary
well depends on the host
ur server could fully go down
then u can still operate bc ur files arent there
and u can host on another server
not sure what hosting providers you are going with
but the ones I use if that happens they can stick those HDD in the backup server
well mine went down once in the past like 2 years
in a big hosting company?
big hosting companies won't keep your data from you
what
generally they are prohibited from doing such things
ik but ur data may be unavailable if its down
why would it be unavailable?
bc its a computer
hdd's are not removable?
i dont think a large company is gonna change their hdd locations for a downtime
depends how long it will be down for, but if you have another Dedi in the same building
they will connect it to that
and they will connect it to the other server....
not sure what makes you think they wouldn't o.O
Usually you have replicas in sep datacenters
if you wanted to prevent network failure related things sure
but in the case of something like spigotmc, it really isn't even necessary
nor would I say worth it. Its not like everyone pays for spigot service
the only thing I would ensure is that the plugins and the DB for the site have a backup not on the same machine
that is the minimum that is necessary
however, just having them on more then one HDD also works too
if I recall I believe all the plugins on spigot currently only take up 300gb
maybe a bit less then that
Guys I encountered a problem
Now the Enchanted book ItemType; the name is the same but the features are different
I wrote something to choose an item by chance but this time it can't distinguish it.
He always gives the same book
What should I do?🤔
ItemType can distinguish those that are not the same, but not others
Do I have to define a unique UUID key for each item?
?paste
hello i need help with a plugin im trying to develop using Intellij IDEA https://paste.md-5.net/wonubijupo.java
could anyone more advanced help ?
As the error says there is no PotionEffectType called SLOW
I assume you mean SLOWNESS
?paste
Hello, the problem I have is that my pickaxe drill isnt doing what it's supposed to which is mining 3x3x1
https://streamable.com/s0k0jo
The code I used is:
https://paste.md-5.net/erebitebeb.cs
I have a feeling it's my direction method that is wrong
uhmmm
There has to be a proper closed solution for this. Ive seen so many switch-case approaches for this.
Probably need discrete vector geometry. Hm maybe joml is now the solution.
Blockfaces have a toDirection method. And they produce a normal vector on the plane.
Yep
yuppers, uhh I tried using mfnalex's code from a while back here in this discord but I used a different way of getting the direction so I assumesd that the direction method was wrong
Idea is to get the block face the player is looking at with getLastTwoBlocks, create a cuboid and shift it by the opposite direction of the block face
getLastTwoBlocks?
it's really degenerate
but it returns the block you're looking at
and the block before
you can get the face a player is looking by comparing the 2 blocks
with getFace or getRelative, one of those methods
list is always expected to have a length of 2
Thats a paper method i suppose
why the actual fuck
I used it way back in the day
Have pairs or array not existed back then
pairs are poor structure and I assume arrays are unsafe?
How about you listen for the BlockDamageEvent, which already has the BlockFace the player is hitting at
that method is so fricking stupid
"get me the two last blocks the player is looking at" like what, who thought that was a good idea
hmmm, ill try doing this
exists since 1.8 at least
Hm maybe the PlayerInteractEvent is more suitable. The BlockDamageEvent doesnt have a BlockFace in spigot
yeh i was able to resolve it but another one always arises 🥲
That definitely has its purpose, only because you don't see a point in something it doesn't make it stupid
public class MultiBreakListener implements Listener {
private final Map<UUID, BlockFace> breakDirections = new HashMap<>();
private final Set<Block> skipBlocks = new HashSet<>();
@EventHandler
public void onQuit(PlayerQuitEvent event) {
this.breakDirections.remove(event.getPlayer().getUniqueId());
}
@EventHandler
public void onDamage(PlayerInteractEvent event) {
this.breakDirections.put(event.getPlayer().getUniqueId(), event.getBlockFace());
}
@EventHandler
public void onBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
if (this.skipBlocks.remove(block)) {
return;
}
BlockFace blockFace = this.breakDirections.get(event.getPlayer().getUniqueId());
List<Block> blocks = this.getMultiBreakBlocks(block, blockFace);
this.skipBlocks.addAll(blocks);
blocks.forEach(player::breakBlock);
}
private List<Block> getMultiBreakBlocks(Block origin, BlockFace direction) {
// Add logic here
}
}
This would be my first idea. Just need to implement the getMultiBreakBlocks(...) method.
This btw automatically supports protections from any plugin because of how the blocks are being broken.
And it incorporates the tool the player has as well
There is certainly a way to make it better without losing functionality
I know not spigot related but anyone got idea for java project thats not a calculator
Game of Go
Im... not sure if this makes sense. In my head it does.
private List<Block> getMultiBreakBlocks(Block origin, BlockFace direction) {
List<Block> blocks = new ArrayList<>();
Vector forward = direction.getDirection();
Vector up = new Vector(0, 1, 0);
Vector right = forward.getCrossProduct(up).normalize();
for (int deltaRight = -1; deltaRight <= 1; deltaRight++) {
for (int deltaUp = -1; deltaUp <= 1; deltaUp++) {
Vector rightOffset = right.clone().multiply(deltaRight);
Vector upOffset = up.clone().multiply(deltaUp);
Block relative = origin.getRelative(rightOffset.getBlockX(), upOffset.getBlockY(), rightOffset.getBlockZ());
blocks.add(relative);
}
}
return blocks;
}
Make an app that lets you browse maven repos, add dependencies to a certain list (like a shopping cart) and then generate a pom.xml/build.gradle including all those dependencies
not a bad idea
And it should also be able to add dependencies to an already existing pom.xml/build.gradle
As well as remove them
and all of that with awt
String UUID = Redis.getUUIDFromUsername(targetName);
Inventory AP_MainUI = Bukkit.createInventory(null, 54, "§c§l/ap §8§l" + targetName);
ItemStack head = new ItemStack(Material.SKULL, 1, (short) SkullType.PLAYER.ordinal());
SkullMeta head_meta = (SkullMeta) head.getItemMeta();
head_meta.setDisplayName(targetName);
head_meta.setOwner(UUID);
List<String> lore = new ArrayList<>();
lore.add("UUID:" + ChatColor.YELLOW + UUID);
lore.add("Rank:" + ChatColor.YELLOW + Redis.getRank(UUID));
head_meta.setLore(lore);
head.setItemMeta(head_meta);
AP_MainUI.setItem(0, head);
plr.openInventory(AP_MainUI);
``` I'm trying to get the head of the player from username (I have UUID saved in my Redis DB).
But I'm getting this error:
org.bukkit.command.CommandException: Unhandled exception executing command 'ap' in plugin NeoWorld v1.0
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServer.java:646) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerConnection.java:1115) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:950) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:26) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:53) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_422]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_422]
at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:696) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
at java.lang.Thread.run(Thread.java:750) [?:1.8.0_422]
Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_8_R1.inventory.CraftMetaItem cannot be cast to org.bukkit.inventory.meta.SkullMeta
at fr.program.neoworld.Commands.Moderation.ApplyPunishment.onCommand(ApplyPunishment.java:52) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot-1.8.jar:git-Spigot-c3c767f-33d5de3]
... 14 more
?
how to make a item with enchantment glint without enchantment in 1.21
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
alright thanks
?paste
We're not paper lol
Also there's no error listed in that paste
Uh you probably didn't add the repo for paper, and theres something wrong in the <project> path where you tried to add a [children] tag?
?whereami
would it be better to have an api and various independant plugins for an entire server or condense it to one plugin
monolithic vs segmented plugin let's see
less code duplication and overall fuckery with the added benefit of being hard to split vs clean, digestable modules that hook into a common base
condense it to one plugin
Users can't update/download dependencies
They don't read documentation nor the Spigot page
its just for me, i am making everything from scratch
Then split it up
yay
and yes this ^^
if you plan on putting everything in one plugin
does anyone know basic electical wiring? i want to be able to control a lightbulb with a switch but i dont have an available microcontroller, any resources to start out?
hi can anyone help pls
as7.setHelmet(new ItemStack(Material.DIAMOND))
the item is there and you can pick it up but its invisible, anyone know why? (as7 is an armor stand)
do you have to put it in the hand slot?
I mean I don't think theres like a rendering process for a diamond on the head of an armorstand
A diamond (unless forced in this way) would never be on an entities head
Therefor no reason to support a model I guess you could say
why would you need a microcontroller if all you need is a switch?
the leds have tiny little micro controllers in them
i have level-data on tutorial world but im not teleporting to tutorial world why
ok you said lightbulb, which isn't LED
Are you sure you're american cmoe?
ping me
I've got the same issue don't feel bad
anyways there really isn't much to controlling the microcontroller. Its more or less give it appropriate voltage
some LED's let you do different stuff, but again its just variance in voltage
i soldered right on the contacts and nothing happens
ok, did you make sure the polarity was correct?