#development
1 messages · Page 15 of 1
but im already doing this
I was only testing the import with a code, I've saw the deprecation and I'had planed to change the code but my problem was to understand if the import was working
Now I've followed the wiki and I've updated my code and It works but I've used version 2.10.10 for the moment because 2.11.X doesn't work with jar
Tomorrow I will use a build system
the repo for 2.11.2 does exist
Hi! How do I get the root path of a server?
What do you mean with root path?
not sure if there is a direct method but you can just do ../ to your plugin path twice
Bukkit#getWorldsDirectory and then get the parent file
any1 got an answer
thanks ill try that
whats in the class?
the class that you called that from
just the custom entity stuff
everything is working fine in that class
aside this part of the code
sorry to ping but have you found out why
can I make the result of an operation equal the value of an integer
for example
int coolInt;
45 - 30 == coolInt;
I believe this would solve my problem
Does anyone know how I could convert this {d2f6c64e-0034-400f-9ea6-4b47367d51a7=1} into this d2f6c64e-0034-400f-9ea6-4b47367d51a7 and this 1
coolInt = 45 - 30 ...?
(aka read a hashmap containing an integer turned into a string and player uuid from a file)
oh thats how
lol i made mistakes like that when picking up java again after a year of not using it
i forgot how to public static void main args etc
is the file contents being written by you?
Yeah using a BufferedWriter
i.e could you use a different format if need be
yup
how do I solve this
if i can solve this
right well easiest option is probably just to use Gson to write
rather than writing manually
and then that handles reading too
happens sometimes
what is that supposed to do
currentHP == blah is a boolean
oh alright thanks
You're performing a boolean check
^
oh
now
yeah yeah
why are you even changing the event damage
if you're just replicating vanilla behaviour
just leave the event alone and it'll handle the health reduction for you
you don't understand what I want to do
it's not about reducing health
it's about custom names
that looks like you're reducing health
I wanted to have both current hp
and max hp
in a custom name
but the current hp part is giving me trouble
ok so do that? ```java
on damage event {
set name to getHealth and getMaxHealth
}
you shouldnt need to be changing the health yourself at all
yeah except get health doesnt work
insted of displaying like 49/50
it just displays 50/50
all the time
why not just calculate the new hp and set it to that
and run the event with high prio
the entitydamageevent?
yes
yes since its cancellable
Cancel the event after the damage 🤔
more effort
i mean scheduler is probably mroe effort
after the damage
just update it 1 tick later
you shouldnt need to recreate vanilla behaviour here
while also potentially breaking compatibility with other plugins
if anything else modifies the event
EventPriority.MONITOR may also be an option
highest > monitor
frankly you shouldnt be modifying an event just to render some UI
especially when you dont need to modify it
true enough
it's in my github
no idea which instance you are calling the method from
lemme check
honestly not sure, i always did name stuff through packets
lemme check the javadocs for it
you should be able to do it through bukkit methods
bukkit goat class implements this
oh good
get the bukkit entity then setCustomName
and customNameVisible
no need to use the nms methods for it
?
i was creating a method called updateName for no reason
nah its good
but
seperating functionality into smaller methods is quite nice
allows for modular usage if needed
sometimes I also tried to use only setname
but when I did this
I didnt add goat.setname to the event
call update from setName
but keep it seperate
in case you need to update the name for whatever reason
i would make it take a string or component though
btw your gunna have issues when you hit a goat that isnt a goatsoldier btw
and set the name to that
will this now display the current name with the current health now
y
oh
you check if the entity is instanceof goat, but then cast the entity as goatsoldier
because instanceof goatsoldier
he fixed it
its old code
ic
let me see im confused again
no issues
really?
you were checking for goa
goat*
then casting into soldier
which is not always true
goat.setCustomName(); is basically not needed
but if I dont use it
then it wont work
cause it already exists
setCustomName is already a method
what
just use updateName
but you cant use getHealth for it
you need to pass the text to it
from its parameters
since health will be full
if you just getHealth
dont you understand
if i use updatename
the custom name never shows up
for some reason
hm
your custom goat is an nms goat
not sure if the one event returns is an nms one
it returns bukkit goat entity
so its probably not passing the "is goatSoldier" check
so what do I do
where are you spawning these goats?
in the same place as the player
when he plays a goat horn
in the code
ok
yeah event.getEntity() doesnt return custom entities
i dont see any spawning goat either
okay
you need to get the nms entity
of the bukkit entity
and compare to it
not sure if its the same reference i think bukkit entity is the same reference but not sure honestly
altho code above would work
if it was the same reference
how exactly do you compare something in java
you mean comparing myself
instanceof does it for you
so thats what instanceof means
okay so I have
public static void saveData() {
File file = new File ("plugins//Masteries//data.json");
file.getParentFile().mkdirs();
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
new Gson().toJson(BreakCobblestoneListener.cobbleBroken, writer);
writer.close();
loadData();
} catch (IOException e) {
throw new RuntimeException(e);
}
}```
but the file doesnt get changed
ive just googled it and i think its ((CraftEntity) event.getEntity()).handle() instanceof GoatSoldier
ah you gotta get the handle
which should pull the NMS version of entity
its a bukkit bs
dont worry about it
not a java thing
(but imho just use the bukkit entity instead of the nms version for names)
k then
so the only thing I got to change is that instanceof part in my event
((CraftEntity) event.getEntity()).handle() instanceof GoatSoldier
use this
and you are fine
you got 3 levels because of bukkit bs
Bukkit/Spigot Entity
CraftBukkit Entity
NMS Entity
you can cast bukkit to craftbukkit, and craftbukkit has the link to the nms entity, which you have to get to beable to tell if its instance of goatsoldier
honestly dont know why they dont just add on top of each other instead of wrapping like this
meh
so you got your entity, which you cast to craftEntity to get the craftbukkit version of entity, which .getHandle() gets the nms entity
you sure it's the right file? that code looks fine, albeit a bit overcomplicated
why they do this idk either aki, its so much bs for some reason i dont know at all
well even if it wasnt my code is written in a way that itd just create the file if it doesnt exist
and does it create the file?
nope
just decorate the original object instead of this wrapping
the whole inventory clone thing is also quite stupid
so many bad choices
It did back when I used a FileWriter saving it as a txt, but now it doesnt for some reason
try something like this instead ```java
public static void saveData() {
Path file = yourPlugin.getDataFolder().resolve("data.json");
try {
Files.write(file, new Gson().toJson(BreakCobblestoneListener.cobbleBroken).getBytes());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
did what you said
thanks, what do I replace path with? a string?
this correct?
thanks, i get the error Non-static method 'getDataFolder()' cannot be referenced from a static context
yeah you need an instance
Entity entity = ((CraftEntity) event.getEntity()).getHandle();
if (entity instanceof GoatSoldier) {
GoatSoldier goat = (GoatSoldier) entity;
}
Entity is the net.minecraft.world.entity
not the bukkit one
k
like that? Path file = new Masteries.getDataFolder().resolve("data.json");
no absolutely not
you can't create a new instance
if you're doing this in the plugin class just use this, otherwise use dependency injection
ohh alright thanks
yeah looks right
now ill actually get the current hp of the mob right?
so like this Path file = this.getDataFolder().resolve("data.json");?
hopefully yes
probably yeah
ofc if you're using this then you cant have the method static
ah yeah true, i now get the error Cannot resolve method 'resolve' in 'File' though
ahh, so like that Path file = this.getDataFolder().toPath().resolve("data.json");?
intellij isnt throwing errors at me so I think im doing something right lol
looks right
okay i have a small problem, since im using this i cant make it static, but that makes it so i cant access it in another class, which is necessary for what im trying to do
does anyone know which theme this is ?
someone else posted it on another discord but they are no longer there
static is not the way to make something accessible from another class, that's what dependency injection is for - you're using an object oriented language
alternatively you could take the plugin in as a method parameter and then make it a static utility method
oh, wait then what does this mean non-static method saveData() cannot be referenced from a static context
context is Masteries.saveData(); being ran from the BreakCobblestoneListener class
eh, i feel like giving access to the main plugin instance statically is quite fine
you want one of it regardless so its effectively a singleton
it means saveData isnt static so you need an object
i tend to still prefer injection unless it's a major inconvenience, as it can be better for testing (eg a fake plugin instance with MockBukkit) but im not gonna argue too much over that
for testing its 100% better and basically everywhere else where its not guaranteed to be only one instance, i just dont see the point in cases like this personally
well if we're talking about testing, using injection would be much much more testable as you could pass in a mocked plugin that returns a specific data folder
i mean bukkit doesn't guarantee there will be a single instance
not that testing IO operations is a good idea
plus you could probably argue passing an entire plugin just to get a Path is anti-DI
just pass the Path lol
yeahh
it still doesnt work
also unrelated, but is there a way to get the player from the ip in velocity? (without looping all players that is)
There could be multiple players under the same IP but you'd probably want to keep your own Multimap, I don't think it has anything for that not even internally
thats what i have atm, just wondering if there is a method for it already
so
public static Masteries obj = new Masteries();
public void saveData() {
Path file = obj.getDataFolder().toPath().resolve("data.json");```
?
Dependency Injection
Dependency Injection is a way of providing objects with the objects they need ("dependencies"). This is usually done with a constructor, but can also be done for individual methods
Read more here: https://en.m.wikipedia.org/wiki/Dependency_injection
Dependency Injection in Java:
https://paste.helpch.at/yijawupoju.java
Dependency Injection in Kotlin:
https://paste.helpch.at/esogakutod.kt
please consult this
or just use a static getter for your plugin if you're feeling lazy
but FWIW you should really have a good understanding of OO principles (such as DI) before doing any serious plugin stuff
thanks
im sorta like half braindead atm cause its quite late and ive been working all day so im gonna go to bed then do that tomorrow so i can actually understand what im reading haha
to be honest most of plugin development happens while im completely braindedad
same but then when i have to debug i try for 6 hours then give up and try again when im not braindead
puke out the trash code while braindead then refactor it afterwards once awake is how it goes usually
did you run updatename()?
because it wont autoupdate the name id you dont
is it normal if sometimes your plugin dont run properly
like you start the server and you do something
(like in my case play a horn)
%votesreceived% NOT WORKING on voteparty pls help
and it doesnt do whats supposed to do
what is voteparty
plugin for votes
im telling you
if i run on updateName
it simply doesnt display the custom name
package me.systemoutprintln.dev.hornspawn.customentity;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.LookAtPlayerGoal;
import net.minecraft.world.entity.ai.goal.MeleeAttackGoal;
import net.minecraft.world.entity.ai.goal.RandomLookAroundGoal;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
import net.minecraft.world.entity.animal.goat.Goat;
import net.minecraft.world.entity.monster.Monster;
import net.minecraft.world.level.Level;
import org.bukkit.ChatColor;
import org.bukkit.Location;
//Goat Soldier made by MouBieCat
public class GoatSoldier extends Goat {
public GoatSoldier(Level level, Location loc) {
super(EntityType.GOAT, level);
this.setPos(loc.getX(), loc.getY(), loc.getZ());
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(50.0f);
this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(10.0f);
this.getAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.2f);
this.setHealth(50.0f);
}
public void updateName() {
this.setCustomName(Component.Serializer.fromJson(
"{\"text\":\"" + "Soldier Goat" + "(" + ((int) getHealth()) + "/" + ((int) getMaxHealth()) + ChatColor.RED + "♥" + ChatColor.WHITE + ")" + "\"}"
));
this.setCustomNameVisible(true);
}
@Override
protected void registerGoals() {
this.goalSelector.addGoal(1, new LookAtPlayerGoal(this, Monster.class, 16.0F));
this.goalSelector.addGoal(2, new RandomLookAroundGoal(this));
this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0, false));
this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Monster.class, true));
}
}
bro wtf is this 💀
yeah that's not what they're after
def not a placeholder
java
yk what nvm
@proud pebble
it does work
but not all the time
only when I hit a mob
I think that
If I just put another custom name without the methods
it will work
ITS WORKING
OMG
what did you change
its working
"its working"
"what did you change"
"i made it work"
probably not the most effective solution but it will work for now
i know its working, im asking what you changed to make it work
lol thats not exactly what they are asking though
that is exactly what they are asking though
it was, guess i replied to the wrong bit lol
so notice how before
their names didnt appear
but they appear when i hit them
so i thought
this was because of entity hit event
because it was only updating after an entity was damaged
so I just added another line of code that was just another custom name
but instead of having getHealth() and getMaxHealth()
i have two strings
each one of them are "50"
just send a screenshot of what you changed
why dont you remove setcustomnamevisable() from updatename
since it only has to be set oncee afaik
i dont think so
Why do you use fromJson btw
tbh i was wondering that too
because textcomponent just evaporated from my ide
I couldnt use it properly
then I tried to re import it
and shazam
gone
like it was never there
so the workaround we found was fromJson
works the same
net.minecraft.network.chat.TextComponent
type that in, it should find it
ive had to do that when looking for pair
bump
kinda hard to tell with only 3 colours lmao
quite a unique one though
if they arent on the server anymore, why dont you try friending them and asking them directly
did so already
but no luck
💩
Brigadier is only available on 1.13+, right?
I believe so yeah
any tutorial and useful lib for sqlite?
its syntax is quite the same as any other sql
if you want serializers for it then probably check out hibernate etc, but its probably overkill
considering hibernate adds about 30MB to your jar it's almost always overkill
you could write a basic serializer for it yourself
its really not that difficult
especially if you just need insert - update - select - delete
is there a way to disable the fire caused by lightning bolts?
like do method .strikelightningbolt
but without any fire
Ah wait
I think that when you summon a lightning with commands it doesnt generate any fire
no, dont call commands from code
you didnt let me finish
World#strikeLightningEffect summons the lightning without doing damage or setting things on fire right?
so I think it might be this way for spigot as well
this is what you want to do
then apply the damage yourself
oh
..
what's the base damage of a lightning
google is your friend
you now I dont think ill disable this
changed my mind
since whoever got struck also caughts on fire
it will be pretty op at first but meh
btw aki
how do I register the time a certain event begun
to limit how long it will last
what type of event?
entitydamageevent, wanted to register the time it happened
you can get the current time in java using System#currentTimeMillis
to limit how long the code i added will last
interesting
but is this really the only way
isnt there an alternative in spigot?
best suited for this stuff
I mean, what's wrong with that one?
time in general is not that simple in genereal
isnt bukkit runnable better for this?
someone mentioned it
no
runnable is for running something x ticks later
or every x ticks
what you want is something to work for a duration
meaning that you can easily achieve it by checking when it "works" to see if duration passed
if yes, disable
for which you want the start time and end time
oh right
1 second = 1000 millis
currentTimeMillis gives the total amount of millis that has passed
since epoch
so you can calculate a duration by just substracting one from another
guess why
yes but why?
i dont know
it goes into negative
and the way the number is stored in memory usually does not support it
(sometimes does)
so it usually wraps around
before I started programming I always wondered why these things were stored in variables
like money in a video game
in most games when you have more than 2 billion and 147 hundred it stops counting how much you have
now I know that its to add and subtract
it just has to do with how numbers are stored in memory
yeah
so
I add 15000 millis (15 seconds)
and I make it so when it reaches that value
it stops running?
all you gotta do is store when you started or when you want it to end
then when an action happens
lets say damage event
you check if you are still in the time
if not, dont do it and clear from memory
its just a basic < > operation
HashMap?
ideally yes
might want to use concurrent hashmap as well if you got multiple threads accessing it
so I just do all that inside my method?
better version
dont know if this is an easy topic or its me whos getting better lol
and when you want to put someone on cooldown
= is better imo
ye probably, wrote it real fast to show
you use a scheduler when you want something to do something at a certain time
so in cases like do this x ticks later or do that every y ticks
(or millis if you use the Timer version)
each tick is technically 1/20 of a second
under ideal circumstances
but this is not guaranteed
so its easier to do with millis
well depends, you can argue that ticks is more fair since when server lags player cant really act
so its more consistent with minecraft time
so it depends on if you want irl time accuracy or in game time accuracy
ok
now changing subject
since you are here
could you explain to me why sometimes my plugin just refuses to work
you are fucking some parts of it up
like I play the horn and absolutely nothing happens
then I play it again and it works
sometimes it works and other times it doesnt
its really random
is it updated on your github?
i think its the server but idk
^
isnt that equal to 40 secs?
in ideal circumstances yes
but if a tick takes longer than 1/20 of a second
aka server is lagging
then no
check tps and see
i was right
800 ticks is equal to 800 ticks
it will wait for that amount to pass regardless of how slow those ticks are
so if each tick is 1 second then 800 seconds it is
there isnt much i can do ig
yep
but the millis approach avoids this issue
since it does not know nor care about the ticks happening
i don't think its worth changing it
no it's not
is there a way to make a mob despawn with a certain particle effect?
like dying/explosion particles
code
spawn particles at their location
k
what method is used to spawn particles
world#spawnParticle
i cant really find the particle name for when a mob is killed
javadocs dont really help
is probably just cloud
what do I do
I can't refer goat outside the for loop because its and object from that loop
if you open a curly bracket after the -> you can add more lines
and press control + c (or p, cant remember) to see the other parameters
u mean like that?
yeah not add a semicolon at the end of remove()
??? what
remove();
the way you put your phrase made me confused
what do I do inside of here
ok I think i figured it out
im just a bit slow
I just needed to put goat
outside the loop
still cant get location tho
goat.getBukkitEntity().getLocation
I think
yeah now IDK
d;world#spawnParticle
void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ)```
Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.
particle - the particle to spawn
location - the location to spawn at
count - the number of particles
offsetX - the maximum random offset on the X axis
offsetY - the maximum random offset on the Y axis
offsetZ - the maximum random offset on the Z axis
use this
looks like
Join the club 😅
line by line im getting there
Whatcha makin exactly? I saw goats something but cant make sense of it with just that bit
i think they are making summonable goats to fight for them
or just goats to kill idk
it's a plugin that uses the goat horns in minecraft to summon effects or attacks
do the goats fight for you?
so i was mostly right?
yeah
Interesting
Hey, i am using bootstrap for my site and i am trying to make a nice and beautiful card row but the cards dont fit very nicely, anyone that could help me with this issue? (basicly i want the cards to be perfectly next to each other even when scaling the screen) Here is a little screenrecording of the issue: https://youtu.be/rp4Qw04OMj0 this is the html(ejs) code: https://paste.helpch.at/fedowoqose.xml
@formal crane put all the cards in the same row/column
Maybe try using a lambda instead of an anonymous class?
They’re pretty neat things, you should look them up
they are in the same row
Hello, i have a question in this plugin : https://www.spigotmc.org/resources/crackshot-guns.48301/ . When we're shooting with their guns there are ammo, but when we i restart the server the same amount of ammo are here where did they store the ammo of the specific gun ? (i dont see any yml file for this)
nbt tags
if there isn't any db or anything related ^
I still need help
naaa lambdas are confusing for me
That's fair 😛. Its pretty much just a shorter way to do it
you are using a lambda in your forEach method btw
so you probably have some idea on the syntax
I didn't really wrote that part
What do a lambda do
could you help me
Do you understand how interfaces work?
yep
watched a tutorial on lambdas and got pretty confused
i usually think of it as a nameless function object made perfect for customizations
what is a function object
java doesnt use functions
is it just another name for something?
what do you mean
an object that acts like a function
like for me lambda is good for intensive storing/using/customizations and its flexible for using/modifying it on a fly
like you have
Function<Integer,Integer,Integer> in an interface or a class where you can port functions to it
you can assign it to be a sum function where two integers will be summed to result
or you can assign it to be a multiplying function where two itnegers will be multiplied for result
you can port/invoke the right methods/functions to it depending on your choice
are methods just another name for functions?
or vice versa
for me it is
methods is a word heavily used in java maybe thats why
it can be useful for creating modules, for convenient manipulations like Stream api(syntactic sugar for manipulating data objects and stuffs), and much more
but its basically just a nameless function that only recognizes parameters and return type
and its best used when you want to use it for a short time
i think ill have to use lambda again for what im doing rn
im not really that much of a lambda user so i cant tell more cases of how it can be used
but thats the best ive got for you
maroon be typing the entire bible tho
Okay so I'm guessing you have a basic understanding of interfaces and how to implement them. Basically there are some interfaces called 'Functional Interfaces', which are pretty much just a regular interface with a single method. Kind of like the BukkitRunnable interface.
interface BukkitRunnable implements Runnable {
void run();
}
To make a runnable, you wanna have a class that implements this interface. So kind of like this
class myCoolRunnable implements BukkitRunnable {
public void run() {
// run some cool thing here.
}
}
That's all good an dandy, but it gets tedious to do this every time you want to run something simple or want to access other things inside your class. That's where 'anonymous classes' are used. You can basically just do a new BukkitRunnable implementation inside wherever. You won't be able to reference it anywhere but usually that isn't necessary. So the syntax evolved to look something like this:
methodWhichNeedsRunnable(new BukkitRunnable {
public void run() {
// run something cool here.
}
}
That's easier than having to make a whole new class to implement your thing in most cases. Now, lambdas came around and made this even shorter. So now you end up writing something like this:
methodWhichNeedsRunnable( () -> {
// run something cool here.
}
The empty () are basically the parentheses in the run**()** method. That means there are no parameters or anything you have to pass.
it would weight roughly a trillion electrons and thats 20 usd in total what payment method do you prefer? paypal?
OMG
the effort
praise maroon
tithe
Yes
And a lambda is a method without a name basically, and can also be in parameters
perfect
cool bro
have fun
ill try to
concerning what data type would be used to store the lambda functions you are messing with please refer to this graph
its lambda bible for me
the stuffs on the left is parameter
the stuffs on the top is return value
Yeah there's a ton of stuff in more modern java that might seem daunting, but you get used to it with practice.
Runnable is how the bukkitrunnable in maroon's example can be converted to ()->{} syntax
because bukkitrunnable implements runnable in the green box
and runnable can be simplified to ()->{} thing without return value
oh rip I forgot to put that in the example
maroon bible stays strong
amen 🙏
Runnable isn't anything "special" when Java sees it btw
You can make your own runnable for example which supports lambda
what is the best way to make a function with a lot of parameters smaller?
builders?
it just builds an object, but builder pattern doesnt really fit my use case
it feels kinda backwards in kotlin honestly
since i can just set the fields directly
Can you show an example of the function you have?
for example this is the class being built
it gets serialized into sql hence the size being this big
dunno it just feels not great, but not sure how i would go around making this smaller
thought about combining the player stuff into a separate object
that holds uuid - name - ip
Oh dear
Hmm yeah if that's serializable then idk what you can do to make it smaller
Hey there, according to https://wiki.helpch.at/piggys-barn/java/hot-swapping, DCEVM is only available for java 8 & 11, does it mean I cannot run a server/compile a MC plugin for newer versions like 1.19?
I'm trying to automate the whole compile to server thing for my plugin which is taking a lot of time from me, and someone recommended this way. What I am trying to achieve is to just push the plugin to my GitHub and make my remote server build and put it in the server, if anyone knows a better method, feel free to share your experience
for your remote (production?) server, you shouldn't use hotswap or similar to update plugins. Those features are mainly meant for development
No it's just a development server, my pc can't handle mc server and intellj and mc client at the same time, that's why
How you create NBT Tags with spigot 1.17.1 for ItemStacks?
What's the easiest way to override the tab completion of a bukkit command (In my case /pl)?
I want to insert new args for the command
declaration: package: org.bukkit.event.server, class: TabCompleteEvent
Ok. How could I check what command triggered the event? getBuffer?
yeah getBuffer and get the string until the first whitespace
what the fuck is this spacing lmao
I think there's a symbol normally as it's an external link?
yeah that's what it looks like for paper
spigot moment
Somewhat ugly, but should do the trick I hope...
https://paste.helpch.at/ureyenerip.java
why dont you register a new command?
there's gotta be a way
PlayerCommandPreprocessEvent
Can't or don't want to?
getMessage()
can't.
I recall trying it but Spigot just ignored it
You can but it's kinda "hacky". I'm pretty sure I do it with aliases. I'll check when I get on PC later.
Yo, stupid question, how do I send a title to a player on a runnable but a title that doesn't glitch and all?
fadeIn/fadeOut at 0, and stay on waht?
Too braindead atm
stay is for how long the title will be shown on the player's screen
wassup
?
There is no time to wait! Ask your question @lyric gyro!
basically
yesterday you told me what i need to do to do that thing i wanted to do
but idk how ill do it
i remember giving you example code
this
whats the issue
something like system.current time
- 15000
yep
what
also note that every time you run that method, timeMap will be empty since you're creating it each time
but i cant use variable time
outside the hashmap
thats why its there
outside the map
the method**
put it as a field
what does that mean
make it a class variable
When using the addItem(ItemStack... items) Method, it will return a Hashmap<Integer, ItemStack> with the key the index of the paramter, what do they mean with the key?
d;spigot Inventory#additem
@NotNull
HashMap<Integer,ItemStack> addItem(@NotNull ItemStack... items)
throws IllegalArgumentException```
Stores the given ItemStacks in the inventory. This will try to fill existing stacks and empty slots as well as it can.
The returned HashMap contains what it couldn't store, where the key is the index of the parameter, and the value is the ItemStack at that index of the varargs parameter. If all items are stored, it will return an empty HashMap.
If you pass in ItemStacks which exceed the maximum stack size for the Material, first they will be added to partial stacks where Material.getMaxStackSize() is not exceeded, up to Material.getMaxStackSize(). When there are no partial stacks left stacks will be split on Inventory.getMaxStackSize() allowing you to exceed the maximum stack size for that material.
It is known that in some implementations this method will also set the inputted argument amount to the number of that item not placed in slots.
A HashMap containing items that didn't fit.
items - The ItemStacks to add
IllegalArgumentException - if items or any element in it is null
index of the parameter array
you mean like that?
okay so
think about it like this:
when you run the method, you create a new HashMap<>()
a new HashMap
every time you run the method
if it's outside of the method, you create it only once
however, for time, you want to create that every time the method is ran, right?
with your setup
chances are you want that hashmap static as well
each instance is one cooldown right?
static abuse
wdym
🚨
no?
I dont get it
you want the hashmap to be shared between instances
?di
Dependency Injection
Dependency Injection is a way of providing objects with the objects they need ("dependencies"). This is usually done with a constructor, but can also be done for individual methods
Read more here: https://en.m.wikipedia.org/wiki/Dependency_injection
Dependency Injection in Java:
https://paste.helpch.at/yijawupoju.java
Dependency Injection in Kotlin:
https://paste.helpch.at/esogakutod.kt
if I put the hashmap outside the method, i cant use variable time
no
thats known as static abuse
making variables static when you can use DI instead
it can be used for that, but it's also known as static abuse
can't really show google example rn since im in the middle of a game
and am typing since I'm dead 💀
nah, not really
it would be abuse if he was using it from another class
its internal to that class
its just shared between its instances
Oh wait thats true
its a perfect case of static
🍿
although its breaking single responsibility principle if you care about it
but its really not a big deal
^
woah ur pfp
yes
^^
what
^
hah, its from 2020
^
so
you mother fuckers
uh
what
what do i do
let me explain again
meh
Im pretty sure you print
jk
Let me check your previous message
print using a static method so dkim loses it
i wanted to do like a thing that runs code for 15 then stops
static mutable 😦
static immutable 🙂
using system.currenttime
What?
why not use bukkitrunnable?
he wants a cooldown
what
just is really bad with explaining it
immutable
i do?
static im
same implementation
i just wanted to do
you want to enable something for x seconds
play the horn gain the ability for 15 then go back to normal
-poster?
yeah
no
here is how you do it
it doesnt get simpler than that honestly

how am I supposed to know what the fuck val means

you dont need to know
its just a variable
im gonna beat you up

turing machines were a mistake
Yes!
idk what this code is doing
its just showing how to check if an amount of time has passed or not
ok jokes aside maybe showing kotlin to someone who (no offence) barely knows java is not a great idea
was the most convenient screenshot
gimme a sec
val (whatever the fuck that means)
is a variable equal to current time
the second line i dont understand
i dont understand this language
good
hope it stays that way
i have a few options of what language i should learn next
h
and kotlin isnt one of them
good good
maybe C, C++, Python or Lua
idk
here full implementation
it doesnt matter much, but clean up after yourself on player quit as well
not really necessary if ur using UUID
oh god
meh, just good practice overall
what is an uuid
back to kotlin
sorry to hear that
so lets see
(when I say 'so lets see' it means I want you to help me understand this)
theres a lot of keywords that I dont understand
like containskey
what ever
you should really look into how the Map type works
containsKey pretty much does what it says in the name... it checks if the map contains the given key
^ extremely useful and used often
i think ive seen this in a tutorial
how do I use this now
i mean its there, not sure how to answer
how do I
make it do what I want it to do
do I write it here
you run addBuff when you want to activate
ok
ill do that tomorrow
for some reason saturdays are cursed for me
i cant code properly on saturdays
what?
Searched in the following locations:
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.pom
If the artifact you are trying to retrieve can be found in the repository but without metadata in 'Maven POM' format, you need to adjust the 'metadataSources { ... }' of the repository declaration.
Required by:
project : > org.spigotmc:spigot-api:1.19.2-R0.1-SNAPSHOT:20220904.115031-14```
Tag me when you found something
I so far only know the PlayerCommandPreProcess event tactic
i fixed this, added mavenCentral() to repos
making action bars (the one above the hotbar) stay is achieved using a repeating task right or is there a better way?
yes
Is deluxe menu open source?
just get rid of the column divs
I need help
There is no time to wait! Ask your question @whole yacht!
I want to make a discord bot but I don't know how to code and I have 0 money so can anyone help me
how can i use the <red> tags and so? in deluxe menus
what are you want to use it for?
gotta learn how to code then, or use one of the templates
but you wont be able to edit
there's discord bot maker apps that u can use
pretty sure there's one on steam
?colors
App what app
Name
Ok I got it
Hi i have some problems to control if an item has custom model data... It gave me problems when the cmodeldata is null (i use getCustomModelData() != null)
private final HashMap<UUID, Long> activeUntil = new HashMap<>();
public boolean isActive(UUID uuid) {
return activeUntil.containsKey(uuid) && System.currentTimeMillis() <= activeUntil.get(uuid);
}
public void addBuff(UUID uuid, Long duration) {
activeUntil.put(uuid, System.currentTimeMillis() + duration);
}
public void onPlayerQuit(UUID uuid){
activeUntil.remove(uuid);
}
why is UUID needed here
because uuids are unique
what
you need something to identifier the player, and their uuid is unique
idk how ill use this
how to implement it in my code
To get someone's UUID, you use Player#getUniqueId
UUID = Universally Unique Identifiers
lol
SHH I knew I was wrong while I sent it lol
??
im not talking about this
im saying that idk how ill use that code
to do what i want to do
you dont want to use the Player object cus it can change and theres alot of data in the player object thats unneeded, the uuid is unique to every player and doesnt change at all.
what dont you understand with using it?
i wanted to use it to run a code for 15 seconds
but idk if i put it where i want the code to be run or in my listener
you would use a bukkit runnable task to run the code
god this is complicated
💀 💀 💀
i assumed that the code above is related to figuring out the cooldown
?
it is ig
i just dont dont know what im supposed to do
what do you want to do?
when you sound a horn, it would give you the ability to struck lightnings on every entity you hit for 15 seconds
So like strike them when you hit them?
yes
That’s pretty simple. You need 3 event handlers and a map
why 3
Wait no 2
You’d listen to the goat horn event (probably just player interact ), add the player to a map that consists of the UUID and the current time in milliseconds
Then when they hit an entity, check if the player is in the map, if they are then get the time that you saved and compare it to the current system time

