#help-development
1 messages · Page 2052 of 1
No idea
because theres one other plugin, with the uppercase start
and it has two registrations for bukkit and sponge
I thought you could since they use a numeric ID, but maybe not
duplicate names are not allowed
bruuhh
Im not exactly implementing auto pickup (More or less, im fixing a bug with our plugin working with other auto pickup plugins), also im not able to use this event as it doesnt exist in earlier versions (Our current plugin is supporting down to 1.8 sad times)
At the moment im just trying to get the return value of this method, but seems like im unable to retrieve this value once its modified by another plugin before it
anyone?
step 1 -> step 3
2 is a lame number anyway
couldnt call it carbon sad
jezus
they decompiled the entirety of minecraft into one package
?
I'm trying to check if the dead person dies from falling into void will keep the item but it seems I'm wrong somewhere, someone help me :/
do you plan on putting any logic in this listener if the played didn't die to the void?
Use the death event and getLastDamageCause
if not, please make the first if statement like flipped (!(e.getEntity() instanceof Player)) and return after that
Also use the normal damage event if you decide to go that route
The void is not an entity
ok tks
how would I go about parsing JSON into an object with non-primitive types?
I'm currently using some crappy methods to transform it, but it isn't the best looking code
well im not close for being good at using regex but let me explain what's going on
im making my own placeholders using this regex (?<=\${)(.*?)(?=})
so for example everything between ${placeholder} returns.
and i need to get rid of whitespaces in it and my brain is completely stopped and I have no clue how am i gonna do it
match.replace(" ", "");?
i don't wanna replace them. I wan regex to detect their existence at all
You need to apply your placeholder regex first, then get the match, then replace the chars
There is no way you can do both in one method call that I know of
Unless you want to have Hello ${title surname}! to be equal to Hello ${title}${name}!
At that point uh, idk
i just don't want ${title example} to be there
actually i would like to see how that works
With a regex like \${(([^ ])+(?: )*)+} you can just match the second capturing group afaik. Idk if it works as I think it does in java
hmm i should test that
It's important that you do not obtain the result of the entire regex but just the second capture group (i. e. the ([^ ]) part)
(?<=\${)([^ ])(?=})
there
fixed it
actually
not exactly
it will just stop if it finds and return what it got so far
well in that case i would rather use geol's way if it worked as it's more easier for people to understand
ohk
Still up in the air, how come sending this component only sends the first text section?
new ComponentBuilder("████████").color(ChatColor.of("#f800f8")).append("████████").color(ChatColor.of("#000000")).create()[0],```
hey
I am having this issue:
package com.zadroit.prestige.commands;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PrestigeCommands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] strings) {
if ((sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
// /creative command
if (cmd.getName().equalsIgnoreCase("creative")) {
player.setGameMode(GameMode.CREATIVE);
}
return true;
}
}
this doesnt change my gamemode. (Sorry if this is a dumb question, im really new to coding)
Every appended component should be part of the extra tag, no?
tag ?
Not a seperate component
Then how do I append it as a extra instead
text is never extra
You aren’t checking the command right
What is the exact command you have to type?
Including text and translatable components
/creative
How are you registering the command?
@Override
public void onEnable() {
PrestigeCommands commands = new PrestigeCommands();
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "Prestige Commands is enabled.");
getCommand("creative").setExecutor(commands);
}```
There’s no reason for you to check what the command is then
Since it will only run if they use /creative
so I remove these lines?
Remove all if statements
And just set the game mode
It can’t possibly be anything other than /creative so no need to check anything
I mean you can keep the player instance check just nothing to do with the command itself
it shows me errors
Like?
package com.zadroit.prestige.commands;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PrestigeCommands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] strings) {
}
Player player = (Player) sender;
// /creative command
player.setGameMode(GameMode.CREATIVE);
}
return true;
}
}
oh
That shouldn’t be there
Also keep the player instance check
Don’t want the console thinking it’s a player now!
so just this right:
if ((sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
// /creative command
player.setGameMode(GameMode.CREATIVE);
return true;
}
}
You need a !
oh yeah
if (!(sender instanceof Player))
Yep
alright
thanks a lot
Np
also
.
one more quesetion
alias a different java binary to the java command ?
I had an issue when using api version 1.18.2
Currently I just set it to 1.14 and it is working
or put the location of the different java binary first in your $PATH
for API you want 1.18.2 :/
else you are missing out on any new features
yea
that doesn't even accept 1.18.2 o.O
I don't really care if you call it extra or children, I just need to combine the two components into one
also @halcyon mica i see what you meant by extra
No they’ve always only accepted just the base ones in my experience
Basically, you wrap the resulting component array in a single components as pure extra
the component builder is trash
look at adventure maybe
if has a spigot platform
and does this a lot nicer
tho, spigot does expose a method that takes a component array
so you could just throw that array at the sendMessage method
How I can do it ?
Ah. I mean just wrap it all in a single component
Might be a lot easier than writing your own framework
Just Google bash aliasing
keep alive plugin messaging channel any chance?
🤔
this is ridiculous how you cannot receive plugin messages when there are no players online
what
Plugin messages suck ass
Use sockets or something
Just handle the custom payload package manually
Or some pub/sub system
alr so no other way round for plugin messaging channel?
Tons out there
No
damn i see thx
If you want to interact with the vanilla client, no
hope they just make a plugin messaging channel without hijacking a player connection
Prob not
°
There’s many other alternatives
^
Uh
That are way better than plugin message channels
Plugin channels literally exist to talk to a individual client explicitly
Anyone know?
Yea
I mean. People use them for cross.server network communication
For which, just use pub/sub
^pubsub does need a redis backend though
Yea but they’re unreliable
Because player has to be online
Really if you think about it there no reason to ever use them
Yea redis is good
I like sockets just cuz I’ve used them a lot 😩
In worst case you could go with a duct taped server socket impl, since even that would be a bit more reliable than pmc (for mqs)
is there a way to remove a spawned falling block mid air?
the thing I made is working
now I want to make the exact same thing but for survival mode:
package com.zadroit.prestige.commands;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PrestigeCommands implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] strings) {
if (!(sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
// /creative command
player.setGameMode(GameMode.CREATIVE);
return true;
}
}
Can you give me link to spigot forum or github because i dont understand how to do it with scoreboards
how do i get the uuid of a spawned falling block?
Well just make another command class
Usually from some event ?
I think you are confused about the command system tbh
Falling blocks fire a bunch
yes
You can’t put the two different commands in one class
No he’s just doing /creative
And /survival
Which he could either make two classes for or just check it in player command pre process
But to me the second option is ugly
just to confirm, I have to do that for every command yes?
Yes if they are separate commands
alright
thanks again
If you do something like /gm creative
Or /gm survival
Then you only need one class
Since the base command is /gm
i created a tester and it didnt go v well tbh
Tho honestly you could just edit the commands file in your server
You don’t need a plugin for this
You can make /creative an alias for /gamemode creative
And same for survival
how about if i want it to not be placed? I'm sorry if i worded it incorrectly, #spawnFallingBlock places the block in the location and im wondering if its possible to just be the effect (or illusion if you would say) of the block falling and not it being placed at the end of the animation
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityChangeBlockEvent.html is triggered
declaration: package: org.bukkit.event.entity, class: EntityChangeBlockEvent
How do you go about reading the ProtocolLib docs with this bug? https://github.com/dmulloy2/ProtocolLib/issues/1334
when a falling block turns solid
sorry but another nooby question
how about bungeecord messaging channel?
does it work without players online?
you can listen to it and cancel it
no
1 player must be online
oh i see, thanks
hello guys. What does it mean?
oh i see,thx a lot
yes they truly do
error:
Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.zadroit.prestige.Prestige.getCommand(String)" is null
code:
package com.zadroit.prestige;
import com.zadroit.prestige.commands.PrestigeCreative;
import com.zadroit.prestige.commands.PrestigeSurvival;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
public class Prestige extends JavaPlugin {
@Override
public void onEnable() {
getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "Prestige Commands is enabled.");
getCommand("creative").setExecutor(new PrestigeCreative());
getCommand("survival").setExecutor(new PrestigeSurvival());
}
@Override
public void onDisable() {
getServer().getConsoleSender().sendMessage(ChatColor.RED + "Prestige Commands is disabled.");
}
}
is the command in plugin.yml?
Did you add the command to your plugin.yml
Register the command in your plugin.yml
Omg
Lol
Stupid autocorrect
ok thx
yeah:
name: Prestige
version: 1.0
author: Zadroit
main: com.zadroit.prestige.Prestige
api-version: 1.18
commands:
creative:
description: Allows you to go into creative mode.
usage: /<command>
aliases: c
survival:
description: Allows you to go into survival mode.
usage: /<command>
aliases: s```
You tabbed it wrong man
fix the indents
Lol yea
Been there
Annoying how they’re different for bungee and spigot
Or
No
Bungee doesn’t even have that
I’m thinking of the depends and depend
Which I have mixed up
how?
I mean like what do I need to do
let them figure it out
See how it’s underneath creative
like this?
commands:
creative:
description: Allows you to go into creative mode.
usage: /<command>
aliases: c
survival:
description: Allows you to go into survival mode.
usage: /<command>
aliases: s```
i aint?
This channel is for helping. If you have a problem then stop talking
Keep the creative and survival in line with each other
commands:
creative:
description: Allows you to go into creative mode.
usage: /<command>
aliases: c
survival:
description: Allows you to go into survival mode.
usage: /<command>
aliases: s
yes but people need to learn
not get spoon fed
thanks
Okay and he’s going to learn by us showing him the right way
Keep your comments to yourself
its not really spoonfeeding
I understand
so everything is going to be always in the correct indent
its just formatting, i would understand if its spoonfeeding if its anything related to writing techincal code
yeah I didn't know
thanks for letting me know
No problem
yeah but don't give them the actual fixed yaml, tell them how indentation in yaml works, imo that would be even more beneficial
How?
It wasnt working so I was confused then I saw I forgot to build it lmao
He literally understands now
its for visualization
People learn in different ways
because if you apply yourself and try to fix it on your own its easier to remember
k
He had a problem and we helped him fix it
its just a little help indentation works with visualization
but if someone teaches you, it sticks better
Got a problem? Keep it to yourself if you aren’t helping
Is there a way to change the velocity of World#spawnFallingBlock? I want it to go other vector directions other than the default downward vector
tbh you learn much more digesting it after memorizing the syntax and everything
Everyone learns different tbh. There’s not just one right way to do it or a best way
Either way I’m sure after this he will remember 😂
yeah lol
Isn’t it an entity? Can’t you just set the velocity of the entity?
Haven’t really messed with falling blocks so correct me if I’m wrong
By how much do I have to move a armorstand downwards for the nametag to be at the position where the entity would usually be?
the problem is the only thing you can pass on to #spawnFallingBlock is its Material and block data
Centered verticially
i'm not too sure how to get the Entity of the block
Hmm listen for entity spawn maybe at the position you spawned it
Then set velocity?
Maybe trial and error 😛
The spawnFallingBlock method returns you the created entity XD
No need for weird entity spanw event shenanigans
I answered this a few days ago lmao what,
<#help-development message>
Lol
That’s kinda what I meant by what I said before
That only accounts for centering the thing relative to the block
But I'm not refering to the block grid here
I have a position and I need the nametag to be at that position
so do i just do World#spawnFallingBlock.setVelocity(Vector)?
Yes
Yea spawnfallingblock returns the FallingBlock object which is an entity
I guess it's time to check the client source again
Huh
Just grab the armor stands hitbox and divide by 2 ? o.O
after that, make it a marker and you can even ignore any height on the armor stand
I need help
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Well, making it a marker also breaks lighting on equiped items
So that doesn't work
the issue is I don't know where to start. I have just done this:
package com.zadroit.prestige.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PrestigeTelport implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] strings) {
if (!(sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
// /tp command
player.teleport(player);
}
declaration: package: org.bukkit.entity, interface: Entity
Hi,
I want to buy a plugin
But I can't pay my bill just because I'm using PayPal whose currency is USD
So what should I do now?
yeah
for there on out you can calculate its centre
I totally understood that
Bukkit.getPlayer
For trying to parse a player from a string name
So you want like /tp <name> right?
If you ever want to be able to actually make plugins you gotta start learning the api using docs videos whatever and try some stuff yourself
Problem solving man
yeah
/tp <name> <name>
OK, it's NametagCenterY = OriginY + EntityHeight + 0.5 + 0.109375
ah
could you send the doc link
I think you know how to teleport people
Your problem is understanding how to get the names from the command and use them
According to client source, the label renderer offsets the matrix by the hitbox height + .5
The height of the nametag is 1 / 16 * 3.5 so this should be what I need to offset it by
I just create a variable called player and store the value there?
or object
Well you have to use the string[] strings variable to get the names
That’s what stores all the command arguments
It’s an array of arguments that comes after the initial command
ah ok
that explains it better
Sometimes tinkering a bit with what you have instead of asking for help right away is the better route
You’ll understand better what you’re dealing with
yeah I should try it myself
and ask as a last resort
So if you’re stuck maybe try debugging
Printing out all your variables you see to the console
Etc
I’m sure you didn’t know what the string[] strings was :p
Maybe rename it to String[] args so you remember what it’s for
Yep
Exactly
Yea dont be like the last guy and get arrayindexoutofbounds!!!
What are your guys thoughts on the best way to get user input
I’m making a jukebox record player plugin and trying to think of how I want the player to be able to add to the list of allowed players to use the jukebox
Wellllll
I mean like maybe using a GUI 😭
But they’re so ugly
Like the anvil gui has a text box
so this is what I do right?:
String arg = null;
Player target = Bukkit.getPlayer(!arg);```
arg is null and it looks for if it is not null
Yea I was thinking that. I’m a big fan of having as little commands as possible because players are naturally not smart at interacting with plugins
But that might be the best route
I placed the ! wrong
Get rid of the !
sorry
yeah I will
I wonder
Is it possible to avoid the lighting issue when a armorstand clips into the ground?
🤔
That's probably a rendering engine issue so I assume not
LWJGL issue most likely
im getting this huge error (2 errors to two different events) can i get the lines at which this is caused by and also why its caused?
do you mean make he darkness?
i believe it is the red marked block
that is causing the problem
i have no idea why
Yep, checks out
First error is at Gui class line 192
Second one is ParticleShoot class at line 46
can i ask how are you telling the lines
It’s in the stack trace man
ParticleShoot.java:46
You can trace each line back and find the issue like that
It starts with SpellManager line 80
Then goes to particle shoot line 46
And something is null there
how do i relocate a package with paperweight-userdev version 1.3.5
i tried
shadowJar {
relocate '*' '*'
}
but it doesnt seem to work
That's a paper thing. They have a discord you can ask in
this to be exact
oh thanks
Verify your account maybe
Idk why I said maybe
That’s exactly what you need to do
hello guys, how i can make <text> argument for command?
i wrote that, but it doesnt work
so now that I am verfied, I should use this one right
I think this is the one I need
alr
sigh. text += and use a stringbuilder
the i == as well
I dont know java
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Oof
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Haha
Intellij is literally crying over that code
Now now
Don’t roast him too much 😭
and how i can make that
you can hover the highlighted area it will tell you what is wrong
Sometimes the "issues" it highlights are just intellisense being not so intelligent
boolean learnJava = true;
My man
glass houses bro
do we got here any dudes who speak in binary
01101110 01101111
01111001 01100101 01100001 01101000 00100000 01001001 00100000 01100100 01101111
If I use a website to convert it then yes
Lol
Lets say i have a number 12, least significant digit of number 12 is 2, is it true that the least significant byte will consist of the digit 2 in this case?
Is there a empty space character that has the same width as █?
🤨
should be, but 99% of unicode chars are not rendered in minecraft's chat.
yeah
this
Can you put it in a codeblock
sure
assert !inv.ItemQueue.isEmpty(); im making sure that the queue is not null yet the current item is still null
oh wait
harry potter's cloak
its not the same width as that one xd
yeah
@quaint mantle im lost bro
assert should stop the method
isnt assert suited for debugging
The null line was 46 right?
Don't use assert
assert is ignored at runtime
Yea just check if it’s empty in an if statement 🤔
well i haven't used assert in java but in c langs they're pretty great since you can catch errors in debug builds, while asserts are not being compiled on release builds, thus saves cpu power on useless if statements
assert needs a cmd line argument to function
imagine if our brains had terminal
yeah im trying to save time using assert since the operation of launching the armorstand is factorial O(!n)
Yeah but assert doesnt do anything so of course it's saving time
It even accounts for all the unicode spaces
yeah i have to get this atleast to O(n) or Linear time its hella slow
if 1 if statement causes that much lag then I assure you the if statement is not the issue
its not the if statement alone its the entire method
ya know i was trying to filter out some useless code
Hey hey, is there a way to detect when a command block is executed?
Then use an if statement
ah ty let me give that a try
Technically that just checks if a command was sent from a block but is there anything other than a command block that can send commands? I don’t think so
If you wanna get specific you can get the block from the BlockCommandSender
And check it’s type
Gotcha
How do you deal with items in ProtocolLib? I have done this so far but I can't seam to figure out how to change an ItemStack in to an ItemSlot.
// ProtocolLib setup
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
// Packet
PacketContainer packet = manager.createPacket(PacketType.Play.Server.ENTITY_EQUIPMENT);
ItemStack hat = new ItemStack(Material.PAPER);
packet.getByteArrays().write(0, EnumWrappers.ItemSlot.HEAD); // Helmet slot
packet.getItemSlots().write(1, hat);
You're trying to set the players helmet to paper?
well it'll have a custom model data later but, yes
Why not just set the players helmet to paper?
They still can't have both
this looks great
how do plugins like HMCCosmetics do it then?
why?: java.lang.ClassCastException: class org.bukkit.Location cannot be cast to class javax.xml.stream.Location (org.bukkit.Location is in unnamed module of loader 'app'; javax.xml.stream.Location is in module java.xml of loader 'bootstrap')
You're putting that in their slot either way, itll just disappear when they click it.
Idk what HMCCosmetics is
You imported the wrong location
i just want to to look like they have a hat on but keep the armour values of their armour
https://github.com/HibiscusMC/HMCCosmetics you can read their source to find out
I have that
int num = arenaSize + 1;
arenaSize++;
Arena a = new Arena((javax.xml.stream.Location) l,num);
arenas.add(a);
plugin.getConfig().set("Arenas." + num, serializeLoc(l));
List<Integer> list = plugin.getConfig().getIntegerList("Arenas.Arenas");
list.add(num);
plugin.getConfig().set("Arenas.Arenas", list);
plugin.saveConfig();
return a;
}```
But if i type (Location) it give an error like: ``'Arena(javax.xml.stream.Location, int)' in 'me.xsenny_.woolwar.Arena' cannot be applied to '(org.bukkit.Location, int)'``
I have been working on the teleportation command for a while now and no progress
I thought they used NMS not ProtocolLib xD
when I type (Location) and press enter, it automatic replace with (javax.xml.stream.Location)
Hm, maybe the Equipment packet just works differently than I thought.
'Arena(javax.xml.stream.Location, int)' in 'me.xsenny_.woolwar.Arena' cannot be applied to '(org.bukkit.Location, int)'
Yes we know
🤦
thats happen when I don't press enter
As you're typing select which one you want don't just hit enter
Yes org.bukkit
tbh what i'm asking is how to change an ItemStack in to an ItemSlot
i should try casting it...
Doubt it will work
A slot isn't a stack. A slot contains a stack but you can't just turn an itemstack into a slot
yes, i have set org.bukkit
okay, how do i make an ItemSlot with the extra info it needs and my ItemStack
What package does the itemslot class come from?
ProtocolLib
More specifically
if we could we'd be there 
:c
Then idk why your code isn't working. Looks fine to me.
I assume you do send the packet?
Oh i haven't tested it just the evil red squiggly lines strike again
and itemslot is an enum
idk what an enum is 😭
This beginner Java tutorial describes fundamentals of programming in the Java programming language
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
PacketContainer packet = manager.createPacket(PacketType.Play.Server.ENTITY_EQUIPMENT);
ItemStack hat = new ItemStack(Material.PAPER);
packet.getItemSlots().write(1, EnumWrappers.ItemSlot.HEAD);
packet.getItemModifier().write(2,hat);
I don't know the field indexes but I imagine it would be something like this
that's what i have, it's the hat item that is erroring
thats some complicated thing
for you to learn rn
you prob should learn basic java first
I probably know it just not the correct terminology because I learn better by learning while I'm doing a project. So i end up learning how to do it not what it's called
well
well depend where you need teleport
this is my entire code currently
package com.zadroit.prestige.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PrestigeTeleport implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
// /tp command
String arg = null;
Player target = Bukkit.getPlayer(args[0]);
if(target != null) {
//the target player is online
}
player.teleport()
return true;
}
}
hmm maybe if return a empty list?
^ returning null defaults to server behaviour
which is just tab completing player names
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player)) {
return true;
}
Player player = (Player) sender;
// /tp command
Player target = Bukkit.getPlayer(args[0]);
if(target == null) {
player.sendMessage(ChatColor.RED + "Invalid Arguments, Player doesn't exist.");
return true;
}
player.teleport(target);
player.sendMessage(ChatColor.GREEN + "Teleport complete");
return true;
}
}
.
it was that simple?
yeah?
wow
Return Collections.emptyList()
thanks a lot
99% of the code is checks
You have to pass in an argument to teleport to
idk why u need a command for tping since /teleport and /tp exist
I need it for a server
Hi can anyone help me? https://paste.md-5.net/perisoteye.bash
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2
Sigh. learn how arrays work
how do i add an entry to an array?
arrays are fixed in size
i need a new array with an added entry
you replace an entry or you make a new arrya adding all the old values and the new
if want to be able to add and remove you need a List
yeah but to save it into the PDC i need an array
for(int i = 0; i < 6; i++){
grid[i] = color;
Bukkit.getServer().getScheduler().runTaskLater(Main.getInstance(), () -> updateGrid(), 60);
grid[i] = null;
}
I want to have an interval between every iteration of the for loop. Currently it just waits 3 seconds and executes all of the code
you can store anything in the PDC
this is my code ty
it doesn;t have to be an array
adding things to the PDC keep them as small as possible
yes, you can store absolutely anything in the PDC
Store a Consumer<T> for me :>
funny guy 🙂
gotta be the bukkit consumer tho 
damn, yes xD
will, you could store the ID of the ability in the PDC
just store the bytecode of your consumer in a byte array
btw one quick question, can you store an list in a PDC?
then load it using weird classloader magic
ElgarL thinks so
that can store lists in PDCs
lol
there it is xD
i have it but there aren't lists
there are arrays...
the last time you said that everything is serialized to a byte internally
nvm i can just join them by ,
please read the whole discussion. I know that there are arrays
for(int i = 0; i < 6; i++){
grid[i] = color;
Bukkit.getServer().getScheduler().runTaskLater(Main.getInstance(), () -> updateGrid(), 60);
grid[i] = null;
}
I want to have an interval between every iteration of the for loop. Currently it just waits 3 seconds and executes all of the code
you could use Runnables
instead of for
i would do like that if i were in your situation
sorry for my bad english
Ill try, thx
ofc there are lists
DataType.asList(DataType.ITEM_STACK)
just read the readme lol
i guess this is a newer version, in the one i'm using there isn't this method
2.0.0 added every possible kind of collection
When I run my code, in which I use the Player-Class, i become that error:
https://paste.md-5.net/efuvohuwam.bash
What can I do about that?
why are you using the nms Player btw?
the Error says that this class doesn't exist for the compiled jar
probably you haven't got the right imports
I don't know. I imported the bukkit-player:
import at.theduggy.project.npc.NPC;
import org.bukkit.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Random;
import java.util.UUID;
public class TestParticleCommand implements CommandExecutor {
public Location lastPos;
public double x =0;
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player) sender;
NPC npc = new NPC(player.getLocation(), UUID.randomUUID(), new Random(1000).nextInt(), "Typ");
return false;
}
}
this is weird
import at.theduggy.project.npc.NPC;
import org.bukkit.*;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;```
You dont need stuff in gray
prob
but thats not the reason
Yes like 100 times
try restarting the whole server
stop the server -> recompile the plugin -> start the server
I did that and it doesn't work
Are you remapping your plugin
yes
Make sure you use Maven to package your jar. I've seen too many people having the right pom but not using it
Yes i do i use the shade plugin
Safe to ignore if the command is in the plugin.yml
it isnt
wait
I mean
it is
Intellisense is not intelligence. It only knows what it's told
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "com.zadroit.prestige.Prestige.getCommand(String)" is null
That's because the plugin.yml is missing the command
I did add it:
name: Prestige
version: 1.0
author: Zadroit
main: com.zadroit.prestige.Prestige
api-version: 1.18
commands:
creative:
description: Allows you to go into creative mode.
usage: /<command>
aliases: c
survival:
description: Allows you to go into survival mode.
usage: /<command>
aliases: s
teleport:
description: Allows you to teleport to a player.
usage: /<command>
aliases: tpme```
To all the people from earlier saying he understands it I laugh at you
You attempt to register a command called teleportme when you register it in the yml as teleport
We were talking about the indentation
Not how to register a command
He clearly understand the indentation now
also he just mistyped a word
Well pointing to a resource to learn would help a lot more than just telling them
So I’m laughing at you actually
I'm laughing as well (not really)
Haha
Because obviously you didn't teach them how to actually learn how to solve their issue
Ok that made me actually laugh
they did
I just had a different issue this time
they didnt teach him how to spell and have a good memory
yeah I have a really bad memory
idk what u talking about
Looking for some good advice. what is the best way for me to sync some player-data among multiple game servers. i have a lobby for example and 4 servers connected where the "minigame" is played.
Use a database
redis
kek
lol
yea i got that far
Bunch of different ways
but what about people switching game server
Use a database
When they switch, load from database
well it will need to be saved first.
Yea
how does the other server know the data is up to date and ready to be loaded?
Or use redis or sockets or something to communicate
it does
not
just load it
yea i could use redis caching
it might not save quick enough
Well when the player joins a new server you load and when they leave you save
sure, but still presents the problem it might take too long to save
It might
yea i rlly cannot have that
Then lazy load
meaning?
No
Lazy loading is the practice of delaying load or initialization of resources or objects until they're actually needed to improve performance and save system resources.
well i could also use Redis pub/sub and work with some custom packets
would that be viable?
You could. Depends what data you're moving
how can i register standard parameters
like
/foo arg0 arg1
and set standard values for the args
like vanilla commands do
I highly recommend using a command library then
That's nms iirc
Hello, I need help, they have been attacking the server for several days, my modality is very rare, it is made full "RPGitems" FULL pvp in items with power, they attack me with "DOS" - "DDOS" and Bots so I don't know what to do I already have several days and well, it's getting complicated.
Please whoever can help can write me the prvado or tag me in the chat
Cloud, ACF or Commodore are good options
Or you just create your own tabcomplete
Working with Brigadier will give better results
#help-server not here
Sigh
hm
Create a tab complete if that's what you're asking
so my plugin is working fine on the server
but for some reason the teleport command only works on my personal server and not the server we need it on
there arent any other plugins that would conflict with it
Check the logs
Debug message time
oh theres an event to override the autocomplete list?
No you can make your own tabcompleter
is it a predefined callback like onCommand?
looks like this
and TabCompleter is a member of the bukkit/spigot api?
yes
Hello guys how are u?? sorry to join and ask but i'm struggling with something. I need to convert names to UUIDs. I'm doing a Rest request to mojang's api but for bedrocks users is not working. is giving me a 204 status code. Any ideas?
a functional interface specifically
https://www.toptal.com/developers/hastebin/ubuzebifiy.md Does someone know what this error is?
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
[18:42:18 ERROR]: cf-0.1.jar//me.katze.cf.main.getDB(main.java:217)
[18:42:18 ERROR]: cf-0.1.jar//me.katze.cf.gui.CFMenu.onItemGuiClick(CFMenu.java:108)
because to determine the uuid of players the server communicates with the auth server from mojang
and those(auth server) are most likely different for bedrock?
these your classes @elfin atlas ?
Also paper 
mye
prob not even the same interface
altho that could very much not be a factor
Don't do database stuff on the maint thread.
How would I do it on a other Thread?
I do database stuff in the main thread cause I'm a rebel
is there any way to get foreign language's unicode characters to show in minecraft? Here is what chinese looks like
Start your own thread or use the bukkit scheduler
i've been reading the api from mojang with no luck... they say just to hit that endpoint :/ so i cant find a good way to solve this... besides doing an on join and storing it somewhere
Example
if (!database.doesPlayerDiscordCodeMatch(player, code)) {
player.sendMessage(createReturnMessage("Invalid code"));
return;
}```
Use UTF8 characters
I am
They should display fine
they show up in intellij but not minecraft
Sounds like you might not be compiling with UTF8 then
one has to disassemble the bedrock server reverse engineer the mechanics used to communicate with the bedrock auth server, translate those methods into your custom java code and then call the bedrock auth server zhe same way as the bedrock mc-server would
CF Menu 108: Connection stmt = main.getInstance().getDB();
Main 217: return this.connection.getConnection();
``` Connection is a DataSource from Hikari I don't see any error
but im not suggesting to do that
they show in chat just fine but on items it is all funky
Thx
and i believe, no offense, that even fewer have the knowledge to do such
Thats what i thought... so ill have to create a custom store then... thabks for ur help!!
Minecraft supports this just fine. Somethings wrong on your end. Make sure to compile with UTF8
I have the build arguement -Dfile.encoding=UTF8 on, Is that enough?
how do you make an item that can’t be repaired?
stop the repair event
is there a simple way to know if two locations are adjacent?
i guess…
Are you using Maven or Gradle?
define adjacent
gradle
figured there would be a way to make it too expensive though
If that was for me? Not at all i thougth the same as you but well... i lost nothing for asking xD
;)
you have a total of 6 faces per block, 12 in total and at least 2 have to be touching
You can make it more expensive or you can prevent it all together
oh you mean like that
idk if adjacent is the right word
I mean check if the block x,y,z have a delta of 1 perhaps?
delta?
or if you could use getFacing (idr the name of that method)
@trail cape so concluded answer? stop bothering with the technically superior cuz cpp but modable inferior bedrock version and stick to java only.
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
Add this to your build file
I have that
lol
hm no idea then
i basically have this json
"Location{world=CraftWorld{name=working0},x=-58.0,y=1.0,z=61.0,pitch=0.0,yaw=0.0}": {
"level": 1,
"target": "Location{world=CraftWorld{name=working0},x=-60.0,y=1.0,z=61.0,pitch=0.0,yaw=0.0}",
"holding": {},
"filters": []
},
in this case blocks are not touchin (x -58, x -60)
so target is invalid
hmm alr
i mean eh, bedrock will unless they implement a callback inferface like spigot never be as good
and lets be honest
that will never happen
one way would be to use sth like
Location::getBlock
Block::getRelative
then use
Block::getLocation
and compare
why only toString and without fromString
yea the logic would be that loc1 (target) cannot be more than 1 number away in each case (x y z )
else you could just straight take the absolute value of x1-x2 and make sure that its equal to one
i think the absolute value could work
ye
with the difference
I suggest writing a couple of static utility methods with clear names to make it maintainable to work with
:3
Hi guys! Quick dev question: Is possible to have TranslatableComponent in item's lore? I need client-side translated Material names
or well if you want code review/code bullying (/s) then perhaps
oh no not with purely spigot afaik
So there is other way to achieve it?
NMS 😓
I'm working on a lib to do something like that
Any example of that? I am not really Pro in Spigot dev 😄
If you're using Paper you can use their API
Oh I am
You'd have to rebuild the item every time though.
Ah great it will make things easier
And do they have any documentation for that?
❤️ it’s truly amazing you’ve helped me so much with it in my plugins
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
Simply lore() and you use Adventure components. Read about them here: https://docs.adventure.kyori.net/
That doesn't do anything for translations though does it?
Seems to me that I can use normal Spigot components with this one: https://papermc.io/javadocs/paper/1.18/org/bukkit/inventory/meta/ItemMeta.html#setLoreComponents()
declaration: package: org.bukkit.inventory.meta, interface: ItemMeta
or yea... lore()
that one is deprecated
this should work theoratically right?
package com.zadroit.prestige.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PrestigeTeleport implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if ((sender instanceof Player player)) {
Player player = (Player) sender;
// the player who is the person typing the command
//checking if they provided an argument, which is needed for the command to work
if (args.length == 1) {
Player target = Bukkit.getPlayer(args[0]);
// gets the instance of the player we wanna tp to and saves it in the argument array
player.teleport(target.getLocation());
// finds the location of the provided player and teleports us there
}
}
return true;
}
}
no
you are casting the sender to player if the sender is NOT a player
smort
oh yeah I should remove the !
sender instanceof Player player ??
yes
its a neat lil feature
automatically assigns player to the casted sender
NOW it should work right?
oh
But he just assigns it anyways right after
bruh moment
Lol
decide on one of the 2
or use kotlin
even neater
sender is Player
and casted for you
I didn’t even know you could do that tbh
Any advise in BungeeCord RGB?
I'm too scared to change anything rn after like a lot of time cause I dont want to have 7 new errors
if(!(sender instanceof Player player)) return;
player.somePlayerMethod();
```In newer java versions
\u00a7x\u00a76\u00a76\u00a76\u00a76\u00a76\u00a76 returns gold color for client
I suggest for you just changing sender instanceof Player player to sender instanceof Player
Keep it simple
Without giving you more headaches
I've rewritten this cleaner if you want
Use the 2nd group, not the entire regex
package com.zadroit.prestige.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PrestigeTeleport implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!(sender instanceof Player player)) return;
// The "player" object is kept as a Player instance, rather than needing to manually cast
if(args.length == 0) {
// Send an error
return true;
}
Player target = Bukkit.getPlayer(args[0]);
if(target == null) {
// Send an error
return true;
}
player.teleport(target.getLocation());
// Send success
return true;
}
}
as you can see there's no need to manually cast
as it keeps the object in scope after the if statement
https://www.youtube.com/watch?v=UvhGFYaNFPE I'm working on translation stuff for a server I'm working on. Lmk if it's what you were looking for as well.
does any1 have a guide for creating custom entities/mobs in 1.18?
I just made this if there is a need for 2 players instead of one:
package com.zadroit.prestige.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class PrestigeTeleport implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if ((sender instanceof Player player)) {
// automatically assigns player to the casted sender
//checking if they provided an argument, which is needed for the command to work
// if they wanna do /tp tom
if (args.length == 1) {
Player target = Bukkit.getPlayer(args[0]);
// gets the instance of the player we wanna tp to and saves it in the argument array
player.teleport(target.getLocation());
// finds the location of the provided player and teleports us there
}
// if they wanna do /tp bob tom
else if(args.length == 2) {
Player playerToSend = Bukkit.getPlayer(args[0]);
//first guy
Player target = Bukkit.getPlayer(args[1]);
//second guy
playerToSend.teleport(target.getLocation());
//tp
}
}
return true;
}
}
and used your advice
no manual casting
I think it should work
hopefully
quick thing
yeah?
try to take your code outside if statements as much as possible when you can
so like
rather than
if(condition) {
stuff;
}
if you can't progress if that condition is true
then do this:
if(!condition) return; // optionally also send a message
stuff;
ah
public class PrestigeTeleport implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player player) || args.length != 0) return false;
Player target = Bukkit.getPlayer(args[0]);
if (target == null) {
// Send an error
} else {
player.teleport(target.getLocation());
}
return true;
}
}
Could clean it up a lot more
I see
ill screenshot this
so I remember
oh yeah
its really small now
public class PrestigeTeleport implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player player) || args.length == 0) return false;
Player target = Bukkit.getPlayer(args[0]);
if(target == null) {
// Send an error
return true;
}
player.teleport(target.getLocation());
return true;
}
}
even smaller
Oops it's != 1 
coding is fun
And how to translate Material by this?
I really love this
I was using LocaleLib but surely Kyori have own way
even tho I dont know much
I really love this
public class PrestigeTeleport implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player player) || args.length != 1) return false;
Player target = Bukkit.getPlayer(args[0]);
if (target == null) player.sendMessage(ChatColor.RED + "Unable to locate player" + args[0]);
else player.teleport(target.getLocation());
return true;
}
}
now he is gonna make it in 4 lines lol
wait
i got it
public class PrestigeTeleport implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player player) || args.length != 1) return false;
Player target = Bukkit.getPlayer(args[0]);
target == null ? player.sendMessage(ChatColor.RED + "Unable to locate player" + args[0]); : player.teleport(target.getLocation());
return true;
}
}
idk if i can go smaller
but its 4 lines instead of 5
damn
public class PrestigeTeleport implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player player) || args.length != 1 || Bukkit.getPlayer(args[0]) == null) return false;
else player.teleport(Bukkit.getPlayer(args[0]).getLocation());
return true;
}
}
If you sacrifice the error message
are you challenging me?
public class PrestigeTeleport implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
return sender instanceof Player && args.length > 0 && Bukkit.getPlayer(args[0]) != null ? ((Player)sender).teleport(Bukkit.getPlayer(args[0]).getLocation()) || true : false;
}
}
there
2 lines rather than 3
hold on
there
1 line
with error message
can't top that can you?
Your code has to work in order to be topped
fixed it
basically
they are fighting on making my code short
the condition was wrong
here is my version
yeah its just fun tho
here is my latest version
Ah ok
now
I think its clear who won
Except you're not using player