#help-development
1 messages · Page 618 of 1
Why not use the block state?
no
are you drunk?
yes
usage
?
wtf is going on here, everyone drunk today
2.8%
I assume you mean it's slow
ofc there is
why
You just need to find it
would you need nms just use blockstate
how is it slow? are you calling it 3 million times per tick?
yeah there is a problem like that
getting a container's inventory is not slow
why are you calling it 3m times per tick
true
getting the block state
is
block.getState()
hm not really
its a huge amount of blocks and im breaking it and adding it to an inventory
oh no
mhm I wouldn't advise doing this shit
settings blocks are also very slow but i managed to fix it
I really wanna see the code for that
please share
yea
what should i do
I should honestly just make a full set of utilities around multi-threaded block manipulation
Including tile states n shit
why do you need the blockstate to get a container in the first place?
the maximum is 1500 blocks being broken at the same time
i used multi threaded
yes
That's what I said
but adding the item to the inventory
oh
blud doesn't know wtf he's talking about
adding items to inventories can be done async
You don't need the blockstate at all
I imagine something stupid like
for (Block b : blocks)
world.getBlock(chestLoc).getInventory().add(b.item());
I hope I am wrong
But it can also cause some problems

https://github.com/JEFF-Media-GbR/InvUnload/blob/master/src/main/java/de/jeff_media/InvUnload/BlockUtils.java#L39
Chuk#getTileEntities() -> check if they are container -> get the blockstate
then you dont have to get the blockstates of all other blocks
@tender shard i have location of the chest
then just get the inventory
dude you are talking about only one single chest?
ig
Also why tf im adding the items in a for loop
Hell naw
Was i drunk coding this shit
well now I really wanna see that
come on, don't be shy
show us some code :)
wow i'm out, i have no clue what kind of weird things you guys are doing, but I could easily get that chest's inventory a hundred times per tick and add a ton of random items every time without ayone complainin about it being slow or anything. literally no reason at all to use slughorn/nms for this
yea
@smoky anchor i will explain
I will get the inventory of the chest for every single block
i thought you were scanning like a 3x3 chunk area for containers and that's why you wanted to avoid getting each block's blockstate,....
one single chest, lmao
what a waste of time to even think about it
One single chest 1600 times
wait SO THIS ?!
Drink some water, sober up
And fucking rewrite that shit
Holy shit
I will also use a queue to add the items
What in the shitcode was that
just use
while(true) {
chestInv.add(item);
}
I always code great stuff when drunk, like MorePersistentDataTypes lol
Or CustomBlockData
Aren't those like actually good ?
don't you even have a ? command for morepdc ? XD
?morepdc
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
?customblockdata
?blockdata
?cbd
Hm
There was a command for cbd too
?customblock
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
imagine forgetting a command for your own plugin
smh
what's Dayzz line 706?
Could someone please help? The plugin works correctly on craftbukkit and there is an error on spigot, I do not understand what is the matter, since in this case there should be no error
what in the name of all that is holy
706 line: double balance = Double.parseDouble(lastMessage);
lastMessage is an empty string
That is, I need to rewrite the system for getting the last line from the console?
Legacy color rgb 😎
rgb
I do know what that is but...
if he's on paper doesn't he have Minimessage or something
Does't that do rgb ?
It can do RGB yes
idk what your weird code is doing in the first place
but if you wanna get the console output, here's how to do that https://blog.jeff-media.com/how-to-read-or-block-spigots-console-output/
okey, thanks
package me.airforce.excavation.Listensers;
import org.bukkit.block.Block;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
public class BlockBreak implements Listener {
public void onBlockBreak(BlockBreakEvent e) {
Block block = e.getBlock();
{
}
}
} ```
how do i make it so if thye block gets broken blocks in 3x3 raduis will also get broken ?
use 3 for loops
3x3 or 3x3x3 ?
assuming you want it to be 3 dimensional
3x3
Let's start by addressing 2 things, maybe 3
For starters you need to annotate your listener with @EventHandler
like excavation enchant
just destroy blocks same way you would print matrix ig
a ?
Second, no point in opening random code blocks for no reason
and make sure these blocks dont call the blockbreakevent..
I'd refer to this but I honestly doubt you'll be able to understand it
Called when a block is broken by a player.
Would not worry about that
okay, well you never know 🤷
bro so what i need to do ?
research
bruh tell me a way man
no
?spoon
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.
You can't even break down your problem into steps
because then youll be back with the next question
hmmmm
And you're just asking to be spoon-fed
In fact he wants to fire a blockbreakevent to not break plugins like worldguard and logblock. He can just extend the block break event and fire that custom event so he can ignore it in his listener
i aint asking for the code tbh
Might be a little harsh but we want you to be able to understand how to solve issues by yourself
Hmm good catch
tell a simple method isnt called spoonfeeding
It might be
Just breaking down the problem for you is spoon-feeding
The problem with spoonfeeding is the mindset you get from it
Well not exactly but it's something so basic
Yeah but you don't learn anything from this if I just do all the work for you
But fuck it let's walk over the steps
Define 3x3
bro
Does it include height?
wdym i guess
Okay so 3x3, in relative positioning
height*
It's -1, 0, 1 in all axis
okay so its a cube of blocks around the broken block
yes
AKA a cube where your origin is your center and it expands by 1 in all axis
ok
So let's start with what you have
Please use a variable for the size so you can easily increase it in case you want/need to
make sense
Remove 1 as it's your center, and divide by 2 to have your radius
So if it's 5x5, the radius is 2
ok
bungeecord
is there some way to check if some server went offline or online?
Red is your center, your radius is the length of yellow
Now you want to loop through all axis
Starting at -radius and ending at radius
I'll do it for a single radius
alr the the ridaius 2 and -2 ?
int centerX = ..:
int centerY = ...;
int centerZ = ...;
int diameter = 5; // 5x5
int radius = (diameter - 1) / 2; // 2
for(int x = -radius; x <= radius; x++) {
}
So this will loop through
-2, -1, 0, 1, 2
Think of those as "relative" positions
(you dont technically have to do diameter - 1 but it make it more clear I think)
Correct
What happens if you add these relative positions to your centerX?
Give me an answer
what will be my x y z ?
ok
Anyways you still haven't answered
int centerX = block.getX();
int centerY = block.getY();
int centerZ = block.getZ();
it give me those options
when retrieving an inventory name, if its colored, does that get retrieved as well? If i need to compare it, do i need the color?
Don't use inventory names to detect inventories
That's a bad idea
I love how it says modern but that's how it was done since always
Apart from having lambdas
really wasn't 😅
too many people used like, item stack comparison
or I guess inventory holders (tho you can't say that too loud or md_5 is gonna come for you)
The correct adjective would be properly not modern, that's what I am trying to say
It's not making use of anything special that I'd call modern as it only exists in newer versions
They used the inventory name for the longest time
Which was equally bad as using holder
for what part of it ? xD
nah i mean like
iso standard or whatever
that languages follow to create formatters
I mean, 8601 is the ISO standard for that
gotcha
Yes
I made a plugin for 1.18.2 with Java 8, which should support other versions. But it doesn't. How to add support for other minecraft versions?
Start by targetting the lowest version you want to support
Set api-version in the plugin.yml to 1.13 and then add submodule for each version of nms/version where new api got added and code that part there
shade it all together and only load code supported on the current version
That's the basics of it ^
Lower than 1.17 uses Java 8
1.17 uses Java 16
1.18+ uses Java 17
But latest versions still support older java versions, right?
I mean in terms of plugin development
So theoretically any version of minecraft supports a plugin that was made for Java 8
1.8+ at least
Ok, thank you!
If you start going lower than that you will have even older Java versions
?paste for me
The plugin is really simple. All it does is reply to some commands with text messages, nothing version-specific
is it possible to change without using reflection
max stack potion?
no
demm(
I believe it is but in inventory it would be "laggy" for the player
Like you can listen to interaction events and do math to set the stack size
and through reflection without lags will be?
even using reflection its buggy
yes
client still thinks the max stack size is 1
and you can't change what client thinks without modifying it
which is impossible via just server
||if you were in the past tho you could have used the log4j vulnerability tho XD||
Does this apply to all items?
yes
how do i make it so intellij won't warn about methods annotated with EventHandler?
Hey guys, how do I add hex color codes to a TextComponent? I need a custom colored clickable link
who knows what the variable is called responsible for this
hover over the annotation and click some text on the tooltip
or the method that shows the warning
bump.
this is so clean now
#1 read what was said below
#2 yes, it gives you the color as well, yes you need to compare it with the color
My guess is to look through the nms Item class
But again, if you do change it it will be buggy for the player.
does this mean that the itemstack is not null huh?
i assume it's just the array itself that is not null, not the items in the array
Hi,
I'm trying to work with scoreboards,
If I use this code :
@EventHandler
public void onPlayerLogin(PlayerJoinEvent event) {
score.playerScores.put(event.getPlayer().getUniqueId(), 0);
ScoreboardManager manager = Bukkit.getScoreboardManager();
Scoreboard scoreboard = manager.getNewScoreboard();
Objective objective = scoreboard.registerNewObjective("Test", Criteria.create("dummy"), Component.text("Test"));
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
Team team = scoreboard.registerNewTeam("ol");
team.addEntry(" score");
team.prefix(Component.text(score.playerScores.get(event.getPlayer().getUniqueId())));
objective.getScore(" score").setScore(1);
event.getPlayer().setScoreboard(scoreboard);
}
Will my teams be shared between all the players or not ?
no
It’s only the array
how can i download java 16 on ubuntu 22.04 for 1.16 minecraft server?
how should one make an editor simillar to LuckPerms?
I was using MiniMessage to parse text in my plugin, but now I'm adding support for older versions and I can't send Component in chat directly anymore. Any way out?
Just adventure
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.14.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.14.0</version>
</dependency>
I don't think they have support, do they?
They have a discord
however, if you are on spigot you'd also need the bukkit bridge
I found the server, thank you
kyori support:
Step One: Use Paper

I try to make my own argument type for brigadier. I registered it via reflections and it is loaded with no errors. But when I try to type the command, the argument input is all red and there are no suggestions. It actually calls the pars method from the type, but still the command fails
wait I think I know this one
'cause I tried it years ago
You have to somehow register that I believe BUT those are somehow synched to client and if the client does not recognize it it throws an error
try looking into the clients console
Ill try that. I have already registered them in ArgumentTypInfos
Any good command frameworks?
So I made a simple plugin. In this context, all it does is reply to a command with some text. Originally it was made for 1.18.2, but since it is so simple I decided to add support from 1.12 and up. I set the API version to 1.12 in plugin.yml and downgraded all dependecies to 1.12, but when I try to load it in newer versions of minecraft I get: org.bukkit.plugin.InvalidPluginException: Unsupported API version 1.12
Also it uses java 8
the argument was added in 1.13
So just put 1.13
It should work on lower versions regardless
I will try that, thank you
Maybe wrap it in “”
ye no
those characters NEVER work with ANYTHING programming related
I am assuming I am correct, since ElgarL stopped typing XD
It worked! Thank you so much
Now the plugin supports ANY minecraft version *insert evil laugh*
I was wondering, is there like some sort of a list of what minecraft versions use what java version?
Couldn't find that
Literally first result when googling "minecraft java java versions"
tho it is not full actually
When I set the output protocol to open, there is absolutely nothing about this command in it, except that it failed.
something with math I'm trying to do,
if a player sets the config every 1000 blocks are 1 level of exp, how can I calculate exp correctly to then every 1000 blocks give a level?
(this doesn't not depends on Minecraft level experience every 200000 exp is equal to some level but it's forced but should show correctly inside the bar if I have 200 blocks remaining it should show like it)
I found this but not sure
ye, I probably should have made myself clear
You can't create custom arguments unless you modify the client
I sent you the information you needed earlier?
But the arguments are for like JSON error message or swizzle error message
So unless you're making something fancy, you should not need them
Oh ok. Thanks
These the the supported Java versions, yeah
About the plugin - yes, it works now, thank you. This is another question
The recommended one is always the lowest java version though - unless you don't care about the userbase
Ok, thanks
if you want to run a server you should use the highest version in the list though
And ideally use a fork that supports newer java versions
But is there a way to allow only the suggested options?
(They are dynamically generated)
I don't think I quite understand
can you show a picture of an example or something ?
Like that you type: /test and then the plugin suggests n number of options. But you can only use these options. Otherwise it will be red
yes
I do believe you can do this
either with just literals or some string argument option
I don't have my old code with me rn, if you don't solve it in an hour, tag me here
Ok thx
Hello, I'm having problems with the encoding of my plugin / server. When I write "¨" in the chat, "¿" this appears in the console instead!
That sounds more like a problem with the console not being able to show that character
nothing you should worry about I think
Are you calling new String() anywhere?
(or String#getBytes) - if not then it is probably that your client and your console are using different codepages
okay but when i use a configfile with this char and i broadcast the char, the same think apears !
no thats just a message logged in the console
Yes, but how do you obtain that message?
broadcast to players (in chat) ?
Yes
If you pass it through any kind of input stream (and thus somehow calling new String(...) with a byte-array) then chances are this happens as intended
Try explicitly saving the file as UTF-8 with your editor
already tried...
And when explicitly saving with ANSI?
Any good command frameworks where you can register commands using annotations
What is the order of events that get called when a player joins a server? I was wondering if there is an event that happens after PlayerJoinEvent. I'm trying to send a PluginMessage packet to a player when they join, but it seems that the messaging channel isn't registered for the Player's connection until a bit after the PlayerJoinEvent happens.
nothing changes...
PlayerLoginEvent before the PLayer join the server and PlayerJoinEvent when the player join the server
I use ShadowJar to produce the .jar, the problem can't come from ? (gradle)
How to make the plugin jar smaller? Mine is giant, like 5MB, while the code is super simple.
What version are you on, do you ha e any resourcepacks
Nah, it is a logic problem
you probably have the wrong scope for your libs
"provided"
I really like the CommandAPI, which has limited support for annotation-based commands (https://commandapi.jorel.dev/9.0.3/annotationsintro.html). I haven't used it mayself, but I also hear AFC is good (https://github.com/aikar/commands).
I mean, if you are shading all of adventure, that is a lot
Maven or gradle?
Maven
Could you show the pom just so we are sure?
no i dont use ressource pack, i'm on 1.20.1 (mc version)
gradle
i need to shade Reflections and the discord api
not relevant for you as I already said it is a logic problem. You are somewhere converting from java.lang.String to byte[] to java.lang.String
build.gradle you mean ?
Actually, most of the dependencies had no scope in pom.xml. Does this matter?
Yes - depending on the dependency it should be provided
Ok, I will try that, thanks
obviously only those dependencies you do not need to shade
Yeah, no - something will break
most likely
cannot wait for you to have set adventure platform to provided
and getting runtime clapped
idek what shading is ¯_(ツ)_/¯
including the dependency in your output jar
which is needed if the depdency is not provided by the server itself
which would be the case for adventure and the likes on spigot
(or by another plugin)
Ohhhhh
my build.gradle loogs like : ```gradle
plugins {
id 'com.github.johnrengelman.shadow' version '7.0.0'
id 'java'
}
group 'fr.toutcourt.plugin'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation 'net.dv8tion:JDA:5.0.0-beta.10'
implementation 'org.reflections:reflections:0.10.2'
compileOnly 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
}
shadowJar {
destinationDirectory = file("../../Minecraft Server/survival/plugins")
compileJava.options.encoding='UTF-8'
}
sourceCompatibility = targetCompatibility = '17'
compileJava.options.encoding = 'UTF-8'
I have these
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.theokanning.openai-gpt3-java</groupId>
<artifactId>service</artifactId>
<version>0.12.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.14.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.14.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.3.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
What should I do? I made them all provided just now
Just give us the jar then
Again, this is probably not a build system problem but if you insist I can make it one
my plugin works but the utf-8 looks like broken
compileJava.options.encoding='UTF-8' is also wrong there
that does not go into the shadowJar configuration
Java 17 is UTF-8 by default anyways iirc
Ok, so I'm back to where I was. How do I make it smaller now?
(Or was it Java 18? Whatever.)
you don't
you are shipping a large amount of code
you can try to ask maven to minimize it
Can I shade only the relevant parts?
How?
That is called choosing the proper libraries
<minimizeJar>true</minimizeJar> in your shade plugin config
I meant like the relevant part of a library
where do you think the problem comes from?
don't expact a magical solution tho
Ok, thanks
Any improper IO or .getBytes() calls
If you were to give me the jar I could quickly check thanks to recaf my beloved
(would also catch improper buildscript configs while we are at it)
how can i give you the jar ?
It worked a little bit. Now it is half a MB smaller than before. Maybe now SpigotMC will accept it. Huge thanks to everybody here
spigotmc has a 5MB limit?
Nope. Still too big. Guess I'll have to use somthing external
Yes, at least for me
Last time I checked
4MB limit for normal resources.
4.5MB for premium resources.
well, should be enough for 95%
how low in terms of version are you supporting
if you are only going down to 1.16.5, you can use the library loader
that thing basically downloads dependencies on the servers for you
so you don't have to shade them
all of them
since the plugin is so simple, I added support for all minecraft versions that support Java 8
It's fine, I'll just post a release on github
yea ¯_(ツ)_/¯
Thx
Use spigot's library system
Given your dependencies are in mavenCentral
Depends on what your plugin does and what the errors are about
Read the exceptions then
That looks fine
We can't do much if we don't know what the error is
Show full code
?paste
I asked for full code not for 2 classes and an exception
Just a copypaste of the class
But I see an issue
And it's called static abuse
Which in this case will cause you issues if you ever /reload
If you're unfamiliar with static read this
Or in short
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
And no, this is not an issue due to a custom spigot jar
Passing your map around with DI certainly helps
But ideally you'd change your get to a getOrDefault and pass false as your second param
Just for additional safety
That's what dependency injection is for
Read this
that article is way too bloated imho
https://blog.jeff-media.com/getting-your-main-classes-instance-in-another-class/ this explains it much simpler
I mean wtf you don't need more than 2 sentences to explain it lol
hey,
itemMeta1.getDisplayName().equals(itemMeta2.getDisplayName())
would be an equavilent to this?
Objects.equals(itemMeta1.getDisplayName(), itemMeta2.getDisplayName());
could I also use getEnchants() and getLore() on 2nd function?
no, that's not the same
first one would throw NPE if itemMeta1 is null, Objects.equals() will not
Objects.equals() will return false instead?
then they are obviously not equal
I'd always use Objects.equals in case one could be null
Yeah, 🤓
Im trying to fix my pyramide with if statements but i am getting these errors: Suspicious indentation after 'if' statement should i just ignore them or have i done it wrong?
@EventHandler
public void onPlayerDamage(EntityDamageByEntityEvent e) {
Entity victim = e.getEntity();
Entity attacker = e.getDamager();
if (!(victim.getLastDamageCause() != null)) return;
if (!(victim instanceof Player && attacker instanceof Player)) return;
if (!(victim.hasPermission("Vagt"))) return;
victim.sendMessage("§3§lVAGT §f§lSYSTEM §8» §7Du blev slået af §a" + e.getDamager().getName());
if (!(attacker.hasPermission("Vagt"))) return;
attacker.sendMessage("§3§lVAGT §f§lSYSTEM §8» §7Du slog §a" + victim.getName());
if(!(((Player) victim).getHealth() <= 20)) return;
List<Player> players = new ArrayList<>();
Bukkit.getOnlinePlayers().stream()
.filter(p -> p.hasPermission("vagt"))
.forEach(p -> sendActionbar(p, "hej"));
}
It's warning you that you may have written something incorrectly based on the indentation
You can ignore it, but instead you should fix the indentation so: you get rid of the error, don't accidentally cause emotional damage to whoever reads the code
ChatGPT response: https://prnt.sc/gtcYyX7zQq2c
XD I read the indentation in your code is correct, which is causing the errors
Basically, don't nest your code, it'll look a bit ugly, try using early returns.
- Each
(must end with), there cannot be 2 starts and 3 ends.
That is what is happening here
But he puts tab after the early return for some reason, which is causing the error I assume
- Don't use
victim.getLastDamageCause(), usee.getDamageCause()
I dont have a e.getDamageCause option when im trying to change it
Oh, it was because i should use e.getDamager().getLastDamageCause()
Thanks for the help
Sorry, e.getCause()
Its fine, thanks
@smoky anchor sadly I didn't find a argument type the matches my requirements
ok, I'll try to go through my old plugin
How do i get ride of this warning? Condition 'attacker instanceof Player' is redundant and can be replaced with a null check'
I have tried many thing but i am still getting this warning
if(!(victim instanceof Player && attacker instanceof Player)) return;
@EventHandler
public void onPlayerDeath(EntityDeathEvent e) {
Entity victim = e.getEntity();
Entity attacker = e.getEntity().getKiller();
if (!(e.getEntity().getLastDamageCause() == null)) return;
if(!(victim instanceof Player && attacker instanceof Player)) return;
if (victim.hasPermission("vagt")) {
victim.sendMessage("You killed " + attacker);
}
}
}

Attacker is a player therefore no need to check if its an instance of player
ok, I have found argument.requires(Predicate)
But I do not think it will do what you need(I tried to look for documentation, but it's not Mojangs Brigadier github page... for some reason)
A way to do that would be to just manually build the command tree with literals
But there is a playerdeathevent too
I was today days old when I learned about PlayerDeathEvent
Ohh, thanks
How do i get the player that damaged the last time? so if a player died to fall damaged it sends in the that the player died to the last that hit the player
Probably need to listen for playerinteractentity event
Use a global object that can be set so when the player dies you can check if they were a few ticks ago hit by a player and then can attribute their death to such
I dont know if this is correct but its kind of this right?
String killer = e.getEntity().getKiller().getPlayer().getName();
I feel scammed, I've been working out for something like 2 years now and I still get DOMS bad enough that it hurts to even program
anyone familiar with the remapped nms code? is #canReach actually whether it has already reached the target?
hm... actually I wonder if moveTo is returning whether the objective can be reached
looks like it might be
How do you make a player "lay down" when they die? (for a few seconds)
What's the best to achieve this? packets?
Ok thank you very much
Can someone help?
Does that happen too, if you restart the server?
Yeah
you have an invald .env path, and the file doesnt exist
I don't know much about this but .env is a file for variables I believe
I use it for completely different thing, vue.js, js framework
I have 1 named files.env and one named info.env and i cant see why i am getting a error because of that
pretty sure thats not have env files work
so you don't have any .env file
you have two filles with a different name and none called .env
I have, i have 2, 1 named files.env and another one named info.env
yes
you have two files that are not named .env
and you have 0 files that are named .env
while you should have one file that's called .env
But when its .env it dosent work, that was the problem yesterday
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
So if i have 1 named .env and 1 named test.env it should work?
i dont even know what you're trying to do
so no clue what you mean with "it should work"
So im not getting the error in the console
all I know is that yesterday you sent a stacktrace where dotenv couldnt find a file called .env
the file has to be named literally ".env"
the only time you have "<anything>.env" is when you are running a different .env for prod/staging
and that has to be configured with dotenv, you don't just magically have three files ending in .env and they all load
why the hecking heck are my entities absolutely crawling with this movement speed...
So when i have one file named ".env" what should i call the other one "info.env" or ".env.info"?
why are you even using env files in the first place
oh there we go now they're moving normally
He doesn't know what he has to do 😭
Does anyone know how to create a protocollib packet SCOREBOARD_TEAM that shows invisible players for the members? Thansk
What's a more efficient idea?
- Creating a listener per inventory.
- Creating a listener per plugin that delegates to different inventories.
I've been a bit mixed on how to implement GUIs in a way that could easily scale while having a nice API.
Latter
Less committed to the spigot api is a benefit imo
Figured. This is meant to be platform-agnostic so registering events could get slower when working with something like Paper.
Yeah
I agree.
For one, I dislike Spigot's API. For two, I need to abstract if I want to support a wider range of platforms.
Yeah right, much nicer to have ur own event bus for ur other modules and eventual api users
My main rationale is that I'm going to be having clients of different server architectures.
Most people'll use Spigot or a fork, of course, but there's always exceptions.
I'm in the process of abstracting away the plugin loading mechanism.
Yeah like spoons
Possibly even a spork.
I love the mineblox spork that allows me to run spigot plugins in robolox
Same, I even use a hacky design to have my own classloader to load my plugin
Oh that was what I was considering doing

I've done classloader hacking in the past to do stuff like runtime class modification
hey, is this the correct way to check if it's the first time the villager get trades? I mean, when it gets the first 2 trades
@EventHandler
public void onVillagerGetTrade(VillagerAcquireTradeEvent e) {
AbstractVillager villager = e.getEntity();
List<MerchantRecipe> trades = villager.getRecipes();
if (trades.isEmpty() || trades == null) {
// insert new trade
}
}
This code would produce an NPE
You check if the value is null after calling a method on it
yea ur right, i just have to invert it
Hello everyone. Some body have a todo list to check for start use Spigot with the wiki, i know java basement.
but is it the correct way to check if it's the first time the villager get trades?
how can i create custom enchant? it gives my that
What version is this code for?
1.19
Okay well getRecipes is marked as @NonNull so the null check is redundant
Just check if it's empty, that might work.
oh, I didn't notice that, thank you
Additionally if you're inserting trades, don't do it with the list returned by getRecipes
Docs say it's immutable, so modifying it would cause an error
yea, there's a method to insert trades
A'ight.
Something I've considered with my plugin mechanism is live reloading
It's not a good idea to live reload Bukkit plugins but if I'm not relying on Bukkit's plugin mechanism then it's no big deal
Only issue is that you can't unload classes in Java
Well actually I think you can.
But only through instrumentation or JVM TI?
Supposedly it is possible to unload a class as long as the classloader is garbage-collected.
Yeah
Not too difficult if that's the case.
By far not reliable but I mean hey it’s there
Yeah but thankfully this is a me-only feature
I dislike restarting the server over and over to test
A long time ago I wrote a Gradle plugin that let you build and start a server but I abandoned that project because it was too hard to maintain
Oh have u tried running debug mode with the jvm thingy that allows for better debug
You mean uhh
Yea paper has good stuff now
yeah
Always forget the name
But it’s pretty neat although unsure how up to date it is
I tried to use that once but it just wouldn't start up, lol
🥲
Stuff like this is why I stopped writing Java
But uh, Spigot is a profitable market so I'm back at it, I guess
For the past few months I've been writing Rust exclusively. Actually had a neat project in development. https://github.com/maow-tty/tokyo
Oo yeah if (almost) everything was in rust we would line in peace 100%
I agree from the standpoint of someone who hates writing C and C++.
I don't actually dislike the languages all that much.
Just the build tools :)
Swear to god, GNU software makes me want to game end myself
Lol understandable
Now I need to enter NameSpacedKey, what should I enter?
can I play a sound when deciding which one to use from IJ because there are a lot of sounds and I dont know what many of them sound like?
I believe there's a page on the wiki.
It'll probably be a pain in the ass to find the specific sound event IDs for each but you can also look at the game files
is this the corrent way to check if custom event is cancelled?
gobbledegook
how can I do it then?
Cancellable myEvent = new MyEvent(...);
// Now call the event
getServer().getPluginManager().callEvent(myEvent);
// Now check if it was cancelled
if(myEvent.isCancelled()) {
// My Event was cancelled
}
HeadDropEvent headDropEvent = new HeadDropEvent
erm no?
no need to cast anything
public class HeadDropEvent extends Event implements Cancellable {
seems like your event class does not extend Event
what event triggers this (bed)
look at the line aboe
above
Cancellable ... = new HeadDropEvent
oh yeah
interact event on a bed?
i assumed Event was an interface that Cancellable extends
@Override
public void belowPrefix(Player player, int score, Component content) {
Scoreboard scoreboard = player.getScoreboard();
Objective objective = scoreboard.registerNewObjective("BelowNames", Criteria.DUMMY, content);
objective.setDisplaySlot(DisplaySlot.BELOW_NAME);
player.setScoreboard(scoreboard);
}
Any idea how i could change the score 0 to the score var?
yea but i see no way to cancel the message and let the event run
Hi ! i have a problem, i'm using some custom configFile but when i try to know if the config file exist,
file.getAbsoluteFile().exists()
always return false... can someone help me ?
just do file.exists
yeah there probably is no way
btw when i set Player#setBedSpawnLocation player still gets message when right clicks the exact same bed
same problem
The file does not exist then
doublecheck that getBedSpawnLocation is equal to the one that is set afterwards
U sure u use the same file for everything thats related?
the file exist
no my file's nbame is lang.ymland he is in the folder of my plugin but when i tried to know if the file exist he saied nop and overwrite my file
?
if (!this.file.getAbsoluteFile().exists()) {
this.plugin.saveResource(template_file_name, true);
}
More than that will be needed
Wait i break the code cause discord sayed too much char
?paste
what is "file"?
thanks
print out the path of file
absolute or not ?
i guess this will work
C:\Users\natha\Desktop\Java\Minecraft Server\survival\plugins\lang.yml
for the message
yeah that's not the correct path
i doubt you want to save your file in plugins/
so this is correct?
it's because you add this weird "parent + /" to your file's path
Oh yeah my bad !
also why aren't you just using getDataFolder() ?
idk
getDataFolder returns your plugin's folder, e.g. plugins/MyPlugin/
you can create files inside that like new File(plugin.getDataFolder(), "lang.yml");
yeah i know but idk why i dont use this !
hey i got a quick question how would i disable a wither not taking arrow damage below 50%?
thank you
What is the difference between rayTrace, rayTraceEntities, & rayTraceBlocks?
EntityDamageByEntityEvent, check if the damager is an arrow, check if the wither got less than 50% HP, if both is true -> cancel event
i think this is just normal minecraft when it activate it's shield that means it cannot take projectile dammage
rayTrace = both
entities = only entities
blocks = only blocks
not sure
yeah
so rayTraceEntities goes through blocks?
yes
also can i force a wither to go lower, ik if a wither is below 50% hp to hover's lower
ty
here my code. so the event get called before the drop adding
I have cancled the event in 2nd class. so its not modifying the drops.
but in 3rd class, I did a task on that event. and that didn't got cancelled :/
wdym "I did a task on that event"?
that is what a vanilla wither will also do, it will lower itself when the ranged shield activates
not like instantly
but gradually
that shouldnt be made like that
yes but can i force it if its not at 50%
not that I know
the event should have the new drop included, then if it isnt cancelled you drop it on the floor
like it will send a notify on discord if a mob drop head.
so if I cancle the HeadDropEvent, it don't drop head. but send notify on discord
i tried looking at EntityWither and it calls a method .cm() which is a boolean, tried overriding it and damageEntity but it just recursively calls
Guys, can you create a plugin that has items with custom textures?
custom model data
and a texture pack
you need a resource pack
Does it overwrite textures or add new items in this case?
add new ones
you can make items have specific textures based on their name or other properties
it doesnt really add new items, it just makes you able to use different textures for already existing items without changing the default item look
Can you explain to me how I can do it?
The Minecraft wiki has all the information you need
Hello, I'm Geegaz ! As you may know, the first snapshots of the 1.14 introduced a new format for the JSON item models custom model data ....
can you help me mfnalex pls :")
Ty
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
i dont get it. why dont you just send the notification in the same block where you add the drops?
Can I also use them in a custom craft?
Ty
it can do all the things a normal item can it just gets rendered differently client side
Ok
send the message if the event isnt cancelled
So I have to create a custom model data pack?
But if I use items from other plugins in the craft, is that a problem?
no
just add the checks for those items
but those items wont have the custom model data (so no custom textures) unless the author or you sets it
whats the purpose of implementing an interface once
how to register Enchantment when server is enabling, it gives me IllegalStateExeption
you are not supposed to register any enchantments
if you want to do it anyway, you gotta use reflection to allow registering new enchantments https://github.com/JEFF-Media-GbR/JeffLib/blob/master/core/src/main/java/com/jeff_media/jefflib/EnchantmentUtils.java#L48
however there is really no reason to do it unless you wanna create a fake glow enchantment
and why not register, I need it to be just like a real one, appear in the enchantment table, for example
Dr Murphy 😄
You're still going to have to handle much of the behaviour yourself
For example the client won't be able to see the name
So you need to listen to a bunch of events and add lore
I only need the appearance in the table of enchantments, trade with the inhabitants, everything else itself.
really?
Yeah
And you won't be able to get it to display the name when hovering the enchantment buttons
that won't happen anyway
but why it has Rarity and can be Traded?
So you can check the rarity and if you can trade for it
?
Is there a way to avoid nbt stuff from Being able to place/use?
Yeah listen to place and interact event
Cancel if it has the information
how instant will a task timer set to 0 be completed once its started?
like the next tick?
wdym?
probably but no guarantee
Im still confused about the question
okay so lets start from the beginning
I am creating a plugin where I want to divide some players from a list into teams, I am currently getting a concurrentmod exception when removing from my list, likely because I am ending the timer too soon
I have a timer which when it goes of should start the game
the timer start when enough players have joined
but in teh config you can set the timer to 0 seconds
so my timer is going off probably before I added the player to the team
and while the timer is timing out, and messing with the list, I am trying to add a player to said list
Are you sure you're not just getting the exception because you're removing whilst iterating over the list?
no
I am explicitly using iterators to avoid that
but
it can still be modified from the outside
because if I just change the timer to be 1 second, I have no issues
hence why I thik its actually because I am adding to the list
hmm
nvm
seems like I will have to do more debugging on the actual feature
for (NamespacedKey key : player.getPersistentDataContainer().getKeys()) {
player.sendMessage(key.toString() + " VALUE");
}```
how do i iterate over the keys and get their values?
player.getPersistentDataContainer().get(key)
Is there an event that's triggered when a suspicious block changes state from a player using a brush?
lol idk actually, I always use pdc where I know what my values are supposed to be
whats your use case
idk what kinda monster plugin you would have to have to make it super long
storing a bunch of different variables with different types in PDC and putting them into a json file
like idk a message and a kill count
actually i guess i dont need to do that cus i can just remove the stuff i dont want to keep since it saves itself
but i still wanna figure it out
yeah the whole point of pdc is that you dont need to save it somewhere else
maybe i want to make backups idk
If you backup the world like you should, that will also backup PDC
fine ill do it the lame manual way
it seems like pdc wasnt made for what you wanna do
just get the correct datatype by checking has(...)
https://github.com/JEFF-Media-GbR/PersistentDataSerializer/blob/main/src/main/java/com/jeff_media/persistentdataserializer/PersistentDataSerializer.java#L116
wait so when is pdc actually saved to the file
every few min or on server shutdown or what
...it saves when it most??
it saves with the parent
on a chunk, it saves when the chunk is saved
on an item, it is saved when an item is saved
oh
I got a question, i made this part to send a player a message the moment the players is standing to long on the same block (not coords, same block):
@EventHandler
public void onPlayerMove(PlayerMoveEvent e) throws IOException {
Player player = e.getPlayer();
if(isStandingOnSameBlock(player))
{
Bukkit.getScheduler().runTaskLater(plugin, () -> {
if(isStandingOnSameBlock(player))
{
player.sendMessage("You have transformed!");
}
}, 60L);
}```
But i got a question, does the task keep the player that triggerd it or is it possible if multiple players are online that the message will go to the wrong player?
Cuz im not sure if im standing still for example and right before the task runs (after 3 sec) another player moves and the message will be send to that player
this would be fine
Ah okay so no multiplayer issues here
the player variable is method local
this would be an issue if the variable is defined e.g. on the class
Ahh okay awesome, thank you!
what does isStandingOnSameBlock do?
io ig
how would one avoid a ClassNotFoundException if a class in my code exists and it references a class from a future version that doesn't exist on the one i'm playing, even if that code is never ran because of a version check?
like i got a custom recipe class that references SmithingTransformRecipe, but this doesn't exist in 1.19 versions so it throws that error, even though the code will never get to that point
its an exception from a reflective call
NoClassDefFoundError is if the class doesnt exist tho
yeah obviously
thats not the point
i want my plugin to support a range of versions but this 1.20 class doesnt exist in other versions, but i still need to work with it
how would i avoid that in a preferably nice way, because i know i can just put that referenced class in a different class and have it do its thing that way
quick and dirty way, only works for local variables and stuff:
you'd wrap that into something that checks beforehand
if(McVersion.current().isAtleast(1,20)) {
SmithingTransformRecipe recipe = new SmithingTransformRecipe(...);
// ,,,
i could have sworn it used to do that before but im pretty sure because i persist and load this object with gson it does it anyway
and the whole stacktrace
pretty sure its just because of gson that it throws the exception regardless
i dont even have any custom smithing recipes made right now so the bit of code that's meant to generate the recipe never runs either
just the reference alone causes the exception
yes its gson
cuz gson uses reflection (sometimes)
and u happen to be getting cnfe
which is impossible to get if u dont use reflection
is there some workaround i can use to avoid it
how exactly do u use gson rn?
like can i make a fake SmithingTransformRecipe to trick gson lol
put your gson deserialization into a try/catch
i guess yeah
i dont think im doing anything special with gson, besides registering some type adapters for my abstract classes and interfaces
its not even allowing me to catch CNFE because it thinks it's never thrown
Isnt the CNFE caused by NoClassDefFoundError?
Or sth
Worst case, catch Throwable and rethrow anything thats not NoClassStuff
you cannot detect that reliably
listen to incoming ServerboundCustomPayloadPacket
idk how exactly the data looks, but that's the one where forge MIGHT send a list of mods
you can easily disable that with another mod though
sooo it's not reliable at all
to listen to that?
you either need to inject a custom netty listener, or use sth like ProtocolLib or PacketEvents
i'd suggest ProtocolLib because then you don't need to update for every new NMS version
PacketEvents requires to be shaded, and yeah NMS you also gotta recompile for every new versino
who? ProtoclLib?
it is
one sec
was there even many changes in 1.20 for protocol
hmmm
weird, idk then
one sec
oh yeah you're right, I thought I was running ProtoclLib but I'm not
hmm then I'd use a custom netty listener
?nms
and then you can follow this guide, it's outdated but the general principle is still valid https://www.spigotmc.org/threads/packet-listener-using-netty-tutorial.69772/
PacketEvents
except you must not use reflection because obviously the names change on every version
PacketEvents would also work if it's on 1.20, idk
never used it
it was updated last week so I'd assume it was
PacketEvents is 1.8+
afaik
idk try it out
Heyo, I've got a few questions about sending custom events as I've never used it before.
- When an external plugin depends on my artifact to have the event should it shade my code or use as provided?
- If shade, if a plugin relocates the artifact would it still be able to use the event as normal?
use packetevents 2.0, 1.8.x is outdated
I sent you the link
on github
compile it yourself then? though you shouldn't need to
its not a plugin
its a library
just use moj maps then
2.0 github https://github.com/retrooper/packetevents/
2.0 examples https://github.com/retrooper/packetevents-example/tree/2.0
you don't even need to use all these libraries just use mojang maps + nms
Use the CodeMC repository as shown here
https://github.com/retrooper/packetevents-example/blob/2.0/pom.xml
ProtocolLib and packetevents both work for 1.20.1
then you gotta compile your own copy
PacketEvents isn't a plugin no?
It can be run as one
it can be, yeah
oh didn't know
I thuoght you had to shade it
they probably just haven't updated the spigot page yet
Use the latest dev build
Own function that checks if person is still on the same block as before
why don't you just compare the move event's getFrom and getTo()
I mean, those locations will always change
ofc I meant the block
ah
basically just check if getFrom().getBlock().equals(getTo().getBlock())
either you are not depending correctly or you are shading the API
yea no scope means it would be shaded
ye
onPacketSending is to listen to outgoing packets
you have to listen to the incoming packet, not the outgoing
public class ProtocolLibTest {
{
Plugin plugin = null;
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.CUSTOM_PAYLOAD) {
@Override
public void onPacketReceiving(PacketEvent event) {
// Stuff
}
});
}
}
works fine for me
idk whether the correct type is Client or Server, protocollib's names are ridiculous
they should use the proper names, Clientbound and Serverbound
simply saying "Client" or "Server" makes absolutely no sense because the packets are alwayws sent between client ADN server lol
idk which is the correct one
no clue why protocollib fails to use the correct packet names
?
then client is the correct one
and it's out of bounds because that packet doesn't have any strings
it only has a byte array or sth
why are you listening to the custom payload packet 
ehm
given how trivial it is to disable that modlist sending
not really an effective way
I mean, depends on the mod you want to counteract ?
anti xray and anti cheat work well
Cheat mods and clients aren't going to announce that they're joining
yeaaa
They'll present themselves as vanilla
lynx typing too slow
I mean, you can do it this way
its a minimal barrier for entry
will it block people that know a bit about abusing mods
no
ive been looking at this for like an hour and idk what im doing
what do you not understand?
anything
yeah well idk how to explain it then lol
imho it's pretty straightforward
better dont look at MorePersistentDataTypes then lol
is this what you mean by has or what am i supposed to be looking for
yes
it loops over all existing primitive PersistentDataTypes, checks if the pdc has(this type) and if yes, returns it
the list of native types (NATIVE_PRIMITIVE_PERSISTENT_DATA_TYPES) is set via reflection in the static init block
yes
I mean, the javadocs explain that
Gets the proper {@link org.bukkit.persistence.PersistentDataType} for the given {@link NamespacedKey}
I'd strongly suggest ordering that
the average speedup of first checking STRING, INTEGER, BYTE_ARRAY
vs them being in a set
Shame we don't have a method to just get an object without a type