#help-development
1 messages Β· Page 80 of 1

or Ill commit a murder
lol tht meme
what meme? that's chocos real life face
I'm dividing up my code into different files based on features. For example everything in TwitchBot.java has to do with twitch integration, meaning it has to listen to minecraft chat. Sometimes the bot needs to be reloaded though so I dont want the old listener to still be active
this is more of a temporary thing ill come up with something better later
sorry
oh right we're supposed to actually talk about coding
That's bad. Bukkit is not designed to unregister Listeners. You shouldn't register new listeners each time.
Otherwise you'll have to do some bad moves to unregister your Listeners (I read about reflections for instance, bet it's not a good idea)
i completely forgot that
yeah you should have one listener for the event, and it could then "promote" that event to your other classes if desired
Huh?? You can unregister listeners just fine
i said its more of a temporary thing for now
im gonna fix it later
pls dont cross post. also I have no idea what you're talking about
Really ???
of course, but IIRC they wanna register a listener like every 5 ticks or so, then unregister them again
Sounds great
and that seems like a bad idea
no im not lol
only when an admin reloads
oh I confused you with someone else then, sry
I think it's cool, the goal is to have the lowest TPS isn't it?
someone else had a similar question today
yes
you can just Thread.sleep() to get low TPS
Well Olivo has your answer then dude
mmm
Doesn't work well, I prefer the infinite for loops, no need to catch exception
if you wanna get really low TPS, just do Unsafe.putAddress(0,0);
Unsafe is always a good idea
tbh the Bukkit unsafe class is awesome
Dark magic
fun fact: the actua implementation is called CraftMagicValues or sth
(jk for legal reasons)
a few days ago, I was bored
CraftMagicNumbers smh
Just put it in spoiler they won't notice anything
so I wrapped CraftMagicValues into an interface https://github.com/JEFF-Media-GbR/JeffLib/blob/master/spigot_1_19_R1/src/main/java/com/jeff_media/jefflib/internal/nms/v1_19_R1/BukkitUnsafe.java
That's really sexy I like it
oh mb. it's CraftMagicNumbers
the other methods are declared in the BukkitUnsafe interface
I'll have a look at it then thanks for the tip
idk if my use case belongs in highest or monitor
Does it modify things in the event
do you change anything related to the event itself?
I'm just trying to broadcast some minecraft chat to twitch
then use monitor
I read it but no i dont modify
and do ignoreCancelled = true
alright thanks
Is posible to get a InetSocketAddress?
From a player you mean?
player.spigot().getRawAddress()
Oh actually that was migrated into Bukkit now. player.getAddress()
No, from vanilla Java
Because InetAddress.getLocalHost() exists, but it cant be constructed into a InetSoketAddress
anyone know how to change a players name tag
Sure you can. InetSocketAddress has multiple constructors
One of those even has a string hostname for you. new InetSocketAddress("play.myserver.com", 25565)
Hmn ok but still in troubles because of my constructor
Hmn i think i will have to redisign that
π‘
i wish it would be possible to provide a
oh
hit return too early
I wish it woud be possible to provide an IP (or at least a fallback IP, when DNS fails) for a HTTPUrlConnection in java
e.g. something like new HttpUrlConnection("myWebsiteThatDoesntExistInDns.com","9.8.7.6",443);
and then it would use 9.8.7.6 as IP but still provide "myWebsiteThat..." as vhost
Hi i need some help to invoke a method via reflection
is it a private final method?
No no
I have done a custom listener class
My goal is to loop over each method and invoke an event
So you mean like a separate event system? Independent of the spigot one?
Why not just use spigots? What does it lack
Its for vanilla java
Its specific for the socket library im doing
π
I really like spigot event system so i have recreated
hey, I'm looking for a free plugin that will allow you to set custom drops for blocks or give you the option to execute a command after destroying a block
Well then you need some manager that holds something like a Map<Class<? extends Event>, List<MethodHandle>>
where you can register methods for each event and later invoke them when an event is raised.
Tysm, I was looking for something like this for days...
@lost matrix im having troubles with the invoke part
Also sorry for pinging
Are you using Method or MethodHandle objects?
Method method = ...;
method.invoke(theInstanceContaingTheMethod, theParameter);
Hello, is there a method to stop/disable the plugin?
setEnabled(boolean enabled)?
There you go
is there a way to add a section before a section
only if it isn't the root one
well technically you can do it if it is the root one just more involved is all
if it is the root one, you would need to hold the config entries in memory, clear everything and then put your section where you want it
anyone know how I get a string from a command that the player types
for example
if the player typed
/name
I want the player to be able to write whatever they want after that command
like
/name potato
and I want to be able to store the word "potato"
that is what args[] is in onCommand()
args[] contains everything they typed after the command name
so in
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
to retrieve what was typed after
String[] args is what you want
args[0] is the first argument after the command and so forth
So it is possible to do this ```String something = "";
for(int i = 0; i < args.length; i++){
something += args[i] + " ";
}```
yes
alr thanks
but you could just do this though
for(String arguments : args[]) {
arguments;
}
yeah
Hello, I would like to know if it was possible in 1.8 to recover the durability lost by each piece of armor when a player is attacked (org.bukkit.event.entity#EntityDamageEvent) ?
thx
If I'm constantly checking the config, will it generate lag?
can i use this to create a file and paste the contents of the old config into that file
if (!getConfig().getString("config-version").equals(configver)) {
getConfig();
createOldConfig();
getOldConfig().setDefaults(getConfig());
saveConfig();
}
You can also try with and without checking the time the program takes to check the configuration
Quick Question. So I am trying to check for items with names that are formatted and such and I was using ChatColor.Bold.Red + "Chat to be formatted" but then that stopped working and it won't detect items that fit the correct syntax anymore... I tried using minimessage but that also does the same thing and doesn't work even with nonformatted text... Does anyone know how I can fix this?
yo
try ChatColor.BOLD + ChatColor.AQUA
I have and it doesn't work
try translating
How do I do that? sorry if I seem a bit stupid i'm quite new to doing plugins
ChatColor.translateAlternateColorCodes('&', "&l&5TEXT")
bump!
Does anyone know how to get a container inventory from a location?
cast the blockstate as Container
then Container has .getInventory()
thanks
So I did that but that doesn't support Hex Codes. Do you know anything that would?
?pdc use this to tag/identify items, not names.
I'm not using pdc because of how i'm doing the items
?
try it and see
or just use java File utils to copy and rename the file
FileUtils.copyFile(File srcFile, File destFile) ???
no
it is fileutil
src is just config.yml?
Files.copy thooo
are you actually trying to copy a file, or are you trying to extract a resource to a file from inside your jar?
im trying to copy yml -> yml
so config -> OldConfig
but getConfig() is FileConfiguration not File
Yes
But thats because it does only resemble the content of the file
Not the file attributes, location on the drive etc
Thats up to File
The color and formatting is used to prevent players from just renaming an item to be the specified thing.
if you used the pdc it would be impossible for anyone to make it
Most used SQL? I have H2, MySQL, SQLite. Any others I should consider?
everyone i know uses mysql or postgresql
I use mongo :P
Yeah Postgre is also quite integral
Especially in enterprise
Don't forget mongo :(
they have really nice java compat
NoSQL π
Would be nice if it wasnβt so unscalable when it comes to relation based data
In terms of most used, I'd say MariaDB probably takes the cake. EDIT: Actually I forgot about PostgreSQL. That would would most likely beat out MariaDB lol
If not just straight MySQL due to legacy
mongo is super scalable wdym?
have never had issues with scaling mongo
anyone know how to make change the name tag of a player
like the box above their head
with their username
Player#setDisplayName() does not work π¦
oh ffs
my plugin is too large due to the translations files
3250kb of text
why is nothing ever easy
You wonβt be able to do that without packets. A solution using ProtocolLib: https://www.spigotmc.org/threads/protocollib-disguise-player-with-new-name.301599/
Host them on GitHub and pull them from there
That is nothing
it pushed it over the limit
the main problem is that I have about 50% of my storage taken up by cloud commands seemingly
so I either host off-site, rewrite all commands or start using something like proguard just to compress the plugin

Thereβs a file size limit on spigot?
yep
How much?
4MB
What's the best coding website
what's a coding website?
jdoodle
its what i use for spigot plugins
Ok
any1 need server developement
Unverified with black PFP. Lol
Racist ^
Time to refactor 14k LOC :DDDDD
Sounds fun
Hello. I finished java lessons, i know basics and more about java and I want to make a plugin but I don't know which part i should start making first
btw you check if player is new on join event
π
its Player#hasPlayedBefore() iirc
okay, thank you
though keep in mind, this only works reliably if you know that the plugin has been there since the start of the server.
o.O
don't quite understand that
that method is reliable regardless of the plugin. What makes it unreliable is if the user data gets cleared out
that method returns true if it can find in the player data directory the corresponding data file for a given uuid/player
doesnt player#hasPlayedBefore() only check against the "userchace.json" file?
So if you played on the server before, it would be "true", irrelevant of if your plugin was enabled at that time or not.
it does not check against the user cache, there is a playerdata file for every player that has joined
but let's say the plugin does something when a new player joins for the first time since the plugin was enabled, like set some PDCs or smth, that wouldn't happen if you only use player#hasPlayedBefore(), cause that could be true, even though you rather want to know if the player has played before the plugin was enabled
I just wanted to note it, as it seems that what Igneliukolaumas wants is just that, when a player has joined prior to the plugin being enabled
I don't think so
the method is not unrealiable, just a missunderstanding as you have stated to what someone could expect of it
that isn't the issue we discussed lol
more of people learning to use the API simply not understanding that method π
since you know people don't read lol
How would you misunderstand the functionality of it
It literally spells it out for in the method name lol
I just wanted to note something, how has this become such a problem of naming schemas suddenly ?
because not everyone who learns to make a plugin, think logically
Well anyway gm
gm 2Hex
it would be easy for someone new not actually think that a player could have played on the server before their plugin existed on the server π
Why isss snakeyaml adding all this crap to my data?
head, serialVersionUID, tail and accessOrder
these things don't exist in the config file
?paste
there is so much code, but hell if you are willing
because it isn't coming from the data
its coming from your code
guaranteed serialVersion exists in one of the classes
you serializing any data?
I would assume so
oh shoot
there is more code hang on
in here
ah its probably the reflection?
could also have it use pdc and check if the value exists already
yes
not sure what you use the reflection on, but in the first code paste I noticed you are using an itemstack as a test I suppose?
if that is the case, ItemStack contains that data as it is required for objects to be serializable
which class and what line are you referring to
ok...not really concerned on the purpose
just informing where that data is coming from, and not quite sure how you are using the reflection as I don't have my IDE opened
but in Java for something to be serializable one of the things the class needs to have is SerialVersionUID
ItemStack is one of those that is serializable
?paste
you don't need reflection for it o.O
anyways, your project is too large for me to go through to see if any of your class files contains it
especially without my IDE
I need reflection to cast the object to a map
The other way is Jackson, but screw Jackson
reflection isn't required to cast an object to a map
it is a way you can do it
important code from the Npc class: https://paste.md-5.net/eqakafimuc.java
code for spawning the npcs (just for testing)
int n = 0;
@EventHandler
void onPlayerInteract(PlayerInteractEvent event) {
Location loc = event.getPlayer().getLocation();
Npc npc = new Npc(this, "npc-" + (n++))
.create(NmsWorld.getHandle(loc.getWorld()))
.move(loc);
npc.setSkinSignature("...")
.setSkinTexture("...")
.updateSkin();
npc.spawn();
}
but when right clicking, it only adds the players to the tablist, they dont show in front of me
please enlightenment me on another way that is different to the two methods I stated
Object x = new HashMap<Integer,String>();
HashMap y = (HashMap<Integer, String>)x;
spawn() goes over every player and calls spawn(ServerPlayer) on them
that shows a warning tho
I don't like warnings
yes a warning
don't say supress
@SupressWarnings("unchecked")
die
supress
how are you gonna do it otherwise
even if you don't suppress the warning it won't prevent it from compiling
it won't
i can guarentee with 99.9% certainty it wont get called out
the reason your IDE gives you a warning and the compiler is just to make you aware of something that you may not be wanting to do
bruh i do @SupressWarnings({ "unchecked", "rawtypes" }) like everywhere when i do any type of generic fuckery
but if it is what you want to do and are aware of the ramifications if misused then no need to pay attention to it
π
Java is a good way to fuck your brain up if you feel like it
yeah
but I still love it
same lol
then moved
I started with c++
exposed
reported to fbi
seems like your viruses sucked, otherwise you'd be in jail lol
but installing Mingw64 or some shit on windows is a fucking pain
I only used it myself other people in the house
so i was never able to really code c++
one person at school
two person at school
did it work?
nicee
but not in the good way
π
always important to add this part when saying that sth sucks
Something funny too is screenshotting the desktop and setting it as wallpaper, then removing all icons from the desktop
got 130 npcs but idk where they are
lol
My teacher was kinda dumb not getting it
they dont spawn as entities for me
nah i was fighting mobs and shit for bored but i forgot it makes 2 every time i click
but does anyone know why
i am adding the entity with packets
uhh packets
have you read this?
quoted from it
playerConnection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER));
you never add the entityPlayer id to the packet, and since is a vararg it does accept this anyway.```
i do do this ClientboundPlayerInfoPacket infoPacket = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, nmsPlayer);
included the nmsPlayer
what version are you using?
1.19
I believe this is correct
public void addNPCPacket(EntityPlayer npc, Player player) {
PlayerConnection connection = ((CraftPlayer)player).getHandle().playerConnection;
connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc)); // "Adds the player data for the client to use when spawning a player" - https://wiki.vg/Protocol#Spawn_Player
connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc)); // Spawns the NPC for the player client.
connection.sendPacket(new PacketPlayOutEntityHeadRotation(npc, (byte) (npc.yaw * 256 / 360))); // Correct head rotation when spawned in player look direction.
}```
comment out your current packet stuff and give that a go, keep in mind I know shit about packets
i have different remappings, and i dont have ClientboundNamedEntitySpawn either
what are u trying to do
npc stuff
spawn an npc
look here for info
?switchmappings
i am on paper mappings idk if thats mojang
ay thanks
paper? are you using gradle?
ye
I remember the time when I was using grad;e
I regret it tbh
also another great source for remapping is here https://neomechanical.com/forums/how-to-remap-124
nah i like my mojang mappings but idk what the equivalent to PacketPlayOutSpawnNamedEntity is
BRUH
its ClientboundAddPlayerPacket
why is it called NamedEntity
π€·ββοΈ
still dont see shit
bruuh
// construct packets
ClientboundPlayerInfoPacket infoPacket = new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, nmsPlayer);
ClientboundAddPlayerPacket entityPacket = new ClientboundAddPlayerPacket(nmsPlayer);
ClientboundTeleportEntityPacket posPacket = new ClientboundTeleportEntityPacket(nmsPlayer);
// send packets
ServerPlayerConnection connection = target.connection;
connection.send(infoPacket);
connection.send(entityPacket);
connection.send(posPacket);
persistent data container is the best thing to come since the creation of minecraft itself
not negotiable ^
na its the 1.19.1 update
nay
yay
ten commandments of minecraft
sounds like a google question
mfnalex, you're german right?
I got a 50 line yml of messages, wondering if you could look over it and make sure it makes sense
anyways if you could take a look at it that would be great https://paste.md-5.net/agizusejev.xml
items as well
I use it for custom items
storing id and other stuff
you can't afford his fees
Lol, have no idea if he charges for translations. But I am sure he will do it for you π
there is a person here though who does in fact do translations as a job for a few languages
I mean its already translated, he just needs to look over it
yes
that is part of translation jobs
not only to actually translate but proof reading translations as well
send it
where
here
wasnt there a site where you could just upload it and let people "PR" the translations
no idea
I just run it through google translate
seems to work alright because people use the translations
doesnt this website https://www.deepl.com/translator work way better?
2.6% of servers I mean
I know a bit of Indonesian and it didn't translate brilliantly but its decent
it looks okay, but the grammatic is shit
Hey :)
Which way is more common/better to use when sending messages?
Let's say I have a waiting queue on my server and in the plugin, I am putting the player who calls some command into a List of UUIDs. I have a method addNewPlayerToList(Player player) and the original onCommand method in some class JoinQueueCommand which implements CommandExecutor of course. After the player calls the command, a message like "You have been added to the queue." should be sent.
Now I have two options.
- Send the message in the onCommand method, after I call
addNewPlayerToList(Player player):
executor.sendMessage("You have been added to the queue.");```
2. Send the message in the `addNewPlayerToList(Player player)` method itself and then just calling that.
Which way is more common?
crowdin?
since the method is only the add to list X and not add and inform player they have been added, the first option is the way to go. the second "option" would most likely break the SRP for that method/class/whereever the method lies
i think that was it, yes
I thought so, thank you :)
how do I send a message from my bungee plugin and get it back to my spigot plugin?
what type of message?
Because that sounds like either a plugin channel or database problem
Unless its a text message in chat, then you can use the standard api for that
crowdin
oh i might have been beaten to it ;)
Has someone here already done something like making an entity unable to move but look at the player when he is close?
So far I used to disable the entities' AI, but this also disables looking at the player
Yeah just remove the other goals
nms or paper api can be used for that
Do you mind if I dm you?
Sure DMs are open
plugin channel
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
try that
Does anyone know about deployment via Sonatype (Jira)?
whats your question
It might be a small error, but all solutions I found through my research did not help at all.
what file writer should I use when dumping yaml?
yaml.dump(data, new FileWriter(file));
what I am currently doing
I saw different ones
I don't know the type of the data
how do i get items that drop from BlockBreakEvent?
the entity
actually i found it lmao
is getDrops() relative to the tool used?
or i need to use the method that accepts tool
^
when I dump like this it saves the config like this ```{language: a}
Id advocate buffered writer
with sth like
try (var writer = Files.newBufferedWriter(file.toPath().toAbsolutePath(),StandardCharsets.UTF_8)) {
yaml.dump(data,writer);
}
how do i cancel BlockBreakEvent item dropping default behaviour?
W
I really dislike shading libs. mysql dependency is so large, but if you want older servers to be able to use current MySQL π¦
makes my plugin 15 times the size it should be
it it possible to make no item display absolutely nothing when hovered in an inventory?
setting it to an empty string makes it display the default item's name
a space will display a space
a chatcolor with nothing after makes an even smaller space display, which is better but it still displays something
plugin.yml libraries π
yep, not on older versions though π¦
can I put a spigot plugin and a velocity plugin in the same jar? so that we can put it on velocity or spigot without having a different file
you have to modularise your plugin
well, its ok for older versions
it might be
its just doing what I already did in other plugins
No good since the new java security changes
i use java 11
yeah
they suck
i wanted to make a runtime packager manager but fucking java pussy security fucked it
that still changes the format
1.19 api compared to 1.12 is like heaven and hell
Hey, so, what I want to do is make an armor stand move in a circle using the player input packet (aka steer vehicle packet). I can't quite get the hang of it. When you press D I want it to go right following the guide of the circle. It's the same with A but it goes left when you press A.
Eait no im wrong
According to javadocs getGroup isnt a method
There is getCreativeCategory
Yeah you ccant change it
Any ideas?
Show us your code
how tf am I meant to save with snakeyaml without it completely destroying a config file?
look at what it did
explosionCap: 50, heartBeatRate: 20}
Your explanation is vague
how?
on which version of minecraft can my plugin work if I use java 11?
Check bukkit wiki
Thats not how it works
configure the yaml instance u use to dump with
there is a reason I am using snakeyaml over spigots config
Theres a reason hes using snakyaml
thank you
my plugin works on all versions since 1.8 in java 8 but if I switch to java 11, will my plugin work on as many versions if they are in java 11?
buoobuoo could probably explain it better
Java version and minecraft version have nothing to do with eachother
which option would you recommend?
Only thing that matters is if your server is running at ir above the compiled version of your plugin
well, it's impossible to launch a 1.13 server in java 17/18 for example
but u can look at spigot source
ScalarStyle looks nice
if u wanna copy that
actually yeah
probably actually possible
Compilation version of the plugin wont have effect on your client
Itβs dependant on your server
And java is backwards compatible doesnt really make sense
i'm talking about server, not client
"Unsupported Java detected (62.0). Only up to Java 12 is supported." @tardy delta
A lot of people are still using it
Java backwards compatible so wondering why that doesnt work
Isn't there a launch flag to disable that check?
Such as IKnowWhatIAmDoing?
without adding a flag, from which version can I use java 11?
Listen to the item craft event
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
And evaluate the matrix yourself
I wonder how many version I will lose if I switch to Java 11 that's all
Get the matrix, check the items and send the craft yourself
wrong chat
magnetMeta.addEnchant(Objects.requireNonNull(Enchantment.getByKey(
NamespacedKey.minecraft(config.getString("magnet-enchant")))),
config.getInt("magnet-enchant-level"), true);
what it might be caused by?
magnet-enchant: "DURABILITY"
magnet-enchant-level: 3
there are config values
oh wait
Just check for each position if it's the good material
and then add the result to the event
look post above
do commands must be in plugin.yml or na?
can i create empty lore if one is equal null and then just add elements to it?
(im gonna try and see first lol)
i have committed a misdemeanor
Could not resolve dependencies for project me.giorno:Balls:jar:1.0-RELEASE: org.spigotmc:spigot:jar:remapped-mojang:1.19.2-R0.1-SNAPSHOT was not found in https://repo.citizensnpcs.co/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of everything has elapsed or updates are forced
<repositories>
<repository>
<id>everything</id>
<url>https://repo.citizensnpcs.co/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.19.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<classifier>remapped-mojang</classifier>
</dependency>
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens-main</artifactId>
<version>2.0.30-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>
</dependencies>
```
why is maven looking for org.spigotmc in the CitizensNPC repository
With float getAttackCooldown() does the attack cooldown go to 0 before or after the execution of EntityDamageEvent?
no
you can use it, it's not reset before the event (because if you cancel it it wouldn't have to be reset)
make a second repository that uses spigot you are only getting the url of citizens
its the nms package
perfect ty
<repository> <id>everything</id> <url>https://repo.citizensnpcs.co/</url> </repository>
you have this you need to add another one that does this
<repository>
<id>spigot</id>
<url>spigot version</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
oh my god π
the error was the remapped mojang classifier
wat is dis
magnetMeta.addEnchant(Objects.requireNonNull(Enchantment.getByKey(
NamespacedKey.minecraft(config.getString("magnet-enchant")))),
config.getInt("magnet-enchant-level"), true);
this is the code
magnet-enchant equals UNBREAKING
and level equals 3
Objects.requireNonNull only gets rid of the warning for you
fixed
its because it was uppercase
okay umm
how can I play chest opening animation
/something 1 2
---------------^^ this is arg[1] right?
you cant pass in empty arguments
i wanna check if argument [1] isnt provided
check if args.length is 2 then
meaning you have an args[0] and 1
ur smart
How can I teleport an entity from an async thread without any delay?
I can't though
why not
I'm using a packet listener called PacketEvents
hmm default reload operation for a plugin is to call onDisable followed by onEnable right?
What if I just use a bukkit runnable and set the delay to 0 ticks?
thats what i told you, to go back to the main thread
// async stuff
// go back to main thread
Bukkit.getScheduler().runTask(plugin, () -> { System.out.println("booo"); })```
It still has a 1 tick delay even if you set it to 0 I think
i believe so
In EntityDamageEvent you have Damage Modifier which is deprecated. Is there something else that is being used to calculate final damage or are these events just utilizing the deprecated modifiers.
Follow up to that, is there a way to bypass and instead set final damage and calculate modifiers on your end
isn't there getFinalDamage?
so what is your goal? what do you need to calculate exactly
im setting health of nearby entities on damage event. I want to be able to then modify the health reduction based on the individual resistances of each nearby enemy
and i need to do this in varying instances so im wondering if i can bypass the modifiers in EntityDamageEvent and write my own util for it and set the final damage to entities
idk, maybe this helps
https://www.spigotmc.org/threads/stripping-down-entitydamageevent-damagemodifier.194446/
alright thanks
would not just be possible to store last damager entity?
elaborate?
if damage from the entity is more then the heath
you dead
stores entity
idk if my idea is useful
thanks, but not entirely what im asking here unless im misunderstanding
ah sorry miss conversion for 1 sec
all good
are you making a rpg?
Which one is better for performance? have multiple yml files with small data each or just one huge file?
I want to do constant searches in the files and I want to know which is the best
stream thro the materials enum filtering on Material::isBlock
no
chests arent full blocks
but they do come in isBLock
and so do enchanting tables
then remove those manually lol
copy enum and make ur own
to edit this project
dunno what this is
if it has a hitbox and is a full block type deal
skills type plugin yeah
is it like dead island level System?
each player seeing different levels on an entity?
no clue what that is sorry lol
Bottom text explains the point
some rpgs Monster increase heath if more players is near
broadcastmesage?
no no i mean like
ahh receive
someone.sendMessage()
CommandSender?
ConsoleSender for Console
ye ye but whats universal for Player and Console
idk confused
CommandSender
its CommandSender
both are instanceof it right?
yes
either way just require the CommandSender
do you still mean receive?
all resolved man
thanks for help yall
Bukkit.getPluginManager().getPlugin(instance.getName()).onDisable()
Bukkit.getPluginManager().getPlugin(instance.getName()).onEnable()
edit fuck no i found something better
how can I use same command for multiple classes?
this is good for restart command right?
BlockCommandSender
ConsoleCommandSender
ProxiedCommandSender
RemoteConsoleCommandSender
nah thats not what im doing
i wanna restart my plugin thru code
Which one is better for performance? have multiple yml files with small data each or just one huge file?
I want to do constant searches in the files and I want to know which is the best
hmmm interesting π
if you do get far please do share video of it
more then one seems manageable and won't overwhelm the user
-Chunking
plus the sake of organizing
[15:43:03 WARN]: could not determine a constructor for the tag tag:yaml.org,2002:java.util.UUID
[15:43:03 WARN]: in 'reader', line 2, column 17:
[15:43:03 WARN]: profile-uuid: !!java.util.UUID '2ea7a15b-8309- ...
``` idk what this means
https://paste.md-5.net/sitapoputi.yaml
send code bruther
that it doesnt find a UUID(String) constructor
hm
i'm just manually doing UUID.fromString(config.getString("uuid"))
E
yes
I wanna make a plugin like the DankMemer bot and give it a global database if possible
its my dream plugin
pretty sure dank memer uses the reddit api
on like r/dankmemes or smth
like that
I meant the economy and fun commands side of dankmemer
cant really show memes in minecraft chat now can I?
titles
you do have algorithms to allow display of images with boxes in chat
or use a map
rendering kinda sucks
I prefer my memes in 4k ultra hd lcd full retina display
also yeah rendering is hell
What the diff between Executor
#exefute() and Executor#submit()
Because im having heavly multi threaded issue
I mean when im writing thru the client socket the server listen the request but then doesnt send it back to client
execute executes immediately where submit only pushes a new task to the queue iirc
read the docs
submit returns a future iirc
I have read 10 diff tutoriales about multi threaded
And i didnt fixed it
Because the client send the message and the sever receive it, but then it doesnt allow me to send it back to the client
Im really sure that is a problem related to threads
Lmao i really hate async and threaded things
You literally burns your few brains
you have more than one brain?
who doesn't?
This isnt working, i want when some player dies remove permanently one heart and the killer gets one heart
public class onPlayerDeath implements Listener {
Main plugin;
public onPlayerDeath(Main plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPlayerKilled(PlayerDeathEvent event) {
Player victim = event.getEntity();
if (victim.getKiller() instanceof Player) {
Player killer = victim.getKiller();
if(killer != victim) {
double vHealth = victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
double kHealth = killer.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(vHealth - 2);
killer.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(kHealth + 2);
if(victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() <= 0.0) {
victim.kickPlayer("Tu foste banido do servidor por teres 0 coraΓ§Γ΅es!");
}
}
event.setDeathMessage(ChatColor.YELLOW + victim.getName() + ChatColor.RED + "(" + victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() + " CoraΓ§Γ΅es) " + ChatColor.WHITE + "foi morto por " + ChatColor.YELLOW + killer.getName() + ChatColor.RED + "(" + victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue());
} else {
double vHealth = victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(vHealth - 2);
if (victim.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() <= 0.0) {
victim.kickPlayer("Tu foste banido do servidor por teres 0 coraΓ§Γ΅es!");
}
}
}
}```
?paste
there is nothing in console
class naming conventions gone?
Agree
the java knowledge here is sometimes worser than in a coding server dedicated to java :/
method naming conventions gone too
stream for each
put return on the same line
If the Listener doesnt work its because its not registered or doesnt contains the @EventHandler annotatiom
Use a lovely stream
that isnt a real suggestion
its just his preference
streams are slower but you arent going to notice
I dont really like normal fors I mainly prefer stream
same
there is anything wrong with the code?
Be serios have you learn java?
streams unncessecary here
Because we can see name conversions problems...
this channel is for what?
Not wondering to soundrude
is not to tell one person doesnt know how to do something is to help
streams are basically never necessary, often used for simplicity
we have a ?learnjava command for a reason
removing boilerplate loop shit
So what is happening? Did you try debugging?
If you havent learn java before you cant expext getting helped because they will explain you things that you wont understand
That one of the main Arguments
But meh I dont care you do what you like
no
so debug it
ok
Pd: no wondering to be rude, just make you realize that you wont really be sucessfull on plugins without knowing the lang itself
put some log messages in between to see if the value is changing as you expect
You know haya
no, language?
Cant expect others to help you if you havent really tried to isolate the issue
nothing
yes
are you sure
@rapid aspen does your event has @EventHandler annotatiom on the method?
put sysouts and youll see
.
takes you 2 seconds to look at that to see it does lol
Im the dumbest person in the world im sorry for spending your time i register it but it didnt save
If it would have correct name conversions and used paste yo see code would be easier to help
π π π π π
Is there such a thing as a set of Material (class Material) so that I could just set a value for all axes instead of needing to do it for each axe type individually
this doesn't necessarily have to do with arrayList?
What is foods ?
you should return when you cancel
because it is already cancelled
because it will go on with the loop
Cause you're looping the whole list
you're cancelling in loop
@EventHandler
public void HeadPlace(BlockPlaceEvent event) {
for (ItemStack items : foods.itemStacks) {
if (event.getItemInHand().isSimilar(items)) {
event.setCancelled(true);
break;
}
}
}```
to exit the loop
same effect
nah
No
it will stop when there is no more items
A loop with loop all over its content it you don't stop it
So the code will be over AFTER looping everything
if you e.g. want to find the first item just grab it and exit early instead of keeping the loop alive
anyone know how to get Color from text
like when the user types /name &ePotato I want to print the word potato in the chat but in yellow
but when I do
/name &ePotato
it returns
&ePotato
instead of just
Potato
but yellow
or a specific item, then you got what you want and don't have to check the other items
The color data is inside the string
so it returns with the color code
any example?
ChatColor#translateColorCode or something very similar
so ChatColor.translateColorCode("&e")?
ChatColor.translateAlternateColors('&', "&ePotato")
yes
Might just wanna take args[0]
But why
how do i generate some randomass string
this no work
impossible to replicate
t.setPrefix(ChatColor.translateAlternateColors('&', name));```
says translateAlternateColors does not exist
SafeRandom r something
What do you mean? Every steing is possible to replicate with a keyboard lmao
SecureRandom might have that
alr thx
javadocs aren't witchcraft
actually
well
idk whats better
having long that increases every time, or random string generated
how big can long be
Very long
just tabcomplete that method lol
or maybe, there is other way to make item not stackable
No
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.
There's a method to set max stack size for the whole inventory but idk if that's what you want
i want itemstack to have max size
it's not performant, if you don't wanna learn good Java it's your choice
Ic
You did however say you don't give a shit about using breaks, while using a break in this case is proper Java
Saying you don't give a shit makes me not want to help no
Someone literally posted the right solution earlier
Your loop will break after the first run, you need to put the break inside the if statement after you cancel the event
break just stops the loop and continues with the code after it
you know what
lmao what is this
yes because if multiple items from your list match , you will cancel the event multiple times, which isnt needed
You would check only the first item in that case
You will stop after the first check, it's like checking the first item
and if it's not correct you break anyway without checking the other items
wait i can use unix milis
I think the "performance decrease" is negligible but good design is good to have
lol
in this case yeah
You break outside the if, so it breaks after checking the first item regardless it being the one ur looking for or not
in that case you never get to check all other items
yes
correct
you have to put the break inside the if
#0 actually
index starts at 0
@EventHandler
public void HeadPlace(BlockPlaceEvent event) {
for (ItemStack items : foods.itemStacks) {
if (event.getItemInHand().isSimilar(items)) {
event.setCancelled(true);
break; // Don't check any further, we have found an item that matches
}
}
}
And please never start a Java method with a capital letter π
I think today is "Ignore java naming conventions" day
remove the 'naming' and you are correct