#help-development
1 messages Ā· Page 372 of 1
org.bukkit.event.player.PrePlayerDeathEvent
what package should i relocate io.netty?
dont think we ever had that so it has to be a fork probably
your.package.netty
oh right sorry i just didn't really worked with maven so far
relocated gotta test it now
<relocations>
<relocation>
<pattern>io.netty</pattern>
<shadedPattern>me.gameisntover.iranmcreportsspigot.netty</shadedPattern>
</relocation>
</relocations>
this is what i wrote
yeah it was fixed
but im getting a new error
org.redisson.client.RedisConnectionException: Unable to connect to Redis server: 127.0.0.1/127.0.0.1:6379```
but i guess ik what is it from
i've created the client via the create method with no parameter can it be caused this error?
127.0.0.1/127.0.0.1 š«”
im trying it on localhost ofc
How can i get a player ip adress on login with bungeecord?
Is there any way to see how spigot handles the getDrops() method of the BlockBreakEvent?
Just inspect the class
sometimes getDrops() indicates that it is empty but actually drops items on the floor :l
You can check the decompiled source to see what it's doing
Block.class?
Does anyone know why this doesn't work?
I'm trying to remove items from a players inventory with certain lore
Inventory inventory = player.getInventory();
ItemStack[] contents = inventory.getContents();
for (ItemStack item : contents) {
if (item != null) {
ItemMeta meta = item.getItemMeta();
if (meta != null && meta.hasLore()) {
List<String> lore = meta.getLore();
if (lore.contains(loreToRemove)) {
inventory.removeItem(item);
}
}
}
}
}```
The best way to find where the event is called is to get the spigot source and then grep for the event
Or you can try your luck with guessing random classes it could be located in and opening them up with intellij
here maybe it could be seen, but I don't know where it could be located: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/nms-patches/net/minecraft/world/level/block
download this
Then you can easily search for any instance of where that event fires
and see how it's determining block drops beforehand
there is no getDrops() in the BlockBreakEvent
There is getDrops() in BlockDropItemEvent
ClientboundLevelChunkPacketData packet = new ClientboundLevelChunkPacketData(levelChunk);
System.out.println("Send Chunk at -1;-1");
((CraftPlayer)player).getHandle().connection.send(packet);
``` Why can't I send the packet? It tells me to cast the Packet to Packet<?>
sorry, Block.getDrops()
those are only the default drops which could drop
Yes, but when you get the drops, sometimes the collection indicates that it is empty but drops items on the floor, this happens with the grass
you can't rely on Block#getDrops()
I've seen on the spigot and bukkit forums people who have had problems with this, md5 said it could be a bug, but I don't know what it turned out to be
if you want to see what is actually going to drop use getDrops() in the BlockDropItemEvent
I am using BlockBreakEvent for an action and by the way I need to know what items the broken block drops, so I use Block.getDrops() or Block.getDrops(tool), but this returns empty in some cases when breaking grass that drops between 0 and 1, but actually items fall on the floor, so it is not according to what the API says
this I guess md5 will know what is going on here, because this should not be like this
Md5 already know about that issue, but he isnt really sure why, so he have claimed its a bug
As I said you can not trust Block#getDrops() as even in a best case it's only going to tell you what could drop. That won;t include things like seeds.
Well, that's the problem, when you break the grass, it returns seeds, which gives rise to this problem, I guess there is no solution for this :l
Yep you've stumbled upon a physically impossible problem
Yes there is BlockDropItemEvent#getDrops() tells you EXACTLY what is going to drop.
so if I have my logic in the BlockBreakEvent, how can I get the drops if to get them I have to verify it in another event? it is a bit complicated no?
Why do you have to verify it in another event
simple, move your logic to the actual event that gives you the correct data
what are you doing in teh Break event which changes depending on drops?
I can't move the logic to that event, it's difficult because let's say my plugin is mainly based on the BlockBreakEvent and 5% of the code or 10% of that event is to do an action with the drops
you didn't answer
is elgar a saint
What specifically are you doing in the Break event which changes depending on drops?
let's say my plugin handles the BlockBreakEvent to break blocks in a region, I have to verify that it is a region of my plugin, that it is not in other regions or claims of other plugins, give compatibility, then proceed to do logic like checking if with the tool that has broken the block has enchantments, and much more, pass all that to the other event I do not know if it is possible, I guess not to have to verify everything I said above, at least I do not know how I would do it if my plugin depends on BlockBreakEvent
all you do is check if it's permitted to break
what it drops has no relevance there
when i reload my plugin sometimes (quite often tbh) it throws an error where it says java.lang.NoClassDefFoundError: kotlin/collections/CollectionsKt during plugin disable process and yes i shaded my jar. how can i fix this?
use java
š¦
yes, when I check all that then I do the logic to check if it has enchantments and start manipulating the data of the block in question
all the break event should be handling is IF the block is allowed to be broken.
drops are nothing to do with that event (other than exp)
The classloader is closed while executing the onDisable method
Henceforth no classes that were not already loaded can be loaded.
do i really need to migrate over to java just to prevent this?
No. Not the proper solution.
And how do I do then that after checking all that to use the other event? make a call to a custom event that extends the BlockDropItemsEvent?
To work around this you may want to use your own classloader or play the classloader yourself and load all the classes early
you can get the block which was broken in the BlockDropItemEvent
decide if it can be broken in the break event
handle drops in drop item event
BlockDropItemEvent#getBlockState() gives you the original block which was broken
minehut be like:
ah shoot wrong channel
ah whatever
(I advertised free op but I made a plugin that instantly kicks em)
ok
I know, but first of all I must verify in BlockBreakEvent if it is a region and more things, then when I am 100% sure that I can break, I would do the logic of the block modifications, which as I would do in the BlockDropItemEvent to know that all the verifications were successful?
if the BlockDropItemEvent runs then the block was permitted to break. The two events are not related
If you prevent the break no drop event runs
if you allow the break a drop event runs
once in the drop event your code shoudl no longer care if it's allowed to be broken
Hey, does anyone know how to use RGB colors in the scoreboard?
hex
whatd be the right channel
none
mmmm interesting, since which version is this event included in the API?
a while
prob 1.8 lol
1.6
longer
~7
1.8 is 7 years old
another 5 peeps
8 and a half years
fuck r u doing
are you trying to grab ips? why are you asking people to join some other server outside of minehut?
ye but why
im trying to get max players
on a server
record
uh but if you kick immediately
BlockDropItemEvent is from 1.13 right?
probably
ye
any ideas?
?commands
its down the bot
?workdistro
thanks smile
why cant we just list the commands btw
yeah, they removed it, we used to be able to list them
why
I think discord helper can list them
Yes they removed it
Ecosia your question before asking it:
https://www.ecosia.org/
?bing
Bing your question before asking it:
https://www.bing.com/
I love it
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.
Google your question before asking it:
https://www.google.com/
There is a ChunkSnapshot you can create from a Chunk. Can even be used async.
the thing is that I gotta send the Object LevelChunk
and a LevelChunk is created with a ServerLevel and a ChunkPos
helllooooo anyone has a good tutorial/video on how to properly create a database? like to store classes or things like that and to get those values back even after u /reload ?
do you just want to store data or actually serialize objects?
If you really want to learn it look into relational schemes and dB normalization
i dont really know, like stock a class maybe?
so objects yas
Then you probably don't want to use relation scheme, but document based one
do you have a document or a tutorial or even a video explaining how to use it maybe?
Google about mongodb, I think there is also tutorial on spigotmc iirc
thx !
Abstract away common parts
Like create a method registerEvents(Listener⦠listeners)
And then pass your listeners to that instead, removes a bit of boilerplate
You can use some hacky stuff to do that
But its not recommended
Classpath scanning incomming
Cause like, classes come and go (they are loaded dynamically and can be unloaded and loaded before and after server start and end)
smile, can I somehow clone a LevelChunk with a String and then get one back from it?
In theory you could use a context & dependency injector like guice to do a lot of stuff with annotations.
But i despise this meta programming style like its used in SpringBoot etc
You mean like storing them in an array and then loop over the array and register each element
.toString obviously just gives something like net.minecraft.world.level.chunk.Chunk@74835ccd
Or sth else?
Ye, its so un-object orientable
I never understood why people like the @Inject annotation
unless you're a google dev you can never understand what it does internally
Its supposed to help with long constructors, like mapping dependencies
a clean event register```java
private List<Listener> events = new ArrayList<>();
@Override
public void onEnable() {
events.add(new RainbowGlow(this));
events.add(new RecipeManager(this));
// ...
events.forEach(e -> pluginManager.registerEvents(e, this));
}```
Since if you have a long ass constructor its gonna be a pain to maintain the order in which the dependencies are passed
I suggested this to him:
Listener[] listeners = new Listener[] {
this, advancementEvents, interactionEvents, playerloginEvents, playerchatEvents, nicknameRequest,
informationRequest, customInventories, potionEffects, reloadPlugin, playerFlight
};
PluginManager mgr = getServer().getPluginManager();
for(Listener listener : listeners) {
mgr.registerEvents(listener, this);
}
Just do
registerEvents(Listener⦠listeners){
Arrays.stream(listeners).forEach(listener->{
this.getServer().getPluginManager().registerEvents(listener,this);
});
}
That way the vararg arr is rest assured to be gcād
And you document your code by making the method explain to the reader what is going on
Is Java's GC routine really dumb enough to leave a dead array reference if it's used/not used in a certain way?
Or does my method make GC slightly slower than others?
No
Maybe if uāre running poopy system with serial gc
Tho i used a stream
Which is like goofy memory usage right there
I seen that, which is why I was asking
Well didnt know if that variable declaration was a scoped local variable or a field
What's the benifiet of using .forEach(<lambda>) or Arrays.stream compared to java's built in for-each loop syntax?
how can I view the actual sourcecode of something like a ClientboundLevelChunkWithLightPacket? Not some description, I gotta know how it works to fork it
Thereās no benefit, but thereās less boilerplate, just readability
Ah
I think a simple foreach there is fine
Yes
Its during server plugin bootstrap
So using little more memory there is no biggie
Not talking about performance/memory, was just saying I think it's probably not needed
isnt there a documentation online for that
isn't that more code compared to just a simple foreach?
idk but I need the inner sourcecode
compared? You mean compact?
so I can manipulate some stuff
no I mean compared to a foreach isn't it more code*
It's supposed to be more readable. Programming is always a battle between performance and readability.
I'm all for readability but I don't think that improves it.
Yeah I also like standard loop more then forEach
NMS is typically obfuscated, you'll need the deobfuscation maps and then you can just decompile the vanilla server and apply the deobfuscation
im using mojang mappings btw.
Just look at the decompiled vanilla server then?
The vanilla server is NMS (net.minecraft.server)
cannot just throw a server jar into enigma and apply some map lol
Theone in this case it doesnāt matter but basically
Normal for each is faster as of now (Java told us streams might be comparable in the future)
For each gets clustered(nested) easier because youāre forced to write consequent code inside the scope of the for each
Stream allow you to do it in a monadic style, that is being able to compose it without the code becoming too nested, of course you can always extract more methods to avoid large functions since large functions almost always decreases readability and maintainability
The other advantage is parallel streams.
Then you have the fact that lambdas compile down to invokedynamic which is nice.
You also have method references, which is nice if you can take advantage of.
But both works, and it doesnāt matter in this case at all.
When you say you are using mojang mappings, are you doing this in Spigot's built tools? Because Spigots build tools (I think) will remap the vanilla server jars. This means you can get the deobfuscated source from the build tools output.
yeah true it does not matter
yes I did use the buildtools
I wasn't talking about whether it mattered but if it was even worth going for a stream
Then you should have deobfuscated vanilla server jars in your build tools output. Just decompile that and you should be good.
I guess it's just preference there?
I haven't really looked into streams but they do look cool
and can shorten code a bit which is always nice
do you mean the one in /work?
Very beautiful stuff but oh god java does use memory for it nonetheless
I don't know off the top of my head, but you can find out pretty easily just by trying it
an enhanced for loop is the same as a foreach just fyi
ye compilers might handle them slightly different if needed but true
After learning about them i literally wrote everything i could with streams.
Mostly stuff i should not have used streams for...
Dropped them almost completely after some jmh benchmarking. They are
better in newer versions but im marked now
š„²
ā¹ļø
Like mojang for instance
Java is a strange beast
implementation wise enhanced for loop uses foreach hence they are both the same
They have bombarded their code with streams unnecessarily
not to be confused with your normal for loop btw which is different
and still handy for its own use
Like you even have path finding and entity fetching being handled by streams
Nothing will save mojangs code
Truly
That's the problem with long-standing projects (of really any language.)
It becomes increasingly harder to keep up with the times.
Indeed
don't need mojang code if you just make your own implementation š
but everyone is also set on trying to make public plugins everywhere XD
I mean its pretty nice just being able to use some api and stuff to get my little hub plugin up running
indeed
hmmm thats weird
I wanna send a ClientboundLevelChunkWithLightPacket without having to modify a Chunk for it
you should be able to send a chunk update packet instead
can you give me the name of it?
should have update in its name
did you want to update the chunk or just the light?
the chunk
that is the one to update the light only
to cut down on the packet size you can exclude the block entities and light update and just send those later
if you want to make it more performant
uhm that seems like an extreme shit-load of work to wrap myself
all I wanna do is having a clone of a LevelChunk
to modify it and send it to the client
well that is what chunk updates entail
?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 was in another chat
I am trying to add a dependency for plguin factions and I can't, it can't find the dependency in maven, I tried to add it as an external dependency but it doesn't work either. Can you help me?
I need help with protection and the end
yes but I gotta send fake updates lol
with my own non-existant chunks
the update is fake if you are sending those packets without the server being aware of it, but there is a lot of packets you are going to need to catch to prevent the client from seeing that it is fake
Then find out how the FriendlyByteBuf works and manually write the bytes of your chunk packet
which is basically all the update packets
oof
How can I add the factions dependency then?
all this just to see the suspection of it being 10x faster than rendering BlockChange-Packets
=(
add the repository information where said dependency can be found
or install it into your local maven repo
You can also try creating an instance of LevelChunk manually and see if you can edit/send it this way
I got an instance of it with ServerLevel and ChunkPos
but, when for example trying to use LevelChunk#setBlockState, its gonna access the real Chunk and change the block
I tried to use the local directory in maven and it still can't find it, am I doing it wrong?
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>LakeAddonFactions</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>local-repo</id>
<url>file://${user.home}/Documents/dependencias</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId>
<version>2.14.0</version>
</dependency>
</dependencies>
</project>```
The jar is exactly in the "dependencies" folder.
is it just the jar or is it in com.massivecraft.Factions.2.14.0
you should mvn install that
I am using mvn install:install-file -Dfile=Factions. jar -DgroupId=com. github. Factions -DartifactId=factions -Dversion=2.14.0 -Dpackaging=jar it and still this dependency does not work for nothing
remove the un-needed spaces
mvn install:install-file -Dfile=Factions.jar -DgroupId=com.github.Factions -DartifactId=factions -Dversion=2.14.0 -Dpackaging=jar
So currently my plugins depends on vault. But i'm wondering how can I make vault be the last priority dependency and depend on other plugins first if they're available. Changing my code accordingly depending which one is available
For example:
Depend on vault or luckperms
If LP is available use LP directy, otherwise vault
soft depepnds
The specified file 'C:\Users\Administrator\Desktop\LakePlugins\LakeAddonFactions\Factions.jar' not exists
run the command where the jar is
Do I make a DependHandler abstract and make each handler extend that?
check if Vault is null or Luckperms is null and handle stuff accordingly
But then somewhere I need to specify different functions depending on which handler is used
Is this the right way?
yeah, that would work
Is there a better way to do it?
not that i know of
Ok cool,
-Dfile should specify the full path to the jar unless you are running the command in the same directory it is located
once you install it with the mvn install command, change your pom to remove the repository information
as it isn't valid and isn't necessary for local repo
The dependency has been added in pom.xml. But in the code below.
import com.massivecraft.factions.Factions;
import com.github.Factions;
public class AddonFactions {
public void printFactionInfo() {
Faction faction = Factions.getInstance().getFactionById("my-faction-id");
System.out.println("Faction name: " + faction.getTag());
System.out.println("Faction leader: " + faction.getLeader().getName());
// etc.
}```
It is not identifying the classes.
did you successfully install it with mvn install?
Yes, the console returned build succes
well to verify, navigate to local repo
to see where it is at
if everything is good, hit build on your maven project
it should cause it to update and see the dependency
of course after updating your pom to be correct
In maven it is correct, without any dependency problems. But when I do the import I run into this problem Cannot resolve symbol 'massivecraft'
did you hit build for maven to pick up the dependency ?
this is assuming you installed it with the correct groupId and artifact name to match what you have in your dependency tag
Faction dependence
My pom.xml file looks like this. The groupID is like com.github.Factions.
<dependency>
<groupId>com.github.Factions</groupId>
<artifactId>Factions</artifactId>
<version>2.14.0</version>
</dependency>
if everything is correct then you should be able to use it
Hey so I'm trying to sort tablist.
I understand tablist gets sorted by teams prefix a-z and such. How could I go for sorting this automatically based on a groups weight or a groups permission node signifying a weight. weight.<int>
otherwise you have something wrong, maven looks in the local repo and maven central for dependencies
Because I see people in old posts say the only way is creating teams and adding those with a hidden prefix.
But how can I create teams with specific names if I Don't know how many teams there will be
Exactly, that's why I don't understand why it's not working
did you hit build?
hi boys
how can I do to add a .yml inside a datafolder
Like
plugins/myPlugin/lang/en_EU.yml
Im confused why would thorw an NPE?
If im already checking, if im creating the section if it doesnt exists
I use a FileHandler class which i coded
it wont
Its giving a NPE, saying that section is null but why? Im creating it, in case doesnt exists
intellij dont has obligation to know what each code does
then you are creating it worng
No no, but the spigot gives the exception
final ConfigurationSection yourSection = config.getConfigurationSection("Section");
if(yourSection == null) return;
for(String path : yourSection.getKeys(false)) {
String al = yourSection.getString(path + ".aaa");
// TODO
}
Isnt what i sent?
I must create the section in case of being null
Yeah its the same logic*
Hmnn
I will prob wait until another answer because im really cofnused, doesnt make sense the exception
Because im creating the fucking config section, in case it doesnt exists, so there is no posbility of having the section null
Yeah the code seems right
its private?
data.set("Previews", new HashMap<>())
ye u can do it too
right i will test it
but why do you need to get the configuration section?
Because I see people in old posts say the only way is creating teams and adding those with a hidden prefix.
But how can I create teams with specific names if I Don't know how many teams there will be
ConfigurationSerializable reason
ur nickname sounds like so much a brazilian boy
Im using this code for using ConfigurationSerializable ith custom model objects
Wizard u from brazil
I cant sent it, because i cant even save the data
š
The same issue tho
a fucking NPE saying that section is null when im fucking telling to create the fucking section in case of fucking beeing null
š”
Sorry man
I didnt want to rage but doesnt make sense the fkg issue
send how you want it to looks like
I cant because it will be a map ConfigurationSerializable
will it be a list?
Hmnn
will it be a List<YourObject>?
bro
you dont need it
just use a list
like this
hm?
Previews
- ==: YourCustomObject
some-data: value
- ==: YourCustomObject
some-data: another value
- ==: YourCustomObject
some-data: value 3```
and the code woul be
i cant use list, was an specific request from my executive to treat it like a map
List<YourCustomObject> list = (List<YourCustomObject>) data.getList("Previews", new ArrayList<>());```
much easier
idk
I must want an explanation
I dont want spoofed code, its easier yes, but i want to learn the why
but i am providing to you a better code
š this guy
Please if youwont help, dont disturb
Im not with humo to support this jokes, im being seriuos
When coding, its coding them yes you can do jokes and what ever
This is why half the dev discord has you blocked. You're not nice
Lmao, its not my problem
I just wondering to get an explanation of why owuld throw an NPE exception, when im telling to create the section in case of not existing
ta
public void reload() {
this.data = new FileHandler(plugin, "data/previews.yml", true);
for (Preview preview : (List<Preview>) data.getList("Previews", new ArrayList<>())
this.previews.put(preview.getKit().toLowerCase(), preview);
plugin.getLogger().info("[PreviewManager] Sucessfully loaded " + previews.size() + " previews");
}```
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
i sent it before
ig
you didnt
aint not way giving the same exception
its similar
It must be something else wrong i will check the file creation, must be that
it dont have anything to do with the file creation
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
Lol
I AGREE
Lmao than im the one who fucks
the right code for your need would be this
Are u trolling?
I know how section works
Either that or havent even read my code
SMH
;.
No sorry
Im really mad with this guy he alays disturbing instead
you are using the section before it was created
xd
if (section == null)
section = data.createSection("Previews");
the .set method would work too
i cant believe
but the section = should be a get
if (section == null) {
data.set("Previews", new HashMap<>());
sections = data.getConfigurationSection("Previews");
}```
That why i always prefer using custom libraries rather 3rd parties š¬
ChatGPT could solve ur problem
ChatGPT is not alays correct, i have been using it
And most of time code its wrong or broken
sure it's an ai
but ChatGPT helps a lot
When people help you the correct thing to say is "thank you" btw
Maybe if you try that people will want to help you out more
you weird
right thanks wizard
,
it is better
I would but it specific ruquest from my executive
20$ per hour?
fucking 20 dolars
that is cheap
Yes its really cheap
So dont expect good things
If you want good custom things == putting bunch of money
not expensive but not cheap
I tell you as experience
For example i was paid around $100 just for adding 3 simple things and refactoring some things
From a src they already provided
u dumb
I love how english people like to give far a way / for free their money to devs
haha its something i love from them
That you consider something is +200 usd and they pay u without any questions
š
That why i dont usually code for latin americans
Just for english people who really have the money
a software dev doesnt have a fixed price
I code
Agree, price is based on some specific things, if its special, etc, etc
It's a joke
no its how much am i worth to myself
is there a method to get arrow land location?
Depends the work ofc
Especially for a freelance dev
projectilehitevent
oh ok thanks
Well but almost in all cases, 20 is low
You cant compare plugins working with backend working
im so poor then
backend get paid around +60% rather mc coders
but your customers have to understand why you are worth that much
Lmao
otherwise they will just look for someone cheaper
Yeah
Then we still sitting at 50 lol
you can
broken down its all code
Well plugin is not plugin
Different buiness logic
I charge the same for all my work. Work is work
^
cya
Yo guys how do I modify a BlockState or LevelChunk without modifying anything in the real world?
Packets if im not wrong, im not sure tho
Thats the issue
I gotta send the packet
But it requires a LevelChunk, and I wanna modify it without modifying the world permanently
You have to get the CraftPlayer, then the handler, usafe sendPacket
I know how to send Packets
No problem
thats just.. annoying
Because this complex thing does a lot more than just setting a variable for a block
Not doing that
I know but i mean
For this type of issue i dont like using none custom framewoorks
Agree
š
Im currently working on custom plugin library for creating multi platform (Bungee and Spigot) plugins in the same way, without chaging the file loading, scheduling, commands, etc
Because i code lot of multi platform stuff
Specially with redis and mongo
And i wont want to be creating diff code for just file loding for example, which can be done by same way
Redis is cool
yeah pretty cool
Specially when having to work with redis shards š
but sometimes its really annoying
Hey so I'm trying to sort tablist.
I understand tablist gets sorted by teams prefix a-z and such. How could I go for sorting this automatically based on a groups weight or a groups permission node signifying a weight. weight.<int>
Because I see people in old posts say the only way is creating teams and adding those with a hidden prefix.
But how can I create teams with specific names if I Don't know how many teams there will be
how can i spawn an arrow that fires at the direction the player is looking at?
and how can i implement two events in 1 listener?
You can listen to many events in one listener
maybe something like §0§0§0§1§bactual prefix
i never worked with it before so idk
how?
they don't let me register my other event as e2
In one Listener, not in one handler
@EventHandler
public void first(SomeEvent event) {}
@EventHandler
public void second(SomeOtherEvent event) {}```
You can't do two events in one handler. There'd be no way for Bukkit to know how to call that
then how exactly can I use both of the handlers in one listener?
how do i create a new body for them
hmmm
I guess I can make the teams for all groups with a permission node but then how do I assign the player to a scoreboard group that I did not keep track of
I'm not entirely sure what you mean. What is it you're trying to do exactly?
is there a way to play a song from a cd disc or a jukebox thing to a player with a minecraft plugin?
How to block explosion of respawn anchor and bed?
There are no respawn anchor and bed explosion
yea getblock should tell you the block thats triggering the explosion
thats what ive been saying without actually pointing out the exact solution lol
if you cancel the event it will not explode in the first place
how can i do GetItemInPlayerHand = Material.TNT or something?
set player invulnerable
um
Cannot get player in BlockExplodeEvent
Yes, It doesn't explode, but it gave me damages
Why would you need a player on the event? Its just for liistening to block explosions
he told me that make player to invulnerable
why the fuck does a cancelled event still go through in the first place
It shouldn't
If that event is being cancelled correctly and it's still damaging players, then it's a bug
hm
you recon the interactevent with the bed in the nether triggers a block explosoin and a damage explosion
I used to had issues related to explosions and was caused because, i was listening to block explode event
And then someone told me tha tbeds and tnt trigger the entity explode event
idk the apis has some weird things
what are anchors?
Tell him to try using the EntityExplodeEvent
public class GunFireListener implements Listener {
@EventHandler
public void PlayerInteractEvent(PlayerInteractEvent e){
if( Material.TNT = e.getPlayer().getItemInHand().getType();)
}
what's wrong with this?
I dont play mc, just 1.8 and 1.19 for debuging
Wait comment all your code
And add a listener to EntityExplodeEvent and check if entity is instanceof Player, and then cancell it
i have player interact event that means when right click tnt it activates the if the held item.type = tnt then i do something
oh right
Hmn confused now
maybe i reply wrong persona
oh yeah
My bad i just realize
Hey bro, try commenting your BlockExplodeEvent listening, and add a listener to EntityExplodeEvent, checking if entity instance of player, return. If not cancell the event
And check if that works, i think that its the same issue i used to have some time ago
?
What are you doing? What your final goal? mainly context please
to summon arrow when the tnt (gun) right clicked
and summon primed tnt at projectile land location
oh math, im not good at it, sorry. You will have to mainly wait pantientlly until someelse answer
Please if you want to persist your message you would have to open a thread
k
Hi , why elese is wrong ?
Imposible to read
Atleast take a cap near the error
No whole screen
Not even with 200% of zoom can read tht
Sorry , you can read ?
else not elese
Its a syntax error, happen because its not elese its else as lynx has said up
Also if you hover over that red lines, you can read the issue reason
lol
If its your first time coding plugins, dont even touch spigot without learning how to use Intellij / IDe you use for coding, neither learning Plain Java, and then yes start using apis or liibraries
sorry
@quaint mantle
Because moslty people here explain you things very technically so if you dont learn Java, a) you will have many issues while coding plugins, b) and also wont understand whtat others explain you
Im not being rude, just telling you the truth because many people make that issue
Ok, I understand , that you don't need to write so many messages
I knew that the problem was from else, but I didn't know why the problem was from else
I just wrote else as elese for a minute
how can I copy the args I got from a command and then paste it in a message?
like if player type /command args then the system would send the player "args command is sent"
public class TpaCommand implements CommandExecutor{
// /tpa playerName - tps to player
// args[0] - "playerName'
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player);
Player p = (Player) sender;
if (args.length == 0){
p.sendMessage(ChatColor.GOLD + "Sent " + ChatColor.RED + "TPA Request" + ChatColor.GOLD + "To " + args[0]);
}
return true;
}
}
will this work?
?tryandsee
args[]..
also code blocks
what if i want to make the args[0] and see if it is a player and if it is player then send a message to that player?
and import the args[0] into the /tpaccept and /tpadeny command?
Dude
Search online honestly
That's such basic questions that have so many threads and tutorials online easy to find.
Use discord if you can't find your answer elsewhere
Don't waste someone else's time
Could've probably been said a little nicer, lol
but yeah, a lot of these questions are asked by most beginners so if you're familiar enough with how to write a decent Google query, you'll probably find your answer on the forums already
First thread that came up when searching "how to make a tpaccept command spigot" https://www.spigotmc.org/threads/making-a-tpa-command.521571/
Sorry šæ
ok
average js developer
Anyone know how to optimize a PlayerMoveEvent listener even if its just a if statement its at the top of my timings
Just an if statement wont even show up in the timings. Even in the PlayerMoveEvent. Show some code. The conditional check must be very expensive.
it just checks if they move a full block
could just be because it gets triggered 20 times per sec per player
its not a lot its like 0.03
and my entire plugin takes like 0.06
ms? percent?
Show some code then i can tell you if you can optimize it. Ive written this check a bunch of times
and optimized it.
@EventHandler(priority = EventPriority.LOWEST) fun onPlayerMove(event: PlayerMoveEvent) { if (!FrozenHandler.isFrozen(event.player)) return if (event.from.x == event.to.x && event.from.z == event.to.z) return event.player.teleport(event.from) event.player.velocity = Vector(0,0,0) }
wtf
why did my chromebook format it like that
Why are you teleporting the player back and setting the velocity to 0?
This is the most expensive code in your move event.
its for frozen
How does isFrozen check the players state
to prevent u moving
Then just cancel the event
It just returns if a list contains a uuid
This can also be expensive with more players in the List. Use a HashSet instead.
https://www.spigotmc.org/threads/guide-beginners-guide-on-improving-your-codes-performance.396161/
This guide explains why a HashSet scales much better than any List for contains() and remove()
So 2 simple fixes:
- Use a Set<> instead of a List<>
- Instead of teleporting & resetting the velocity: just cancel the event
theres a mix of ij and eclipse in that
also no early return stuff so smh
how to make a boss?
Early returns are not a concern for code performance but rather code cleanliness.
They should never change the actual flow of your code.
ah true ig
But yeah i wrote this guide after about a year of programming and still used
Eclipse back then... Just updated a few pics over the years.
how can i make spigot plugin multi version :l
nms?
it coded purely with spigot and no NMS
just depend on the lowest version you want to support and set the api version to the same
it will work on all higher versions
I have a map of String, int
How can I sort this by int going from highest to lowest
Specifically I need to sort a list of groupnames by weight
You can use stream api, use its #sorted method
Iirc there is builtin comparator for sorting by value, I just can't remember it's name
what format is your command meant to look like? And what exactly are you trying to do?
oh its /tpa playername
yeah that should work. args[0] should return the playername
cum
meh i couldn't fix this error yet
org.redisson.client.RedisConnectionException: Unable to connect to Redis server: 127.0.0.1/127.0.0.1:6379```
these are also my dependencies am i missing something?
Whats the full stack trace? You need a running redis server so you can connect to it.
lemme
any tuts on how to make a boss?
why did you shade and relocate netty?
its provided in the server
not the issue i think but unnecessary
it is but it is also outdated
ah
you could maybe have it provided by putting it in the libraries block under plugin.yml
oh
might be
what format libraries need for an object
since im receiving a warning while typing
- netty```
groupid:artifactid:version
e.g.
libraries:
- "io.netty:netty-all:4.1.89.Final"
yeah i got it thanks
but server isn't downloading the libraries
idk why
server version is paper 1.8.9
Too old! (Click the link to get the exact time)
it got added in like 1.14 or 1.13 iirc
lol
1.16.5
ah
- paper != spigot
- 1.8 is old enough to buy booze meanwhile
the libraries feature is 1.16.5+
damn
in germany, you can buy booze with 7+ years
wtf
WTF
why not?
they are a child
however, it's not allowed to sell it to <18 year olds
but they could legally buy it
paper is a fork of spigot and they didn't really fucked up spigot api so they're almost the same
have you seen the patch that deprecates 80% of spigot's api?
they did fuck up the api recently
Anyone got an idea how this is serialized in protocolLib (1.19.3)
Trying to send a meta data packet for a dropped item and dont feel like digging through nms for this
even more yesterday
oh they fuck it up very often, e.g. the Advancement api
they introduced their own plugin.yml stuff
one sec
yeah i did but i don't think that they've even touched the plugin.yml
I also don't know anything about that
but as I already said, libraries is 1.16.5+
https://docs.papermc.io/paper/reference/paper-plugins
https://docs.papermc.io/paper/dev/getting-started/paper-plugins
yeah
i do
but i have some servers that are using +1.16
except the bedwars one (I seriously hate bedwars but im not the server owner so)
i dont get it - so what did they xhange in plugin.yml?
change*
ahaha
they're absolutely ruining up many spigot plugins for paper why are they doing this
its al on the 2nd link
yeah...
I mean, deprecating all string methods already was a bad joke
but now this?
I guess i gotta learn minestom š
if they do such a thing most of my plugins for the server that im working on would be fucked up how stupid is this idea of making spigot and incompatible only for making the plugin development process easier or whatever bullshit that they're planning to
tho
the fuck?
i dont get it lol
That's why we took precaution
at the moment its still compatable, but they are deffo on their way to not being compatable with spigot plugins
most likely will happen when hanger fully releases
Yeah, I just thought they wouldn't do it yet
people have to make a plugin that goes on spigot for spigot, hanger for paper
dont question it, paper is known to make weird choices from time to time lmao
IMHO most people won't do it for paper
mainly for spigot
90% of tutorials are for spigot anyways
even though literally everyone uses paper for servers, none of us care to support their features
ikr but it seems that sooner or later they'd do such a thing
yeah
depends, paper is at like 50% or so
exactly
exactly
yeah
57%
i've worked with the paper api and its dumb
facts
fr
i worked with it once
it would be awesome if they didnt enforce components that much
i just use the string versions
LegacyTextSerializer.ampersand().deserialize(getConfig().getString("message")); (Didnt' have a string to put in š )
it is not - they semi-hard-forked from spigot with the new paper plugin loading system
Many spigot plugins fail to load under paper now
and if you use LegacyTextSerializer.char('&') it doesn't recognize it as an ampersand lmao
we can still use plugin.yml on them
oh damn
The irony is: Not always.
so they have fully gone and hard forked
smh
https://github.com/PaperMC/Paper/issues/8867 issue in question
LegacyComponentSerializer.builder().character('&').hexCharacter('#').hexColors().useUnusualXRepeatedCharacterHexFormat().build()
bro nah
the fuck
Watch them remove reflection into nms lmao
?
thats what i use for minimessage legacy stuff
hurts but works
Does player.swingOffHand() just call the animation or would it also hit something i.e. a sword hitting?
animation only
In that case do you know how I'd get if a player is looking at another player?
the only thing that made me interested in paper api was that they were trying to complete the bukkit api to enforce that ppl wont use nms.
the idea was cool but they made it with a horrible way by adding components and deprecating strings.
1s
raytracing
they keep giving people reasons to hate them
people might have used paperapi before components
now barely anyone wants to
and with plugin.yml stuff more people dont wanna use it
meh I still do and I don't see all the fuzz
you can
A. raycast forward from eyepos till hit distance
B. Use A
btw who still uses bukkit š
though remember to use a max distance otherwise you'll crash the server if they look at the air
And the plugin.yml thing is minor - it will mostly affect server owners
Never worked with raycasting any resources you can share on that?
world.rayTraceEntities(Location, Vector, double); (Start, Direction, Max Distance)
@timid jetty
The function returns a RayTraceResult
declaration: package: org.bukkit.util, class: RayTraceResult
in your case you need getHitEntity() and getHitPosition() (to calculate rotation if you need it)
Thanks yeah i found the documentation should be fine :)
Also, taken from the mc source, maximum client hit distance is 4.5 in survival and 5 in creative, iirc the server allows up to 5.5-6
my brain's been infected with c#, is there no way for me to create an async task that retuns a value which I can use once it's been obtained similar to the await c# keyword?
You could use CompletableFutures
oh? can it be why that redis wasnt connecting?
Use kotlin or callback in java (Consumer funct interface)
var future = new CompletableFuture<MyThing>();
CompletableFuture.runAsync(() -> { // Use any async task, I just used runAsync for simplicity
var result = ...;
future.complete(result);
});
try {
var result = future.get();
} catch(Exception e) {
// error
}
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> someExpensiveAction());
future.thenAccept(result -> System.out.println(result));
I wasn't sure if completable future would work here
also this
This is to keep running on the same thread outside a lambda
This probably does the same but inside a lambda
It doesn't
Your code blocks main thread, the one from 7smile7 doesn't
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> someExpensiveAction());
// You can also pass the future somewhere and wait for the result:
String result = future.join();
That's
that's the point?
He wanted to use await
thus
Await is not blocking thread, but suspending
Oh shit, looked it up join is so useful lol
im getting this warning on compiling i guess that might be why that redis isnt working on my server
https://paste.md-5.net/yupesufuzu.sql
what should i do?
the redis error has no clue to see whats wrong
and im having no idea how can i fix that
can you show some actual code as well
sure
Looks like you haven't relocated netty
init {
instance = this
channel = BungeeCordChannel()
client = Redisson.create()
topic = client.getTopic("BungeeCord")
topic.addListener(String.Companion::class.java) { channel, msg ->
if (!channel.equals(this.channel)) return@addListener
var response = msg.toString()
if (response.startsWith("resp")) {
response = response.substring("resp".length - 1)
val args = response.split(":", limit = 1)
val i = args[0].toInt()
println("${args[0]} |||||| ${args[1]}")
conMap[i]!!.accept(args[1])
conMap.remove(i)
}
}
}
wait you need to relocate?
see
He is shading it I assume, but Minecraft or spigot (idk tbh) have it shaded too
Oh, I forgot it was shaded by mc lmao
Hey there. I have this code generated by mineskin. but the npc skin is just steve. anyone knows why? (online-mode set to true 1.16.5 api)
https://paste.md-5.net/azoxafufih.java
is there a setProperties for GameProfile
no
alright, that could've been on eissue lmao
Can you show your pom
So I'm using getItemMeta().getAttributeModifiers(Attribute.Generic_Attack_Damage) and it's returning null
Anyone know ankther way to get the damage of an item or do I need to write my own utility for it?
Nvm found an alternative
sure
Is there a resource on using configs thread safe?
What does "configs" specifically refer to?
YamlConfigurations
Those are not thread safe. Basically just a HashMap<> underneath.
And you should also never have to use them on multiple threads.
Hey sorry to bother you, I'm using player.getLocation().getDirection() for the direction vector, it still outputs null don't know if that's wrong
Best practice: Dont use configurations on runtime. Load your config in concrete class implementations and use those instead.
Nvm i lied it's working
man this code is a pain
all of this because I didn't want to write two nearly identical methods
Okay nvm it works sometimes very gimmicky
turns out completable futures' #thenAccept() method is async?
which is weird, I don't think that's right
I mean there's a method specifically for async
thenAcceptAsync
ok so it's sync with only the thread it's on? that sucks
i believe so, i always misused it lol
well how the hell am I going to dump this back to the main thread
scheduler::runTask :(
Are you trying to do something on a different thread using CF and using the result on the main thread?
yeah
thenAccept(result -> Bukkit.getScheduler().runTask(() -> { use result here }));
should i add mongodb to the dependencies if i want to use redis ?
or join it if thats what you want (probably not)
or atleast install mongodb
Also no
