#help-development

1 messages · Page 1412 of 1

summer scroll
#

someone help?

cold field
#

Is it ok if I call the getLocation() from a player obj inside an async task?

#

the player is stored inside a synclist

wraith rapids
#

the location may not be accurate

#

since the fields in Location that hold the position and direction aren't volatile or synchronized

cold field
#

ok thanks

wraith rapids
#

it won't explode, but you might get stale data

cold field
#

it isn't very important for me so I'm fine with it

wraith rapids
#

the material of the placed blocks and the items is different @summer scroll

#

make sure you're using the correct material

maiden briar
#

ProxyServer.getInstance().getScheduler().schedule((BungeePlugin) api.plugin, () -> {}, 0, TimeUnit.NANOSECONDS); @wraith rapids is this the way to do this in bungee?

wraith rapids
#

i don't do bungee

maiden briar
#

Ok

wraith rapids
#

but iirc bungee doesn't have a main thread

#

so idk

maiden briar
#

Only async works without delay

summer scroll
wraith rapids
#

use a set

summer scroll
#

aight

quaint mantle
#

@wraith rapids what's a stack trace?

main dew
#

You know Event to x+(1-9)?

quaint mantle
#

what?

cold field
#

why when craftbukkit sends a packet that contains the yaw it is recalculated with this formula yaw * 256.0F / 360.0F?

main dew
#

Event to this

eternal oxide
main dew
#

why?

#

x+(1-9) to load this

eternal oxide
#

Try asking a complete question

main dew
#

is there an event to load the quickbar? (bookshelf)

#

on creative

eternal oxide
#

Do you mean is there an event fired when someone puts an item on the hotbar? or you want to put a bookshelf on the hotbar?

quaint mantle
#

what now?

quartz anchor
#

so the next thing you might want to do is to create new command

#

right?

quaint mantle
#

but my event doesn't work

quartz anchor
#

why it doesn't work?

quaint mantle
quartz anchor
#

show me the part that starts with @EventHandler

quaint mantle
quartz anchor
#

alright look like your plugin.yml have a problem

#

look at author: part

quaint mantle
quartz anchor
#

change authors to author

quaint mantle
#

Should I test the plugin now?

main dew
quartz anchor
#

yes

main dew
#

this

cold field
#

😦

main dew
#

event to load one with quick bar

#

"Saved Toolsbars"

eternal oxide
main dew
#

event to load "Saved Toolsbars" on creative

quaint mantle
#

@quartz anchor it worked

quartz anchor
#

so what else you want? commands? or other events?

quaint mantle
#

i want to learn how to make plugins

cold field
quartz anchor
#

it will let you create your own command

eternal oxide
sour sand
#

is there an event that runs every tick

quartz anchor
#

no

#

just create new scheduler

quaint mantle
quartz anchor
#

you forgot to implement CommandExecutor

quaint mantle
quartz anchor
#

try to replace implements Listener to implements Listener, CommandExecutor

#

or you can just create new class

quaint mantle
quartz anchor
#

you see this part?

#

the reason why CommandKit is in red is because there's no class called CommandKit

#

but since your main class is also CommandExecutor, you can replace new CommandKit() with this

quaint mantle
quartz anchor
#

well actually it would be nice if you learn a bit about java and object oriented programming

quaint mantle
#

how?

quartz anchor
#

no you have to put this, not this()

maiden briar
#

Bungee: How can I now set the MOTD? They made it a bit difficult in their newest version with ModItem, and ModInfo

quaint mantle
#

How am I supposed to learn Java?

quartz anchor
#

there's a video that's 2 hours long

#

or you know, just read some e-book about java

#

but ye look like you forgot to import some classes

#

in intellij if you hover on those red text, it will suggest an edit for you

#

in this case, it told me to import class

quaint mantle
quartz anchor
#

hover on CommandSender and find the "Import class" button

quaint mantle
quartz anchor
#

right there

quaint mantle
quartz anchor
#

now do the same with Command, ItemStack and Material

quaint mantle
#

can anyone help me ?

lost depot
#

can we please not make this a java learning channel? thx

lost depot
quaint mantle
#

im making a factions server and every time i make a world for the factions server to be on theres just so much sea

eternal oxide
quaint mantle
#

like so much sea and for a factiuons server ofc you dont want the biggest hugest oceans ever i

#

oh ok

quartz anchor
quartz anchor
eternal oxide
#

Nothing wrong with teaching, if theres not other questions to answer.

lost depot
#

how do i set up permission restrictions for individual command arguments? So that /mycommand foo requires a different node than /mycommand bar. I've tried a few ways but I'm not getting anywhere. Testing with LuckPerms btw.

eternal oxide
rigid hazel
#
            OfflinePlayer sender = this.plugin.getServer().getPlayer(mail.getSender());
            if(!sender.isOnline()) // line 160
            {
                sender = this.plugin.getServer().getOfflinePlayer(mail.getSender());
            }
            else
            {
                sender = (Player) this.plugin.getServer().getPlayer(mail.getSender());
            }```
#
        at de.cimeyclust.util.MailAPI.showMail(MailAPI.java:160) ~[?:?]
        at de.cimeyclust.listener.CustomInventoryListener.onMailMenu(CustomInventoryListener.java:268) ~[?:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor37.execute(Unknown Source) ~[?:?]```
#

What I can do to fix this error?

eternal oxide
#

line 160

rigid hazel
#

I commited it

#

Elgar?

eternal oxide
#

I have no idea what you lilne 160 is

rigid hazel
#

if(!sender.isOnline()) // line 160

#

I marked it for your

covert valve
#

wait until you hear about js

#

string to boolean is a surprisingly common thing (truthiness)

eternal oxide
#

why are you trying to get a Player when you don;t know if they are online?

rigid hazel
eternal oxide
#

You can;t do that

#

what does mail.getSender() return? a String?

covert valve
#

if (!(OfflinePlayer player instanceof Player))

#

you can

rigid hazel
rigid hazel
eternal oxide
#

then use getOfflinePlayer(mail.getSender())

#

if the returned OfflinePlayer still has a name then its a valid OfflinePlayer and you can check .isOnline()

rigid hazel
#
            if(sender instanceof Player)
            {
                sender = this.plugin.getServer().getPlayer(mail.getSender());
            }
            else
            {
                sender = (OfflinePlayer) this.plugin.getServer().getOfflinePlayer(mail.getSender());
            }```
#

I will try this first.

#

But thanks for advice me

eternal oxide
#

That won;t work

rigid hazel
#

We'll see. I want to test out anything.

eternal oxide
#
if (sender.getName() != null and sender.isOnline()) {
    sender.getPlayer();```
rigid hazel
#

It worked Elgar

#

Perfectly

eternal oxide
#

you can get the player straight from the OfflinePlayer, if they are online

covert valve
#

yeah just cast it

eternal oxide
#

Use sender.getPlayer()

eternal oxide
rigid hazel
eternal oxide
#

ok

eternal oxide
#

depends on a few things. What you mean by "script" and how you are starting your timer

#

?paste you are going to have to show code.

queen dragonBOT
eternal oxide
#

ok a few things.

  1. Your startSecondsCountdown() says it returns a Runnable but only returns null.
  2. If you make a final local field for your player in your onCommand and start the runnable there it can access it.
quaint mantle
#

Help me which is the best hosting 24/7 free

lost depot
#

ok so it seems like player.hasPermission(String) isn't influenced by LuckPerms, how do i properly check if a player has a permission regardless of what permissions plugin is used by the server...?

#

kind of annoying that i even have to ask that here, but anything google turns up on this is so vague

vernal basalt
#

how do i make something like this

#
{
success: true,
player: 
  stat1: 203
  stat2: 304
  name: "Need_Not:"
}```
#

i can't figure out how to add keys inside keys

#

using javalin which uses jackson

lost depot
#

what

#

oh

vernal basalt
#
public class JsonData {
    boolean value = true;
    boolean success = true;
}```
#
        app.get("/player/:uuid", ctx -> {
            JsonData hi = new JsonData();
            ctx.json(hi);
        });```
indigo iron
#

Someone help me out please
How can I cancel the teleport event

#
                
                Player player = e.getPlayer();
                
               double cooldown = player.getCooldown(Material.ENDER_PEARL);
               
               if(player.hasCooldown(Material.ENDER_PEARL) && cooldown > 1) {
                            return; 
               }
            
                        
                    e.setCancelled(true);```
quaint mantle
#

Wht is this

indigo iron
#

when a player is hit enderpearls go on a 15 second cooldown and I want to cancel it if the player threw the pearl before they were hit

lost depot
#

e.setCancelled(true);

#

oh u already had that

indigo iron
#

yeah but it doesn't cancel

indigo iron
lost depot
#

but youre returning if the cooldown is higher than 1

indigo iron
#

so get rid of the return?

lost depot
#

so yeah, setCancelled will not be reached

quaint mantle
#
    @SuppressWarnings("deprecation")
    public void set(Player p) throws IllegalStateException, IllegalArgumentException, UserDoesNotExistException {
        Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
        Objective ob = board.registerNewObjective("main", "dummy");
        ob.setDisplaySlot(DisplaySlot.SIDEBAR);
        
        ob.setDisplayName("§l" + p.getDisplayName());
        
        Team money = board.registerNewTeam("money");
        Team online = board.registerNewTeam("online");
        
        ob.getScore("§fKontostand7: ").setScore(3);
        ob.getScore("§d").setScore(2);
        ob.getScore("§fOnline§7: ").setScore(1);
        ob.getScore("§e").setScore(0);
        
        money.addEntry("§d");
        money.setPrefix("§e" + Economy.getMoney(p.getName()));
        online.addEntry("§e");
        online.setPrefix("§e" + Bukkit.getOnlinePlayers().size() + "§8/" + "§e20");
        
        p.setScoreboard(board);
    }
    
    @SuppressWarnings("deprecation")
    public void update(Player p) throws IllegalStateException, IllegalArgumentException, UserDoesNotExistException {
        Scoreboard board = p.getScoreboard();
        Team money = board.getTeam("coins");
        Team online = board.getTeam("online");
        
        money.setPrefix("§e" + Economy.getMoney(p.getName()));
        online.setPrefix("§e" + Bukkit.getOnlinePlayers().size() + "§8/" + "§e20");
    }```

I have problems with my scoreboard update. The set method works fine but the update don't. Here's the error:
https://paste.md-5.net/okidiponol.http
lost depot
indigo iron
lost depot
#

return; stops the codeblock within onTeleport from running after that point

#

which explains why your e.setCancelled(true); is probably never executed

indigo iron
#

oh ok I'll try to removing it and tell u if it works

indigo iron
#

it doesn't cancel still ;-;

lost depot
#

"money"

#

"coins"

quaint mantle
#

oh

#

thanks

lost depot
#

👍

lost depot
indigo iron
#
    
            public void onTeleport(PlayerTeleportEvent e) {
                
                Player player = e.getPlayer();
                
               double cooldown = player.getCooldown(Material.ENDER_PEARL);
               
               if(player.hasCooldown(Material.ENDER_PEARL) && cooldown > 1) {
                            
               }
            
                        
                    e.setCancelled(true);
                    player.sendMessage(ChatColor.RED + "You cannot teleport while binded!");
}
}```
vernal basalt
quaint mantle
#

do you have the @EventHandler?

eternal oxide
lost depot
#

within the { }

lost depot
indigo iron
#

rightttt

quaint mantle
#

could be

indigo iron
#

if(player.hasCooldown(Material.ENDER_PEARL) && cooldown > 1) { so the && cooldown > 1 should be a if statement?

vernal basalt
#

what else

cold field
#

Hum guys. Just a quick question. Does anyone have a link for a good scoreboard tutorial. I don't know what are its usage. (I've read about storing data, player teams)

#

@eternal oxide

indigo iron
# lost depot also this 😂

it cancels the event even if the enderpearl only has 1 second cooldown it's suppose to cancel if the enderpearl has a cooldown higher than 1

obtuse basin
#

I've tried following this tutorial for SQLite integration https://www.spigotmc.org/threads/how-to-sqlite.56847/ but It can't resolve Main in the error class any Ideas?

quaint mantle
#

Hello. Can i know how to play a sound correctly for 1.16, i tried but i failed and it prompts an error.

quaint mantle
#

Uh does canceling the event affect it?

lost depot
cold field
#

thanks

near crypt
#

how can i ask if my inventory is the right inventory by the name in the InventoryClickEvent (event.getClickedInventory().getName() does not work)?

eternal oxide
#

getView()

near crypt
#

is getView the new getName?

eternal oxide
#

no, it contains teh two linked inventories from that event

#

its better to check instances though

near crypt
#

so java if (event.getClickedInventory().getView().equals("Name"))

eternal oxide
#

no

near crypt
#

but how can i get to the name of the Inventory?

eternal oxide
#

getView().getTitle()

indigo iron
near crypt
#

oh and that returns the name? @eternal oxide

eternal oxide
#

yes

near crypt
#

so i can .equals() it?

lost depot
lost depot
#

i think

cold field
#

nvm

near crypt
#

and how can I ask if the Clicked Item in the Inv is for example dirt?

#

oh i know it

#

sry

eternal oxide
near crypt
#

it is event.getCurrentItem() ==

#

and than Material.DIRT

eternal oxide
#

.equals on objects

cold field
#

I want to hide player names without hiding the player itself. Can I use teams or do i need to use the packet PacketPlayOutPlayerInfo?

eternal oxide
#

then yes to compare to an Enum you getType() and ==

near crypt
#

oh yes trueeeee thx

eternal oxide
cold field
#

ElgarL

quaint mantle
#

yo how do i add a dict to a config n get the value?

eternal oxide
#

dicts in Java are Maps

#

Maps can be put straight into a config with config.set("path", map)

quaint mantle
#

n getting it?

eternal oxide
#

BUT you must save and reload the config for them to be correctly accessed

#

you access them the same you would with any config entry

quaint mantle
#

send the error from console

vast quest
#

how can I check for irl time

queen dragonBOT
vast quest
#

bujt timezones and stuff

vast quest
quaint mantle
#

this checks for time where the host is located

vast quest
#

Im trying to execute a command when its like 12AM

quaint mantle
#

lemme give you example

vast quest
#

Thanks!

quaint mantle
#

@stiff topaz whats at line 21 at Launch.java

vast quest
#

oh so 0 is 12 am?

quaint mantle
#

yea

vast quest
#

in that case

#

what is 12 pm

quaint mantle
#

bcz its an 24h

#

just 12

vast quest
#

ok pardon me my english is bad but isnt 12 am the one that its day?

quaint mantle
#

i dont really know i have 24h format here but 0 is 12am and 12 is 12pm

vast quest
#

also I put that in onLoad right

quaint mantle
#

yeah you could bcz this is java stuff and not the spigot things

vast quest
#

im guessing this is right

eternal oxide
#

0 is midnight, 12 is middle of the day

vast quest
#

Ok thats what I thought

quaint mantle
#

yes should be but change the hour == 0 to hour == 12 if you want the middle day

vast quest
#

Ok!

#

Thanks!

quaint mantle
#

yw

eternal oxide
#

if you have no chestplate the returned object will be null so you can't use .getType()

vast quest
#

how can I get it so like

#

its 12:30 am

vast quest
quaint mantle
#

w8

vast quest
#

im guessing

quaint mantle
#

oh yeah thats allright

#

good job

vast quest
#

uh

#

it says condition hour == 17 will always be false

#

in the 29th line

quaint mantle
#

dont mind it its only bcz the int hour is 0 but the 17 line changes it

vast quest
#

o ok

#

also command executing is right

#

right

#

its suppose to send the command thru console

quaint mantle
#

you didnt send any commandexecutor class

vast quest
#

no the commands from another plugin

#

its just suppose to execute the commands

quaint mantle
#

oh yes

#

that is

vast quest
#

correct?

quaint mantle
#

yes

vast quest
#

yay

eternal oxide
#

if an Object can be null you must always null check

ivory sleet
#

if (obj == null) {
//handle
}

eternal oxide
#
ItemStack item = inventory.getChestplate();
if (item != null && item.getType() == ...```
quaint mantle
#

the error is causing the line 6

eternal night
#

i = size - 1

eternal oxide
#

arrays index from zero

eternal night
#

can't access arr[arr.length]

eternal oxide
#

if it says size is 9 then its 0 to 8

quaint mantle
#

oh so i just do "for (int i = 0; i <= instance.getConfigHandler().SETTINGS_TABLIST_SORT_PRIORITY.size(); i++) {"

#

*<

#

and fixed ty

eternal oxide
#

line 13 shoudl be continue unless you want to stop at teh first null name

quaint mantle
#

okay

eternal oxide
#

and yoru name is not null

#

its owner

#

nowhere do you initialize team. You only loop teamName

#

at least not till after you output 5

quaint mantle
#

i do

solid oxide
#

does anyone know how to fix this?

eternal oxide
#

yes, when its initially null

quaint mantle
#

okay how do i fix that then idk

eternal oxide
#

have you created the team?

quaint mantle
#

yes

eternal oxide
#

you can;t get a team that you havn't created

quaint mantle
eternal oxide
#

debug your initializing of team

quaint mantle
#

okay

eternal oxide
#

your getTeam on the scoreboard is returning null so you can;t have registered your teams at this point

quaint mantle
eternal oxide
#

that just shows the code is running. Output some field values

quaint mantle
#

like?

eternal oxide
#

teamName, the index i. also why is 4 firing? If this is the first run though there shoudl be no team to unregister

quaint mantle
#

instance.log("value: "+(team != null)); Output: [AstreansLobbySystem] value: true

#

the team name is 0_owner

eternal oxide
#

shouldn't this be looping over the values no tthe keys? instance.getTabListSortPriorityTeams().keySet()

#

you added the names as the value not the key

quaint mantle
#

im checking for the key

#

the key is whats in the config (owner) and the value is what the name of the team (0_owner) is

eternal oxide
#

you are registering the team with teamName but you add that to your Map as the value not the key

quaint mantle
#

yes

eternal oxide
#

You seem to never use teh value in your Map again

quaint mantle
#

wait i dont get it

#

im just trying to do sort priority in tablist but idk

#

whats the error with the team being null

eternal oxide
quaint mantle
#

oh now im reaching getting the team.addplayer working

#

forgot to use value and not key in the "team = instance.getServer().getScoreboardManager().getMainScoreboard().getTeam(instance.getTabListSortPriorityTeams().get(teamName));"

#

but its not showing any kind of suffix or prefix

eternal oxide
#

where are you expecting to see the prefix/suffix?

quaint mantle
#

prefix is "prefix" and suffix is "suffix"

eternal oxide
#

where are you expecting to see that? in tab list?

quaint mantle
#

yes

eternal oxide
quaint mantle
#

yes

#

everything works except the sortpriority and suffix prefix

quaint mantle
#

spoiler section?

eternal oxide
#

in that thread

quaint mantle
#

like this ?

eternal oxide
#

the very last spoiler section

quaint mantle
#

?

eternal oxide
#

yes

quaint mantle
#

okay?

eternal oxide
#

I see you adding the player to the team. I don;t see you setting the scoreboard for the player

#

I'm not sure you have to for teh Main board

#

but it seems to be the only difference other than you useing Main and not a new

quaint mantle
eternal oxide
#

doesn;t addEntry take the players uuid as a string?

quaint mantle
#

idk i saw it in the thread

eternal oxide
#

ok, and still not in tab?

quaint mantle
#

nope

eternal oxide
#

then try using a new scoreboard instead of main

quaint mantle
#

okay

#

nothing

eternal oxide
#

no clue then

quaint mantle
#

same

#

well ty for help

woven coral
#

hey, so I asked a few people about this, but they couldn't give me a good answer, but have you had an issue with entity location's printing not the same coordinates even if I teleport to the location with the correct ones? Like I know it rounds it up, but I don't know how I can stop it from rounding it up
for example, if my intended location is 121, 64, 128, and print my location and go to the intended one, I will get 121, 64, 129, it's rounding it up, completely messing my code up, how can I make it stop rounding it up?

eternal oxide
#

getX() is precise location getBlockX () is rounded.

woven coral
eternal oxide
#

accurate

eternal oxide
quaint mantle
#

okay

#

same for me its problem with my new class of scoreboard

eternal oxide
#

typo

#

in the name

quaint mantle
#

ohh

#

sry my bad

main dew
#

How decompiler project with fernflower?

quaint mantle
#

how do i get the prefix of the group player is in vaultapi im using chat

timber crescent
#

So if I have a mongoDB database im using in my plugin would I create a collection for every player?

dense flame
#

Anybody know how I can set the direction of a sign?

Trying to make it face where the player is facing but casting it to a rotational and using .setrotation does absolutely nothing

eternal oxide
#

did you set teh BlockData back on the Sign after rotating?

dense flame
#

No, how does one do that? 🙂

eternal oxide
#

block.setBlockData(data)

dense flame
#

Ah ok cool. Didn't realize thats how it worked. Couldn't find anywhere that said that. I'll give it a shot. Thanks!

#

Eeyyyy it worked. Thanks a bunch.

spring river
#

Hello, I want to created a custom NPC.
When a player is login, I'm sending packets to displayed him the EntityPlayer. But the npc dissapear from player when the chunk is unload. Do you know if I need to resend the **PacketPlayOutPlayerInfo **and **PacketPlayOutNamedEntitySpawn **packets to the player please ?

ivory sleet
#

I have a pro tip, use citizens

#

they have an api iirc

chrome beacon
#

Was about to say

ivory sleet
#

hehe xD

chrome beacon
#

;/

sour sand
#

is there a way to when detecting for an itemstack to make it ignore the itemmeta

ivory sleet
#

elaborate

spring river
chrome beacon
ivory sleet
#

Well it's a plugin but can be seen as a lib in your case

sour sand
# ivory sleet elaborate

i am tring to detect when a player makes a netherite pick but i want to ignore if it is enchanted

spring river
#

Ahh, i doesn't want to use an external plugin/lib :d

chrome beacon
ivory sleet
#

Why not

sour sand
#

o ok thanks

spring river
#

Because I'm actually creating my own lib for my plugins

ivory sleet
chrome beacon
quaint mantle
#

hey how could i make smth like server and client? server would be like a bungee server and if somebody writes command (ex. /hello) then the server would retreive something like memory status from all the clients?

hybrid spoke
ivory sleet
#

yeah people and libraries these days lol

chrome beacon
spring river
chrome beacon
quaint mantle
#

by server i mean bungee server and client spigot server

olive lance
#

Is there a way to get nearby players to an entity without checking every player? If not what is the fastest way to do it

chrome beacon
hybrid spoke
#

and check if the entity is a player

olive lance
#

Sick thanks

quaint mantle
#

i dont really wanna use plugin messages channels for this

ivory sleet
#

redis

hybrid spoke
#

Redis/Jedis

quaint mantle
#

okay

olive lance
#

Sorry for being dumb but I’m trying to find the source for entity and just can’t find it cause I’m on my phone and it sucks

bright spire
torn oyster
#

how would i make an entity's customName be visible only from a certain distance

#

cuz rn i am making a mob levelling system

#

and i dont want to have to look down

#

and see like 100 name tags

#

but i also dont want to have to walk up to a zombie to see it's level

deft widget
#

Hey, i guess that will be pretty easy for ya but i want to know how to create one itemstack for one item and can use it in different classes? i tried to make it static but i didnt know how. somebody will help me?

hybrid spoke
torn oyster
#

uhh how do i do that

#

@hybrid spoke

hybrid spoke
#

by sending packets 🤔

torn oyster
#

i havent really used packets much

hybrid spoke
#
torn oyster
#

i have used packets before

deft widget
#

@hybrid spoke can you help me please?

torn oyster
#

i dont know what packet to use and what to fill in

hybrid spoke
#

?ask

queen dragonBOT
#

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.

torn oyster
#

what is the packet name @hybrid spoke

glass sparrow
#

god cipher fr got it in for himself

hybrid spoke
torn oyster
#

i dont know what to look up

#

on that page

hybrid spoke
#

and you want to play that OUT via PACKETS

#

or am i wrong

torn oyster
#

i want to show a name if they are within 5 blocks

torn oyster
#

yes

#

idk

cold field
#

Guys, is there an hacky way to hide a player from the tab list or do I need to use the PlayerOutInfo packet using Remove_Player?

hybrid spoke
hybrid spoke
cold field
#

Ok, The packet that i must send is PacketPlayOutPlayerInfo right?

cold field
#

k

vast phoenix
#

Why is it that when I use Player#setExp or Player#setTotalExperience that it doesn't change the player's level.

#

Does anyone know about this?

hybrid spoke
#

it doesn't automatically update the level of the player

vast phoenix
#

already found a way to probably fix it

#
                while(user.getExpToLevel() == 0)
                    user.setLevel(user.getLevel() + 1);
chrome beacon
#

Why 👀

vast phoenix
#

Because I'm trying to give a player a XP reward for something.

chrome beacon
#

That's the most useless loop I've seen

vast phoenix
#

and the level of the player doesn't change by changing the XP.

#

any suggestions?

eternal oxide
#

there is xp and level. xp is distance to next level

hybrid spoke
#

there is a #giveExp. maybe that will update the level. but i am not sure

vast phoenix
#

Okay I'll try and figure it out

cold field
#

Is there a method to delete a non-empty directory without first removing the files recursively?

eternal oxide
#

no

cold field
#

😦

minor garnet
eternal oxide
#

?paste

queen dragonBOT
sage swift
#

something is null

#

crazy stuff

#

show LootManager line 67

minor garnet
#

...

eternal night
#

is local null maybe ? xD

#

kekw

minor garnet
#

if is nul

#

Bukkit.broadcastMessage("Iniciando metodo de spawnar armor stand com a localização: " + local.getX() + " " + local.getY() + " " + local.getZ() + "com o item: " + item.getType().toString()); this debug work

cold field
eternal night
#

if you were running a fun version of java it would neatly tell you what is null xD

minor garnet
#

i dont know if is because i returned a armor stand

eternal night
#

java 16 when

minor garnet
#

i'm using 8

eternal oxide
#

Consolidate all file access through one class

#

you can multi read but single write

cold field
#

this make sense

minor garnet
#

i cant understand how solve my problem

#
        Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
            @Override
            public void run() {
                Bukkit.broadcastMessage(getConfig().getString("messages.loot_resetar"));
                LootManager.loot.stream().filter(e -> LootManager.roolItem(e.getChance()))
                .forEach(e -> LootManager.spawnLoot(e.getLocation().setDirection(e.getDirection()), e.getItem()));
            }
        }, 0, 10 * 20L);
    }```

setDirection() can be a problem ?
eternal oxide
#

you are getting the direction and setting it. you are doing nothing with the direction

minor garnet
#

''setting it'' ? you mean setting a location for a direction ?

eternal oxide
#

is your e.getDirection() supposed to give a different direction to the location?

#

what are you spawning?

minor garnet
#

a armor stand

eternal oxide
#

your direction is near zero, so pretty much South

minor garnet
#

ooh,

#

i need spawn a location with pitch and yaw i think

#

i need spawn a armor stand like this understand

eternal oxide
#

yaw is rotation. you don;t want pitch unless you are going to tilt it

vast quest
#

just wondering is it possible to change the text that comes up when player switches a item
like the text just above the hotbar but below actionbar

wraith rapids
#

that is clientside

#

and is the name of the item

vast quest
#

not just that but

#

I have seen servers change that text

#

when the name of the item isnt there

wraith rapids
#

maybe some protocol fucknuggetry, don't know

vast quest
#

o well

minor garnet
vernal basalt
#

how do i fix

#

playerslist: "[CraftPlayer{name=Need_Not}, CraftPlayer{name=Ned_Not}]",

eternal oxide
#

LootManager.java:67 is being passed null

vernal basalt
#

i did

quaint mantle
#

link it

vernal basalt
#

String playerslist = Bukkit.getOnlinePlayers().toString();

quaint mantle
#

What's the issue it's doing what it suppose too.

vernal basalt
#

and then put it in jackson API to make it json

#

the issue is i want it to say

#

playerslist: "Need_Not", "Ned_Not"

eternal oxide
#

Then write your own toString

quaint mantle
#

^

vernal basalt
#

how

eternal oxide
#

Its not a difficult thing to loop over your Collection and build a string

vernal basalt
#

how can i remove the craft player and { and [

quaint mantle
#

Well .replace()

minor garnet
#

ArmorStand armor = local.getWorld().spawn(local, ArmorStand.class); line 67

eternal oxide
#

local is null

wraith rapids
#

i bet whoever implemented the helpful npe's in modern java versions has committed suicide

dusky sierra
#

Why?

wraith rapids
#

because nobody knows it exists

dusky sierra
#

its great

wraith rapids
#

and there are still millions of people screaming REEE WHY NPE

dusky sierra
#

when the next LTS comes out everyone is gonna use it

#

i use java 16 for my dev servers already

vital ridge
#

Hey, just a little question. is there possible to change items display name randomly? By that i mean lets say you had 1 pickaxe in ur hand for like 5 mins, and if you right click on it the item meta changes?

#

so like just under interactevent or smthing

eternal oxide
#

yes

vital ridge
#

Ok ty.

#

basically

#

i have to if statements

#

two*

#

if booktype is teleportationbook

#

set books display name to a certain name, and under that i have if book type is dashingbook, set the display name to a certain name

#

and im setting the itemmeta after both of the if statements

#

Is this the right way to do it or i should add them in both if statements?

#

Or how exactly setmeta is used?

#

In this case

leaden falcon
#

what event do i listen to

#

for button presses

vital ridge
#

PlayerInteractEvent

#

and check if the clickedblock

#

is button

eternal oxide
leaden falcon
#

for example

eternal oxide
#

Then as Nuxoria said

olive lance
#

where can i see the implementation of getNearbyEntities

wraith rapids
#

in the source

leaden falcon
wraith rapids
#

yes

#

there's an event for it but I don't remember what it is

#

iirc levers share the same event

olive lance
#

@wraith rapids i can only see the interface method

wraith rapids
#

that's because you don't have the source

olive lance
#

i been tryna find it for a while

wraith rapids
#

you need to build it yourself

#

the sources aren't distributed publically because they include mojang source

#

and redistribution of that is a no no

olive lance
#

so decompile the actual server jar?

eternal oxide
#

java -jar BuildTools.jar --generate-source

olive lance
#

oh

wraith rapids
#

so instead you need to run buildtools and use it to build the sources from the diffs

olive lance
#

thanks

wraith rapids
#
    @Override
    public Collection<Entity> getNearbyEntities(BoundingBox boundingBox, Predicate<Entity> filter) {
        org.spigotmc.AsyncCatcher.catchOp("getNearbyEntities"); // Spigot
        Validate.notNull(boundingBox, "Bounding box is null!");

        AxisAlignedBB bb = new AxisAlignedBB(boundingBox.getMinX(), boundingBox.getMinY(), boundingBox.getMinZ(), boundingBox.getMaxX(), boundingBox.getMaxY(), boundingBox.getMaxZ());
        List<net.minecraft.server.Entity> entityList = getHandle().getEntities((net.minecraft.server.Entity) null, bb, null);
        List<Entity> bukkitEntityList = new ArrayList<org.bukkit.entity.Entity>(entityList.size());

        for (net.minecraft.server.Entity entity : entityList) {
            Entity bukkitEntity = entity.getBukkitEntity();
            if (filter == null || filter.test(bukkitEntity)) {
                bukkitEntityList.add(bukkitEntity);
            }
        }

        return bukkitEntityList;
    }
olive lance
#

thank you i appreciate that

wraith rapids
#

and the nms method it defers to

    @Override
    public List<Entity> getEntities(@Nullable Entity entity, AxisAlignedBB axisalignedbb, @Nullable Predicate<? super Entity> predicate) {
        this.getMethodProfiler().c("getEntities");
        List<Entity> list = Lists.newArrayList();
        int i = MathHelper.floor((axisalignedbb.minX - 2.0D) / 16.0D);
        int j = MathHelper.floor((axisalignedbb.maxX + 2.0D) / 16.0D);
        int k = MathHelper.floor((axisalignedbb.minZ - 2.0D) / 16.0D);
        int l = MathHelper.floor((axisalignedbb.maxZ + 2.0D) / 16.0D);
        IChunkProvider ichunkprovider = this.getChunkProvider();

        for (int i1 = i; i1 <= j; ++i1) {
            for (int j1 = k; j1 <= l; ++j1) {
                Chunk chunk = (Chunk)this.getChunkIfLoadedImmediately(i1, j1); // Paper

                if (chunk != null) {
                    chunk.a(entity, axisalignedbb, list, predicate);
                }
            }
        }

        return list;
    }
leaden falcon
left swift
#

How can I teleport armorstand to the player with every tick? I tried to create a bukkitrunnable in a new class and get armorstands from the hashmap, but that didn't work.
Code:

    public static HashMap<Player, ArmorStand> armorStands = new HashMap<>();

    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
        Player p = e.getPlayer();

        ArmorStand armorStand = (ArmorStand) p.getWorld().spawnEntity(p.getEyeLocation(), EntityType.ARMOR_STAND);

    }```
```java
    @Override
    public void run() {
        for (Player p : Bukkit.getOnlinePlayers())  {
            ArmorStand armorStand = TestClass.armorStands.get(p);
            armorStand.teleport(p.getEyeLocation());
        }
    }```
```java
Loop loop = new Loop();     loop.runTaskTimer(this, 0, 1);```
olive lance
#

is chunk.a comprehendable?

lilac dagger
#

what version?

#

i mean, you may have to check those out

#

nms is just a research project everyone should do

vast quest
raw basin
#

hey, how can i spawn minecraft:item particles?

    player.spawnParticle(/*insert smart things*/);
    // /particle minecraft:item honey_block ~ ~1.5 ~ 0.3 0.3 0.3 0.000001 15
lilac dagger
#

@raw basin check java docs

raw basin
lilac dagger
#

there is

#

i dunno why the one in the ide doesn't have proper variable names

raw basin
#

I need a particle with some data /
there is NO minecraft:item honey_block

lilac dagger
#

maybe you want step effect

#

ona block

#

you wouldn't need this at all

#

i think it's this

left swift
vast quest
#

Oh Ok

raw basin
torn oyster
#

im pregenerating my world

#

what is a good speed of chunks / sec

#

i am doing 50

#

and the tps is 20

#

no change

#

im using WorldBorder

#

because RWG recommends it

#

wrong channel

sage swift
wraith rapids
#

tps is a poor measure of performance

eternal oxide
#

watch TPS but also CPU load

wraith rapids
#

the actual metric you want to look at is mspt

untold rover
#

Is it possible to add Persistent data to a block? eg add a String to a block, and it won't go away even after a restart?

wraith rapids
#

if it is a tile entity, yes

#

use the persistent data container of TileState

#

if it's a regular block, you're fucked

eternal night
#

if you were feeling it, you could try to use the Chunk PDC and kinda go from there

#

tho tbh, that is pretttyyy hacky and will fail the second a piston or something moves the block

wraith rapids
#

that takes a lot of effort to get working properly

eternal night
#

^ yea

wraith rapids
#

with bukkit it's like borderline impossible to even make sure your data for a block gets removed when the block disappears

#

need to have an event listener with like 30 different event handlers

#

and there's still shit that is literally impossible to deal with, like plugins setting blocks

untold rover
wraith rapids
#

it's not a tile, no

eternal night
#

:rip:

wraith rapids
#

tiles are things like furnaces and chests

left swift
eternal night
#

aww no custom emojis right

untold rover
#

Is there a temporary data storage for blocks?

wraith rapids
#

what are you trying to achieve with this hay block though

#

there's nothing

#

a block is just a few bits in some block palette in some chunk

#

there's no room or capacity for extra stuff to go in there

eternal night
wraith rapids
#

you could try registering your own tile entities or something i guess

untold rover
#

we are a RP Server, and we use a structure of 3x3 hay blocks for the fire department when a person wants to jump from a building. like a big cushion. and we want the firedepartment to be able to just break the center of the hayblocks, and using the data stored we know if its a structure for the firedepartment or just a normal block of hay

wraith rapids
#

well

#

if you're rp enough, you probably don't have pistons or anything pushing these hay blocks

eternal night
#

^ then chunk pdc might be a valid option

wraith rapids
#

you can probably just store the Block in a map or a set somewhere and associate data with it, or go with the chunk pdc

#

former being transient while the latter is persistent

untold rover
#

does anyone have a ressource that explains chunk pdc

eternal night
#

I mean, it is just a normal pdc

#

¯_(ツ)_/¯

wraith rapids
#

this but with a Chunk instead of an itemStack

#

both are persistent data holders

eternal night
#

also a few youtube tutorials out there for PDC if you are more of a visual learner

wraith rapids
#

at least on paper, i'm guessing spigot has pulled that from downstream since you're talking about it here

eternal night
#

Chunk PDC ?

wraith rapids
#

yeah

eternal night
#

I think it got introduced in upstream actually

#

killed all worlds it was used on 😂

untold rover
#

okay so once the blocks are moved the pdc is gone right? or atleast the data I added

wraith rapids
#

really? i vaguely remember people raving about it in the paper discord a good while ago

#

no, the pdc is part of the chunk

#

the chunk doesn't give a shit about your blocks

#

you'll have to track them manually

eternal night
#

which is the hard part about this 😅

#

but yeah, paper had a PR open for it, then someone implemented it incorrectly on spigot and it broke every world it touched for a commit lol

wraith rapids
#

average day in the bukkit ecosystem

eternal night
#

tru 😄

worldly ingot
#

Not sure what ecosystem you're in but I don't recall the last time there was a breaking change in CraftBukkit beyond that most recent one

#

and it was because of an untested PR

eternal night
#

pretty sure it wasn't even too breaking 😂 paper broke, spigot just kindly doubled your chunk size on the disk

#

damn those optimisations paper 😦

worldly ingot
#

Yeah it was hardly "breaking"

eternal night
#

Yeah, sorry got it mixed up with the paper merge of upstream which just kindly corrupted all them worlds

past glen
#

how do I set the item for a custom item as a custom head?

#

like the material

#

I want to make a guardian helmet and I want to use a guardian head

sage swift
#

SkullMeta

#

also sadness

#

alternatively, hdb api

past glen
#

how to use skullmeta?

sage swift
#

sadly

#

youtube is a great source

wraith rapids
#

the material is player head

#

you'll need to apply your texture with the meta

maiden thicket
quaint mantle
#

Is aternos best?

fading lake
quaint mantle
#

Bro i cant run citizens plugin

#

It shows internal error

fading lake
hollow river
#

so i read up on nms and want to get started with it, seems pretty scary to get into but do you guys think just a small scale npc entity dialogue/quest system would be a nice start? already made a working mob arena with normal spigot

young knoll
#

Maybe, but you can already do that with citizens

#

Or the citizens API

#

It’s easier to start with small things the API doesn’t have access to

#

But generally you don’t need NMS that much

hollow river
#

yeah but i dont want to use citizens, its partly a learning experience for me to get into nms and it's flow

#

What would you use nms for mostly? custom entities like skeletons shooting 2 arrows and such?

young knoll
#

Mob AI, packet manipulation, a few things here and there the API doesn’t cover

hollow river
#

and also yeah im planning on using just spigot and using nms for things i can't use spigot for (i was about to add a boss mob to my arena but found out i'd need nms for more customization so that's how i got into it)

#

i'll get working on it!

woeful moon
#

Line 17 in onenable:

        getCommand("donationwebhook").setExecutor(new DonationWebhookCommand());
dusky lynx
#

Is donationwebhook a command in your plugin.yml?

past glen
#

I just accidentally clicked build project instead of build artifacts while saving my pluigin, wl that do something bad?

woeful moon
dusky lynx
#

🤦‍♂️ I am an idiot. Happens every time 😂
@woeful moon haha, happens to everyone... I hope

dense goblet
#

Do we have to check for e.isCancelled() when doing event handlers?

sage swift
#

by default it ignores cancelled

young knoll
#

False

dense goblet
#

so it will never be called if a previous handler cancels it?

sage swift
#

ignores cancelled events, no?

young knoll
#

ignoreCancelled is false by default

sage swift
#

i don't think that's true

dense goblet
#

I have if(e.isCancelled()) return; at the start of all my event handlers and im just wondering if I need it

sage swift
#

oh youre right it is

#

huh

sage swift
young knoll
#

Just add ignoreCancelled = true to the annotation

dense goblet
#

aaa ty

sage swift
#

is there an alternative to the deprecated InventoryClickEvent#setCursor? it says the reason it's deprecated is because This changes the ItemStack in their hand before anycalculations are applied to the Inventory, which has a tendency tocreate inconsistencies between the Player and the server, and tomake unexpected changes in the behavior of the clicked Inventory.im thinking i should just setCursor in a delayed task...

#

seems to work

deft sedge
#

?paste

queen dragonBOT
quaint mantle
#

Hey guys! Do any1 of y'all know how to get a player skull in 1.16.5?
I used to know it in 1.8 but I don't know how to get it in 1.165

cyan bluff
#

How can I detect if a player opens a crafting table?

#

What event would basically be in this category

quaint mantle
#

with a PlayerInteract event

random epoch
#

^

quaint mantle
#

then check if the block, which gets clicked is a crafting table

cyan bluff
#

ok thanks

quaint mantle
#

No problem

quaint mantle
cyan bluff
#

Ah I see e.getClickedBlock()

quaint mantle
#

yes

random epoch
#

Or this

quaint mantle
#

or that

#

but if he wants to make an own crafting menu of something he has to use the interact event

#

to cancel it before it opens

random epoch
#

Then cast the item meta to SkullMeta

quaint mantle
#

ah I see

#

then the uuid in setowner?

sage swift
#

well setOwner takes an OfflinePlayer

final fog
#

player.getMaxHealth is deprecated, should I use something else. Or is it ok to use.

sage swift
#

attribute

#

player.getAttribute(Attribute.GENERIC_MAX_HEALTH)

torn oyster
#

how would i make a plugin

#

that sends people to the hub

#

if a server goes down

quaint mantle
#

you mean after a server crashed or if as example a bedwars game is over?

torn oyster
#

like

#

if i do /stop

#

or they get kicked

#

they are put in the hub

#

or kicked (if they are already in the hub)

quaint mantle
#

Did you code before?

torn oyster
#

wdym

quaint mantle
#

are you a developer?

cyan bluff
#

How can I check if a player has a crafting menu open?

torn oyster
#
    @EventHandler
    public void kick(ServerKickEvent e) {
        ProxiedPlayer p = e.getPlayer();
        
        if (!e.getKickedFrom().getName().equals("lobby1")) {
            p.connect(GlobalMessage.getPlugin().getProxy().getServerInfo("lobby1"));
            p.sendMessage(ChatColor.RED + "You have lost connection to the server you were on, so you have been put in the lobby.");
        }
    }```
#

YES

#

caps

quaint mantle
#

oh I see

torn oyster
#

yes i am a develop[er

#

thats my code so far

quaint mantle
cyan bluff
#

but like this could be a while after, is there no other way?

quaint mantle
torn oyster
#

no

#

it only works when ur disconnected while joining the server

#

like if u have wrong version

quaint mantle
#

ok

#

I don't have a solution, bc I don't code bungeecord?

random epoch
#

Override the /stop commands and/or any other commands you want (/kick) to send them to the lobby then execute their respective function

opaque mango
#

assuming you mean the 3x3 crafting menu

torn oyster
#

yea but

cyan bluff
#

@opaque mango Thx

torn oyster
#

what if the server stops by me pressing the X on the bat file

#

instead of /stop

#

ik its not good

#

or another reason

#

that isnt a command

dense goblet
torn oyster
#

i am programming bungeecord anyway

sage swift
torn oyster
#

is it open source

#

ah

torn oyster
#

alright

sage swift
#

both ItemStack and ItemMeta implement Serializable

dense goblet
#

they implement ConfigurationSerializable but not standard Serializable, should I just assume it's a superset of it?

#

or subset ig

sage swift
#

oh umm

#

im not sure actually

opaque mango
#

built-in java serialization sucks

#

ConfigurationSerializable basically means you can serialize it as YML

#

and YML is for configs, not for data storage, so...

dense goblet
#

I would ideally serialise it as a byte array

opaque mango
#

and it sucks even for configs, but we are stuck with it

drowsy helm
#

how does java serialization suck

dense goblet
#

I want to save to file a class, representing a chunk, who's only non-transient field is this:

protected Map<LocCoordinate, CustomBlock> blocks = new HashMap<>();

where LocCoordinate is 2 bytes and a short (for local x,z and y) and CustomBlock is fully represented by an ItemMeta field

#

so LocCoordinate should serialise fine

#

I'm just worried CustomBlock will serialise ItemMeta as a reference

#

my other option is to serialise as text but that is space inefficient

quaint mantle
torn oyster
#

?javadoc Fireowrkl

torn oyster
#

?javadoc firework

torn oyster
#

bruh

drowsy helm
#

i think it just links to the jd

#

no fancy lookup

torn oyster
#

whats the default firework velocity

rigid otter
#

Hello! Anyone help me how to make class that work like Player class? I mean it syncs to every stored player variable. Example if a function contains Player parameter(public void changePlayerName(Player player){...}), if we edit player name vai the variable in parameter, it will affect to the original Player instance right? So, why it does so. And how can I do like this in my own custom class? You understand me?

drowsy helm
#

are you asking how to change a variable?

rigid otter
#

No

dense goblet
#

(almost) everything in Java is passed by reference

rigid otter
#

If so, first, where do Players store?

lilac dagger
#

in a heap

dense goblet
#

changePlayerName takes a reference to your player and sets some values in the memory that the reference points to

rigid otter
#

Eample it store in a list, then where is that list?

drowsy helm
#

i usually have manager classes

#

that hold those collections

lilac dagger
#

all objects separately are stored in a heap

#

if it works as c++

#

which i think it is

rigid otter
lilac dagger
#

ohh

#

yeah

#

it's stored in multiple locations actually

#

you should be careful what'u doing

dense goblet
#

one singular player is stored in only one location no?

#

it is just referenced in multiple locations

lilac dagger
#

yes it's stored in heap with an address

#

nothing else holds but a reference to it

#

a pointer

#

the heap is simply stored when you do
new Object();

#

even if it's not asigned

dense goblet
#

I think Sivann thought when you pass player to a function it receives a duplicate

#

which isn't the case

rigid otter
dense goblet
#

modifying a String creates a duplicate I think

lilac dagger
#

strings usually are cached but don't relay on that

dense goblet
#

either that or you are reassigning your string reference

rigid otter
#

Ohh

lilac dagger
#

you should always string.equals

#

just use equals

dense goblet
#

then that will just reassign s to a different memory location (that of "aaa")

lilac dagger
#

it'll make the cheap check

#

if it's cached

#

otherwise it'll go deeper to check it

#

i think modifying a string will give you a new String() which is no longer supported by caching

rigid otter
#

Yes, it looks duplicate, you are right🤔

#

But if in parameter, it's not mean duplicate?

lilac dagger
#

if as literal

#

ye

dense goblet
#

so in memory you would have at first:
0xA: Player
0xB: -some data
0xC: -name: "bobb123"
0xD: -more data
0xE: String s: points to 0xC

then you run s = "aaa"

now in memory you have:
0xA: Player
0xB: -some data
0xC: -name: "bobb123"
0xD: -more data
0xE: String s: points to 0xF
0xF: "aaa"

lilac dagger
#

String a = "a";

and
String b = "a";

#

these are cached

#

but not

String c = "a".substring(1).concact("a");

#

because it uses new String(chars);

rigid otter
#

Ahh, yeah

dense goblet
#

in short if you want to modify a field of the Player, you need to do Player.xyz = "aaa"

#

doing String s = Player.xyz and then s = "aaa" will not work

lilac dagger
#

but why would you wanna know this?

rigid otter
#

Can I do this to store player in another class?

class User {
  Player player;
  public User(Player player) {
    this.player = player;
  }
}```
dense goblet
#

in English, it would be like saying:
make s point to the memory at Player.xyz
then, make s point to the memory with "aaa" in it
But you want to say:
make Player.xyz point to the memory with "aaa" in it
Which is different

eternal oxide
lilac dagger
dense goblet
#

yeah you can't do ref or out in Java like you can in C# 😦

#

or C and C++ pointers

lilac dagger
#

it's not worth it imo

#

this is called hardcoding

#

and you're creating stress over changes

rigid otter
#

Haha

dense goblet
#

passing a reference is hardcoding?

lilac dagger
#

no

#

but switch a reference pointer to something else

#

is not a thing in java

rigid otter
# dense goblet yup

That means when we modifiy player in User class, it will affect to the original Player that hold by somewhat class, right?

lilac dagger
#

we have design patterns to allow us to switch or adapt classes

dense goblet
lilac dagger
#

if you want that

eternal oxide
#

Player is not guaranteed to be persistent where UUID is.

rigid otter
#

What if I want to copy a player? Makes it duplicate.

eternal oxide
#

The Player object may go stale

lilac dagger
#

that you can @rigid otter

rigid otter
lilac dagger
#

just take the player's EntityPlayer in init in yours

#

oh nvm

#

it can only be 1

rigid otter
#

What?

lilac dagger
#

unless you're modifying entity player to hold 2

#

but then it'll be a lot of work

dense goblet
#

the thing I like pointers for is functions such as bool tryParseInt(int *out)

#

though luckily in Java for this specific scenario there is Integer

lilac dagger
#

so you can have side effects?

#

cool yeah

dense goblet
#

still it feels heavy to need to create a new object just to package multiple values into one return

#

you can pretty much do side effects with lists so it would be good to allow them for all types

rigid otter
#

Ok, but now I got the main point! Thank you Fr33styler#7673 Kaktusz#7790 ElgarL#3528 Buby#2953

lilac dagger
#

also

#

all the pointers

#

are copies

#

the one passed via the function param are copies of the one you used to call that function

#

i think c++ has it too

dense goblet
#

so chaining 5 functions with the same argument creates multiple pointer objects?

lilac dagger
#

int som = 5;
foo(som);

#

foo gets a copy of som

dense goblet
#

ig that makes sense considering you don't want a reassignment to mess with the previous function

lilac dagger
#

exactly

bright yoke
#

have you done a java course before?

lilac dagger
#

same for objects tho

dense goblet
#

doing one rn ramidzk

#

though its pretty basic

bright yoke
#

it'd be much much better if you spent a day just learning java without anything spigot related

near crypt
#

what is wrog with this code?:

if(Objects.requireNonNull(event.getCurrentItem()).getType() == Material.BEDROCK) {
                Player online_player = (Player) Bukkit.getOnlinePlayers();
                Player target = (Player) event.getWhoClicked();

                Location target_location = target.getLocation();

                online_player.teleport(target_location);
                target.sendMessage("§aAlle Spieler wurden zu dir teleportiert");
                online_player.sendMessage("§f" + target.getName() + "§a hat dich zu ihm teleportiert");
                target.closeInventory();
            }```
dense goblet
#

intro to OOP

#

or was the question directed at sivann?

bright yoke
dense goblet
#

aye

random epoch
bright yoke
near crypt
#

and how can i get all of them in a variable?

dense goblet
#

most of my misconceptions about Java are adjusting from other languages

bright yoke
#

multiple players could be on, how would you handle that

dense goblet
#

doing C# since 2014, then started uni this year which was C, Assembly and now Java which I used briefly before

bright yoke
#

if you've been doing c# this should feel very familiar

dense goblet
#

yupyup

#

its an easy switch

near crypt
#

@bright yoke and how can i get the Online Players in a variable

dense goblet
#

and you?

bright yoke
#
Collection<Player> players = Bukkit.getOnlinePlayers();
#

but its a collection

near crypt
#

okay

bright yoke
#

how do you want to handle that

near crypt
#

i want to teleport all online players

#

when they click on a item

bright yoke
#

ah

#

so you'd want to loop through them all and run a teleport code, right?

near crypt
#

yes...

bright yoke
#

i dont want to spoonfeed you, try to write something

near crypt
#

okay

bright yoke
#

do you know how to loop through all the players?

near crypt
#

with a loop but idk wich one xD

#

forEach i guess

bright yoke
#

forEach works

near crypt
#

so players.forEach or so?

bright yoke
#

yes

#
for (Player someone : players) {
    // Teleport 'someone'
}
``` this would also work
dense goblet
#

is there a difference between forEach and for(... : ...)?

bright yoke
#

minor speed decrease

#

but 99.9999% of the time the code is slow because of something else, not something as simple as forEach

bright yoke
dense goblet
#

ah so they're not as powerful as in C#

bright yoke
#
String list = "";

players.forEach(player -> {
    list += player.getName() + ", ";
});
``` this won't work for example
dense goblet
#

but in exchange there's java enums so you win some you lose some

bright yoke
#

java enums are god but other languages cant use them because of a stupid patent

#

yes oracle has them patented

dense goblet
#

wow that sucks ass

bright yoke
near crypt
#

but what should i write into the () after players.forEach()?

bright yoke