#help-development

1 messages · Page 2052 of 1

glossy venture
#

?

#

can you not have duplicate plugins?

#

like globally on bstats

young knoll
#

No idea

glossy venture
#

because theres one other plugin, with the uppercase start

#

and it has two registrations for bukkit and sponge

young knoll
#

I thought you could since they use a numeric ID, but maybe not

glossy venture
#

maybe

#

guess ill call it carbon loader

tender shard
#

duplicate names are not allowed

glossy venture
#

bruuhh

noble lantern
#

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

modern vigil
#

anyone?

glossy venture
#

step 1 -> step 3

young knoll
#

2 is a lame number anyway

glossy venture
#

couldnt call it carbon sad

#

jezus

#

they decompiled the entirety of minecraft into one package

modern vigil
#

?

rigid cradle
#

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 :/

modern vigil
#

do you plan on putting any logic in this listener if the played didn't die to the void?

young knoll
#

Use the death event and getLastDamageCause

rigid cradle
#

ok

#

I will try

modern vigil
#

if not, please make the first if statement like flipped (!(e.getEntity() instanceof Player)) and return after that

young knoll
#

Also use the normal damage event if you decide to go that route

#

The void is not an entity

rigid cradle
#

ok tks

modern vigil
#

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

topaz cape
#

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

quiet ice
#

match.replace(" ", "");?

topaz cape
#

i don't wanna replace them. I wan regex to detect their existence at all

quiet ice
#

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

topaz cape
#

hm

#

i can just return if they contain white spaces currently i guess

quiet ice
#

Unless you want to have Hello ${title surname}! to be equal to Hello ${title}${name}!

#

At that point uh, idk

topaz cape
#

i just don't want ${title example} to be there

topaz cape
quiet ice
#

With a regex like \${(([^ ])+(?: )*)+} you can just match the second capturing group afaik. Idk if it works as I think it does in java

topaz cape
#

hmm i should test that

quiet ice
#

It's important that you do not obtain the result of the entire regex but just the second capture group (i. e. the ([^ ]) part)

topaz cape
#

doesn't seem to be working yet

#

ill have to retest that in game

rough drift
#

there

#

fixed it

#

actually

#

not exactly

#

it will just stop if it finds and return what it got so far

topaz cape
rough drift
#

ohk

halcyon mica
#

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],```
unique geyser
#

hey

eternal night
#

Well you are extracing the first component from it ?

#

The [0] part

unique geyser
#

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)

halcyon mica
eternal night
#

tag ?

halcyon mica
#

Not a seperate component

eternal night
#

they are

#

your append appends a new component

halcyon mica
#

Then how do I append it as a extra instead

eternal night
#

text is never extra

quaint mantle
#

What is the exact command you have to type?

halcyon mica
#

So this is just a limitation of the bungie api then

#

Alright, nms it is

eternal night
#

no ?

#

NMS would do the same

halcyon mica
#

It does not

#

Anything can be extra

eternal night
#

it does

#

wat ?

halcyon mica
#

Including text and translatable components

unique geyser
eternal night
#

do you mean children ??

#

like child components ?

quaint mantle
unique geyser
#
@Override
    public void onEnable() {
        PrestigeCommands commands = new PrestigeCommands();
     getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "Prestige Commands is enabled.");
     getCommand("creative").setExecutor(commands);
    }```
quaint mantle
#

There’s no reason for you to check what the command is then

#

Since it will only run if they use /creative

unique geyser
#

so I remove these lines?

quaint mantle
#

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

unique geyser
#

it shows me errors

quaint mantle
#

Like?

unique geyser
#
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;
    }
}
quaint mantle
#

Lol

#

You left in some brackets

unique geyser
#

oh

quaint mantle
#

That shouldn’t be there

unique geyser
#

yeah

#

lol

quaint mantle
#

Also keep the player instance check

#

Don’t want the console thinking it’s a player now!

unique geyser
#

so just this right:

        if ((sender instanceof Player)) {
            return true;
        }
        Player player = (Player) sender;

        // /creative command
            player.setGameMode(GameMode.CREATIVE);
        return true;
    }
}
quaint mantle
#

You need a !

unique geyser
#

oh yeah

quaint mantle
#

If the sender is NOT instance of player

#

Then it looks good

unique geyser
#

if (!(sender instanceof Player))

quaint mantle
#

Yep

unique geyser
#

alright
thanks a lot

quaint mantle
#

Np

unique geyser
#

also

safe edge
#

.

unique geyser
#

one more quesetion

eternal night
#

alias a different java binary to the java command ?

unique geyser
#

I had an issue when using api version 1.18.2
Currently I just set it to 1.14 and it is working

eternal night
#

or put the location of the different java binary first in your $PATH

quaint mantle
#

Yea

#

1.18

eternal night
#

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

halcyon mica
#

I don't really care if you call it extra or children, I just need to combine the two components into one

eternal night
#

also @halcyon mica i see what you meant by extra

quaint mantle
#

No they’ve always only accepted just the base ones in my experience

eternal night
#

Basically, you wrap the resulting component array in a single components as pure extra

#

the component builder is trash

halcyon mica
#

I can tell

#

I'll just set up my own

eternal night
#

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

safe edge
halcyon mica
#

Well, it's not used to send an array

#

It's nametag formatting

eternal night
#

Ah. I mean just wrap it all in a single component

#

Might be a lot easier than writing your own framework

eternal night
solid forge
#

keep alive plugin messaging channel any chance?

quaint mantle
#

🤔

solid forge
#

this is ridiculous how you cannot receive plugin messages when there are no players online

quaint mantle
#

What

#

My guy

solid forge
#

what

quaint mantle
#

Plugin messages suck ass

eternal night
#

That's kind of bow they work

#

They just hijacke a player connection

quaint mantle
#

Use sockets or something

halcyon mica
#

Just handle the custom payload package manually

eternal night
#

Or some pub/sub system

solid forge
#

alr so no other way round for plugin messaging channel?

eternal night
#

Tons out there

quaint mantle
#

No

solid forge
#

damn i see thx

halcyon mica
#

If you want to interact with the vanilla client, no

solid forge
#

hope they just make a plugin messaging channel without hijacking a player connection

quaint mantle
#

Prob not

eternal night
#

°

quaint mantle
#

There’s many other alternatives

eternal night
#

^

halcyon mica
#

Uh

quaint mantle
#

That are way better than plugin message channels

halcyon mica
#

Plugin channels literally exist to talk to a individual client explicitly

sonic cosmos
#

Anyone know?

quaint mantle
#

Yea

eternal night
#

I mean. People use them for cross.server network communication

#

For which, just use pub/sub

halcyon mica
#

^pubsub does need a redis backend though

quaint mantle
#

Because player has to be online

eternal night
#

They are garbage for that yes

#

Hence redis/rabbitmq/something else

quaint mantle
#

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 😩

ivory sleet
#

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)

unique geyser
#

I need help again

#

so

valid solstice
#

is there a way to remove a spawned falling block mid air?

unique geyser
#

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;


    }

}
eternal night
#

If you have it's uuid you. An just remove it ?

#

With #remove()

sonic cosmos
#

Can you give me link to spigot forum or github because i dont understand how to do it with scoreboards

valid solstice
quaint mantle
eternal night
#

Usually from some event ?

quaint mantle
#

I think you are confused about the command system tbh

eternal night
#

Falling blocks fire a bunch

quaint mantle
#

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

unique geyser
quaint mantle
#

Yes if they are separate commands

unique geyser
#

alright
thanks again

quaint mantle
#

If you do something like /gm creative

#

Or /gm survival

#

Then you only need one class

#

Since the base command is /gm

topaz cape
quaint mantle
#

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

valid solstice
# eternal night With #remove()

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

eternal night
tulip owl
eternal night
#

when a falling block turns solid

solid forge
#

sorry but another nooby question
how about bungeecord messaging channel?
does it work without players online?

eternal night
#

you can listen to it and cancel it

valid solstice
ocean hollow
#

hello guys. What does it mean?

solid forge
#

oh i see,thx a lot

quaint mantle
#

Just forget about messaging channels haha they suck

#

Your array size is 1

solid forge
#

yes they truly do

quaint mantle
#

You need to look at array[0]

#

Array indexes start at 0

unique geyser
#

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.");
    }
}
valid solstice
quaint mantle
#

Did you add the command to your plugin.yml

eternal night
#

Register the command in your plugin.yml

quaint mantle
#

Omg

eternal night
#

Lol

quaint mantle
#

Stupid autocorrect

ocean hollow
#

ok thx

unique geyser
#

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```
quaint mantle
#

You tabbed it wrong man

quaint mantle
#

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

unique geyser
rough drift
#

bruh

#

don't

#

reply

#

to them

unique geyser
#

I mean like what do I need to do

rough drift
#

let them figure it out

quaint mantle
#

You have to move the indent to the left

#

Of survival

rough drift
#

dude

#

don't

#

let them

#

figure it out

quaint mantle
#

See how it’s underneath creative

unique geyser
#

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```
rough drift
#

i aint?

quaint mantle
quaint mantle
valid solstice
#
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
rough drift
#

not get spoon fed

quaint mantle
#

Okay and he’s going to learn by us showing him the right way

#

Keep your comments to yourself

valid solstice
unique geyser
#

I understand
so everything is going to be always in the correct indent

quaint mantle
#

Yep

#

That’s how yml works

#

Very strict on formatting

valid solstice
#

its just formatting, i would understand if its spoonfeeding if its anything related to writing techincal code

unique geyser
#

yeah I didn't know
thanks for letting me know

quaint mantle
#

No problem

rough drift
#

yeah but don't give them the actual fixed yaml, tell them how indentation in yaml works, imo that would be even more beneficial

quaint mantle
#

How?

unique geyser
#

It wasnt working so I was confused then I saw I forgot to build it lmao

quaint mantle
#

He literally understands now

quaint mantle
#

People learn in different ways

rough drift
#

because if you apply yourself and try to fix it on your own its easier to remember

quaint mantle
#

….

#

Just stop talking

rough drift
#

k

quaint mantle
#

He had a problem and we helped him fix it

valid solstice
#

its just a little help indentation works with visualization

unique geyser
quaint mantle
#

Got a problem? Keep it to yourself if you aren’t helping

valid solstice
#

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

solid forge
#

tbh you learn much more digesting it after memorizing the syntax and everything

quaint mantle
#

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 😂

unique geyser
#

yeah lol

quaint mantle
#

Haven’t really messed with falling blocks so correct me if I’m wrong

halcyon mica
#

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?

valid solstice
halcyon mica
#

Centered verticially

valid solstice
#

i'm not too sure how to get the Entity of the block

quaint mantle
#

Hmm listen for entity spawn maybe at the position you spawned it

#

Then set velocity?

valid solstice
#

hmm ok

#

thanks

quaint mantle
eternal night
#

The spawnFallingBlock method returns you the created entity XD

#

No need for weird entity spanw event shenanigans

quaint mantle
#

Oh yea

#

Doesn’t it just return the block

worldly ingot
quaint mantle
#

I mean

#

Fallingblock

eternal night
#

Lol

quaint mantle
#

That’s kinda what I meant by what I said before

halcyon mica
#

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

valid solstice
#

so do i just do World#spawnFallingBlock.setVelocity(Vector)?

worldly ingot
#

Yes

valid solstice
#

ohhh its that simple

#

alright thanks

quaint mantle
#

Yea spawnfallingblock returns the FallingBlock object which is an entity

halcyon mica
#

I guess it's time to check the client source again

quaint mantle
#

Huh

eternal night
#

Just grab the armor stands hitbox and divide by 2 ? o.O

unique geyser
#

me again

#

now I am working on a TP command

eternal night
#

after that, make it a marker and you can even ignore any height on the armor stand

unique geyser
#

I need help

undone axleBOT
#

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!

halcyon mica
#

So that doesn't work

eternal night
#

oh

#

welp you have its hitbox

unique geyser
#

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);


}
eternal night
buoyant path
#

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?

unique geyser
#

yeah

eternal night
#

for there on out you can calculate its centre

unique geyser
#

I totally understood that

quaint mantle
#

Bukkit.getPlayer

#

For trying to parse a player from a string name

#

So you want like /tp <name> right?

river oracle
#

Problem solving man

unique geyser
#

yeah
/tp <name> <name>

quaint mantle
#

Yeaaa

#

Oh

halcyon mica
#

OK, it's NametagCenterY = OriginY + EntityHeight + 0.5 + 0.109375

unique geyser
undone axleBOT
unique geyser
#

thanks

#

ill check the teleport thing

quaint mantle
#

I think you know how to teleport people

#

Your problem is understanding how to get the names from the command and use them

halcyon mica
#

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

unique geyser
#

or object

quaint mantle
#

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

unique geyser
#

ah ok
that explains it better

quaint mantle
#

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

unique geyser
#

yeah I should try it myself
and ask as a last resort

quaint mantle
#

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

unique geyser
#

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
quaint mantle
#

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

quaint mantle
#

Get rid of the !

unique geyser
#

sorry
yeah I will

halcyon mica
#

I wonder

#

Is it possible to avoid the lighting issue when a armorstand clips into the ground?

quaint mantle
#

🤔

vocal cloud
#

That's probably a rendering engine issue so I assume not

topaz cape
#

LWJGL issue most likely

halcyon mica
#

HUh

#

Ironicially making it a marker fixes it

sage merlin
#

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?

minor garnet
sage merlin
#

i believe it is the red marked block

#

that is causing the problem

#

i have no idea why

halcyon mica
#

Yep, checks out

quaint mantle
#

Second one is ParticleShoot class at line 46

sage merlin
#

can i ask how are you telling the lines

quaint mantle
#

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

glossy venture
#

how do i relocate a package with paperweight-userdev version 1.3.5

#

i tried

shadowJar {
  relocate '*' '*'
}
#

but it doesnt seem to work

vocal cloud
#

That's a paper thing. They have a discord you can ask in

glossy venture
#

this to be exact

glossy venture
unique geyser
#

So I think this is the one I should use

#

oops

#

cant post images

quaint mantle
#

Verify your account maybe

#

Idk why I said maybe

#

That’s exactly what you need to do

ocean hollow
#

hello guys, how i can make <text> argument for command?

vocal cloud
#

huh

#

like /command this is the text

ocean hollow
#

i wrote that, but it doesnt work

unique geyser
#

so now that I am verfied, I should use this one right
I think this is the one I need

#

alr

vocal cloud
tardy delta
#

Your problem is

#

🥶

vocal cloud
#

the i == as well

ocean hollow
vocal cloud
#

Well

#

?learnjava

undone axleBOT
quaint mantle
#

Oof

undone axleBOT
quaint mantle
#

Haha

vocal cloud
#

Intellij is literally crying over that code

quaint mantle
#

Now now

vocal cloud
quaint mantle
#

Don’t roast him too much 😭

ocean hollow
#

and how i can make that

vocal cloud
#

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

unique geyser
quaint mantle
#

My man

vocal cloud
#

glass houses bro

mortal hare
#

do we got here any dudes who speak in binary

vocal cloud
#

01101110 01101111

unique geyser
quaint mantle
#

If I use a website to convert it then yes

unique geyser
#

dont reveal

quaint mantle
#

Lol

mortal hare
#

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?

halcyon mica
#

Is there a empty space character that has the same width as ?

quaint mantle
#

🤨

mortal hare
#

should be, but 99% of unicode chars are not rendered in minecraft's chat.

halcyon mica
#

Can you put it in a codeblock

unique geyser
#

sure

sage merlin
#

assert !inv.ItemQueue.isEmpty(); im making sure that the queue is not null yet the current item is still null

unique geyser
#

oh wait

mortal hare
#

harry potter's cloak

unique geyser
#

its not the same width as that one xd

halcyon mica
#

Yeah no

mortal hare
#

told you

#

half of them don't work

#

sadly

unique geyser
#

yeah

mortal hare
#

well if you force unicode font maybe it would work

#

idk

halcyon mica
#

I mean

#

It does work

#

It's just not the right width

sage merlin
#

assert should stop the method

mortal hare
#

isnt assert suited for debugging

quaint mantle
#

The null line was 46 right?

vocal cloud
#

Don't use assert

sage merlin
#

ye

#

very well

eternal oxide
#

assert is ignored at runtime

quaint mantle
#

Yea just check if it’s empty in an if statement 🤔

mortal hare
#

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

vocal cloud
#

assert needs a cmd line argument to function

mortal hare
#

imagine if our brains had terminal

sage merlin
#

yeah im trying to save time using assert since the operation of launching the armorstand is factorial O(!n)

halcyon mica
#

ffs

#

Why does MC have to filter out more than one space

#

It's bs

vocal cloud
#

Yeah but assert doesnt do anything so of course it's saving time

halcyon mica
#

It even accounts for all the unicode spaces

sage merlin
#

yeah i have to get this atleast to O(n) or Linear time its hella slow

vocal cloud
#

if 1 if statement causes that much lag then I assure you the if statement is not the issue

sage merlin
#

its not the if statement alone its the entire method

#

ya know i was trying to filter out some useless code

hollow arch
#

Hey hey, is there a way to detect when a command block is executed?

vocal cloud
quaint mantle
#

Check it commandsender is instance of command block I think

#

BlockCommandSender

hollow arch
#

ah ty let me give that a try

quaint mantle
#

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

hollow arch
#

Yeah that's all I needed to know

#

ty

quaint mantle
#

Gotcha

tulip owl
#

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);
vocal cloud
#

You're trying to set the players helmet to paper?

tulip owl
#

well it'll have a custom model data later but, yes

vocal cloud
#

Why not just set the players helmet to paper?

tulip owl
#

i want to let the player still be able to use armour

#

as it's a hat

hasty prawn
#

They still can't have both

vocal cloud
#

this looks great

tulip owl
#

how do plugins like HMCCosmetics do it then?

desert tinsel
#

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')

hasty prawn
#

You're putting that in their slot either way, itll just disappear when they click it.

#

Idk what HMCCosmetics is

quaint mantle
tulip owl
#

i just want to to look like they have a hat on but keep the armour values of their armour

quaint mantle
#

“javax.xml.stream.Location”

#

Is wrong

vocal cloud
desert tinsel
# quaint mantle “javax.xml.stream.Location”

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)'``
unique geyser
#

I have been working on the teleportation command for a while now and no progress

quaint mantle
#

Why are you using the javax location

#

I told you it’s wrong

tulip owl
desert tinsel
#

when I type (Location) and press enter, it automatic replace with (javax.xml.stream.Location)

hasty prawn
#

Hm, maybe the Equipment packet just works differently than I thought.

quaint mantle
#

Well stop pressing enter

#

Who cares what automatically gets imported

desert tinsel
#

'Arena(javax.xml.stream.Location, int)' in 'me.xsenny_.woolwar.Arena' cannot be applied to '(org.bukkit.Location, int)'

vocal cloud
#

Yes we know

quaint mantle
#

🤦

desert tinsel
quaint mantle
#

Get rid of the javax part

#

Can you show your entire arena class

vocal cloud
#

As you're typing select which one you want don't just hit enter

quaint mantle
#

Yes org.bukkit

tulip owl
#

i should try casting it...

quaint mantle
#

Doubt it will work

vocal cloud
desert tinsel
#

yes, i have set org.bukkit

tulip owl
vocal cloud
#

What package does the itemslot class come from?

tulip owl
#

ProtocolLib

cobalt tinsel
#

?

vocal cloud
#

More specifically

vocal cloud
tulip owl
cobalt tinsel
#

:c

vocal cloud
#

shrug1 Then idk why your code isn't working. Looks fine to me.

#

I assume you do send the packet?

tulip owl
tulip owl
vocal cloud
#

what does the method require

#

jeez caps

tulip owl
vocal cloud
#

and itemslot is an enum

tulip owl
#

idk what an enum is 😭

vocal cloud
tulip owl
#

just googled it

#

so i do know what it is just not a fancy name for it xD

#

anyway

vocal cloud
#
        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

tulip owl
#

that's what i have, it's the hat item that is erroring

grim ice
#

for you to learn rn

#

you prob should learn basic java first

tulip owl
#

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

grim ice
#

No you dont

#

example is

#

you're static abusing

#

in the worst way possible

unique geyser
#

what am I supposed to do here?

#

I am making a /tp command

visual tide
#

well

late sonnet
visual tide
#

do you want to tp to an entity

#

or coordinates

unique geyser
#

yeah

#

entity

visual tide
#

then use teleport(entity)

#

and pass the entity to the method

unique geyser
#

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;
    }
}
late sonnet
#

hmm maybe if return a empty list?

eternal night
#

^ returning null defaults to server behaviour

#

which is just tab completing player names

grim ice
#
    @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;
    }
}
unique geyser
#

it was that simple?

grim ice
#

yeah?

unique geyser
#

wow

tardy delta
#

Return Collections.emptyList()

unique geyser
#

thanks a lot

grim ice
#

99% of the code is checks

quaint mantle
#

You have to pass in an argument to teleport to

grim ice
#

idk why u need a command for tping since /teleport and /tp exist

unique geyser
tardy delta
#

Yes

#

But empty list is already cached

#

So quicker

#

Np

midnight shore
vocal cloud
#

Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 2

midnight shore
vocal cloud
#

Sigh. learn how arrays work

midnight shore
#

how do i add an entry to an array?

eternal oxide
#

arrays are fixed in size

midnight shore
#

i need a new array with an added entry

eternal oxide
#

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

midnight shore
#

yeah but to save it into the PDC i need an array

plush gulch
#

 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

eternal oxide
#

you can store anything in the PDC

midnight shore
#

this is my code ty

eternal oxide
#

it doesn;t have to be an array

midnight shore
#

thats not how that work i guess

#

i could make it a byte

eternal oxide
#

adding things to the PDC keep them as small as possible

midnight shore
#

but not "anything"

#

btw thank you for the help

eternal oxide
#

yes, you can store absolutely anything in the PDC

eternal night
#

Store a Consumer<T> for me :>

eternal oxide
#

funny guy 🙂

eternal night
#

xD

#

tho anything that can be serialized/de-serialized would work

opal juniper
eternal night
#

damn, yes xD

modern vigil
#

will, you could store the ID of the ability in the PDC

tender shard
#

just store the bytecode of your consumer in a byte array

eternal night
#

if only there was a cool lib

#

with like

modern vigil
#

btw one quick question, can you store an list in a PDC?

tender shard
#

then load it using weird classloader magic

eternal night
#

LOL yes

#

I heard of a lib out there

midnight shore
eternal night
#

that can store lists in PDCs

tender shard
opal juniper
#

lol

eternal night
#

there it is xD

midnight shore
opal juniper
#

there are arrays...

midnight shore
#

the last time you said that everything is serialized to a byte internally

modern vigil
#

nvm i can just join them by ,

midnight shore
plush gulch
#

 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

midnight shore
#

instead of for

#

i would do like that if i were in your situation

#

sorry for my bad english

plush gulch
#

Ill try, thx

tender shard
#

DataType.asList(DataType.ITEM_STACK)

#

just read the readme lol

midnight shore
#

i guess this is a newer version, in the one i'm using there isn't this method

tender shard
#

2.0.0 added every possible kind of collection

midnight shore
#

whoah i'm at 1.1.0

#

why am i so low

#

i'm updating

quaint mantle
#

Ohhh I gotta update mine too

#

I love that library

manic furnace
midnight shore
#

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

manic furnace
#

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;
    }

}
midnight shore
#

this is weird

grim ice
#
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

midnight shore
#

did you reload the plugin?

#

sometimes it breaks the plugin

manic furnace
#

Yes like 100 times

midnight shore
#

try restarting the whole server

#

stop the server -> recompile the plugin -> start the server

manic furnace
#

I did that and it doesn't work

chrome beacon
#

Are you remapping your plugin

manic furnace
#

yes

chrome beacon
#

Make sure you use Maven to package your jar. I've seen too many people having the right pom but not using it

manic furnace
#

Yes i do i use the shade plugin

unique geyser
chrome beacon
unique geyser
#

wait

#

I mean

#

it is

vocal cloud
#

Intellisense is not intelligence. It only knows what it's told

unique geyser
#

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

vocal cloud
#

That's because the plugin.yml is missing the command

unique geyser
#

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```
vocal cloud
#

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

unique geyser
#

oh

#

yeah

#

my brain died

quaint mantle
#

We were talking about the indentation

#

Not how to register a command

#

He clearly understand the indentation now

grim ice
#

also he just mistyped a word

vocal cloud
#

Well pointing to a resource to learn would help a lot more than just telling them

quaint mantle
#

So I’m laughing at you actually

grim ice
#

I'm laughing as well (not really)

quaint mantle
#

Haha

vocal cloud
#

Because obviously you didn't teach them how to actually learn how to solve their issue

quaint mantle
#

Ok that made me actually laugh

unique geyser
grim ice
unique geyser
#

yeah I have a really bad memory

grim ice
#

idk what u talking about

quaint mantle
#

We literally showed him how to properly indent a yml file 😭

#

That’s it

tall dragon
#

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.

unique geyser
tall dragon
quaint mantle
#

Bunch of different ways

tall dragon
#

but what about people switching game server

vocal cloud
#

Use a database

quaint mantle
#

When they switch, load from database

tall dragon
#

well it will need to be saved first.

quaint mantle
#

Yea

tall dragon
#

how does the other server know the data is up to date and ready to be loaded?

quaint mantle
#

Or use redis or sockets or something to communicate

tall dragon
#

yea i could use redis caching

grim ice
#

when player leaves, save

#

when player joins load

tall dragon
vocal cloud
#

Well when the player joins a new server you load and when they leave you save

tall dragon
#

sure, but still presents the problem it might take too long to save

grim ice
tall dragon
#

yea i rlly cannot have that

vocal cloud
#

Then lazy load

tall dragon
#

meaning?

grim ice
#

load after an amount of time

#

for the save to finish

vocal cloud
#

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.

tall dragon
#

well i could also use Redis pub/sub and work with some custom packets

#

would that be viable?

vocal cloud
#

You could. Depends what data you're moving

tall dragon
#

would be all data related to the player

#

which would be quite a bit

granite owl
#

how can i register standard parameters

#

like

#

/foo arg0 arg1

#

and set standard values for the args

#

like vanilla commands do

chrome beacon
#

I highly recommend using a command library then

tardy delta
#

That's nms iirc

cobalt tulip
#

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

chrome beacon
vocal cloud
#

Or you just create your own tabcomplete

chrome beacon
#

Working with Brigadier will give better results

cobalt tulip
#

where can i find help?

#

a ok

vocal cloud
#

Sigh

granite owl
#

hm

vocal cloud
unique geyser
#

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

vocal cloud
#

Check the logs

chrome beacon
#

Debug message time

granite owl
vocal cloud
granite owl
#

is it a predefined callback like onCommand?

vocal cloud
#

looks like this

granite owl
#

and TabCompleter is a member of the bukkit/spigot api?

ivory sleet
#

yes

trail cape
#

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?

ivory sleet
#

a functional interface specifically

granite owl
#

aight teye

#

gonna try that in a sec

elfin atlas
ivory sleet
#
[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)
granite owl
#

and those(auth server) are most likely different for bedrock?

ivory sleet
#

these your classes @elfin atlas ?

vocal cloud
#

Also paper dogekek

ivory sleet
#

mye

granite owl
#

prob not even the same interface

ivory sleet
#

altho that could very much not be a factor

chrome beacon
elfin atlas
vocal cloud
#

I do database stuff in the main thread cause I'm a rebel

twilit wharf
#

is there any way to get foreign language's unicode characters to show in minecraft? Here is what chinese looks like

chrome beacon
trail cape
kind urchin
granite owl
#

@trail cape serious answer? you cant prob

#

real answer:

twilit wharf
#

I am

chrome beacon
#

They should display fine

twilit wharf
#

they show up in intellij but not minecraft

chrome beacon
#

Sounds like you might not be compiling with UTF8 then

granite owl
#

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

elfin atlas
#
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
granite owl
#

but im not suggesting to do that

twilit wharf
granite owl
#

and i believe, no offense, that even fewer have the knowledge to do such

trail cape
granite owl
#

like ive said theoretically u could

#

but if you could

chrome beacon
granite owl
#

you would prob not ask here

#

thats not meant offensive

twilit wharf
desert musk
#

how do you make an item that can’t be repaired?

twilit wharf
#

stop the repair event

sharp bough
#

is there a simple way to know if two locations are adjacent?

desert musk
chrome beacon
ivory sleet
twilit wharf
desert musk
#

figured there would be a way to make it too expensive though

trail cape
sharp bough
vocal cloud
ivory sleet
#

oh you mean like that

sharp bough
#

idk if adjacent is the right word

ivory sleet
#

I mean check if the block x,y,z have a delta of 1 perhaps?

sharp bough
#

delta?

ivory sleet
#

or if you could use getFacing (idr the name of that method)

granite owl
#

@trail cape so concluded answer? stop bothering with the technically superior cuz cpp but modable inferior bedrock version and stick to java only.

chrome beacon
# twilit wharf gradle

tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

Add this to your build file

twilit wharf
#

I have that

chrome beacon
#

hm no idea then

sharp bough
#

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

ivory sleet
#

hmm alr

granite owl
#

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

ivory sleet
#

one way would be to use sth like
Location::getBlock
Block::getRelative
then use
Block::getLocation
and compare

grim ice
#

why only toString and without fromString

sharp bough
#

yea the logic would be that loc1 (target) cannot be more than 1 number away in each case (x y z )

ivory sleet
#

else you could just straight take the absolute value of x1-x2 and make sure that its equal to one

sharp bough
#

i think the absolute value could work

ivory sleet
#

ye

sharp bough
#

with the difference

ivory sleet
#

I suggest writing a couple of static utility methods with clear names to make it maintainable to work with

tender shard
sharp bough
#

yea i have an utils class

#

i can drop it there

ivory sleet
#

uh no worries

#

unless it doesnt work then no need to

clear raptor
#

Hi guys! Quick dev question: Is possible to have TranslatableComponent in item's lore? I need client-side translated Material names

ivory sleet
#

or well if you want code review/code bullying (/s) then perhaps

ivory sleet
clear raptor
#

So there is other way to achieve it?

chrome beacon
#

NMS 😓

vocal cloud
#

I'm working on a lib to do something like that

clear raptor
#

Any example of that? I am not really Pro in Spigot dev 😄

chrome beacon
#

If you're using Paper you can use their API

clear raptor
#

Oh I am

vocal cloud
#

You'd have to rebuild the item every time though.

chrome beacon
#

Ah great it will make things easier

clear raptor
#

And do they have any documentation for that?

quaint mantle
# tender shard :3

❤️ it’s truly amazing you’ve helped me so much with it in my plugins

clear raptor
#

setLoreComponents this one?

#

With normal use of Spigot's Components?

chrome beacon
vocal cloud
#

That doesn't do anything for translations though does it?

clear raptor
#

or yea... lore()

#

that one is deprecated

unique geyser
#

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;
    }
}
tender shard
#

you are casting the sender to player if the sender is NOT a player

visual tide
#

smort

unique geyser
#

oh yeah I should remove the !

warm light
visual tide
#

its a neat lil feature

#

automatically assigns player to the casted sender

unique geyser
warm light
#

oh

quaint mantle
visual tide
#

bruh moment

quaint mantle
#

Lol

visual tide
#

decide on one of the 2

#

or use kotlin

#

even neater

#

sender is Player

#

and casted for you

quaint mantle
#

I didn’t even know you could do that tbh

lapis lark
#

Any advise in BungeeCord RGB?

unique geyser
rough drift
#
if(!(sender instanceof Player player)) return;

player.somePlayerMethod();
```In newer java versions
lapis lark
quaint mantle
#

Keep it simple

#

Without giving you more headaches

unique geyser
#

alr

#

thanks

rough drift
unique geyser
#

sure

#

id love to see what I can change to make it neater

quiet ice
rough drift
# unique geyser id love to see what I can change to make it neater
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

vocal cloud
wild marten
#

does any1 have a guide for creating custom entities/mobs in 1.18?

unique geyser
# rough drift ```java package com.zadroit.prestige.commands; import org.bukkit.Bukkit; import...

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

rough drift
#

quick thing

unique geyser
#

yeah?

rough drift
#

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;
unique geyser
#

ah

vocal cloud
#
    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

unique geyser
#

I see

unique geyser
unique geyser
rough drift
#
    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

vocal cloud
#

Oops it's != 1 kek

unique geyser
#

coding is fun

clear raptor
unique geyser
#

I really love this

clear raptor
#

I was using LocaleLib but surely Kyori have own way

unique geyser
#

even tho I dont know much
I really love this

vocal cloud
# rough drift ```java public class PrestigeTeleport implements CommandExecutor { @...
    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;
        }
    }
unique geyser
#

now he is gonna make it in 4 lines lol

rough drift
#

hm

#

lemme think

unique geyser
#

wait

rough drift
#

i got it

unique geyser
#

I was joking

#

WHAT

rough drift
#
    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

unique geyser
#

damn

vocal cloud
# rough drift ```java public class PrestigeTeleport implements CommandExecutor { @...
    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

rough drift
#

are you challenging me?

unique geyser
#

🍿😳

#

wait

#

im allergic to popcorn

rough drift
#
    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?

vocal cloud
#

Your code has to work in order to be topped

rough drift
#

hold on

#

done

#

it works now

quaint mantle
#

Lmao what did I miss 😂

#

You guys are crazy

rough drift
#

fixed it

unique geyser
rough drift
#

the condition was wrong

quaint mantle
#

I don’t think making your code short helps tho

#

You have to understand it

#

Lmao

unique geyser
rough drift
quaint mantle
#

Ah ok

rough drift
#

now

unique geyser
#

I think its clear who won

vocal cloud
#

Except you're not using player