#help-development
1 messages · Page 957 of 1
// BlockBreakEvent
System.out.println(event.getBlock().getBlockData());
if(!(event.getBlock().getBlockData() instanceof Ageable)) return;
System.out.println(2);
CONSOLE OUTPUT:
CraftBlockData{minecraft:wheat[age=7]}```
It never prints out the 2
make sure you're using the org.bukkit.block.data.Ageable import and not the entity one
Ahhhh silly me, thank you !
are there any libaries that let you add custom enchantments?
plenty
is it even possible to customize like
because ones ive found add weird guis that aren't vanilla enchantment system
that would be a plugin then not a library
nah never really used any so not any i can recommend, I do know theres a few though if you search it on spigot
but I'd recommend just coding it yourself, it's not too complicated to do
and you get more flexibility
idk how I would do it
im very new to development
I know u would add lore? to make it show up
but idk how to make it work with anvils and enchantment tables and stuff
ah yeah might be a bit complex for your then
idk if there will be much libs that support it atm
this one
dang i really thougth there would be more
i've seen heaps in the Help dev forum but xenforo search sucks ass
if its like
a private server I can take a open source plugin and update it to work in 1.20.4 right
that wouldn't be too hard
they made it so you have to use reflection and stuff for enchants now, so would be pretty hard
hmm but these enchantments arent real right
can you add custom blocks
its very difficult in vanilla
im kinda assuming its similar
Correct
damn
you can't add a ton other than custom items right?
everything else u need to do workarounds
The items are technically workarounds too
yeah but you can give them custom textures
everything else you need to replace stuff right
yeah
ok so this doesn't allow images but when defining a command u have to define its permissions? what does that mean what do I put there
it just says "yourplugin.yourcommandpermission"
how do I set that up
idk what that means
im so new to all this
what would I put if I just want it to be available to everyone
I tried to look it up but i cant find anything
Anything
But then add it to the permissions section and set default: true
I think you can also just not include it
oh ok
is there a way in eciplse to just click on button or key and have it export all the right files
are you using maven?
also check out IntelliJ, eclipse is outdated garbage 🙂
literally still actively updated
it cost money
(right)
nope
oh
im stupid then
uhhh
ok im so confused about player xp
so theres getxp which is a float? for some reason
and then getLevel
theres no way to get the totalxp?
is getxp the points? why is it a float
oh
get total expirence
false alarm
event.setKeepInventory(false);
var player = event.getEntity();
var playerInventory = player.getInventory();
var playerInventoryContents = playerInventory.getContents();
for(int i = 0;i < playerInventoryContents.length;i++) {
var itemstack = playerInventoryContents[i];
if(itemstack != null && itemstack.getType() != Material.DIAMOND_SWORD) {
playerInventory.remove(itemstack);
player.getWorld().dropItem(player.getLocation(), itemstack);
}
}
var xp = player.getTotalExperience();
event.setNewExp(0);
event.setNewLevel(0);
event.setDroppedExp(xp);
player.setTotalExperience(0);
im trying to get players to drop expirence when they die
but none of this is working
the xp wont drop and the player wont lost any
keepinventory is ON but otherwise item drops get funky
do u know how I could do this do i need keepinv off?
but when keepinv is off Idk how to have the player keep items
what's wrong with getContents().clear()?
I said I want to drop xp
ah ik why
not items
what's that event btw
PlayerDeathEvent
this is so confusing
now its just deleting items
this event does not work like how you would expect at all
make sure you have registered your listener
i mean
the event runs
thats not the issue
the xp just refuses to drop
ok
I got it to work somehow
for(int i = 0;i < xpSqr;i++) {
player.getWorld().spawn(player.getLocation(), ExperienceOrb.class, x -> x.setExperience(xpSqr));
player.sendMessage("i: " + i);
}
var orb = (ExperienceOrb)player.getWorld().spawn(player.getLocation(), ExperienceOrb.class);
orb.setExperience(xp-(xpSqr*xpSqr));
this only spawns the last one
for some reason
wtf
experience orbs merge
I'm not sure if you can prevent it or limit it
What event would I use to detect the destroying / despawning / removal of a custom item?
I've been searching docs and my best conclusion is a mixture of listeners
hey so I have webhosting hosting my servers website on domain.com
and I have a a record pointing to play.domain.com is there any way I can also have it allow me to connect to my server via domain.com with out putting another a record because putting a second a record will break part of the site
You might get better help in #help-server
might with a grain of salt
👍
I found this guide on spigot about world generation and I have been trying to play around with it. I am generating ores under ground and am checking the surrounding blocks to see if an ore will chain off to the block being generated. I keep getting these flat ore veins and im not quite sure why im checking the block to the left, behind, and under to generate blocks off of them and they only seem to be generating horizontally not vertically.
Line 88 is where it is getting the blocks around it
Then from line 91 to 122 its generating ores and determining if it should make the block an ore because of surrounding blocks
https://i.thick.at/jajhVo8d.png
https://pastebin.com/WSZfh8M0
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
could be two points, either your frequency is too low or your height calulation is wrong
Well the frequency should be the same as when its generating to the left and behind because I make a list of all of the ores in each direction and just loop through to see if there is an ore to transfer so I believe it would be even on all sides.
have you tried giving your y an offset
Offsetting it how?
float currentY = (65 + (noise2 * 30) + (y / 20));
for example
(gemini told me that)
Turns out i was only calculating the y value with a minimum of 0 so if I went to the negatives it wasnt checking blocks below it to spread
isnt 64-bit supposed to take any amount of RAM?
im pretts sure minecraft can run on more than that
are you actually running java 22 ?
do java --version
What you showed is a zip file... don't think you can run java from there
i unzipped it ofc
try just one -
java -version
you need to restart your terminal for env var changes to take effect
then you didnt do them propperly lol
Can anyone heko me wiht plugins translation? I can pay too!
Use chatGPT
can u get all tasks without a list?
there must be a way, bukkit can cancel all tasks from a plugin and cancel task from the id
Not sure what "get all tasks without a list" means
List<BukkitTask> allTasks = Bukkit.getScheduler().getPendingTasks();
But you should not need that
Basically ever
Pending is kinda sus, does it include active tasks
oh wow i didn't know
What do you need this for?
Bukkit#getSchedule#getActiveWorkers()?
skript addon, i want a way for them to create and retrieve tasks or cancel
actually now that i think abt it they can just create a list of tasks when they create them
You could just use BukkitRunnable
pretty sure it's the same as BukkitScheduler
Its not...
what's the difference?
Are u ignoring me?
preach
not really, i'm checking activeworkers
You want to write a skript addon which lets users create and cancel tasks, right?
But not via taskIds but by having an actual object that can be cancelled.
no like
well basically yes
i didn't realize that till now, i'm just gonna make it impossible to retrive tasks
How can I make coppy of ArrayList without beaning modified by first change in source list? I tried this:
List<ItemStack> defaultEventDrops = new ArrayList<>(event.getDrops());
But when ever I will do event.getDrops().add(itemStack) it will be added to defaultEventDrops as well and I don't want that
Do you need defaultEventDrops to be modifiable?
nop
List<ItemStack> defaultEventDrops = List.copyOf(event.getDrops());
How to make night slowly fall? It's possible with that animation how it slowly gets night and day as well?
Just set the worlds time and gradually increase it
still its modified when I modifie event drops
is there a difference between async task and a thread
Are you actually modifying the ItemStack inside?
event.getDrops() returns a copy
yeas, I just need default drops from event saved somewhere
List<ItemStack> defaultEventDrops = List.copyOf(event.getDrops());
System.out.println("defaultEventDrops " + defaultEventDrops);
List<ItemStack> eventDrops = event.getDrops();
ItemStack helmet = killer.getInventory().getHelmet();
if (helmet != null) {
MaskEffect dropEffect = MaskEffect.DROPS;
if (HelmetManager.haveEffect(helmet, dropEffect)) {
double dropIncrease = HelmetManager.getEffectValue(helmet, dropEffect);
if (dropIncrease != 0 && !eventDrops.isEmpty()) {
eventDrops.forEach(item -> item.setAmount((int) (item.getAmount() * dropIncrease)));
}
System.out.println("MASK DROPS: " + event.getDrops());
System.out.println("defaultEventDrops: " + defaultEventDrops);
}
}
drops = e.getDrops().stream()
.map(ItemStack::clone)
.collect(Collectors.toList());
try that
A Collection is just holding a bunch of references to Objects.
If you have 20 different collections, all holding the same Object, and you modify the Object itself, then
every List will still point to the same modified Object. Even if the content of the lists cant be modified, the
Objects inside still can.
Oh I get it now... Im saving more then 1 list but every list is list of same Objects so thats why Is happening... Thanks for the explanation
Do what W Person suggested. But use .toList() instead of .collect(Collectors.toList())
toList is for java 16 so u might not be able to use it
intellij should change the language level for u tho
yeah, intellij idea suggested .toList() to me as well so I got it. thanks again
Hi is it possible to do what i'm trying?
Here's the code
((Player) commandSender).getInventory().addItem(new WandItem(Material.BOOK, "Grimoire", false, Spells.testSpell,Spells.testSpell2));
public class WandItem extends ItemStack
if(e.getItem() instanceof WandItem wand){}
PlayerInteractEvent is unable to cast the itemstack to the wandItem
bro this is so annoying, either u get Consumer<BukkitTask> as parameter but void return or a normal Runnable and BukkitTask return value
u cant get both consumer and return value
Function?
send WandItem
Function takes a values and can return a value
when u create a task using Bukkit.getScheduler().runTask
pretty sure you can use the return of runTask
it's the same
u can do this
BukkitTask runTask(@NotNull Plugin var1, @NotNull Runnable var2)
or
void runTask(@NotNull Plugin var1, @NotNull Consumer<? super BukkitTask> var2)
the consumer purpose is only for the within code
How about you use the BukkitRunnable like i suggested earlier
oh
can u turn a runnable into a task
or cancel runnable outside of the code
ykw screw tasks
bukkitrunnable time
wait
can i cancel a bukkitrunnable from this
Bukkit.getScheduler().cancelTask(int)
or do i need the object
yes
cool
BukkitRunnable has a method
yeah but you can do it with cancel() there
i can have the runnable object outside the actual runnable and inside
there's a solution btw
yeah i want to cancel from the outside
you can have your void runTask(@NotNull Plugin var1, @NotNull Consumer<? super BukkitTask> var2) if you just make a check first and if it fails you can cancel it from within the consumer
not as pretty
the thing is idk what's in the consumer really, it's a skript addon
bukkitrunnable is prob my only option
either only or one of the best
oh skript
yeah so they might want to cancel it or not cancel it
? wdym
the WandItem class
public class WandItem extends ItemStack {
private Spell[] spells;
private int currentSpell;
private final boolean consume;
public WandItem(Material m, String name, boolean consumeOnUse, Spell ...spells) {
super(m);
consume = consumeOnUse;
this.spells = spells;
if(spells.length>0){
currentSpell = 0;
}
setAmount(1);
ItemMeta meta = getItemMeta();
assert meta != null;
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_ATTRIBUTES);
meta.setDisplayName(ChatColor.BOLD.toString() + ChatColor.BLACK + ChatColor.MAGIC + "X " + ChatColor.WHITE + name + " " + ChatColor.BLACK + ChatColor.MAGIC + "X");
setItemMeta(meta);
}
public void useSpell(Player p){ }
public void toggleSpell(){}
}
}```
is there an error when you try to cast?
yep when trying to (WandItem) e.getItem()
Caused by: java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_20_R3.inventory.CraftItemStack cannot be cast to class xceing.untitled1.Folder.WandItem
Yeah, dont extend ItemStack
The conversion from bukkit to nms and back will result in a regular ItemStack class and all data being lost.
I would recommend using a wrapper class which uses the PersistentDataContainer of the ItemStack to rebuild.
unless you know what wands exist you can prob just make a listener tbh
By the looks his wand has dynamic spells
What would the pdc contain? it being a wand and strings of spells?
thanks
does custom model data have to be tied to a item or can it also be universal so every item turns into salt or something when the data is 100
ok thanks
yeah does look like it's tied to an item
Not sure why you need it to be universal though
If you want to prevent the loss of the item when replacing it with your own you can simply store it in PDC
i want a invisible texture which can be applied to everytghing
but why?
🤨
armorstnands
textdisplays are not available in bedrock
I always use projectiles to stack armorstands.
Because how else would you do it, if not with Projectiles...
can basically eveything be stored in a base64 string?
Pretty much
that's pretty sick, ngl
which entity has no hitbox and can be invisible?
Im gonna ignore the very generalized premise of this question and just gonna say yes.
@hybrid turret
i mean yeah i intentionally generalized it bc i mean it that way
If you can convert it to bytes you can base 64 it
And you can convert anything to bytes with enough effort
You can technically store anything you want by engraving it into the wall of your neighbour in hex.
Doesnt mean thats always a good idea.
Region files are technically a bunch of bytes
lmao
So let’s base64 region files
i cant tell if this is irony or not, is there a better way to stack armorstands with passengers that i missed?
so why does it need to be applied to everything
Just have one invisible model and use that
??
i was going to have an enum with all custom models
and their names
but now
its hard
What is your actual goal
You're not making much sense
Im getting xy vibes
wait a minute
Coll ^^
no this is not problem, but
i want to store the custom model data in an enum
so i have it named
sure you can do that
??
CustomModelData.INVISIBLE cannot be applied to everything
therefore it doesnt make much sense
You could just have a constant itemstack for the invisible model
^^
currently projectile
Then no need to clone
ok
Have fun making the bedrock texture pack too :p
im currently looking how to convert it :/
imagine supporting bedrock
why cant minecraft just be all the same in both versions
It’s probably not that hard for a single invisible item
Idk ask bill gates
when you have a game and create a mobile version why do you think its a good idea changing game mechanics :(
because everyone always thinks they can do it better
tbh i think every1 would play windows edition if it wasnt feeling so off
doubt
the best part is its c++ and can render chunks 10x faster
c++ will just make is harder for people to make proper mods
It also really isn’t that much faster most of the time
😩
Not the microtransactions

armorstand markers can be teleported async?
no
teleportation is done in sync so no
uhm is the teleportasnyc method only paper?
if you conform to ocp then no
"illegal" lol. no
Yes
you just cant fuck around with the world async
i will try this now :)
its illegal
and async
which is the same
i think the serrver is crashin
MY PC TOO
ITS LAGGING SO HARD
its wont close
help
what the flip
much better :)
not sure if you’re trolling or just never done multithreading before
im not trolling just testing something

its for science
mhm of course
Yeah, while(true) wont max out your CPU because the code feels what you want through ethereal energy and goes easy by pausing a bit
Here testing the validity of OCP
it still has the delay even tho im teleporting a light speed
it doesnt work
😔
not enough ocp
Because teleporting 50 times in one tick will literally just result in every 50th teleport being registered
laziness
Ah, in that case the server spins up to 200 TPS
He might know something we dont 
i mastered ocp
yup
you whaT???
i know every secret of the universe
no fucking way tell me everyithn
ocp = know every secret of the universe
teleportAsync is a utility method, used to teleport entities into chunks which arent loaded yet.
It uses papers async chunk loading system and teleports the entity as soon as the chunk is ready, simply to prevent force loading a chunk on teleports.
It is async, but not on a different thread.
you are laplace's demon
async != multithreaded
okay, do you have a good idea to create a fake nametag? there are not entities with perfect size and no hitbox, the ones without hitbox need a texturepack to be invisible
(perfect size for stacking armorstands)
I dont know what that means. Im just gonna make a few assumptions.
Mount your entities like this:
- MarkerArmorStand
- Invisible Slime of size 1
- MarkerArmorStand
- Invisible Slime of size 1
- MarkerArmorStand
- Invisible Slime of size 1
etc
Or try an ender mite
but the slime should have a hitbox and deflect arrows?
just use a text display + translation?
text display doesnt exist on bedrock
Mounting is always calculated using the hitbox of the mounted entity.
You cant have stacked mounting without a hitbox.
snowballs have none tho and can be stacked, or do they have one?
Snowballs have a hitbox as well. But projectiles have different behaviors embedded in both client and server.
okay so there a no entities wihch can be invisble but also cannot be hit?
text displays :)
sucks for them
Write datapacks then i guess?
is that still java
Not even close
c++?
lol
any good language?
No. Its a weird scripting language from mojang
you mean mcfunctions?
and datapacks are allowing me to change the game more than plugins?
Which you write in a random text editor
that's just regular Minecraft commands in a text file lol
No, you only have whatever mojang provides you
i dont really get how datapacks are gonna help?
Datapacks are less powerful than plugins tbh
do they have anything plugins dont
yes
They might work for both versions
They definitely won't they're inherently different things between java and bedrock
Bedrocks is much more capable and powerful not to mention in general different
Java Bedrock support in one is a mistake
It'll never be perfect
parity updates :copium:
My approach would be this: Screw bedrock players and tell them to go where the pepper grows
This is the best approach
i dont like bedrock too, but this is where most ppl play
Then make a bedrock server
Ditch java
Im 95% sure that this doesnt translate into english... "go where the pepper grows"
go where the sun doesn't shine
Look at bedrock server software it's comparatively primitive. If you wanna do bedrock do it right
yo does every language have some kind of sentence like this?
The source code is compiled binaries.
So if you wanted to write a bedrock implementation, then would have to start from literally scratch.
People already have :P pretty sure one is in java too
there is no bedrock spigot ?
no server software
Yeah one in Java and another in PHP

No that's just not true
Where do the php devs live? Asking for a friend.
They are idioms
Iirc the PHP one is much more developed
no
why php out of all languages?
why not :p
It's a pretty good servers language
You don't really have room to talk of you've never used it
someone probably started some implementation in any language you can think of
i opened intellij and my autocompletion doesnt work anymore and if i try to compile my plugin the following error occurs: java.lang.NoClassDefFoundError: com/sun/tools/attach/AttachNotSupportedException. i tried reinstalling intelli, invalidating cache but none worked.
now whether or not it is mediocre is a whole other story
We won't finish that argument until the heat death of the universe so probably better not to start xD
Hmm. Yes.
$arbitrary_garbage = explode(",", $str);
Because explode makes a lot of sense
xD ima explode you
split
render a memory address unusable?
I've never used php just saying lot of people shit on jt and don't know anything about it
i will shit on php until it stops being funny
also updating intelli didnt help
hey! i have a plugin which is in turkish language. I need to translate in english. I am a youtuber and bought these plugins from a dev but they were in turkish. I don't have the source code as the dev have lost them. I have around 15 plugins which needs to be translated. If anyone can help please message
The real problem is not translation of Turkish to English but translation of the plugin as it doesn't have any source code...
I CAN EVEN PAY!
Contact :-
Discord - thunderzlucky
Email - techthunderz443@gmail.com
Update your plugins as well
so this was not enough huh
how do i update them? i didnt change my minecraft version nor my java version, just my intelli
double shift click and search for plugins
seems like all are updated
Nobody is gonna do that, especially the way you are phrasing that "I CAN EVEN PAY!"
Such a job costs money
This is a very obscure exception which can only occur when you do something shady.
Do you have virtual drives?
Do you have admin permissions?
What java version are you running?
i dont think i have virtual drives (i just use normal nvmes)
i have admin perms, but dont run intellij with them
my project runs on 17, my main os uses 22
it worked before, but one day i opened it and it just didnt work anymore
i will pay 120$
Is it just this one project? Or does that happen with a clean new project as well?
i have 15 plugins which needs to be translated
yes, i tried it with a clean one too, same error
oops, wrong msg replied
If you completely reinstalled the IDE then it might be a problem with your temp files.
I would recommend using an LTS version for your main system. Downgrade to java 21
What OS are you on?
endeavour os
No idea. Update your packages as well.
you mean my system or are there intellij packages?
I have a system so that you run a command which sets a boolean as true and then when you interact with a block it has special rules. It doesnt work like the boolean doesnt change but it does change in the command but just not in the interact event
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
You are probably setting two different booleans to true
is you boolean static?
I spent 2 hours looking asked for help then found it instantly
it was me registering the listener and the command executor both as new
well atleast i wont do it again
cant you just go into the jar and replace the strings
Btw you should not distribute variables like that.
Your boolean should be in a manager class of which only one instance exists.
Your command and listener should be separate classes. Then pass your manager to both your listener and command.
This way both always see the same content from the manager.
a jar file is just a zip right
Okay
you'll prob break the bytecode somehow
ive seen people do it before
You can just string replace, but you have to keep them the same length
thanks @lost matrix , full system upgrade did the trick, even tough my system kernel paniced on reboot lol
That's why you better decompile it lol
idk anythinf
anything
can you come DM
i will explain you.
how can i check if a list contains an index?
without causing indexoutofboundsexception?
.size()?
what? list contains an index?
Lmao
yes isnt a list just a fancy array
Not the best way to describe a list
An ArrayList yes, but there are List implementatins which arent backed by an array
Is a linkedlist one of them
Yes
It contains linked nodes, which just point to the next node in the list.
Thats why LinkedList index access is O(n) instead of O(1) because it needs to start iterating from the first node and then increment a counter on each node jump
It is an actual garbage collection with only a very specific benefit
try/catch
Removal while iterating is instant (constant time)
So methods like removeIf() or retainAll are really good on it, because it can just iterate through nodes
and if it found something to remove, it simply takes the node before it and the node after, and then links them together
while throwing out the currently linked node. This makes it really efficient for removal while iterating.
inb4 even the author of java's LinkedList considers it useless
I see no real usages of it, but who knows
lul
I can show you one specific Spigot example
What is it
So create an abstract representation of your Projectile (the implementation doesnt matter, can be whatever you want)
public interface Projectile {
void tick();
boolean isDone();
void onHit(Block block);
void onHit(Entity entity);
void onTimeout();
}
And a Task that starts with the server:
public class ProjectileTask implements Runnable {
private final List<Projectile> projectiles;
public ProjectileTask() {
this.projectiles = new LinkedList<>();
}
@Override
public void run() {
this.projectiles.removeIf(projectile -> {
projectile.tick();
return projectile.isDone();
});
}
}
This is a really efficient way of ticking every element once, and then throwing those out that shouldnt be ticked anymore.
(Was an example from 2 day ago i think)
I mean unless you have hundreds of thousands of elements in there, the performance benefit is not gonna be noticeable
screw that, millions, arraycopy is absurdly fast for mere kilobytes
Depends on what you use. An ArrayList gets bad really really fast as removal while iterating is O(n^2) as it needs to shift the entire array every removal
big o doesn't matter unless you expect to work in separate orders of magnitudes
Meh, then lets go for memory footprint. arraycopy allocates a ton of space that needs to be GCd
short lived objects generally aren't an issue for modern GCs
we're talking kbs unless you have millions of elements
Im gonna buffer my lists with 10k emily dummy objects on each side from now on so you dont go in there and swap my impl from LinkedList to something atrocious

you're lucky I can't use emotes here

is working with the protected access modifier good practice or should i create an interface where the interface is always returned instead of the impl and it contains the api?
protected fields make sense if you want to give your child classes access to your fields.
It kind of violates the open closed principle and is primarily useful for sealed classes.
protected methods on the other hand are more lenient
so interfaces are worse than protected?
They are completely disjunct from each other and i dont see a correlation between them. No idea how you compare an access modifier with an object type...
when i protect stuff from a class it can be used in the inner workings of the program, but not accessed in the api. when using an interface its the same, all the methods are hidden of the impl except the methods which the interface provides
Alright. I still dont see a correlation. You can use protected fields and implement an interface without a problem.
If you return an interface, then you will never be able to access the fields of the impl. No matter what access modifier they have.
if (!player.isFlying()) {
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "fly " + player.getName());
}
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "fly " + player.getName() + " off");
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "fly " + player.getName() + " on");```
What would be the best way to enable fly to a player?
because the first one, the player could not be flying but still has the fly activated right?
player.setAllowFlight(true) i suppose
Yea, i know that
always use API over commands
But i prefer enabling the fly without that method to prevent bugs if other plugins manages better the flying
if thats the case you should not be using dispatchCommand as Console. you should be using https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#performCommand(java.lang.String)
oh
if you want plugins to intercept and manage flight
but, should i be doing the first or the second method then?
because the first one could disable flight instead of enabling it right?
there is the crux of the issue. fly command in other plugins may vary
or i can just enable it without any problem xd
hmm
you do realize
that doesnt make any sense
maybe xd
at the end the /fly command uses the same method to make players fly as spigot .setAllowFly does
However i got advised time ago that this fly method wasn't perfect, as the player could recieve damage or others
what does the .fly method have to do with damage lmao
you do realize that .setAllowFlight and /fly use the same methods deep down
so any problem that method would cause
/fly would have the same problem
like, when falling i think
I mean
it probably isn't a thing but was concious about that
yh well
just be aware
dispatching commands
is usually not a good idea
no matter how you do it
why?
well, if the other plugin is a dependency I don't see why it is bad
for one, you never know for sure what the commands do under the hood
just do your own thing instead of depending on some random plugin which might also randomly update
You should always call methods and never go the unnecessary extra route of dispatching commands.
It could result in undefined behavior.
Yea yea
Dispatching commands is also not compiletime safe. Calling methods is.
But if you want something from other plugin
calling method could not be the way
some plugins have apis
even if you have the dependency
some not
Its always the way.
what plugin are you currently referring to
How can i remove this warning? Its there because of DiscordJDA but I dont know how can i remove it on spigot.
1 sec
lemme check how i did it in mine
i used LoggerFactory
(logback)
you have to shade differeng things
i don't know
but there could be
like this?
when there's something like that go ahead and do your own thing
well u dont have to do the config part
every competent plugin that many servers depend on should have an api for other developers
you can permanently disable it ofc but
smh
i prefer to have a debug mode
slf4j has a easier way
slf4j is 1
get absolutely shit on
or per package
technically Configurator is a log4j class so logback might have it
u do realize i can also bring this down to 1 line
@icy beacon why r u adding more reactions than sending messages
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
what help do you need
I tried but I found no one there
well noones gonna help you here either
My plugin is in Turkish I need to translate in English i have 15 plugins
put your request on the forums and wait
Just translation is problem
But let's see if anyone can help me here
But let's see if anyone can help me here
translate messages?
this isnt the place for this
Yeah, actually the whole plugin
no one here will help you
dm
we wont do that for free or spoonfeed it you
I am ready to pay btoo
Bro
find somone on forums and dm them
But I made a post 2 days ago and found no one
find people in offering and dm them then
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
i cant find LoggerFactory in logback
I did
you didn;t make a post. I looked
cause its not a logback object lol
import org.slf4j.LoggerFactory;
is correct
I deleted that and again made one yesterday
And even today
then what is wrong?
I looked yesterday, after you said you had posted
lemme see
im not seeing any posts
I have posted 2
send the link
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
not there you didn;t post
I think not here, my acc is new I can't post here
find someone on the offering developers section and send them a dm
Then you did not post
ask them if they will translate it for you and there you go
can you send me that as an acual text and not image
[18:29:44 ERROR]: Error occurred while enabling DcBoosterSync v1.0-SNAPSHOT (Is it up to date?)
java.lang.ClassCastException: class org.apache.logging.slf4j.Log4jLoggerFactory cannot be cast to class ch.qos.logback.classic.LoggerContext (org.apache.logging.slf4j.Log4jLoggerFactory is in unnamed module of loader 'app'; ch.qos.logback.classic.LoggerContext is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @17af5f5b)
at me.adabugra.discordboostsync.DiscordBoostSync.onEnable(DiscordBoostSync.java:93) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:518) ~[patched_1.16.5.jar:git-Paper-794]
at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:432) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:599) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:298) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1074) ~[patched_1.16.5.jar:git-Paper-794]
at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:291) ~[patched_1.16.5.jar:git-Paper-794]
at java.lang.Thread.run(Thread.java:840) [?:?]
Can't you help, I'll pay you.
join the discord and create a ticket
You've spent three days asking, and instead of doing as we all told you you refuse and still you have no help.
try this:
org.apache.logging.log4j.core.LoggerContext loggerContext = (org.apache.logging.log4j.core.LoggerContext) LogManager.getContext(false);
Configuration config = loggerContext.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(Level.ERROR);
if that doesnt work show me ur pom
should i add log4j as depencendy?
yh
I did
org.bukkit.World bukkitWorld = Bukkit.getWorld("world");
com.sk89q.worldedit.world.World world = BukkitAdapter.adapt(bukkitWorld);
try (EditSession editSession = com.fastasyncworldedit.core.Fawe.instance().getWorldEdit().newEditSession((com.sk89q.worldedit.world.World) world)) {
Region region = new CuboidRegion(pos1, pos2);
BlockType toType = BukkitAdapter.asBlockType(to);
BlockType fromType = BukkitAdapter.asBlockType(from);
Mask fromMask = fromType.toMask();
editSession.replaceBlocks(region, fromMask, toType);
Bukkit.broadcastMessage(""+fromMask);
Bukkit.broadcastMessage(""+toType);
Bukkit.broadcastMessage(""+region);
editSession.flushQueue();
}
} ```fawe api meant to replace blocks in an area the stuff broadcasted is correct I dont know why it doesnt replace.
https://leonardosnt.github.io/jar-string-editor/?ref=gh
Here you go, either do it yourself or ask in the correct place.
🙂
I really tried alot but can't do I also don't have time I am a Youtuber can you help.. DM?
could try looping through all loggers
for (LoggerConfig logger : config.getLoggers().values()) {
logger.setLevel(Level.ERROR);
}
Dude, you wasted THREE days asking in here (The WRONG place) and have NOT posted or made tickets as you have been instructed. Instead you wasted all that time annoying people.
@eternal oxide Where do you generate a ticket? I'm new.
there are no tickets here
ask development related questions here, server related questions in #help-server
still same
do i need to shade log4j?
sorry that message was to ThunderzLucky
Oh okk
I'm trying to understand how to just run it on windows 11. lol
I haven't had this much trouble on a launcher before.
Is Player being extended by anything?
I‘m wondering bc Bukkit#getOnlinePlayers returns a Collection<? extends Player>
HumanEntity, CraftPlayer
Ignore that... its an artifact of old bukkit days and their shenanigans
Wait what i though that‘s the other way around (at least for HumanEntity)
Oh so it should just be a Collection<Player>?
Yup
Lol
Afaik there's also basically no reason for HumanEntity because it's basically Player lol
? Doesn’t make any difference
it's gonna stay like that on the server, HumanEntity represents Minecraft's Player, it's just some common player entity class with shared logic between ServerPlayer and ClientPlayer
Is anyone knows how to remove this?
what are all the events that can be triggered where an item is being moved
O- oh
Fair point, why did i not google before asking?💀
Bit embarressing if i‘m honest
Thanks anyway :)
PS: This i pretty useless for most cases unless you specifically design your objects for it
Is there an event that gets called when a TNT is ignited, from which I can also get the block? BlockIgniteEvent does not seem to do the trick (does not get called)
how can I remove knockback from Player#damage(damage, player)?
declaration: package: org.bukkit.event.block, class: TNTPrimeEvent
Oh I totally missed that, thx, will test that
Guys, hello! I have a problem with InventoryClickEvent with custom inventories. This event works with all vanilla inventories (chests, player inventory etc.) but doesn't work with my custom created inventory. I have tried to do this simple method, but nothing shows up in console. Event is registered and other events in this class work fine. Is there any ideas why it doesn't work?
What is a "custom created inventory" in your case?
The InventoryClickEvent is fired for those
well, I don't receive anything in console for the sout(e.getAction()) (lazy to type the full method xd)
What happens if you click into a random chest. Do you get the event output in that case?
yes
That sounds pretty much impossible unless an exception is being thrown.
Given that it's 575 lines I wouldn't be surprised if you are cancelling it somewhere
Here's an output for the random chest and no PICKUP actions from my GUI inventory
idk if it matters, but there's only one inventory event I cancel and it's InventoryOpenEvent
Try to see if you call setCancelled literally anywhere, it could be that you are cancelling the event under some obscure conditions that you happen to meet in this case
Ah
Probably not the case then
I'd suggest unregistering basically all your listeners and only leaving this one to see if that helps. If it does, something is faulty in the ones you've unregistered
okay, let me check
Not sure if /reload will promptly unregister the handlers btw you might need to restart
you are opening the inventory to the player as normal?
For development, especially when the plugin is not too large, it's fine imo
I still restart to be safe but I don't see the need to restart when your plugin is, say, one command and two listeners
Do you think there's a way to correlate the ignited block to the resulting entity in TNTPrimeEvent? I don't see how I could do that except for like calling getNearbyEntities with radius 0.1 which is hacky
Check if the EntityChangeBlockEvent is fired. Otherwise no idea.
The logic when the custom inv opens: Player clicks enchanting table -> InventoryOpenEvent called and the event is canceled -> called the method to open the custom inventory
Well, I disabled all listeners and seems like I actually cancel it wherever, time to search where I do it xd
you know opening the custom inventory is going to also fire an open event
?gui
If you want to write a robust GUI lib
thx
here's the whole event xd
and the gui inventory is a chest one
does it involve linked lists?
Yes, with 10k emilies padded on both ends to repell you from touching it
does it follow the ocp..?
Nope, breaks it wherever i can
god damn
The most weird thing is that I don't use InventoryClickEvent anywhere
No, unfortunately not. Maybe this is an XY problem. I'm trying to implement custom TNTs and for that I give a NamespacedKey to the TNT block with CustomBlockData. I'm able to detect the ignition, but to execute some effects I imagine I would need to listen to the the explosion event and check if the TNT is a custom one. Perhaps this is just wrong design?
Idk, cancel the event and spawn your own primed TNT which has a custom fuse time and some PDC data. Then on EntityExplodeEvent you can add your shenanigans.
Works fine, though because I'm getting the original location from a block, it snaps to (X = .5; Z = .5) and thus the location isn't accurate. I'll see what I can do about that tomorrow, or maybe you have an idea.
(example before ignition & after - moves .5 blocks to the left & to the right because that's the "block location")
@EventHandler
public void onIgnited(final TNTPrimeEvent event) {
final Block block = event.getBlock();
final Location location = block.getLocation();
final NamespacedKey key = // some stuff
event.setCancelled(true);
block.setType(Material.AIR);
location.getWorld().spawn(location, TNTPrimed.class, tnt -> {
if (event.getReason() != TNTPrimeEvent.PrimeReason.EXPLOSION) tnt.setFuseTicks(25);
else tnt.setFuseTicks(0);
tnt.getPersistentDataContainer().set(key, PersistentDataType.BYTE, (byte) 0);
});
}
Just add 0.5, 0, 0.5
Hey !
I want to play a sound to a player, but I don't want that when the player go away, the sound disapear
you can probably use the player itself as entity sound source
ye it work ! Thanks
I am getting this error NoClassDefFoundError: com/mysql/cj/jdbc/MysqlDataSource
Does someone know how to implement the class into grandle that the error is resolved?
any1 able to help me im trying to make it so i can craft a custom sword with certain items but theres more than one custom sword and i need to make a seperate recipe for them,
private void removeMaterials(Inventory inventory) {
inventory.removeItem(new ItemStack(Material.DIAMOND, 3));
inventory.removeItem(new ItemStack(Material.STICK, 2));
}
like how wud i make it so i can craft 2 swords instead of only being able to craft one bc right now i can only craft one as there both under the same recipe and idk if i need to make it so each recipe is asigned to each sword or can i just make more inventory.removeItem(new ItemStack(Material.DIAMOND, 3)); code likie this?
nah it is now had to change the whole code ahahhahaha
Hi, I'm trying to create a Boss for a plugin.
the usual 10 hearths of a skeleton aren't very the perfect choice for a boss.
https://pastebin.com/EQySH9yD
Placeholder
Indicates it's an instance method
Ye, also im quite new to OOP so I don't really get everything xd
object.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(yourValue)
Yea
what about "Attribute"
wdym?
skeleton.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(30);
what do you not understand?
well cant really send images here but it's not quite understood by my ide
oh wait. I have to import a class before
dm me the img
xd
After you increase the max health you can then do setHealth
oh
done
anyone know about the new snapshot update?
Whats up with components on blocks?
https://i.imgur.com/LX9ClkH.png
Custom model data can be applied now? or is this related to the hardness and fire resistance etc?
Components = Attributes afaik
Yea, they changed it to components in a new snapshot
Ah
Instead of NBT its now called Components
is it just a rename? or does it add things
Not sure you're gonna have to check the wiki
iirc blocks loose nbt's when placed
It’s how items store data now
Rather than NBT
It’s still saved as NBT, but it gets parsed into components
makes sense
lowkey watching this one https://feedback.minecraft.net/hc/en-us/community/posts/360049940152-CustomModelData-for-Blocks
https://www.youtube.com/watch?v=yQAyKFfgmpU
Phoenix explains it pretty well
gotta love how he makes his stuff
But you can change alot now
like max stack size
etc
just give it a watch i think he also links the update log, so you can check it out yourself
and you can make litteraly anything eatable, which is hilariouse
can you have a special toolip show up when players hold shift
not sure if I will like the components part
or at least understand why it is something that is needed
dammit
One of the reasons they cited was not having to parse armor trims from NBT every frame for rendering
Is there any other way than barriers blocks to make invisible colliders?
Hey guys I have been working on creating my own custom world and generation and its going well but I cant seem to change the biome of the world I create. I want the entire world to be a desert since its a desert themed world but when I add the lines 181 and 182 it seems to freeze im not quite sure if its just intensive to switch the biome since I am doing it for every block in the chunk or if im just going outside of the loaded chunks any recommendations are welcome and if you see anything else I can do to make my code more efficient or better dont be afraid to let me know I havent done much with generation before so im trying to learn
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
are you sure that location is correct
if x is real x not chunk x you need to divide it to get chuink x
Use a custom biome provider that always returns desert
x is chunk x not real x and I would need real x to change the biome with world.setbiome because every block has its own biome not chunk based right?
Can you explain further? What is a custom biome provider
It’s an interface you extend
declaration: package: org.bukkit.generator, class: ChunkGenerator
ill take a look into this thanks
Im not quite sure if I did this correctly im not too familiar with custom interfaces but I made this file for the Desert Biome
https://pastebin.com/M39sgFzR
Then for the full code you can look at the paste below but this is what I did
https://pastebin.com/bYrd2M6g
BiomeProvider biomeProvider = new CustomBiomeGenerator();
biomeProvider.getBiome(worldInfo, x16 + x, y, z16 + z);
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Just set the biome provider in the method I linked
That’s it
You can’t set biomes inside generateNoise
Im kind of lost im not going to lie
@Override
public BiomeProvider getDefaultBiomeProvider(String worldName, String id) {
if(worldName.equals("Dim-01"))
return new CustomBiomeGenerator();
return null;
}
I threw this into my main class since I did something similar to the ChunkGenerator with getDefaultWorldGenerator but it still doesnt seem to work
Do it in the chunk generator
Like in the same class I am calling generateNoise? If I put it in there it says Method does not override method from its superclass
I sent you the exact method you need to use
.
I see what I was doing wrong thanks! For some reason I had string worldName instead of WorldInfo
Is there a way to get a class and subclass access to a method (i dont want the package to access it)
private should work
unless the method is in the subclass
then you need at minimum package private
I have a plugin that puts a armor stand as a passenger for players to give some cool effects, but then users cant teleport. How can I listen to the teleport packets or something to make sure they can still teleport? I know client side armor stands is an option, but I dont want to have to go that route. Is there another way?
Just listen for teleport events. When you get one dismount the armorstand teleport player and armorstand and remount
No. You can't have subclass only access. You have either package private or protected (package private + child), there's no child only
Closest would be anonymous inner class but that isnt quite the same as subclass
whats the best way to remove a certain amount of a specific item
.removeItem doesn't work for offhand and armor slots weirdly
I could do it manually but idk if theres a better way
it does?
yep
player.inventory.itemInOffHand.subtract(1) ?
i think they are trying to remove items from the whole inventory in general
so inventory.removeItem should work
cause i mean
at the end
inventory.getItems is just an array
val enemiesInAOE =
caster.location.getNearbyLivingEntities(rasenganAOE).filter { !it.equals(firstEnemy) && !it.equals(caster) }
enemiesInAOE.forEach {
it.velocity = it.location.toVector()
.add(Vector(0.0, 0.5, 0.0).subtract(caster.location.toVector()).normalize().multiply(1.5))
}
it bugs out when its called
any suggestions?
?
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
finally
Has anyone got experience with modelEngineAPI? If so perhaps you could provide me with an example snippet to mess around with?
I have experience with both MEG3 and 4
Currently using 4, the idea is to create custom mobs that can be interacted with in terms of killing, taming, and breeding... got any tips for something like this?
So.. you want to reinvent MythicMobs
Making something with slimeworldmanager and got a bit confused how I could be ensured if the world has been loaded to bukkit before I try to teleport a player there?
that's a code snippet what I load the world with, ik I could put player.teleport into the bukkit scheduler sync task code block but it's not the case ```CompletableFuture<SlimeWorld> loadSlimeWorld = loadSlimeWorld(plugin, gameMap);
loadSlimeWorld.thenAccept(loadedSlimeWorld -> Bukkit.getScheduler().runTask(SpigotCore.getInstance().getPlugin(), () -> {
gameMap.setGameWorldName(clonedGameWorldName);
plugin.generateWorld(loadedSlimeWorld.clone(clonedGameWorldName));
World world = Bukkit.getWorld(gameMap.getGameWorldName());
for(String serializedLocation : gameMap.getCageSpawnPoints()) {
Location location = ServerLocations.deserializeLocation(world, serializedLocation);
GameMapConstructions.getInstance().spawnGameCage(location, false);
}
}));```
what is the problem with putting the teleport inside the sync task?
I think there is no way to have it separately? Well as for me rn I have a minigame. When a player joins the server and there is no game loaded rn, then we create a new game, in the minigame class constructor we call a method loadGameWorld(); and then we return the game's class object and teleport the player who joined to the world
lemme know if you need more clarification because I believe I poorly explained it
as for now when player 1 connects to the server and it loads the game for the first time, it teleports the player 1 to regular world, but when player 2 joins he is properly teleported to the world where he is supposed to be because it was loaded before he joined
well
just save the gameworld uuid somewhere
if its there. a world is loaded and u can teleport
else. load a world
I mean I could do something like that but because the slimeworld is loaded on another thread I would have to use delayed runnable every a few ticks to ensure if the world has been loaded or not and it doesn't feel like a good solution
no u dont?
when the first play joins, load a world and populate a uuid var with the uuid of the world. whenever a player joins check if the var is already poplulated. if it is get the world using the uuid and teleport
no runnables needed. unless im not understanding u correctly
yes but when the first player joins how do I know when the world is already loaded or not? The slimeworld is loaded on another thread and the player is teleported on the main server thread, as the result when I try to teleport the player 1 the world is not really loaded yet
by either doing teleporting inside the thenAccept future, or calling some callback from there
you could also consider using WorldLoadEvent but idk if thats such an elegant solution
Okay, I think I will modify my world loading code to be able to teleport players correctly inside the thenAccept, thanks
personally i just load the world blocking since its a minigame there isnt anything else to do anyway
but that might obviously differ for you
I tried loading slimeworld on the main thread but it was throwing me exceptions and in their docs they highly recommend to do this async
yea i assume ur also using the new advanced slime world manager
i did this using the old one
I am on the old one
if you think it's gonna work sync I will try this once I come back home
it works for me
u gotta make sure u have async loading off tho
in swm config
else it aint gonna work
this is what i did
listening to all the events like this, will cause lags right ? ``` @Override
public void onEnable() {
RegisteredListener registeredListener = new RegisteredListener(this, (listener, event) -> System.out.println(event.getEventName()), EventPriority.NORMAL, this, false);
for (HandlerList handler : HandlerList.getHandlerLists())
handler.register(registeredListener);
getServer().getPluginManager().registerEvents(this,this);
}
Ideally this is not how it should be done
Under IDEAL circumstances you have a uh
game of each type
or like a game service managing stuff
For example the way I usually do it is that I have a dedicated game service application that takes care of creating games on game servers
And if a game starts another is created on "the best" server
It's also responsible for matchmaking to the game with the most players with the given params (game type / preferred map / where party members are at etc)
That way you never have to create a game for a player, but rather assign a player to a given game
No, only if the listeners have substantial compute needed
Well there are a lot of events
Otherwise it’s just calling an empty method
YeH, still not a good idea but it wont lag
it is just for testing i won't use sout
If you assume 10 microseconds for each sout and a few thousand events you're already at milliseconds
If I was to make something like hypixel with many minigames and subminigames like Skywars (Solo Skywars, Doubles skywars etc...) would the hierarchy below be okay? I assume that each point is a separate project module. Also, they are dependent on each other hierarchically, e.g SpigotCore extends Core, SkywarsCore extends SpigotCore, etc...
Core (redis, db)
- ProxyCore
- BungeecordPlugin
- SpigotCore
- SkywarsCore
- SoloSkywarsPlugin
- DoublesSkywarsPlugin
- RankedSkywarsPlugin
- SkywarsCore
Looks fine to me, as long as it’s modular
Might be worth waiting for the new update with transfer packets, going to change proxies as a whole
Or just have a separate application to handle the proxy stuff and abstract it a bit
Uh
IIRC the way I do it is uh
- Common
- GameService
- Spigot
- Lobby
- Game Server
- Proxy
- Velocity Plugin
uh
how tf do I do indent list
Wouldn‘t it be possible to use a record instead of a class with lombok @Data?