#help-development
1 messages · Page 1811 of 1
that will give you level
then you only have to work with 1 number rather than level and exp
Anyone have a large open source project where they used the cloud command framework? I'm looking for some starting points on how to use it, I've looked at their documentation but I'd like a real-world example.
It's not a big one but this should explain some things 🙂
Thanks!
I've also made a pr to their repo that adds bungee and velocity support if you are looking to support multiple platforms
I bought a plugin but it does not appear, what do I do?
Mind elaborate a bit more ?
¿?
I bought a plugin about 20 minutes ago and it still does not appear in my account
Oh okay can't help with that :p
@vagrant stratus
so i just tried to update from spigot 1.17 to 1.18
i use eclipse
and after running buildtools and it gave spigot-1.18.jar and changed the referenced libaries to 1.18 instead of 1.17 eclipse is insisting that any import starting with org.bukkit doesnt exist
any ideas what im doing wrong?
Use maven itll make your life much easier
Can anyone that is familiar with using lists tell me if this is the proper use of iterators? https://pastebin.com/5Z55PygT
If there are formatting problems they can be ignored I’m coding at work in notepad.exe lol will move to an ide when I get home if this is proper
?paste
you need to declare the iterator type iirc
why not just use a for loop?
and you also have to use iterator.next()
Block.getLocation() wont work
So blocklist returns a List of Block objects right so iterator<Block> ?
yeah
Iterator<Block> it = blocklist.iterator();
while( it.hasNext()){
Block b = it.next();
//do stuff
}```
Ah ok
but thats just a harder way of doign
for(Block block : blocklist){
}```
does exactly the same thing
So the first way when I read it makes sense but I’ve never used for() before so for now at least ill@stick to doing it the hard way :p
Thank you for your help
no worries
never used for before? wtf r u? functional?..
Anyone know the event name for Enderman block theft? Lmao
Idk what to call it and google doesn’t know what im talking about
declaration: package: org.bukkit.event.entity, class: EntityChangeBlockEvent
Hmmm sweet thanks 🙂
Hi, can I get some help with this? I transfered computer and brought all my plugins to this pc but I'm getting this error and I have tried a few things but still nothing 😦
as if maven didn't exist
but it does
I just re installed everyhing including maven
Yes
There
I even tried starting a new project with spigot's plugin. Auto generated pom.xml and same issue
Yeah
I tried removing all dependencies and same issues
I think its related to maven but don't get what it is
What if you relocate build after getting repo/dependency
I have tried making new projects
empty ones
and the generated pom.xml contains the same issue
Like this <build> after your repo depen stuff.
Other then that it all looks good to me
Yeah
Yes
and dependencies at the end
do you think it has to do with a network issue or something?
Like the firewall perhaps?
is it possible to loop something x amount of times with a delay? like a bukkit runnable but loop it?
yeah it sounds like that to me
theres a repeating task runnable with a delay let me find the name
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
@Override
public void run() {
Bukkit.broadcastMessage("This message is shown immediately and then repeated every second");
}
}, 0L, 20L); //0 Tick initial delay, 20 Tick (1 Second) between repeats```
runTaskTimer
thanks
is it possible to only look it for example 3 times then stop it? i know with a runnable you can use task.cancel() but i tried to store it in a bukkitrunnable and it corrected to int?
wdym corrected to an int?
Some return an int and some a task
nvm i just realised i did task instead
Man I have no idea how to fix this
XD
fix what exactly? I just joined
btw I just had an awesome idea for a new paid plugin
ugh why are you using spigot 1.14 api
It was for an old plugin
That's not the point xd, the point is I have no idea why it is not loading maven at all
like if it was a network issue or something because I even created a 1.18 new plugin and the generated pom.xml has the same issue.
yeah gimme a minute pls
still kinda confused with this say i wanted to use
@Override
public void run() {
Bukkit.broadcastMessage("This message is shown immediately and then repeated every second");
}
}, 0L, 20L); //0 Tick initial delay, 20 Tick (1 Second) between repeats```
to loop something every 20 ticks but i only wanna loop it 3 times then stop it, i cant cancel it inside of the schedular since it says it wouldnt be initialized so?
your pom seems to be fine, it does work for me
this will refer to the runnable iirc
run mvn clean -U pls
wdym
nvm
wait nvm
int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(..);
Bukkit.getScheduler().cancelTask(taskID);
``` try that
sorry I misunderstood xd
wrong directory @spare marsh
run it where your pom is^^
after that try mvn package -U
i got BukkitRunnable task = Bukkit.getScheduler().scheduleSyncRepeatingTask(PLVPlugin.getInstance(), new Runnable() { but i cant acess task inside the runnable so i can cancel it unless theres another way?
show the full code pls
erm wait
that's totally wrong
you can use the keyword this
the scheduler will only return an int, which is basically sth like the "process" ID
wdym how
no you're not understanding the problem @drowsy helm
@dry forum . You want to assign an int to a variable that was declared to be a instanceof BukkitRunnable
that's like saying SomeObjectWhichIsNotANumber thing = 3;
do you understand what I mean?
If yes I explain what you should do instead
kinda but why is that necessary when i can just use task.cancel()
yeah
wtf did you enter? looks like you entered mvn mvn
also this didnt work
You are messing two things up here
Bruh I am a complete noob with this maven stuff so a little help plz xd
on the right side, you have a section called maven
Yeah i see it
int[] task = {0};
task[0] = Bukkit.getScheduler().scheduleSyncRepeatingTask(PLVPlugin.getInstance(), () -> {
...
if (someCondition) {
Bukkit.getScheduler().cancelTask(task[0]);
}
}, 1, 1);```
Don't do new Runnable() {, use a lambda instead
what the fuck are you doing there
sorry, not meaning to be rude but
It's one way to do it
do you know basic java?
Excuse me
that makes no sense at all
Why not
you declare an array with a length of one, which a value of "0" at index 0. Then you assign the task ID of the Runnable you are starting into that array
Yes
I'm wondering, why?
bro what does this mean?
Could not transfer artifact org.apache.maven.plugins:maven-resources-plugin:pom:2.6 from/to central (https://repo.maven.apache.org/maven2): transfer failed for https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom```
Yeah ok so you begin by insulting me
I did not
When I've done that because it's necessary
i mean, you can take a method thst takes consumer and cancel the task inside runnable
I just asked whether you know what you are actually doing there
Go ahead and try doing it without an array
All values referenced by a lambda must be effectively final
You can't use a plain int
The easiest way around this is using a size 1 int array instead
You can also use an AtomicInteger
scheduleSyncRepeatingTask only takes a runnable
I know that. But you can easily cancel your task by simply running cancel() inside it
You can use runTaskTimer and pass a Consumer<BukkitTask>
O never mind
Task.syncRepeating(t -> {
...
if (someCondition) {
t.cancel();
}
}, 1, 1);```
this.cancel works
I am sorry
if you use a BukkitRunnable
I did NOT
You asked "do you even know basic java"
pls shutup
yes I did ask that but that's not an insult so don't throw a tandrum now pls
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new BukkitRunnable() {
@Override
public void run() {
this.cancel();
}
}, 0L, 20L);``` works well
I'm not
but scheduleSyncRepeatingTask is deprecated i think runTaskTimer is the newer equiv
Well then you need to use the long declaration for run
Much easier to use a lambda
You can cancel it fine with a lambda too
If you use runTaskTimer
Honestly I have never used runTaskTimer so I'm just used to doing it with an int array
in fact your code runs fine, I just tested it @waxen plinth
so what exactly was your question again lol
I went from doing it with runSyncRepeatingTask to using my wrapper so I never really looked into runTaskTimer
I didn't have a question I was answering that guy's question
He was using runSyncDelayedTask and asking how to cancel the task from within itself
So I showed the simplest way to do that
I'm a bit tired, excuse me pls
If you use an int variable instead of an array it won't work
true
I don't
mfnalex I did what you said
this is for maven clean install -U
Could not find artifact org.yaml:snakeyaml:pom:1.26 in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)```
and for package -U
anyway I'd suggest to use a BukitRunnable instead, it's way easier @waxen plinth
new BukkitRunnable() {
@Override
public void run() {
if(true) cancel();
}
}.runTaskTimer(whatEver);
}
No I really don't like that syntax
Cause then you always need the @Override public void run() {
add snakeyaml to your pom, it's the easiest way
I find the lambda much cleaner
package one was
Could not find artifact me.carleslc.Simple-YAML:Simple-Yaml:jar:1.7.2 in spigotmc-repo (https://hub.spigotmc.org/nexus/content/repositories/snapshots/)
it's not about lambdas, it's about having to store final things about the task id vs. using an anonymous class
the anon class can cancel itself
no need to store any "self-identificating" task IDs
Well
of course both things will work
Why does UnicodeFont not exist in my project?
neither is better than the other
I can't extend it
Bukkit.getScheduler().runTaskTimer(plugin, t -> {
...
t.cancel();
}, 1, 1);```
Cleaner
sure, that also works. but that's not what you posted above 😛
There we go
Yeah I wasn't thinking of runTaskTimer
Doing it with syncRepeatingTask, the int array is the easiest way
no
in fact there's like... 10 ways to get a runnable/task working
but the one with storing the task id inside an array / atomic integer is imho the worst one
in x,y,z for loops too imho
or int i = 0; i < ...
Yeah I try to abstract those away as much as I can
Hmm
Maybe I should make a helper for that
anyway sorry I really didnt mean to be rude @waxen plinth let's just move on 🙂
Or you could just not use that version
NDimensionalIterator.forRange(0, 10, 0, 10, 0, 10); //Returns a Stream<int[]>```
That would be cool
1 letter variables = less data to process = faster program 😉
You could do stuff like this
haha
Block block;
NDimensionalIterator.range(0, 10, 0, 10, 0, 10).forEach(a -> {
Block b = block.getRelative(a[0], a[1], a[2]);
b.setType(Material.STONE);
});```
Wouldn't that be so clean?
wait how would you get an array from that
minecraft@niere:~$ free -h
total used free shared buff/cache available
Mem: 62Gi 25Gi 23Gi 0.0Ki 13Gi 36Gi
Swap: 31Gi 0B 31Gi
minecraft@niere:~$
If you need to save 32 bytes... go ahead. I'd rather save myself 5 minutes from debugging because all my variables are 1 char strings
look at the byte code see what it does to your variable name
where do you split t
What do you mean
It would take an int... for the range function
Every int pair represents a dimension and the range being iterated on
So, it's iterating on x from 0 to 10, y from 0 to 10, and z from 0 to 10
oh pair
That would be a 3d for loop and it would pass an int array with 3 elements for each pass on the lambda
exactly. the variable name is only stored once anyway
just use extremely verbose variable names and then use a proper obfuscator lol
Or just don’t use an obfuscator
The dependency issues are gone only maven issue now
int numberThatCameToMeInADreamOnTheNightOfChristmasEve2021 = 4;
sheesh you guys cant take a joke lol
when people argue that renaming "number" to "i" saves bytes, then so does an obfuscator with proper settings
EWG moment
it's just not worth it in any way for that case
I use those names way too often lol
🌚
hashmap enthusiast
Yes hashmaps are the best data structure
agreed
fair
Prefix trees are probably second on my list
They're not useful in the majority of cases but they are super cool
I like overly verbose method/variable names. Makes debugging easier
And in the cases where they are useful... woo boy do they save a lot of time
That's not that verbose, seems pretty reasonable
yeah I'm glad it was just a bug in MMOItems and they weren't actually calling a second PlayerDeathEvent on purpose
that's why that method is unused, thank god
lol what
One time there was a bug with a plugin
Don't remember what it was exactly
But I had to debug it by calling a fake EntityDamageByEntityEvent and erroring when it was cancelled so I could see the stack trace and determine which plugin was cancelling it
MMOItems / MythicLibs used to call a playerdeathevent one tick / in the same after the real playerdeathevent occured. it got fixed meanwhile though
"which bastard moron plugin is messing with this event???"
How did they manage to do that accidentally
and that was of course not good for my death chest plugin
they set the players maxHealth to 0 during the "original" playerdeathevent
no idea why they did that
but they fixed that within 1 or 2 days after I reported it
sooooo
Fair enough, I guess
Lmao what project is this out of cause it’s actually hilarious
yeah bad mistakes can happen for everyone
Oh shit lol
I was only looking at the variable names not the method name
The method name is insanely long
lool
that was my dirty fix in my AngelChest plugin to fix a stupid MMOItems bug that existed for about 2-3 days
there simply was no other solution than to check the stacktrace
Actually hilarious
yeah thank god they fixed it quickly lol
Oh I remember!!!
Holy shit I remember
Ok so there's this fucking awful anticheat called AngelX
We had this bug where people would randomly get teleported to another world and dropped out of the sky, die and lose all their items
wtf lmao
Yeah
better install AngelChest too so they don't lose their items lol
We eventually figured out that they were being teleported to the same coordinates in another world
AngelChest, AngelX, ...
@waxen plinth I fail to see the problem
Exactly
It would do it to innocent players all the time
Sounds like a feature not a bug
So I had to add a listener for when players were being teleported to another world at the same coordinates and print the stack trace so I could see which plugin was responsible
“Minecraft but I randomly fall from the sky”
Lmao
It was AngelX
oh btw there was this debugging plugin but it's dead now I fear
And I was very annoyed because we had paid for that anticheat and it was really damn bad
I can already hear people screaming GEORGE in my head
-> this was a masterpiece when it came out https://www.spigotmc.org/resources/eventdebugger.82055/
I went in their support discord to report this bug and they wouldn't hear anything about it unless I brought the server owner in because he's the one who bought the plugin
Wouldn't let me tell them about a critical bug unless I could prove I had given them money
lmao
Truly high quality developers
very professional indeed
I mean I also wouldn't give support to anyone who claims to have bought something then fails to verify
Even if they were reporting a critical bug?
but when it's about serious bug fixes, then one should listen to the bug report first, and THEN ask them to verify their purchase
Yeah lol
Yeah I mean the but still exists for those that actually did buy it though
I never claimed I had bought the product, I told them point blank that I was a developer on a server that used their anticheat
btw does someone want to see really really really ugly code?
Sure
Is it skript
Do you want to see some of my ugly code
is it mine
modern anticheat devs simply do not want to hear that their code is broken
I produced this today to fix a bug in another plugin that was related to my CHestSort plugin (really not my fault, but wanted to fix it anyway), but I didn't have time to properly refactor ChestSort's API I had to vomit this into another plugin's source and it was actually merged for now lol -> https://github.com/christopherwalkerml/ShulkerPacks/pull/15/commits/3fb2bd8a67d8ebb8b840482722c083bbedd43136
Class<? extends Event> chestSortEventClass = (Class<? extends Event>) Class.forName("de.jeff_media.chestsort.api.ChestSortEvent");
ChestSortListener chestSortListener = new ChestSortListener();
getServer().getPluginManager().registerEvent(chestSortEventClass, chestSortListener, EventPriority.HIGHEST, chestSortListener.getExecutor(), this);```
Jesus christ
Why would you do this
Instead of just adding an @EventHandler method
because in 1.18 that didn't work anymore for events that aren't in the classpath yet
Wat
and I didn't have time to update CHestSorts API
What do you mean it wouldn't work for events that aren't in the classpath
you can't register a listener to that event in 1.18 anymore when ChestSort isn't installed
even when you shade that API into your own plugin
Weird
the class would have been shaded into all other plugins
I don't know why that would have worked
I would have just made a separate class for the event listener that is only instantiated if the chest API plugin is loaded
but in 1.18, the classloader "detects" that the actual event isn't the one coming from chestsort
seems like they introcuded some kind of "namespaces" for classes that were shaded, idk how to say it properly
@tender shard chris walker is going to be so disappointed
nah we talked about it
it's my fault for not having the API adjusted for the new classloader changes yet
ironically
smmh
but I didnt want him to get a hundred bug reports so I fixed it on his side quite dirty for now
Chris Walker is the name of an enemy from Outlast
and will adjust the API for ChestSort in a few days
but its really strange
in 1.17 and earlier, people could just shade the ChestSortEvent and listen to it, without problems
in 1.1.8 it throws a weird error
1.18*
NoClassDefFound?
cursed MC version
I dont recall it right now
the problem wasn't NoClassFoundError, that makes no sense anyway since ChestSortAPI used to just have all plugins that use it shade that event themselves
so whether Chestsort is installed or not - the class is available for all plugins that listen to it
but somehow it stopped working in 1.18
I dont remember details right now
Pester MD about it :p
no it's my fault anyway, I know that
every plugin should check whether that event class exists before registering a listener for it
it's just... it worked fine in 1.17 and earlier 😄
I'll just have to remove that event from the API and make people check for the class existing before registering listeners for it
but because I didnt have time for that today, I made that PR which does work, it's just totally ugly
Hi, so I fixed the maven issue but now it won't recognize one of my dependency 😦
What dependency
dependency>
<groupId>me.carleslc.Simple-YAML</groupId>
<artifactId>Simple-Yaml</artifactId>
<version>1.7.2</version>
</dependency>```
It was working perfectly fine on my other computer but just transferred to this one and this happens
At first it didn't recognize maven or any dependenc
dependency
now it recognizes maven
them the dependencies
but on build time it says this
And I have no idea if it is a network issue or something else
Do individual chunks have a chunk id of any sort?
Or do you have to use a set of coordinates
Damn this channel died
Chunk coordinates + world is the only unique identifier
Hmm alright bummer
Every block inside a given chunk shares the exact same chunk coordinate tho right? Or not exactly
Yes
Ok cool I think using chunk coordinate would work the same then
Is that a piece of information that’s stored inside of a Block object already or do you have to do some stuff to figure out what that chunk coordinate is
Ah yeah you can do that too
Like getChunk().getX() and getZ() apparently will work
Heyoo, I'd like some advice or any suggestions/feedback about this block of code i've created.
Pretty much made an item that actively changes its description in the GUI and that seems to work as expected, however I'm a little concerned as to how I've used the schedulers/async threads as I think I can do a better job handling it.
I would use a repeating async task instead of a while loop and sleeping
And have it run every 10 ticks, which should be the same as 500ms
And then in the close event you can cancel() the task
How would you access the close method in a lambda expression?
Or well, access the task from the close event?
Oh wait my bad, I'll try it out
does anyone know whether's its possible to keep a referene to an itemstack while another plugin removes it and then, without chaning it, adds it back to an inventory?
because IIRC spigot calls .clone on the itemstack everytime you do inventory stuff
so e.g. when I do something like this:
ItemStack item = inv.get(0); // get item from first lot. no idea whether the method is actually called "get(int)", you know what I mean
inv.set(0,null);
inv.set(0,item);
//////////// -> but now
inv.get(0) will be != to item
you know what I mean?
is there any way to see whether inv.get(0) is still the SAME item as item?
equals does not help, those could equal without being the same itemsatck
I fear that itll be impossible because spigot always clones itemstacks for such stuff
pls ping me when someone replies 🙂
it uses craftMirror so you can modify item directly, without updating it in inventory
any way to listen to a certain event manually?
Hello, I would like to know if it is possible to create a plugins with an extension of another plugn? If yes, how?
Hi, has Spigot support for LootTables? Let's say I don't want to have an item to be generated in chests.
How would I do that?
You’re going to have to be more specific about what you’re trying to do that question is a little vague
Yes, search the docs for loot
Do you mean create a plug-in to be an extension of an existing plugin?
why my command wont work for no reason
no output
Seems to be the LootGenerateEvent then. Alright, thx.
I’m sure there’s a reason….
Code?
and its not my first time coding a plugin
i have this before any return
and i register it
it is in plugin.yml
oh wait i have a return in onEnable
wait
Hover over setExecutor
bruh nvm
Your mistake is there
example as if Worldedit had to be mandatory WorldGuard to use worldedit
Also don’t use sysout use Bukkit.getLogger
That is just a null check
Technically yes, realistically, at least for that example, no
i want to register a listener by providing the event class (or its name). is that possible?
I is fine it was just an example but I would like as an addon of another plugins
Yes, look at the other registerEvent methods
how to stop players from placing redstone
on BlockPlaceEvent
i guess redstone place wont be called
event.setCancelled(true)
how to check if it is redstone
i can check the material
but redstone
is not a block
it's an item
and redstone placement wont call BlockPlaceEvent
you can check the material in the player's hand
it will
redstone placement should call blockplaceevent
redstone is a block
interesting
He would not have a document for what I want to do?
well, blockplaceevent should still be called
Is it redstone_wire
ah yes
PlayerInteractEvent, if player.getInventory().getItemInMainHand().getType() == Material.REDSTONE and action is block do event.setCancelled(true)
But BlockPlaceEvent should be triggered on redstone place
It means that player could walk throught i guess
oh that's great!
however, using the class instance also means i don't have direct access to the event class (like reflection). how do i implement the Listener then?
@EventHandler
what would be the method arguments then?
as what i said above, i don't have direct access to the event class.
What do you mean you don’t have access to the event class?
Can you clarify your use case
in other words, idk which event it is until it happens.
then check all that could apply
how? can i use Event?
afaik Event won't work in a listener.
and usually if you have a clear enough vision of what your plugin should do you know which event will be called
if you want to elaborate on what you want to do I could help out but its hard without information
you can check for every events
😂
like every single one of them
just do system.out.println lol
i know which to call, i just don't have access to it.
imagine u have to use Class.forName to get the event class.
No, why would you?
@quaint mantle god I thought we got rid of this guy
🆗
like a soft dependency.
nobody here can currently imagine what you mean (I believe). if you show some code we could understand
Or tell us what exactly you’re trying to do
Above you said you wanted to stop red stone from being placed, if that’s what you want to do then BlockPlaceEvent is the event you want to listen for
usually you can make another class to get the event in if its impossible in your current class (which usually doesnt happen since you can just implement Listener aswell even if you implement something else first)
i've got a string of class name from somewhere else and its content is like "com.blabla.SomeCertainEvent". what i need to do is listening to it and maybe cancel it.
PluginManager.registerEvent
basically a switch(eventString){
case CreatureSpawnEvent: PluginManager.registerEvent
why my plugin is acting strange
when it uses symbols like »
it turns in to A with something above it
but not other plugins
Umm just Class.forName
i have to expain that again: i don't have the event class in dependencies, so this won't work.
this class only exists at runtime.
utf 8 issue?
maybe ?
why so
im not sure how Class.forName works tbh...
Class.forName and registerEvent is a way to go
wtf. only exists runtime
it literally gets class by name
bet you otherwise
do you have any idea of what events could possibly be in there or are you trying to make a plugin where players can register their own events
prob
also @junior briar you should probably listen to this more than me.
Im lost tbh
why do you need to get that event
without code my guess would be that theyre trying to let people register events from scratch
cancel it maybe?
cancelling events by name wouldnt be a good idea. you could be cancelling the PlayerMoveEvent
or something else you wouldnt want cancelled in every situation
get string, convert string into event class, cancel event of that class
but why
from what im getting
in what case you need this
that's just an example. the purpose to listen to an event might be various.
what important is to realize it.
So you are wanting to see every single event and then dependent on what that event is do something or don’t do something with it?
ive read about a plugin that was discontinued in which people ingame could code their own plugins without touching an IDE or something like that. maybe something along those lines?
well, PluginManager.registerEvent
not every single event. depends on the class name.
but every single event is possible
we cant help you without knowing your intentions or code
Yeah you need to either listen to everything or know what you want to listen to there is no in between
it's ok if i have to. but is there a way to listen them all?
If you tell us what exactly you are trying to do and walk us through a better example of what you want we may be able to help more
Like you want to listen (for what) and (do what)
something like this?
Depending (on what)
you can listen to Event appearently
just gonna be heavy as hell since its gonna do it for literally anything, including PlayerMoveEvent, etc
I wont test it and Im out of ideas if that is correct
Just use EventExecutor
Does someone know any free online maven repository? I want to add a maven repo for my libs, idc if it's public/private.
then it will be accessible, so long as it has a pom
how can i access it?
something like xml <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories> <dependencies> <dependency> <groupId>com.github.ElgarL</groupId> <artifactId>Regen</artifactId> <version>0.0.1</version> </dependency>
wow, i didn't know you can do that with github
so i got this from jitpack.io site, and it says "Could not found artifact ..."
needs a tag
publish a release?
you can, or you can find the tag jitpack generates when it builds it
if you publish you use teh version number you published
if you use a jitpack tag its a random string
can i make it if i update the libs, i didn't need to change the tag?
let's say the version would be latest at all time
publish a release on Github and you can use teh version number as the tag
you might be able to use latest, I've nto tried
testing
nope, it doesn;t like latest
you need to specify the branch for jitpack
Woah
also “latest” should now work
jitpack only builds it when you request it
meaning initial requests will fail
so what should i do, to get the dependency
publish a release with the jar on github?
yeah, it's still cannot resolve
latest as a version fails for me
you may need to invalidate caches or something
okay, one sec
I did, still fails for me
different dependency, but one I know works with a version
nope, I cleared and updated
I'd use own repository if you have a server
it doesn;t like latest
check out reposilite
I'm fine using version numbers, but it would be nice to use latest
is there no event.getPlayer() in the inventoryclickevent?
getWhoClicked
returns a humanentity
works for me (gradle)
why not just a player
did you login to jitpack and fetch latest?
yep, but the first lookup on their site is
this is when it was built
i would just use master-SNAPSHOT anyway rather than github releases signalling it but latest would've worked
i tried to use master-SNAPSHOT, but the version on the pom.xml has a red text
guys why when i use Player#getInventory#setItem in PlayerInteractEvent, the item slot gets cleared
code?
if you are setting the slot that was clicked you need to also cancel the event
once again works fine
master-SNAPSHOT works fine for me
just not latest for some reason
because maven caches failures for like a day
or an hour
no idea but you can clear it if you google it
is it this one?
that’s intellij
intellij good
that’s your local repository
would you safe coins and language in something like playerdata tatabase or safe it in two (coins, language)
no error on maven reload
Why are you checking items with item name though
cause pdc is not in 1.8
i dont know but i fixed it
aha
how do i set a player's persistent data?
i only find the methods to get data from the PersistentDataContainer
set
there is no player.setPersistentDataContainer
thats why im asking
i know how maps work
so manipulating the container directly is enough then?
get the container, set or get data
ah ok
thanks
different question, can i remove all entries from that map from a specific plugin?
or do i have to keep track of the keys i set?
you can read all keys and delete only yours
@unreal quartz you know how to reobfuscate remapped-mojang on gradle?
why when i right click with a dye itemstack i made in my plugin, it disappears
i removed playerinteractevent
and there is no plugin doing it
@eternal oxide like this?
public static void delAll(PersistentDataContainer container, String plugin){
for(NamespacedKey key : container.getKeys()){
if(key.getNamespace().equals(plugin)){
container.remove(key);
}
}
}
the documentation is just empty for that
for some reason
why loop through all keys?
remove all entries of a specific plugin
resetting the data
and i asked earlier because i thought there was a simpler solution
i guess if you remove the key, it will remove all entries
i might be wrong tho
on remove method, you don't need to specify the data type
so i'm assuming it will removes all data types for that key
issue being you cant do that.
thats all you can do with container
and namespaced key requires a specific plugin and string as key
i usually will keep reference of the NamespacedKey
or you can just new NamespacedKey(plugin, "some-key")
well unfortunately i need to keep possibly one entry per minecraft item
so i dont know what entrys there exactly are
Yes
That is how you do it
will probably throw a concurrentmodificationexception
-1 for not being verbose enough
What doesn't work
have you set the item meta back?
getItemMeta returns a new item meta, you need to set it back to the ItemStack
If you're working with an items pdc, you need to update the items itemmeta
its the players pdc
key.getNamespace().equalsIgnoreCase(plugin.getName())
In that case are you sure that the code runs through the remove?
could be one-liner container.getKeys().removeIf(key -> key.getName().equalsIgnoreCase(plugin));
^
getName()
because the method takes a string
dumb thing is
the equalsIgnoreCase was the solutoin
lol
Yes he passes it as a string but key.getNamespace() returns the plugins name
well yes but why in lowercase??
Which is also a string
because its a namespace, it has to be lower case
im going to pretend to know why namespace cant even work with all ascii characters
thanks for the help tho
Keys may only contain lowercase alphanumeric characters, periods, underscores, hyphens, and forward slashes.
it then uses the plugin.getName()
ah
though
new NamespacedKey(plugin, String) seems to be able to use upper case characters
considering i can use a big M as both key and to get what i set
it may, but it should not
Is it possible to change LivingEntity's arrgo range without NMS?
not sure about increasing aggro range, but if you want to reduce it you can cancel the EntityTargetEvent or whatever it was if the distance is too great
hmm
i dont think so. you could loop over the entities and set the target manually if there is any in range, but this may not be the best solution here
at least for extending the range
for minimizing do what shreb said
you could get nearbyEntities on the location of the LivingEntity and consider targetting those
but that basically just loops over all the entities anyway
There is an nbt tag for some entities iirc that defines the follow range
High values can be a bit laggy tho
Check if spigot has api for that tag
um, so i kinda new to Java Consumer, i found a problem where i can't use the method of the Type of the consumer, as you can see the image, the wrapper.getSender returns a CommandSender, and i can't use that for some reason
Has anyone had this issue before? I'm trying to download the sources for ACF and it seems to be bugging out... I've tried:
- Clearing my .m2 repo
- Invalidating my IntelliJ caches
- Tried downloading sources from other repos (it worked)
is there a way to ignore netherrite knockback resistance?
what options do you get on wrapper. ?
does it auto complete to getSender()?
yes
hovering over getSender() does it show an error?
have you restarted the ide aglerr
i haven't, i'll try
ill try to restart the ide too
because that code looks fine to me
oh wait, it looks like you must complete all of the parameters argument first
oh lmao yeah thats probs it
bump
why do people make fields without an access modifier?
i saw it's package scope
but private fields in a package??
When an access modifier isn't specified for a field, that field can only be accessed from classes in the same package
Protected is the same but subclasses can also get the field
Is the class you want it to be accessed in in the same package?
but default is also private in some way
It's not, as i told you
Only the class of the field and classes in the same package
Anyways you can use reflection to access it
If you can't modify the field access modified
ah its similar to protected?
Java - Access Modifiers, Java provides a number of access modifiers to set access levels for classes, variables, methods, and constructors. The four access levels are −
oki
can anyone tell me what im doing wrong w/ my iterator? https://paste.md-5.net/ogohulirej.cs
Protected can also be accessed by subclasses
but default also can if they're in the same package?
Yes
nothing
yep
i used toString() instead 😒
you have a lot of redundant code in there
@EventHandler
public void onentityExplosion(EntityExplodeEvent event){
if (event.getEntity().getType() == EntityType.PRIMED_TNT) return;
event.blockList().forEach(block -> {
if(sqllogger.blockexists(block.getX(), block.getY(), block.getZ(), block.getWorld().getName()))
sqllogger.removeBlock(block.getX(), block.getY(), block.getZ(), block.getWorld().getName());
});
}```
hey does anyone know what the replacement for hideEntity is
oh
is it useable?
or like are they working on it
i havent heard of it but i need smth like it, its pretty neat
It’s usable
sweet
nvm didnt work
im trying to add debuffs to players by adding certain items ontop of their heads and just wanna have them follow the player around
is there a way to spawn something in with no hitbox?
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("You cannot execute this command in console.");
return true;
}
Inventory testGui = Bukkit.createInventory(null, 9, "Test");
settingsGui.addItem(createGuiItem(Material.IRON_HELMET, "§bExample Helmet", "§aFirst line of the lore", "§bSecond line of the lore"));
return true;
}
@EventHandler
public void onInventoryClick(final InventoryDragEvent event) {
if (event.getInventory().equals(testGui)) {
event.setCancelled(true);
}
}```
i can't use testGui in the event, any way i can do it? because each players get the inventory made uniquely for them
you can check the inventory name or can use a library like https://github.com/MrMicky-FR/FastInv
Don't use inventory name for matching. You store the inventory instance in a map against the players UUID. Pull the inventory from the map and compare to the clicked inventory.
How do I repeatedly run something(for example broadcastMessage) after a random amount of minutes(like a runnable but in random delays)?
a repeating task with an internal counter
when teh task starts set an int, increase a counter every time the task runs, when it hits the target value, reset counter, set a new target value and send message
if it never ends you could have a non repeating delayed task execute a fresh instance of itself
That question makes no sense
exactly
no, i mean where do I put the code of that
prob whereever you need the counter
If you tell us exactly what you are doing we could probably advise better
i'm getting this error with gradle when trying to use spigot: Could not find spigot-api-1.18-R0.1-SNAPSHOT.jar (org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT:20211201.040401-5). , could anyone help? i can send my build.gradle if you need it
i want to execute my code at just a random time
That doesn;t really help
where i should put the file with mongo-driver
make a while with a random from 0 to 1000?
i dont really know how to say it lmao, if the setting in the config is enabled, i want to repeatedly broadcast a message with a random delay (if that makes more sense)
does thsi need to run all teh time? What kind of message?
just a scheduled timer with a random?
??
So i have a timer, that I can start and stop with commands, and I can also check if the timer is running. i want to repeatedly send a message (for example "Hello World") with a random delay
;
i know, but i dont know where i'm supposed to put that code, like in the onEnable in my Main or in an event?
Random random = ThreadLocalRandom.current();
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
Bukkit.broadcastMessage("Hello World!");
}, 1, random.nextInt(100));```
i know how to code it, but i dont know where(what file/what function) to put the code.
Is it possible for an Entity's Target to be the Entity itself?
Imagine entity attacking itself
One hand trying to attack it
While other hand trying to stop it
Nooooo
i dont think it would do anything
it's supposed to run whenever the timer is running, so ```java
if(timer.isRunning){
Random random = ThreadLocalRandom.current();
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
Bukkit.broadcastMessage("Hello World!");
}, 1, random.nextInt(100));
}
You want like a mob would hurt itself and the player should be the one who rescue the mob?
in command
mob suicide hehe
lit cute
Hmm then use function that will hurt the mob over time then
I just looking for useless value to return when there is no entity matches
null
?
just make a new BukkitRunnable
check for ifRunning and if its false, cancel the runnable
i just want to know where in my code im supposed to put that runnable?
in the command that starts the timer?
Do anyone know a good tutorial for how to send packts?
yes it will run the codes then it starts the timer
dead channel atm
undead it now
whats the min/max value of random.nextDouble?
prob max double limit
oh lol
1.7976931348623157 x 10 ^ 308
Can someone help me with a really basic issue?
I want to ban a player when they die i've got that sorted
but I've got it so player.banPlayer("REASON", duration)
but spigot dosent clarify what should be in the duration?
Date?
like wdym?
I've already had a look at it but I dont know how I would go about adding the date for it, Would it be getting the current date then adding 2 hours somehow?
yes
this
you can use Duration for make the 2 hours and add this to the date...
or make a Instant.now() and then use .plus(Duration) and create the Date using the Instant with Date.from(Instant)
you build correctly the plugin?
im pretty sure?
i mean the only way spigot not load your plugin is not build correctly.. like bad plugin.yml or missing main class defined and many other causes
How do I add to hours to the date?
I've defined it but I'm just confused what to do next
what has?
Like how to I add the 2 hours onto the date?
Date now = new Date();
player.banPlayer("Reason", new + ??);
idk it is built correctly im 99% sure but how can plugin.yml be bad
How do I modify attributes on LivingEntity? I've only found tutorials on Inventory nah
entity.getAttribute...
Is there an event for when a entity gets loaded, so like when you enter old chuncks ?
then setBaseValue()
or addModifier(...)
dont know if EntitySpawnEvent will trigger when old chunks load back again ...
doesnt seem like
@proven river
maybe this can help (i use instant because in D4J/Discord i work more with Instant and not Date)
Instant now = Instant.now(); // The current date
Duration duration = Duration.ofHours(8); // A duration in hours
Instant future = now.plus(duration); // Make a copy with the added
Date dateExpire = Date.from(future); // Generate the date using the instant modified
System.out.println("Now is " + Date.from(now));
System.out.println("Expire in " + dateExpire);
How do i get console logs?
How can i make an ü bold?
ChatColor.BOLD
§l ... nothing else
ü
Thanks, my translator made me confusing
Instant now = Instant.now();
Duration duration = Duration.ofHours(2);
player.banPlayer("You have died", now.plus(duration));
It says it cant resolve the method?
the plus create another instant.. you need convert to Date
like player.banPlayer("You have died", Date.from(now.plus(duration)));
not sure if the method like this ok is a paper method...
Is it possible to give two potion effects to one entity?
yes
the internet is full of wrong information
I trolled by wiki
damn
My Snowman still have a Fire Resistance, it keeps Damage and died bruh
im trying to deactivate suffocation damage. in my plugin, when you get damage, you get teleported. i want that when you get suffocation damage you dont get teleported. i tried with cancelling suffocation damage event but you still get ported?
damage cause
the event get cancelled when the damage cause is suffocation.
did you make the teleport thing?
yes
You can change the order your listeners get the events in with EventPriority
Try setting the one that teleports to a higher event priority, and return out of it immediately if it's been cancelled
Higher event priorities are called later, so they get the final say in whether an event is cancelled
How would I teleport a player back to a certrain coordinate if they reach below a certain y level?
player#teleport
Listen for PlayerMoveEvent
If they go below a certain Y level you teleport them somewhere
How...? I know how to tp but I dont know how to check for this
if (event.getTo().getBlockY() < 5)
if (event.getTo().getBlockY() < 10)
{
player.teleport(new Location(player.getWorld(), 1, 73, 0));
}
}
```?
and cancel the event
event.setCancelled(true)