#help-development
1 messages · Page 635 of 1
the error is that it doesn't go back to the original block. it is as if he did not enter the if.
what is "game.typedBlocks"?
what is game.typedBlocks?
and where is that
I'd have to check if the player is moving inside the task right? So when a player is stopped the particles stop appearing too
does it print "Change true"?
no
Store the position and then the next time it runs check if the position has changed
does it print "Run Task"?
yes. "Run Task"
That's one if statement with a (weak)hashmap
how i can?
thx
??
whats ConcurrentHashMap
hashmap thread safe
How can i make that a player doesn't loose his hunger
cancel FoodLevelChangeEvent
if the event's getFoodLevel is less than the entity's current food level
hello, in a gui, it's a bad thing to make a
if to check every possibility of what the item might be? I imagine so? Is there a technique to avoid doing this?
so?
I usually just apply a PDC tag for the "function" of every item
e.g. "next-page" etc
Show your entire code
yes I have already done this system, but I have changed it a little because I do not like this button system, I prefer to keep a single function which recovers the click event
Then do a massive switch statement with PDC data 🤷♂️
else i can make a switch?
how to decide should event handler have high or low priority or does it even matter that much if we specify it ?
You usally don't need to set it
sometimes ye
The entire class
how do you decide if it should be like highest or high or whatever option
is there no event for when a book is placed onto a lectern?
do I just have to have a special check with PlayerInteractEvent and check if the clicked block is a lectern?
if u want it to run before or after other event handlers
egh
what class. the listener?
Where ever that code is
or just put the entire project on github so we don't have to has for more code multiple times
eh I'm just going to do smth else
Lol
I'm not going to waste another half an hour asking for more code
Hello, i have a problem,
private double calculatePrice(User user, double numTreats) {
double treatPrice = ((user.hasCustomObject("treats") ? user.getCustomObjectInt("treats") : 0.0) * 100.0) + 100.0;
treatPrice = Math.min(treatPrice, 10000);
return numTreats * (treatPrice + treatPrice + (numTreats - 1) * 100.0) / 2;
}
at this line:
return numTreats * (treatPrice + treatPrice + (numTreats - 1) * 100.0) / 2;
I want to add the price + 100 for every treat, but if the price goes higher than 10000 it should be capped at 10000 and every next Treat should cost 10000. I cant use for loops because if my number to buy is like: 1000000000000.0 it crashes the Server.
You can simple use an Proxy System with functions to reset the server after a match ends.
bruh why did you say ich
dont let server save the world so if it is not saved there will be no other blocks after you restart server
Sorry, my bad i am a german programmer and the word "Ich" means "i". It was a mistake from me. Translation at a late time is not good for me. xD
or if you would take different approach but idk if it is better you can listen while game is on for block place of each player and save it into a map and on game end event you can just go through maps or arrays or whatever you want to use to store those blocks and just remove them one by one which will be quite fast 🤷🏻♂️
yes i know ich is i hahahah i didnt get what are you even trying to make i mean that is too much math for me im not good with it but i would say from text you sent there is no need for such math
i know, i show for different code but there isnt any solution for my problem. 7 Hours of life wasted.
i mean if you want to go 100 for each threat you can go in for loop and make it go price go + 100 until price is 10000 and there shouldnt be number like 1000000000000.0 because it will break out of loop once it reaches 10000
I know a good friend told it me at the same point. I try it.
just multiply then Math.min
did you go to university if so what did you study ?
no, university is only for indoctrination
Did you do cs in college
no cs wasn't a course when I went to college
just make an if statement that checks the number and returns appropriately
Damn
so that means its good right?
Hello, I am trying to check if player has broken wool, and that with switch case get what color is it. My code looks like this, but I am not sure about LEGACY_WOOL. I looked on Spigot documentation, but couldn't find any description. So maybe it's not even possible to do it this way. Thank's for any help
if (e.getBlock().getType().equals(Material.LEGACY_WOOL)) {
final DyeColor color = ((Wool) e.getBlock().getState().getData()).getColor();
switch (color) {
case MAGENTA: TeamData.addWool(Groups.MAGENTA);
break;
case LIGHT_BLUE: TeamData.addWool(Groups.AQUA);
break;
case LIME: TeamData.addWool(Groups.LIME);
break;
case YELLOW: TeamData.addWool(Groups.YELLOW);
break;
case BLUE: TeamData.addWool(Groups.BLUE);
break;
case BROWN: TeamData.addWool(Groups.BROWN);
break;
case RED: TeamData.addWool(Groups.RED);
break;
case BLACK: TeamData.addWool(Groups.BLACK);
break;
default:
break;
}
Block break? And getData.
Yea block break event
1.19.4
no but you could set it to null and manually send it
just loop over all online players and do player.spigot().sendMessage
that takes components
broadcast also does
hi question , iam trying to think of a system to make for my plugin :
- Timed Items , so its a shop , when you buy the item it will have a time in the lore [the time when it will expire]
after that , when ever you join , interact click , or damage the item , it will check if its expired .
what's the best aproch to go with , what Time utils i can use ?
what i was thinking is a :
would be better if they didnt obfuscate at all 🙂
Expired time? In the end time this will be deleted?
yes indded
yes
yes
well, yes but the mapping "patch" this problem
it will check , when player join if its expire , when player damage the item , when player do other stuff with the item ..
why obfuscate when you give mappings anyway tho
except for the fact that the mappings change with every version
File size
how big the difference is
Mmm
well, not really a problem with multi-module
No idea
isnt it like 10 megs
obfuscated, it's a problem, remapped it isn't really
well you then have 10 times the same code in your plugin, just with different mappings
I find this quite annoying
🥲
craftbukkit's elements are a little annoying
Add only most version used
i got people who complain if something doesn't work on 1.16.2
no idea why they use 1.16.2

for having brute piglins without bug fixes
this dude is using 1.16.3
Delete support for this version
support only the latest of each major version, problem solved
Then you get 1 star reviews
the guys who makes me angry 
CombatLogX keeps getting 1 star reviews from rule breakers in our discord
POV : my plugins
They 1 star because they get muted for a bit
I haven't recieved a review in a looong time
Isn't that plugin OS?
no
pterodactyl
ah
1 star : crack recognition
it was open source but once I removed the github link and raised the prices, much more people bought it lol
🐀
I Will delete
... they won't
their cracked version only supported 1.16 anyway
A little question :
Do Herobrine is autorized in spigot public resources ?
that's why they had 2 versions, the free 1.20 version and the cracked 1.16 version
?
because Mojang don't want things with Herobrine
I think I'm not sure
They don't care
just call it Heroacid
heroin
Herobrian
Steve 
Dude's I need to make a regeneration system for a arenas like block to block. Anybody can help me?
Not without any information
What information? Only need the use. And proposed
I need to make API for plugins like bungee multi arena world
Where can I find the 1.19 equivalent of 1.18's ClientboundPlayerInfoPacket ? (a doc for this ? a tip to find it ?)
it's still called like that
(I know it's ClientboundPlayerInfoUpdatePacket but something to find it easily will be better)
oh wait I only checked 1.19.2
there are different 
so I need to do it for 1.19.2 and 1.19.1 ?
with BuildTools ?
(who is making my pc burning)
😂
Yeah it's the CPU having to decompile
20 seconds on m2 max 🥲
how can I speed it up or saving my processor life ?
not generating docs and sources 
I'll remove this parameter
Get a better cooler?
"C:\Program Files\Java\jdk-17\bin\java" -jar BuildTools.jar --rev %Input% --generate-docs --generate-source %remappedArg%
a better motherboard, compatible, and after a better cpu
and losing 500$ for this
just to compile
You don't need a new motherboard for a new cooler
cooler isn't the problem
I used burning for dying
If it's just the CPU being slow then just go do something else while it's running
well, my english is bad so I need to contourn the path
I don't have any friend... 
I usually just watch youtube or smth
My i5 3470 could handle it just fine
Your CPU probably can too
Laptop 💀
3* faster without overclocking for you 
you are not havinga good time are you
Just go do smth else. Watch youtube on your phone 🤷♂️
I think without generating docs and sources it will work
add more sysouts or see if its any issues with the url building or something
making stuff thread safe is hard tbh
its either something throwing an error that isnt caught or its some jank
but I have ~10 minutes of generating docs and sources
Is it possible to detect when someone is unbanned? or what ways could I go about doing that?
once they were able to join ig
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
ive sent it like 5 or more times today
You've been asking for help every single night writing no more than 5 lines of code per day
xd
It's also just copying tutorials
Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.
That are outdated and then trying to merge stuff
you have been sent the learnjava links so many times in the past 4 days youneed to go and learn java
We aren't your personal code assistants and we're giving you pointers on how to learn to code
It's been longer than that
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Your problem doesn't matter to us at all as much as your ability to problem solve
I'm also good at problem causing if needed
yes ofc ,you have to be able to provide your own work ofc
i have been ip banned from spigot MC website and i have no idea why, how do i get help??
are you using a vpn
hi uhh , i have weird problem :
why it does not work ?
this check does not work .-.
should i do a for loop in the lore list and check each line?
why are you using lore and not PDC
You would need to have the full line to use contains
you have to loop through the list and use contains
or if you're on older versions NBT
PDC?
?pdc
yes iam on older versions .
use NBT
if you don't use NBT you will end up shooting yourself in the foot
Lore is such a bad way to keep data
yes i know NBT
turns out you can have abstracts in enums like wtf how did I not know this, this is genuienly useful
You what
lets say i want to use NBT
ADD('+') {
@Override
public double apply(double x1, double x2) {
return x1 + x2;
}
},```
this is valid java code
here is where i add the lore
when you add the data? just focus on making the lore look good not on data storage
add the raw data no conversions necessary to the NBT
Anyone know what 7x9 is i need help
you fuckin what mate
show me more
What is 7x9
CAT {
public String makeNoise() { return "MEOW!"; }
},
DOG {
public String makeNoise() { return "WOOF!"; }
};
public abstract String makeNoise();
}```
63
so i can do this right?
that is great
Why use a Boolean and not a long
With the timestamp of when it expires
i can do that too?
Why should it not be valid?
Well with a long you can store the expire time in a simple format
just didn't know that you could add abstracts to Enums is all
Oh yeah sure
At the end of the day, your enum boils down to just this, which is probably a little more understandable as to why it works
public abstract class MyEnum extends Enum<MyEnum> {
public static final MyEnum EXAMPLE = new MyEnum() {
@Override
public void example() { }
};
public abstract void example();
}```
ahhhhh interesting
Spigot actually uses this syntax for ChatColor
Could you not have just used a field
Yeah I kind of question that as well. It's not like the enum constant itself isn't already being removed. A { is added anyways
¯_(ツ)_/¯
the system is working and it does remove the item after the time usage expired .
need to improve it now :p
When is it smart to store data in the player NBT data and when / how can i create my own data files (if they are better)?
ugh why using nbt when you could use pdc
thats what nbt data of the player is
personaldatacontainers are the nbt data
im using pdc, but i feel like a bad developer and it would be better to create a data base
I mean if you can use a database you probably should. It will end up being more performant at the end of the day
He’s on an old version
If it's trivially simple data then it's fine
no
Up to you, really
Not you
is there a way for me to learn how to create data bases, i tried but failed miserably everytime ?
yes
Practice mostly. There are different flavours of database. If you want something simple and flatfile you could look into SQLite, but if you want something remote and more robust, MySQL (or MariaDB or Postgres) would be good ones to look into as well
tf is that link?
📄
i want to store the clan a player is in, what would be the most fitting for this?
Definitely a DB
You won't be able to access that data unless the player's logged in otherwise
What if you want to get all players in a clan?
and you can do some cool sql lookups to get all people in clans
Or kick a player for that matter?
does offline player not impl PDH
Not yet
huh
guys i dont really understand what you are talking about
doesn’t matter, just use a database
yes, but i dont know how to do it? do you know a good tutorial?
read the link i sent, you will need to learn some basic sql though
mysql database you would need :
-
2 tables
-
a table for clan info itself [ID, NAME, TAG, COLOR, LEADER, KILLS, CLAIMS] this is just an exmaple.
-
a table for players it use the ID for each guild , this is how i created my system UUID , NAME , ID , GUILD_RANK PRIMARY KEY (UUID, ID) , [this is also an example.]
its a bit hard and its goona take allot of time to finish but the result in the end is great .
thank you for the response, but what does sql mean?
i think you mean sqlite?
it’s the language used to interact with databases
so i need to learn another language?
Yes
it’s very simple
It’s fairly simple tho
updated .
SQL is mostly English keywords
Syntax is rather self explanatory, but yes, it is a different language
okay, i will look into this
And there are different flavours of SQL too. SQLite's SQL isn't 1:1 with MySQL's SQL
Because heck you
hi am i doing anything wrong ?
when i buy the item it should set it to the current time of buying :
i bought it now but it set it to 1:24 , now its 1:45 ..
LGTM. Could just be setting the wrong value on your item
Set a format
yes i see
oky
let me test it
i only need to put hourly items , you know i won't be using a day or a week or smth .
the value is 1 for the hours
but for some reason its give 2 hours , 53 minute this .-.
How should I go about having a mob never despawn?
Set it to be persistent
will try
Whats up fam
trying to work harder .. ❤️ thx for asking
And you likely should use OffsetDateTime instead of LocalDateTime as winter/summer time could mess up your logic
the problem now :
when ever i buy an item from the shop , it set the time to 3 hours , 4 minutes , 20 seconds ..
all items have 1 hour only :
oky thanks ..
yeah didn't work ..
Don't work?
Dont populate within the constructor. The approach in this tutorial was meant for very dynamic guys that might change every
time a player opens it. If you want to define GUIs that are only initialized once because they are static then you need to externally decorate them.
My actual system deviates quite a bit from the tutorial. I have an implementation for GUIs that are static and one for GUIs that are dynamic.
This version work fine?
yes and no , it set the incorrect time .
i set it only 1 hour in the config file
but its set it to 3 hours ..
What does the duration contain (in millis) in the constructor? Debug msg it pls
And show the code where you add the expiration string in the lore
ok i figured out why its bugging .. it should set the time of buying [when player accutlly buy it , and not in the Item Constructor
kind of got it xd
i dont save it in milis .. :
date: 10
time: m
so that mean its 10 minute .. this is how iam trying to make it
naah still a bit buggy ,-,
i will fix it tomrrow iam sleepy now its very late 3:18 am :p
poland? / spain?
iraq :p
1:19am here
Wut
hi i have a question , when this event is triggered?
PrepareItemEnchantEvent
But it’s 8:29 here
When the item is placed in an enchantment table
Not sure if it requires that enchantment options actually appear
something tells me my sleepy ass can't read
well iam trying to do is :
if player enchant the item from the itemframe [bought it ] he can drop it or it will drop from him when he die
i only need to check if item is enchanted .
is there a event for that?
ItemSuccedEnchantEvent xd?
ItemEnchantEvent iirc
EnchantItemEvent
yes that's the correct one , i just found it from google :p
should i do remove key?
if i want to remove a nbt tag?
USING this one ..
Hmm I wonder how I can make an extensible "custom data" system that still has full database support
I'd make a Map<String, Object> but that is funky to serialize when it comes to sql and mongo
Maybe an interface but then each one needs to have serialization logic for literally every single type of database that exists
I think my best approach is to probably just fire events and let plugins handle its own loading logic
Can you call World#save async?
for sql you can always do blobs
Yeah but what if the data isn't serializable?
personally i think data can always be serialized if u try hard enough
all data is serializable
sockets are not data
they are a transport layer
but you can however serialize a socket object
A java socket object
Just turn the object into a byte
and then store those bytes into the blob
you could then reverse it
why not?
Let's say I want to add 2 fields
Level and points
I can just store that in a collection and serialize that into a blob
what does that have to do with socket objects?
But it won't play nice if I want to get the players with the most points
Socket objects are not going to serialize nicely either
no because ideally you wouldn't do that at all
Yeha that's what I'm thinking
since there is typically nothing in the object you don't already know
Im using a custom Gson adapter to serialize literally anything to bson for mongodb
Yeah but I'm not limited to mongodb
Drawback: It heavily relies on reflections
I do that at work too
serialize a socket... what kind of fever dream is this
just fyi, blobs can hold files too. So if its easier to store the data in a file like structure you could just toss that into a blob as well
I'm working on a sharded skyblock system and I like the idea of having plugins being able to append their own data to islands but it'll be a pain to actually do the IO for the 19 database types I support
Well if you want to support different databases then you need to first serialize
your data into a common format (json for example) and then write an adapter
from your common format to the different data stores:
- json -> json [FlatFile]
- json -> bson [MongoDB]
- json -> SQL Model [SQL]
Right now my database stuff is just an interface with the methods I want and each driver does its own query logic
and you can query file types and names as well to make your queries easier
just to give you an idea how versatile a blob really can be lmao
But I see some idiot trying to hook a shitty little plugin and trying to append a whole bukkit player
And that just won't play nicely
I am saving a number as a double by .01, and when increasing said number at times it's pretty ugly (0.023434) type ugly. Is there anyway with a double to round to the nearest hundredth?
So my idea is to just write events for everything and let plugins do their own logic
Yeah i feel like you will end up with Entity, Player, World etc fields in objects.
In this case recursive reflection serializers just break.
That way they can adapt their database drivers to have the most optimized queries
yes
Instead of some fancy algorithm written by an idiot (me)
And I don't get the blame when things break
who am I kidding I'll still get blamed
Maybe I could make some sort of transient map for placeholders
But that's about it
I think the best performance would be to just truncate the number by casting.
You can add 0.5 to round it to the nearest full number
So you’re telling me I can’t stick the entire server into your database?
Nope
;(
just tried to serialize CraftServer into your database any reason why its failing???
All fun and games until that one degen tries to serialize the whole world and push an 18tb blob to an sqlite database
do you just want to round without caring about precision or do you want to round any number to nearest hundredth?
I will just give you both ways
double num = 0.00255;
double rounded = ((int)(num * 1000)) / 1000.0;
System.out.println(num + " -> " + rounded);
Out
0.00255 -> 0.002
double x = 1.234;
double y = Math.round(x * 1000.0) / 1000.0;
BigDecimal a = new BigDecimal("1.234");
BigDecimal b = a.setScale(2, RoundingMode.DOWN); // => BigDecimal("1.23")
So yeah I might just avoid that problem entirely
oh 7smile7 got the first way nice
Sorry using Google as well.
this is exactly what i do for my database
granted I use this database called Nitrite so I didn't have to fuck with SQLite
no MySQL support for my system yet though
I got all forms of sql and mongo in atm
I was gonna do an indexed flat file but it was getting ugly
I don't have to use my database much though. Since I don't usually work with Data heavy plugins I can usually store in PDC or sometihng with minimal issues
I believe it has an official json type
you would need something like an xml file or some similar type for that
for binary, it would be something like csv
I still need to add prometheus support to my metrics abstraction
Is there a way to remain the name tag, even tho the player is invisible?
Just got influx atm
In 2 weeks I'm going to start messing with NoSQL I understand the very basics of databases but I need to expand my knowledge
you would need to use entities for that I believe
use an armor stand and what not or if on new version you could try out the display entities for it
ok
Are there any other low-latency caching databases other than redis?
I urge you to write your data into files first for a while
Kindof Hazelcast
Dragonfly hmm
It's not for Minecraft although I'm using Minecraft as a learning playground.
Can anyone help
Bruh
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I created a smp like hypixel but I want that my lifesteal npc have the only access to the lifesteal plugin
Plss
Someone suggest me this server
Show us some code
I don’t… think they are writing any code?
Which code
Scylladb huh
Just realized lol
Grr
Didn't understand??
what in the world
Someone explain
there is also memcached as well
#help-server
PS: Keep creating hypixel like smps. We dont have enought of them.
Yeah I might just hook into all those

I've had that one mf asking for amazon s3 support
lol
I used to like denizen plugin that works with citizen, it was a good stepping stone to understanding how to make my own plugin
Buckets. Just throw it in there.
Don't laugh it was your employer
well aws does have their own caching mechanisms too
Which one?
Minecrypto
but I generally don't incorporate such things since they cost money to use lol
Ah lol
I'm on my journey to support more database types than luckperms
Might even write a web app where you fill out a form and it provides the perfect config files lmao
I'm bored :/
Can I store it on GameCube memory packs
In this video we make and evaluate several hard drives that we didn't want. Drawing some inspiration from vexing current events, we find that creative, structured thought on adjacent (but frivolous) problems is a sort of digestive act, and one that is ultimately laxative.
Paper, source code, ringtones (and for a limited time, the data and viewe...
If you can’t provide those storage options I don’t want it
Harder drive sounds like my mental state atm
I wanna write my own obscure database in Ruby, make it popular with your
users and create a horrible serialization workflow.
Bet
you would need like 100,000k to just have 800GB
But yeah I'm thinking of a webapp that does all the logic locally
Like a static page with a bunch of js
Just efficiently compress your data 😄
I suppose 1,000 of them for 8GB would suffice for a small DB
but the problem is going to be how you how you hook up 1k or more of them to use them
I do want to fix my sleep schedule but this sounds fun
compliment it with terrible support and always in a polite way tell them they are wrong indirectly
Image having to split a single object onto multiple cards and then having
to write additional data on other cards to keep track of which cards contain
correlating data
this would get really interesting XD
Im currently on a very weird 4h 3h 1h split... exams fked me up this year
would end up needing more cards because of the extra data needing to be saved lol
I finished school
I made a presentation of a product that didn't exist and claimed the datacenter I had it on had a network outage
91.5%
well now you have to elaborate on this
4 hours of sleep, 3 hours of awake, 1 hour of N A C H O?
So we had to do a final project
And we were aware of this for like 3 years
Anyways I did some poor choices and got a massive project and simply didn't manage my time well
for 3 years you didn't manage your time?
It was like a webapp that did spatial audio based of your position in-game
alright continue lol
Nah we only had approval like
in december of the final year
But we had 3 years to plan and think
anyways I had no fucking idea what to do
and just thought of this in like february
hired my brother to help me finish it in like may
Dude spent a month sitting on his ass and on the last week he tells me he had nothing done
So I was like "fuck it, I'll present next year"
Went there just for shits n giggles and my hardcode network teacher just went to me and said
this exists btw
"go home, sleep, wake up and drink like 5 red bulls"
and basically told me to make a "theorical presentation" which means I had no product but the research alone was worth a lot
So I made this entire powerpoint in like 7 hours
Got it looked at by the teacher like 30 minutes before, did last-minute fixes and presented
Had like the top 3 grade or something
so much for hired help
yeah he's basically disowned now
left there hella happy, went to domino's, got home and passed out at like 3pm
but yeah spatial audio stuff exists though as product related things especially with games
woke up at 6am the following day
OpenAudioMC or whatever
hadn't heard of it back then
but the idea was that it was a plugin and a web app
And all the spatial audio logic happened with the WebAudio API
lot of sockets, wrote a whole protocol
It was a spring server talking to all the minecraft instances and doing all the audio routing for the web clients
Thanks worked like a charm
Also all the images I had of the web app were made in photoshop
still, kind of funny you did a presentation on something you believed to not exist. Either way still cool you got a good grade without presenting a physical thing
it was a really beautiful presentation
I talked about multithreading, security, firewalls n shit
Even gave pointers that I wanted to do internal metrics and pulled the work grafana dashboard
and they just bought it
lol
when you spend more time on the presentation to fool everyone then the actual thing 😛
Speaking of, irl I'm not someone who is good with people, somehow communications was my gpa, on top of that the last presentation I scored 5 points above for creativity
Nah I did put in the work
good thing this wasn't some sales pitch
7 hours on the presentation and like 12 trying to do the project
people worked like 6 months on their projects and got shit grades
but there were also a lot of shit ideas
there was this dude that made an AI with a human-sounding name so it tripped on most conversations
what was the theme for the finals?
Anyways the way for his AI to signal it was listening was to just overlay a stretchy low-res image occupying half the screen like it's some kind of arabfunny meme
lol
reminds me of this gif
And it had like 3 commands
worst part is that it was just a fork of a github project with like 2 subcommands
One of them was to open spotify, which had the .exe path hardcoded
And I don't remember the other one which means it was useless
Hi guys, sorry for the inconvenience. I'm making a Plugins in Spigot 1.20.1. But it seems to me that a lot of things have changed. Is it possible to get help? (Sorry, I'm a beginner..)
package fr.mrezor.lcdm.event;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
@SuppressWarnings("deprecation")
public class EventMod implements Listener{
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction().name().contains("RIGHT_CLICK_AIR")) {
PlayerInventory playerInventory = event.getPlayer().getInventory();
ItemStack itemInHand = playerInventory.getItemInMainHand();
if (itemInHand != null && itemInHand.isSimilar(new ItemStack(Material.DIAMOND_AXE))) {
String itemName = itemInHand.getItemMeta().getDisplayName();
if (itemName.equals("§4Reload")) {
event.getPlayer().sendMessage("Vous avez cliqué avec un item nommé '§4Reload'");
} else {
event.getPlayer().sendMessage("Vous avez cliqué avec une hache en diamant !");
}
}
}
}
}
Yeah you don't compare items with their name
And isSimilar does meta checks, only skips amount checks
ItemStack#getType and
?pdc
Are your homies
Comparing the event action with a string is… interesting
I'd use it to see if it's a RIGHT_CLICK because it can either be block or air
but yikes
no
if (event.getAction() == Action.RIGHT_CLICK_AIR)
if (itemInHand.getType() == Material.DIAMOND_AXE)
But you should check custom items by tagging them and then checking for this tag.
Look at the persistent data container link from above.
Hm item in hand cant be null iirc
Depends on the server version
I still do nullability checks
Because ancient versions sometimes give issues
Better safe than sorry
It gives me this error:
Description Resource Path Location Type
Incompatible operand types ItemType and Material EventMod.java /LCDM/src/fr/mrezor/lcdm/event line 19 Java Problem
package fr.mrezor.lcdm.event;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
@SuppressWarnings("deprecation")
public class EventMod implements Listener{
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_AIR) {
PlayerInventory playerInventory = event.getPlayer().getInventory();
ItemStack itemInHand = playerInventory.getItemInMainHand();
if (itemInHand.getType() == Material.DIAMOND_AXE) {
String itemName = itemInHand.getItemMeta().getDisplayName();
if (itemName.equals("§4Reload")) {
event.getPlayer().sendMessage("Vous avez cliqué avec un item nommé '§4Reload'");
} else {
event.getPlayer().sendMessage("Vous avez cliqué avec une hache en diamant !");
}
}
}
}
}
You can also just use event.getItem to get the item involved in the event
That would be the proper way actually. And check which hand the event was fired for.
What the heck is ItemType
I was just looking at the javadocs
Hey smile whilst ur around. Ever thought of taking ur modern approach article for guis and doing a custom inventory one? 😁
Very closely aligned approaches I'd imagine
What do you mean by custom inventory?
E.g a custom barrel that can age brews.
A custom inventory that can make custom items (that works with in panel itemstack buttons) etcs
E.g: not just a menu, but an inventory with additional functionality depending on what's done in it
Its giving me this error with the code
Caused by: java.lang.NoSuchMethodError: 'org.bukkit.inventory.ItemType org.bukkit.inventory.ItemStack.getType()'
at fr.mrezor.lcdm.event.EventMod.onPlayerInteract(EventMod.java:19) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot-api-1.20.1-R0.1-SNAPSHOT.jar:?]
... 23 more
That... sounds like a GUI to me 🙂
I mean there is added subtlety.
Persistsncd for one
thats more of the underlying system behind it than a gui itself
the gui is just the fascia for the system
You’ve got some weird dependency in your development environment
I mean that's fair to an extent , but utilising the ability to pin down what inventory an event is dealing with using a simnilar approach to the modern gui approach could be a shout.
Inventories are merely a way of letting the user interact with, and modify data.
You can create a Barrel, store some data like brewing content and different settings
inside its PDC and simply use an inventory to let the user modify this data by placing
items in it or changing the brewing temperature etc.
the new pr right
Yeah I guess that is from the new PR
I only have spigot-api-1.20.1.jar
Inventories or GUIs itself should usually not store anything. They should be stateless
in most cases and just provide functionality in a UI
But the heck are they doing with that build
Oh aye I figured that's the approach don't get me wrong. I was asking if ud ever considered an article about it.
Ur a good teacher and I admire your work 😁
Hm. Im currently updating my plugins and afterwards i might write something in the forum again.
Not sure what topic since ive done mostly machine learning and image processing in the last months...
Keep that away from spigot peoples
How to break everything beyond comprehension in the hackiest way possible (ASM)
But it’s fun
Yeah especially if you do meta programming
I mean tbh considering ur thread style, maybe a guide on using async properly?
I got "threading for beginners" but halfway through i realized that this is a huge topic
so it kind of cuts out at the end
Ooor one that I'd love to collab with a few authors on as a dream pet project:
OOP Design Patterns: Taught through examples of their utilisation in spigot plugins.
Was this post a response to mine?
Mhm
Hey throw it my way and I'll finish it :L
Where did you get your spigot api jar
Threading for beginners more like slapping CompleteablFuture around everything and go full yolo
To be honest CF are very nice. I mostly use them when doing multithreading.
Oh fuck don’t sue
I sometimes use executor services
Used those in my last plugin
But then again, you can just pass them to a CF and have a nice reactive pattern instead
Fk it has been so long. What did i forget?
Ah just read remapped and then it came. Need to run bt with the remapped flag. Woops
What gui framework?
Has been a while until i realized you can stylize swing components with css
On a site, I don't remember, but where am I supposed to install it?
?bt
Or since you just need the api you can use the maven/gradle dependency
Hope it wasn't malware fingers crossed
Thats official
You must not be up to date on the registry pr
It's in an experimental branch of spigot atm
What site is distributing that
Nope im not. Pretty much 4 months behind
Prob the site that shall not be named at the top of search results
Yeah but why tf are they
Anything cool coming from 1.20?
Sigh it’s best to not question it
Hopefully the component PR
I'm biased but InventoryView#setTitle already merged 
Sorry I use setTitle way too much not to be happy about it lol
Interesting. Does it send the inventory + items to the player again?
Or is renaming an open inventory now possible.
It uses the client quirk by sending a container with the same ID and different title
you could always do it with packets
It's done with packets internally
Ive tried that in 1.18 and it cleared the item contents
It doesn't
Tried and tested :P
Not anymore I guess
Alright then. Nice 😄
setTitle is misleading its more like sendTitleChange but the InventoryView stores the new title
Yay
Api wise 1.20 didn’t change much
Just signs
Actually NMS wise not much changed either
I love when NMS doesn't change
Mappings certainly help with that
The change to mojang mappings was a good idea
Shoutout to Mojang for actually making them usable license wise
Interesting
?
Just some things ive discovered in Player
You can now open a ton of GUIs via the api
can i hide blocks from certain players? and other people can just go right thru it?
i swear i wanna end my life
I mean same but for the wrong reasons
i somehow dont trust fabric
it says it takes 3ms for this process
i somehow doubt that
and i just realized i'm in help-dev channel
now i wanna end my life even more smh
can we hold hands while at it
yes, please
can i join @slender elbow @slate mortar
No, there are not static. So Add param in the constructor si bad ?
sure
Why ?
You mean populating within the constructor? Because it breaks inheritance.
The constructor should not decorate the inventory.
Ah no, i don't good understan your I thought you were saying don't add arguments in the constructor
So i décorate on open?
well i meant handholding but yeah that too
And, why decorating on constructor is bad ?
Just do it and if it doesnt cause any problems then you should be fine.
Its only a problem if you want to continue with the abstraction pattern.
?learnjava! 
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
Okay, but why decorating in constructor break the inheritnace ?
I'm updating some old plugins from pre 1.19 to some modern versions.
The main feature I'm updating is some custom command stuff, is there any good guides on what has changed with Brigadier. In the past I was able to get the ArgumentItemStack directly but now it seems like it needs a CommandBuiltContext?
Because if you have a child class which relies on the decoration being done at a later time
then you wont be able to undo it because the parent constructor needs to always be called.
Just use it and change it if you have problems.
I don't have constructor parents the constructor is in the child
Just dont decorate inside the abstract class' constructor
And if you call it in your child class then make it final
So if i décorate it in the child is good ? And Why final?
So you dont extend it and wonder why it breaks later on.
He never breaks.
Menu (abstract)
Testmenu extend Menu
In the constructor of testmenu.
But calling it in the constructor is still dirty in my opinion.
Its an implicit implementation detail. You have to remember to
call it in every childs constructor.
What if you want another abstraction level?
Then it breaks
What do you mean on another abstraction level?
Menu
-> PaginatedMenu
-> -> PaginatedBookMenu
-> -> -> BibleMenu / CookbookMenu / TravelersGuideMenu
If you call decorate in the constructor of PaginatedBookMenu
but CookbookMenu relies on the decoration being called after
the constructor, then you are fked.
My pagnited menu system is implémented in mu décorate but i understand your raisonnements
But more importantly: Its an implicit implementation detail
If you have to "remember to implement it" then thats a bad design.
So i add it on the opening? Or on the getter getinventory?
If the GUI doesnt change then you should not decorate it every time a player opens it.
No, he change
so I must not have a constructor in my menu?
I'm using trouble creating a bukkit runnable runtasklater it asks for a plugin I tried putting the class name and plugin name here and it doesn't work
?nms
You dont need the name of your class. You need an instance of your class.
Guys, is there a nice way to listen to packets in mojang mappings, although i know i should use protocol lib stuff but i would like to learn it without it, where i should start when trying to listen to packets
if i don't need I don't need to access/modify the items after the constructor, can I leave it in the constructor?
else I made this code with a method to open it is better?
public void Open() {
System.out.println("oo");
this.setMenuItems();
System.out.println("bb");
this.owner.openInventory(this.inventory);
}
is there any events for health generation and hunger?
EntityRegainHealthEvent and FoodLevelChangeEvent are they way to go
thank you
You need to inject your own packet handler into the netty pipeline
Its not easy to find out how to do this on your own. But you can grab code from someone.
Ok so netty still a thing, cause i found an old spigot post about using it. I'm trying to go deep into how minecraft server communicate and understand more about network in general. Thanks for the help, imma study how they did it and try to get my own solution
You need to add your handler before the "packet_handler" component in the current netty pipeline
Hm okay, that makes sense
I saw i need to create an reflection to be able to read the packets
Only if you dont use NMS
Its a pretty extensive topic damn
So the reflection is used when i intercept the packets outside the NMS scope? Idk writing my own listener non-minecraft/nms/spigot/bukkit related
the default walk & fly speed is 1?
This is how the pipeline looks like
You will get an Object if you register your own handler before the "packet_handler"
If you have nms on your classpath then you will actually have the nms packet at your disposal.
If not then you just have an Object. In this case you need to use reflections because you
dont know what the packet looks like
e
Oh, got it
That's exciting imma go write some code
Thanks for the help @lost matrix
could help to learn basics of netty
I was going trough the docs rn lol
Thought that was a wise ideia to do.
protocollib, viaversion are open source
but thanks for the tip
mine also does it
xd
so yeah
but still knowing netty basics works
knowing how to make a handler
What project is yours?
different kinds
order of the pipeline
so you know why you want to be infront of packet_handler
Imma jump and trying to develop something using netty to get the feel
packetevents
thing is
mine and viaversion’s project dont want the nms object
I got really interested into this networking side of minecraft servers
we want the buffer
so we need to be placed differently in the pipeline
we aren’t next to “packet_handler”
but the reflection code to inject to access the pipeline you can take from us
Mainly because of how minecraft anti-cheat works
i see
Thats sound really nice, thanks
there’s anticheat communities
Just got into your git repo
although sometimes can be toxic
Yeah, i don't have good experiences with coding communities in general
my general advice for anticheat development is study the client
This one is pretty chill
its reallt digging into mc source
seeing how client behavior works
making checks for it
but writing injection code for packets on your own itself won’t help you anticheat wise
Oh, i was diving into a decompiled version of minecraft made by forge for creating a custom client
but if you desire to do that, go ahead
Idk if its legal but, old times, old crimes
if you don’t distribute your client jar then its legal
Just want to learn how it works.
that would be leaking minecraft
Might look at going for anti-cheats after
Oh, i'm safe then
aight
you can modify the client on your computer
for yourself
following the EULA
it asks us to just not make grief mods(cheats) :)
if you have any basic netty questions i can answer
in netty handlers are kind of like listeners
event listeners
Sure, imma hit you with some if i can't figure it out in my own
there’s multiple cause they transform the data from one format to another
some handlers decompress
some decrypt
Mojang TOS are don't make capes, don't make cheats lol
some convert from buffer to your nms object
so therefore its important to know where to place yours
you be after the handler that converts to nms
but then pipeline has an interesting order
incoming packets are fired from left to right
My main goal now, is to listen to when a player interact with a client-side entity.
Basic NPC stuff
outgoing packets from right to left
Just to undestand how to intercept it
I'm copying your messages to my nodepad 😂
since its your main goal
Oh, yes in the past i used the libs to do some freelancing work
But i want to develop it using no lib to learn how it works
Like an scavenge thing
okk
idk lol
the pipeline stuff makes sense?
Just out of curiosity and passion
Yeah Yeah, i can see it
if we look at this
now i need to take the logic to code
most of these should make sense
by the names
left to right is incoming
what do you expect decrypt to do
to the buffer
the bytes
I couldn't indentify from what direction was what on my own
but your explanation of it makes sense
splitter splits them up sometimes packets are chunked together when sent
decoder converts from buffer to nms object
That sounds like websockets, but i might be tripping
Not the NMS part tho
hm, ok
i'll try to get something running here
Thanks for the help dude
Hello, does anybody know how I can check in the PlayerInteractEvent if the interacted item is a item in the players inventory?
I don't undestand your question. You mean like if the player interact with a diamond block if checks if the player has a diamond in the inventory or a diamond block?
Cause if this is your question you can use a code like this
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
Block interactedBlock = event.getClickedBlock();
if(interactedBlock == null) return;
Material interactedBlockType = event.getMaterial();
Inventory inventory = player.getInventory();
if(inventory.contains(interactedBlockType)) {
player.sendMessage("You have interacted with an item that's in your inventory!");
} else {
player.sendMessage("The item you interacted with is not in your inventory.");
}
}
I didn't run the code to test it
idk if it works 😂
Oh, it wont check the diamond tho only the block
?learnjava!
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming. https://media.discordapp.net/attachments/694661573125472256/998143126373941248/6n0v4g.gif
what is the best way to disable default hunger? canceling FoodLevelChangeEvent makes level change by foods get canceled too
so if you have a lever in your inventory and your right-click it, function a should run, but if a right click a lever that is in the world, then function b should run
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
// Get Player and the world block the player interacted
Player player = event.getPlayer();
Block interactedBlock = event.getClickedBlock();
// Guard Clause to check if block is null
if(interactedBlock == null) return;
// Get Type of the block and the player inventory
Material interactedBlockType = event.getMaterial();
Inventory inventory = player.getInventory();
//Checks if the inventory contains any stack with the interacted block material
if(inventory.contains(interactedBlockType)) {
// Run if the inventory got any similar block
player.sendMessage("You have interacted with an item that's in your inventory!");
} else {
// Run if the inventory doesn't got any similar block
player.sendMessage("The item you interacted with is not in your inventory.");
}
}
I commented the code out
If you have a lever in your hand and interact (Left,Right Click) with it in a Lever (Block), it will trigger the first message, if the block isn't the same or you don't have the item in the inventory it runs the second message
You might wanna add some Item Specific Logic to complement the code
I also recommend running this code to understand what it does before start coding with it
I don't get why the player need to eat if they don't get hungry? Anyway you can create a bukkit runnable that sets the player saturation to 20 every 20ticks (1 sec)
I think this is a workaround
can't think of anything else rn
imma do some research
You can change that in the spigot.yml iirc
yea i figured out there is a gamerule called NATURAL_REGENERATION
i changed that to false and created a runnable to remove half a hunger each minute
True, in the hunger field there are the exhaustion
because its for a roleplay server
they have to call medic or go to hospital to regain their health
Oh, makes sense lol
Isnt this for regaining health through hunger?
no
what d u think about this? D:
lmaoooo, thats so good
i'm disabling that with EntityRegainHealthEvent too* sorry
thanks
What a nice ideia
You did you customize the UI?, using an Rest API or are those placeholders value?
i did that with a text shader inside a resourcepack
so the text shader modifies the position of my actionbar
to top-left of every screen in any resolution
Making multiple lines is the tricky part
That's interesting
Doesn't it change resolution wise?
i don't understand



