#help-development

1 messages ยท Page 1546 of 1

sage swift
#

then you can define the method and cancel

wraith rapids
#

BukkitRunnable declares a cancel method

#

new BukkitRunnable() { @Override public void run() { } }.runTaskTimer(plugin, 20, 20)

sage swift
#
new BukkitRunnable() {
  @Override
  public void run() {
    //code here
  }
}``` will allow you to cancel
digital plinth
#

but how does the plugin know which runnable to cancel if you dont feed it the taskID

sage swift
#

cancels itself

wraith rapids
#

because of this

#

it cancels the runnable you call cancel on

digital plinth
#

uhh

#

so i create a method

wraith rapids
#

learn java

digital plinth
#

thta has a runnable in it

#

and that runnable cancel other runnables

wraith rapids
#

no

#

paste the code you are trying to get working

digital plinth
#

im just creating multiple runnables and im kinda having a hard time canceling them

hot hatch
#

is there a way to make a string like "0.4" into a Number?

wraith rapids
#

paste the code

sage swift
#

?paste the code

undone axleBOT
wraith rapids
#

you are too daft to understand an explanation

#

so the only remaining option is a demonstration

#

Double.valueOf("0.4")

hot hatch
#

oh ok thanks

sage swift
#

but beware

wraith rapids
#

or parseDouble

sage swift
#

the exception demons might getcha

hot hatch
#

lol

digital plinth
#
id = Manhunt.getInstance().getServer().getScheduler().runTaskTimer(Manhunt.getInstance(), new Runnable() {
            @Override
            public void run()
            {
                


            }
        }, 1,20).getTaskId();```
sage swift
#

cant refer to itself

wraith rapids
#
new BukkitRunnable() {
            @Override
            public void run()
            {
                
                 cancel(); //this cancels this task

            }
        }.runTaskTimer(Manhunt.getInstance(), 1,20)```
#

notice that Runnable was changed to BukkitRunnable

sage swift
#

well you think wrongly

#

Bukkit.shutdown(); //this cancels the task too

digital plinth
#

nuice

sage swift
#

not necessarily better

wraith rapids
#

only if you need to cancel the task from within itself

#

in any other case, a runnable is cleaner

digital plinth
#

does it run slower or something

digital plinth
wraith rapids
#

no, but it is more ass to read

#

tuinity?

#

starlight ftw

main dew
#

how I can clone object?

sage swift
#

depends on the object lol

wraith rapids
#

month 2 of trying to clone a packet

main dew
#

but you remember wow

main dew
sage swift
#

depends on the object lol

visual tide
#

is there an alternative to myBlockBreakEvent.setDropItems(false) in 1.8?
or do i just cancel the event and set the block

sage swift
#

1.8 is unsupported

#

use a time machine to go back 7 years and ask then

visual tide
main dew
sage swift
#

then dont run 1.8

sage swift
visual tide
sage swift
#

kek

#

use 1.17 api on a 1.17 server

#

no problems

main dew
sage swift
#

i dont know how it can indeed

visual tide
sage swift
#

so stop coding something for a 1.8 server and start coding something for a 1.17 server

visual tide
#

well yes

#

but not the answer i was looking for

#

thx anyway

nova notch
#

how do i make a task id for a task to cancel it?

sage swift
#

@nova notch

nova notch
main dew
#

Bukkit.getScheduler().cancelTask(id);

sage swift
#

oh he wants the id

#

runTask will return the task

#

then you can getId

main dew
sage swift
#

then there is no way to generally clone an object in java

main dew
nova notch
#

the i is the id?

sage swift
#

well no wouldnt that return the task

#

then you can getId

main dew
nova notch
#

yeah

sage swift
#

now yvo see!

nova notch
#

kinda

wraith rapids
#

the .schedule methods return task ids

#

the .runtask methods return the tasks themselves

sage swift
#

i dont care idiot

wraith rapids
#

it's ๐Ÿคก

main dew
#

always posible task.getId

#
public static <T extends Object> T copyObject(T sourceObject) {

        T copyObject = null;

        try {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
            objectOutputStream.writeObject(sourceObject);
            objectOutputStream.flush();
            objectOutputStream.close();
            byteArrayOutputStream.close();
            byte[] byteData = byteArrayOutputStream.toByteArray();
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteData);
            try {
                copyObject = (T) new ObjectInputStream(byteArrayInputStream).readObject();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return copyObject;
    }

    public static void copyInto(Object source,Object destination){
        Class<?> clazz = source.getClass();
        while (!clazz.equals(Object.class)) {
            for (Field field : clazz.getDeclaredFields()) {
                field.setAccessible(true);
                try {
                    field.set(destination, field.get(source));
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
            clazz = clazz.getSuperclass();
        }
    }```
#

I find intresting method

nova notch
#

it says "Variable 'taskID' might not have been initialized"

main dew
#

what?

#

you want change task id?

#

sorry but I don't understand

nova notch
#

im trying to cancel the task using the task id

#
countdown.cancelTask(taskID);```
main dew
#
Bukkit.getScheduler().cancelTask(id);```
#

use this

nova notch
#

oh

#

still says its not initialized

#
BukkitScheduler countdown = player.getServer().getScheduler();
int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable()

and then theres a bunch of stuff inside the thing, didnt include the brackets or anything

#

wait i dont need the countdown anymore

#

so just the task id thing isnt working

rotund pond
#

Hello, good night !

I will need a little help ...
I am learning to use different configuration files than the default one.
For this, I am looking to set a value defined as follows:

   @Override
    public void setMailRead(UUID receiverUUID, Mail mail){

        File mailPlayerDataFile = this.createFile(receiverUUID.toString());

        FileConfiguration yamlDB = YamlConfiguration.loadConfiguration(mailPlayerDataFile);

        yamlDB.set(mail.getId().toString() + ".isRead", true);

    }

My problem: This file is not written. Should I save the file? If yes, how ? Thank you.

digital plinth
#

is anyone familiar with mv api

#

why is newGroup null

main dew
#
    public static <T extends Object> T copyObject(T sourceObject) {

        T copyObject = null;

        try {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
            objectOutputStream.writeObject(sourceObject);
            objectOutputStream.flush();
            objectOutputStream.close();
            byteArrayOutputStream.close();
            byte[] byteData = byteArrayOutputStream.toByteArray();
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteData);
            try {
                copyObject = (T) new ObjectInputStream(byteArrayInputStream).readObject();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return copyObject;
    }``` I find this to clone object
What you think about it?
wraith rapids
#

nothing transient will be cloned

proud basin
#

Would I need to create a new inventory to be able to not take items from someones inventory or could you still just InventoryClickEvent on other players inventory

whole stag
#

What's the accepted way to have multiple commands in a single plugin? One class per command, or multiple commands with the same handler and a check to see what string triggered the command

quaint mantle
#

I broke IntelliJ ๐ŸšŽ

vagrant stratus
whole stag
#

Wouldn't one class per command also get messy though, because java?

vagrant stratus
#

Not really

whole stag
#

All the files though

vagrant stratus
#

easier to read though ๐Ÿ˜‰

whole stag
#

Gosh I hate java lol

#

Why did they have to make file structure part of the syntax

quaint mantle
#

its just a preference, idk why someone would ask what they should do for that

vagrant stratus
wind shoal
#

where can I report bungeecord bugs

whole stag
quaint mantle
#

none of those seem liek an issue

vagrant stratus
#

^

whole stag
#

Name another language that makes file structure part of the code

proud basin
#

so I have java Player target = Bukkit.getPlayer(args[0]); if (checkOnline(args[0])) { player.openInventory(target.getInventory()); } and ```java
@EventHandler
public void onInventoryClick(final InventoryClickEvent e) {
if (!e.getInventory().getName().equalsIgnoreCase("Inventory")) {
return;
}
e.setCancelled(true);
if (e.getCurrentItem() == null || e.getCurrentItem().getType() == Material.AIR) {
return;
}
}

wraith rapids
#

literally any language that groups source files hierarchially

vagrant stratus
#

C# iirc

whole stag
#

Name a major one besides java or kotlin

#

Not C#

vagrant stratus
#

why not C#?

whole stag
#

Because it doesn't do that

wraith rapids
#

also, strictly speaking, file structure is not part of the language

#

package structure is

vagrant stratus
#

You could also not use a file hierarchy with java by putting everything all in "src/main" or "src/" however that just gets messy as hell

wraith rapids
#

there is no constraint that a source file that belongs to a certain package needs to be in a corresponding folder

whole stag
#

c#, python, c++, rust, js, php, perl, ruby, go, swift, and r are all file name agnostic

#

Languages that I can think of off the top of my head that aren't are java, kotlin, and to a limited amount matlab

wraith rapids
#

there is also strictly no need to have any more than one source file

whole stag
#

There is if you need more than one public class

wraith rapids
#

as static inner classes act just like regular classes

#

static inner classes can be public

vagrant stratus
#

classes in classes, but that's also messy

whole stag
#

That's a subclass though, which is a very different construct

wraith rapids
#

it is not

#

it is literally the same as a top level public class

quaint mantle
#

i didn't list that because I understand why you wouldn't consider it

#

butyeah if you don't do what intellij does and never import the top level class

#

inner class acts the exact same

wraith rapids
#

the only difference is that you need to use a different syntax to refer to it from a different top level class than the one it is declared in

#

under the hood, it is the same

#

it even compiles to a distinct and separate top level class file

whole stag
#

They can act the same under certain situations, but that does not mean that they are the same thing, and it certainly doesn't mean that they mean the same thing by convention

vagrant stratus
#

?paste

undone axleBOT
whole stag
#

Java essentially forces you to use a single paradigm, and if you need to use anything outside of that paradigm things get messy very fast

wraith rapids
#

'certain situations' majority of situations, and even in the minority of situations where they are not, the difference is a negligible difference in syntax

vagrant stratus
whole stag
#

For example, why do we even need a create a class and then make a new instance of it to accept custom commands?

wraith rapids
#

because, uh, it's an object oriented language

#

i'm not sure what you're looking for

whole stag
#

It was mostly a rhetorical question

vagrant stratus
#

you could use JavaPlugin#onCommand for everthing, but again... it gets messy

wraith rapids
#

"why do we need to use objects in an object oriented language"

whole stag
#

You don't

wraith rapids
#

"why do we need to use functions in a functional language"

whole stag
#

That's not a requirement for most object oriented languages

vagrant stratus
#

It's not a requirement here either

whole stag
#

For example, we could do something like

@register_command("something")
def something_command(context):
    # do stuff with context when "/something" is run
vagrant stratus
#

There's command libraries for that kinda thing ๐Ÿ˜‰

quaint mantle
#

its literally just a preference

#

you either make it annotation based, or the way bukkit did

wraith rapids
#

see ACF

quaint mantle
#

but that commandmap thing exists so yeah.. you can just add support for annotation based

whole stag
#

Yes, but that basic paradigm is very messy to get working in Java, especially when most of java is built very strongly around objects and interfaces

wraith rapids
#

yes

#

it is an object oriented language

#

everything is an object

#

object is a first class citizen

whole stag
#

That's not what an object oriented language is though

vagrant stratus
#

Even your annotation commands shockingly end up becoming an object

main dew
vagrant stratus
#
Object-oriented programming is a programming paradigm based on the concept of "objects", which can contain data and code: data in the form of fields, and code, in the form of procedures. A feature of objects is that an object's own procedures can access and often modify the data fields of itself.
#

i mean.. how doesn't java fit this?

whole stag
#

Java is an object oriented language, but an object oriented language is not a language where everything is an object

vagrant stratus
#

as for ruby

Ruby is a pure object-oriented language and everything appears to Ruby as an object. Every value in Ruby is an object, even the most primitive things: strings, numbers and even true and false. Even a class itself is an object that is an instance of the Class class.
eternal oxide
#

What in Java is not an object?

whole stag
#

Correct

wraith rapids
#

java is actually less oop pure than some other oop languages, as it has the primitive data types

whole stag
#

There are object oriented languages where everything is an object, like ruby, and there are object oriented languages where most things are objects, like java

proud basin
wraith rapids
#

in the end, everything is an object

#

you can throw annotations at it all you want

#

but at the end of the day, you're still fucking with objects

#

you're still instantiating a class and setting it as the command executor

whole stag
#

Yup

wraith rapids
#

even in your example, even in another oop language

whole stag
#

And that's where java gets annoying in my opinion

wraith rapids
#

objects are objects, syntax sugar is syntax sugar

#

if you want more syntax sugar, use kotlin

whole stag
#

This sort of command registration screams functional programming, but you can't really do functional programming in java

vagrant stratus
#

even pointers are classified as objects it seems :p

wraith rapids
#

sure you can; Bukkit just doesn't support it for command registrations

whole stag
#

You can emulate functional programming through objects, it's not really the same thing

wraith rapids
#

streams and functional interfaces are a thing, and in recent years java has become far more functional

vagrant stratus
#

?paste

undone axleBOT
vagrant stratus
whole stag
#

Object emulating functional

ivory sleet
wraith rapids
#

yes, shockingly, the object oriented language doesn't natively support functional programming

whole stag
#

And yet there are other OOP languages that do

ivory sleet
#

yeah typescript

whole stag
#

JS, TS, C++, Python...

ivory sleet
#

kotlin does

#

I believe

quaint mantle
#

kotlin is, yes

whole stag
#

Yup

ivory sleet
#

heard kotlin might even get union types

#

which is like super pog

whole stag
#

Java is all in all a very, very limited language

ivory sleet
#

depends on the definition of limited

whole stag
#

There's a lot of common stuff you can't do, a lot of comman stuff that's very hard to do

ivory sleet
#

be more concrete

quaint mantle
whole stag
#

Add that in with all of the syntax noise, and it becomes a pain to work with when you're used to more elegant or powerful languages

quaint mantle
#

Huhhhhhhhhh

#

lol

ivory sleet
#

oh yeah surely it lacks of developer sided quality of life features

quaint mantle
#

idk why you surprised about that one imagine

whole stag
#

It's just generally a painful language

vagrant stratus
#

I've worked with python a good bit, don't really have an issue with java as a language ๐Ÿคทโ€โ™‚๏ธ

quaint mantle
#

the only downside of mine to java is that its so strongly typed

#

i just wish kotlin improved java but didn't make its syntax ugly

#

very sad

wraith rapids
#

java does suck, but your basis for saying it sucks is rather silly and seems pretty biased

whole stag
quaint mantle
#

??????????????????????

whole stag
#

Don't worry, I have many more reasons to believe it sucks

ivory sleet
#

yeah java is pass by value

#

all the way

whole stag
#

These are just usually the easiest to explain

quaint mantle
#
private final A a;

public boolean b(A a) {
    return a.equals(this.a):
}
#

idk what you mean by reference

nova notch
#

i still cant get this to work, anyone know why it says taskID isnt initialized?

int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable()
Bukkit.getScheduler().cancelTask(taskID);
ivory sleet
#
var a;

void x(Object o) {
  o = "string";
}

{
  log.info(a); //prints null
  x(a);
  log.info(a); //prints string
}
``` for instance
quaint mantle
#

how many languages are pass by reference/value

#

i wonder what the difference is

#

then how many do both

quaint mantle
wraith rapids
#

noob

ivory sleet
#

Java is pass by value which means that only the value of references get passed

quaint mantle
#

๐Ÿ˜Ÿ

ivory sleet
#

(not talking about java Reference class)

wraith rapids
#

just wrap it in a 1 length array ๐Ÿ˜Ž

ivory sleet
#

lmao

whole stag
#

A good way to check if a function passes by reference is to write a "swap" function

void someFunction(a, b) { 
    tmp = a
    a = b
    b = tmp
}
#

If the variables you passed swap values after calling swap, it's pass by reference

ivory sleet
#

python
a, b = b, a
or smtng lol

whole stag
#

Yup

quaint mantle
#

yall mean

String string = "Dog";
String reference = string;

print(string == reference); // True

this right?

#

instead of like in python

obj#copy
whole stag
#

That's java not allowing operator overloading

#

Another thing that makes it annoying btw

ivory sleet
#

I mean operator overloading doesn't seem that crucial to have in a language

#

of course it's still syntactically nice to have

#

but nothing of the life saving side

whole stag
#

For a language like java where it hides memory management, no, it's not necessary

ivory sleet
#

anyways, speaking of functional programming, you code in haskell?

whole stag
#

Very nice for mathematical classes though

#

I've used some haskell. That's a weird place

ivory sleet
#

monads and monoids ๐Ÿฅฒ

whole stag
#

lol

ivory sleet
#

yeah well Java has Unsafe and is going to get the incubator thing also

#

so it kinda exposes memory management partly

quaint mantle
#

java pretty cucked because of how much they want to preserve compatibility

#

sad times

whole stag
#

Just give me pointers, you're a c type language ๐Ÿ˜ญ

ivory sleet
vagrant stratus
#
So overall Java doesn't have pointers (in the C/C++ sense) because it doesn't need them for general purpose OOP programming. Furthermore, adding pointers to Java would undermine security and robustness and make the language more complex.
quaint mantle
#

can java give me loom, metropolis, panama, valhalla first

ivory sleet
#

yes please

whole stag
#

trust me, I get that pointers have security concerns

quaint mantle
#

java is even going harder on security

#

tough life

vagrant stratus
ivory sleet
whole stag
#

There are times when things would just be faster to throw a quick pointer

quaint mantle
#

definitely

whole stag
#

Nothing critical, they're just another nice to have

#

I guess that's one of the main things with java, all the "nice to have" features it doesn't have, while the main thing that's nice about it is it's enums

#

Side note, java enums are amazing

wraith rapids
#

material enum duke

vagrant stratus
#

Go yell at md_5 for that one

shadow cedar
#

I have multiverse core and I'm trying to find a way to get a queue system for different multiverse worlds. Any help?

whole stag
#

Anyway, gtg

glossy scroll
#

how do you convert a bungee component to a nms chatcomponent?

ivory sleet
#

Probably through pure strings

glossy scroll
#

yea... just dont like the idea of serializing to just unserialize

worldly ingot
#

There are some examples of it in Spigot's implementation iirc

glossy scroll
#

i cant find D:

#

nvm

#

found

#
            // asserted: components != null
            if (CraftMetaBook.this instanceof CraftMetaBookSigned) {
                // Pages are in JSON format:
                return ComponentSerializer.toString(components);
            } else {
                // Convert component to plain String:
                return CraftChatMessage.fromJSONComponent(ComponentSerializer.toString(components));
            }
        }```
#

@worldly ingot idk if ur interested

#

for future use maybe

worldly ingot
#

Yeah I'd figured it had to do with the ComponentSerializer

glossy scroll
#

yea thats basically what i did anyways

#

i just dislike the serializing/unserializing

ivory sleet
#

yeah its gross

nova notch
#

can anyone help me with canceling a task using a task id

#

it says taskID isnt initialized

#
int taskID = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable()
Bukkit.getScheduler().cancelTask(taskID);
wraith rapids
#

use a bukkit runnable

bright jasper
#

Hey is this a good idea? Its in the AsyncChatEvent event ```java
// Due to the nature of spigot chat messages it is not a good idea to disable the event and broadcast later
// Luckily chat is handled on async threads anyway and members are cached after the first time so this is not that huge of a problem
Member member = plugin.getBot().getGuild().retrieveMemberById(playerInfo.getDiscordID()).complete();

#

Read the comment, its basically my question

#

Should I be doing that, usually id add a callback but the issue with that here is that I would have to Bukkit.broadcast instead of just editing the chat event, possibly making my plugin super intrusive? I thought since chat has multiple threads anyway and its likely not a very long task I can just wait for it to finish and block that one of many chat threads

nova notch
#

but now im really confused because people keep saying different stuff

whole stag
bright jasper
nova notch
#

???

bright jasper
#

๐Ÿคก pid moment

#

dont worry

#

yeah use runnables

#

its a lot better

nova notch
#

i thought this was a runnable

#

what

bright jasper
#

Bukkit runnable

whole stag
#

Kinda

quaint mantle
#

Im getting this error with my plugin
Cannot invoke "Object.toString()" because the return value of "net.nukeStudios.nukeNPCS.PacketReader.getValue(Object, String)" is null

bright jasper
#

Bukkit has their own event loop and task queue system for this, theirs is better than using classic Runnables for this since it uses the bukkit threadpool/queue

#

instead of making a whole new one

nova notch
#

i dont know what any of that means

#

but ok

bright jasper
#

Which means you dont need to do shit like Bukkit.getScheduler().runTask(plugin, () -> etc code);

nova notch
#

how do i make this in the form of a bukkit runnable?

bright jasper
#

in random regular runnables

nova notch
#

ok

#

so its deprecated even tho it says it isnt?

bright jasper
#

Well depends on which version of the API you use

nova notch
#

im using 1.17

bright jasper
#

BukkitRunnables are generally way better though

#

Yeah use BukkitRunnables

nova notch
#

so one of them is deprecated i guess?

bright jasper
#

EXCEPT

#

replace Runnable

#

with BukkitRunnable

#

or provide a lambda instead

nova notch
#

it still says taskID isnt initialized tho and thats what i cant figure out

bright jasper
#

It SHOULD exist, which is weird, a bypass I guess is to use cancel() from within the task itself

nova notch
#

ok

bright jasper
#

Read the error

#

The value is the return value was null

#

you cant toString a null

#

its nothing to make into a string

quaint mantle
#

idk how to fix

bright jasper
#

Figure out why the return value was null

nova notch
#

so i have ```java
int countdown = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new BukkitRunnable()

and i used cancel();
but now when i run the command it says Internal error message thing
#

(renamed to countdown)

wraith rapids
#

call runTaskTimer on the BukkitRunnable itself

#

don't use the scheduler

idle tulip
#

i wanted to start with making something in dependencies i cannt add 1.17 spigot jar file

sage swift
idle tulip
#

i was seeing tht only

#

netbeans i m using i m using tht tutorial

nova notch
wraith rapids
#

call it on the bukkitrunnable

#

not the scheduler

nova notch
#

like inside the brackets?

wraith rapids
#

on the bukkit runnable object that you instantiate with new BukkitRunnable

nova notch
#
BukkitRunnable countdown = new BukkitRunnable() {
                @Override
                public void run() {

                }
            }.runTaskTimer(plugin, new BukkitRunnable()```
this?
#

ok i think i might have got it

bright jasper
#

Asked before but no response, ama bit confuse
Its in the AsyncChatEvent event ```java
// Due to the nature of spigot chat messages it is not a good idea to disable the event and broadcast later
// Luckily chat is handled on async threads anyway and members are cached after the first time so this is not that huge of a problem
Member member = plugin.getBot().getGuild().retrieveMemberById(playerInfo.getDiscordID()).complete();

Read the comment, its basically my question
Should I be doing that, usually id add a callback but the issue with that here is that I would have to Bukkit.broadcast instead of just editing the chat event, possibly making my plugin super intrusive? I thought since chat has multiple threads anyway and its likely not a very long task I can just wait for it to finish and block that one of many chat threads
sage swift
#

it would delay the chat though, no?

bright jasper
#

Is the AsyncChatEvent which means there are many threads processing chat at once

sage swift
#

it would still delay the chat message itself somewhat

bright jasper
#

So it would block a single chat thread and if/when another message gets sent while it blocks one of the threads it will just get picked up by another thread

#

Yeah it would

#

It usually would be instant unless something goes wrong with discord API

sage swift
#

i would schedule an async task within

#

you don't want your in game chat breaking if discord does

bright jasper
#

True, I might attach a max timeout to it so the max time it takes is like 5 seconds and if that happens just handle it differently

#

Simply since it would lag chat either way if i have to attach a callback to it, just wouldnt lag the thread but the message

#

and its a bit... wack to cancel chat event just to send another broadcast yk?

sage swift
#

why broadcast?

bright jasper
#

Well i need member data to get the required stuff for a message,

sage swift
#

so cache it

#

async upon join or when they connect their discord or whatever

bright jasper
#

But I may not have it cached already, the problem is that if i need to put it in an async event i need to cancel the chat event or it gets processed before i can change the chat format

sage swift
#

so make the placeholder return "Not Loaded" if it's not cached

bright jasper
#

Actually for here i might be able to use cache

#

interesting

sage swift
#

or however you're doig it

bright jasper
#

The thing is that when you do retrieveMemberById and not cache it checks cache anyway

sage swift
#

it's not worth it to lag a chat message just for the linked account

bright jasper
#

i forgot emote no work

#

lmao

#

but yeah I need to do cache check

#

it will load in at some point so yeah ill do that

ornate heart
#

How would i detect whether a chest is in a generated structure?

sage swift
#

with great pain

hollow bluff
#

What would be the optimal way of storing unlocked and selected cosmetics? For large amount of players, I wouldn't imagine a YML file?

candid silo
#

I have made a sniper rifle for a minigame that uses shift to scope and a pumpkin with a resource pack but I think it would be a lot better to use a spyglass with left click to shoot. When I tried this out, when scoped in, an Interact event listener wouldn't hear left clicks. Is there a way to either detect left clicks while an item is used or to fake it for the client and give them the visuals of a spyglass?

wicked remnant
#

anyone know which api version 'org.bukkit.Material org.bukkit.Material.getMaterial(java.lang.String, boolean)' was first introduced in?

#

1.13?

ornate heart
worldly ingot
#

1.13, yes

sage swift
#

why would it be used before 1.13

digital plinth
#

wut is this

sage swift
#

it

#

tells you

#

right there

hardy swan
#

although the jar name doesn't have space, the plugin name, i assume it is the name specified in plugin.yml, does

sage swift
#

have you ever seen a plugin with a space in its name, SupaGamer?

digital plinth
#

ohh

hardy swan
#

like?

sage swift
#

for the jar file, maybe

digital plinth
#

so i cant have spaces

sage swift
#

i'm talking about the name in /pl

digital plinth
#

interesting

sage swift
#

every single plugin uses CamelCase

hardy swan
#

Ok maybe there was a time where spaces were permitted

nova notch
#

isnt camel case likeThis

hardy swan
#

Both are correct

#

As in both are camelcase

nova notch
#

no i think the one where it starts capitalized has a different name

#

but idk

hardy swan
#

Nope

#

Some people wanna be specific and say upper camelcase

nova notch
#

tf

#

that just sounds so wrong

#

anyway i also figured out how to do the bukkitrunnable thing and everything works flawlessly, spleef game now almost done :)

hardy swan
#

Then maybe

#

but i rmb it is correct to say both are camelcase

worldly ingot
#

PascalCase, you mean

#

but yes, lowerCamelCase vs UpperCamelCase/PascalCase

quaint mantle
#

is there a way i can make a genorator type thing were if i put all diamond ore and blocks down when you break them the whole mine resets after a minute or so and it randomly places the diamond ore and blocks?

hardy swan
young knoll
#

Up here in the north itโ€™s called MooseCase

dull ridge
#

can you modify the block list from BlockExplodeEvent#blockList() to change which blocks it removes?

digital plinth
#

oh my gosh customModels are annoying

#

anything wrong with that

sage swift
#

gonna cwy

digital plinth
#

Y?

quaint mantle
#

how

digital plinth
digital plinth
quaint mantle
#

bruh

#

besides that

digital plinth
#

learn java

sage swift
#

i believe there are multiple plugins out there that do that

quaint mantle
#

easier

sage swift
#
proud basin
#

gecko

digital plinth
#

am i right

digital plinth
sage swift
#

with one simple search!

digital plinth
#

duckduckgo

sage swift
#

Yes

digital plinth
quasi flint
quasi flint
sage swift
#

that's not what they were looking for, Player

quasi flint
#

Not?

sage swift
#

I'll be honest, you seem to try to shut up conversations by giving a crappy or unhelpful answer just to send a message in the chat.

quasi flint
#

Me?

#

Why :(

#

Just missunderstood the question

digital plinth
#

can i detect when a player gets hit by a snowball

#

and get the instance of thqat player

#

and the snowball

quasi flint
earnest sonnet
quasi flint
#

ProjectileHitEvent

digital plinth
#

no that wont do

#

i cant get the player

#

or and snowball

sage swift
#

sure you can

#

what

quasi flint
#

Projectile p = e.getEntity();

if (!(p instanceof Snowball)) return;

Snowball s = (Snowball) p;

digital plinth
#

.getEntity might give me the player

digital plinth
quasi flint
#

And there's ur snowball

digital plinth
#

but what about the player

sage swift
quasi flint
#

Is there a .getPlayer method?

digital plinth
digital plinth
quasi flint
#

:7

silver wadi
#

theres getHitEntity

#

if that helps

digital plinth
sage swift
#

reading helps more, i think

digital plinth
#

i was in the help.wiki or something

quasi flint
#

Good thing

#

There u go

digital plinth
#

Forum staff

sage swift
#

helpchat 1.8 lol

silver wadi
#

getEntity is not who got hit btw

digital plinth
#

close that Misleading website

sage swift
#

that's not... spigot

digital plinth
#

:0

sage swift
#

helpchat insists on justifying 1.8 by hosting the javadocs

digital plinth
whole stag
digital plinth
#

like what to put in the parent

quasi flint
#

Lol

digital plinth
#

another ppl said to put items/generated no matter what

digital plinth
#

found nothin

#

tbh

quasi flint
#

Just fucking google

digital plinth
#

๐Ÿคฃ

quasi flint
#

The first thing I found was that resource

digital plinth
#

i did but well

#

okie

quasi flint
digital plinth
quasi flint
#

Indent that thing please

#

My eyes

#

It burns

whole stag
#

Thus spake the Lord: Thou shalt indent with four spaces. No more, no less. Four shall be the number of spaces thou shalt indent, and the number of thy indenting shall be four. Eight shalt thou not indent, nor either indent thou two, excepting that thou then proceed to four. Tabs are right out.
Pep 8:22

quaint mantle
#

how does the new 1.17 NMS work? im using an nms util class that uses net.minecraft.server but like ItemStack is in .server.world.item which throws errors

sage swift
#

almost everything is repackaged

#

people are used to using reflection or NMS util, but those old ones won't work anymore

hardy swan
#

Though is normally 4 for java

whole stag
#

Two is passable, it just isn't as visually distinct

#

Of course, if you use the indent rainbow plugin like me it's still plenty distinct

digital plinth
#

who are you asking

#

:>

lucid jacinth
#

what's the method to spawn a new entity, like a new snowball, at a particular location?

#

or do i just initialize a Snowball object?

sage swift
#

well, projectiles are kinda required to have a shooter

#

so you can use the ProjectileSource interface to shoot the projectile

spark solstice
#

how would i separate the skywars code and the survival games code into separate files, so i have a file for my main class, a file for my skywars class, and a file for my survival games class

public class Main extends JavaPlugin {
    
    // Create SkyWars Teams
    Team sw_team_one = scoreboard.registerNewTeam("sw_team_one");
    Team sw_team_two = scoreboard.registerNewTeam("sw_team_two");

    // Create Survival Games Teams
    Team sg_team_one = scoreboard.registerNewTeam("sg_team_one");
    Team sg_team_two = scoreboard.registerNewTeam("sg_team_two");

    @Override
    public void onEnable() { 
        // Setup SkyWars Teams
        sw_team_one.color(NamedTextColor.RED);
        sw_team_two.color(NamedTextColor.YELLOW);

        // Create Survival Games Teams
        sg_team_one.color(NamedTextColor.BLUE);
        sg_team_two.color(NamedTextColor.GREEN);
    }

    @Override
    public void onDisable() {
        // Remove SkyWars Teams
        sw_team_one.unregister();
        sw_team_two.unregister();

        // Remove Survival Games Teams
        sg_team_one.unregister();
        sg_team_two.unregister();
    }
}```
#

i have the scoreboard defined elsewhere this is just a placeholder

dusty sandal
#

If I'm making one of my classes serializable with the Config API is it okay for my deserialize(map args) method to return null or something else to indicate it can't properly be deserialized?

#

or wait
do i just throw an exception if i cant deserialize it?

sage swift
#

well if you set a value to null it just won't show up

#

so you can technically set and get null values just fine

brave trellis
#
  @EventHandler (ignoreCancelled = true)
  public void onDamageCheck(EntityDamageByEntityEvent event) {
    Bukkit.broadcastMessage("Hit"); 
  }

Technically this should stop the message from appearing when getting hit in a worldguard region right?

sage swift
#

priority matters

#

what priority does worldguard cancel at

#

try yours at highest, or monitor if you're not gonna modify the outcome of the event

brave trellis
#

Thank you

#

Works now

sage swift
#

:)

#

never forget priority

smoky oak
#

Can I somehow override one plugin's method with another plugins method? I am writing both.
What i want to do is for a second plugin to impose restrictions on the reacttions of the first.

#

IE, as long as the second plugin is active, you need it's permissions too

frosty tinsel
cedar rampart
#
 for(Entity e: location.getChunk().getEntities()){
                          if(e.getLocation().distance(location)<1){
                              if(!e.equals(player)){
                                  e.setGlowing(true);

                              }
                          }
                      }

how do i cancel the glowing effect after sometime

sage swift
#

e.setGlowing(false)

cedar rampart
candid silo
#

is there way to listen for left click while the player is using an item, in this case a spy glass

candid silo
#

when looking through the spyglass the event isn't called for a left click

sage swift
#

interesting, must be client side

candid silo
#

does that also mean a packet isn't sent at all

sage swift
#

probably

#

unfortunate

candid silo
#

is there a way to send packets to make the client look like they're using the spy glass

#

or would that run into the same input problem

sage swift
#

probably not

candid silo
#

dang

#

gotta stick with the ol' pumpkin and texture pack

hardy swan
#

you can check whether item use statistic increments when using spyglass

sage swift
#

oh interesting

#

so must be a packet sent then

#

just no api i guess

#

seems entirely clientside though

#

couldnt someone just send a shit ton of "i looked in spyglass" packets

candid silo
#

I think the stat for spyglass is just looking through it

sage swift
#

no, there's definitely a packet sent

#

spyglass is right click to look through though

hardy swan
#

there is also an event when statistics increase for a player

sage swift
#
    @EventHandler
    public void onSpyglassLook(PlayerStatisticIncrementEvent evt) {
        if (evt.getStatistic() != Statistic.USE_ITEM || evt.getMaterial() != Material.SPYGLASS) return;
        Bukkit.broadcastMessage("spyglass looked through");
    }``` works just fine
#

guess now you need to detect when they stop

candid silo
#

that's not my issue, my issue is that I can't detect left clicks while they are looking through it

#

the left click doesn't trigger the event

sage swift
#

clientside, you can't left click while looking through it

candid silo
#

yeah

hardy swan
#

you tryin to make csgo in minecraft?

#

XD

candid silo
#

minigame, one class has a sniper

hardy swan
#

interesting, worthwhile to figure this out

candid silo
#

been using shift and it gives you a pumpkin with a texture pack

#

works fine but would be nice to use spyglass

cedar rampart
#

can someone give me a beginner project to work on?

#

im so lost on what to do

sage swift
#

an item that clears a whole chunk when placed

torn shuttle
#

a chunk that clears a whole item when placed

torn shuttle
stone sinew
torn shuttle
cedar rampart
#

seems doable for me

sage swift
#

was one of my first plugins

quasi flint
#

i think so. but not sure

spare prism
#

?paste

undone axleBOT
spare prism
hybrid spoke
#

extend? more implement and its totally fine

cold field
#

How Do I import documentation into my IDE using gradle?

torn shuttle
#

anyone remember off the top of their heads what the max image size limit was for a spigot post?

torn shuttle
#

pretty sure it's the only reason every spigot post isn't just one giant gif

dire marsh
#

like 5MB

stone sinew
#

I was thinking resolution.

#

My bad

dire marsh
#

but you can link to an external image url

torn shuttle
#

hm

#

hmm

#

was it 3MB before because it seems like that's what I was targetting before

#

but ok

shy wolf
#

?jd

quaint mantle
#

hi I have a problem in my geyser

#

when becrock players enter, their name it shows lik this

#

Bedrock Name: Derek

#

Server Name with Bedrock: .Derek

#

Can u help me

shy wolf
#

i dont have bedrock

#

and i dont think spigot have server for bedrock

quaint mantle
#

no, with the plugin geyser

#

and the foodgate

stone sinew
quaint mantle
#

ohh ok thank u

#

๐Ÿ‘

covert bluff
#

what is pigstep's material in spigot

silver cove
#

MUSIC_DISC_PIGSTEP

shy wolf
#

my server crash

#

for no reson

hybrid spoke
#

01.07 06:52:49 [Server] ERROR app//it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap.get(Long2ObjectOpenHashMap.java:356)
there is the reason

reef wind
#

damn why do some many "devs" not now how to read errors

smoky oak
#

Can i have my question answered? Can you overwrite functions from other plugins?

earnest sonnet
smoky oak
#

i write both plugins

earnest sonnet
#

It's just basic java then, though, I think you can use event priorities to overwrite events?

smoky oak
#

got a reference? I'm not too sure what you mean

earnest sonnet
#

and player pre process or how ever it's called for commands

smoky oak
#

cancelling the command before it gets to the other plugin you mean?

earnest sonnet
#

PlayerCommandPreprocessEvent

#

for the commands

hybrid spoke
#

polymorphism is a thing

smoky oak
#

problem is i need that for a playerInteractEvent

earnest sonnet
smoky oak
#

Would i get an error were i to register two events with the same name but different priority?

#

or since this is bukkit same @EventHandler?

#

Wait can i listen for the activation of plugin functions?

earnest sonnet
#

?google

undone axleBOT
smoky oak
#

fair enough lol

stone sinew
#

You have to make a method for it yourself.

#

If you can't do anything with that info you probably wouldn't be able to do anything in the first place ... ๐Ÿคท

#

And if you gave me a few seconds I would post the code

earnest sonnet
#

Alright, a more detailed response, you can either write a method by yourself to check the length, add the write letter / remove the a few numbers, there is also another way, which you just need to think a the logic on how to use the Math class and google to write only a few lines, but by being rude isn't going to bring you any help

stone sinew
#
public String formatMoney(double amount) {
    if(amount < 1000L ) { return format(amount); }
    if(amount < 1000000L ) { return format(amount/1000L)+"k"; }
    if(amount < 1000000000L ) { return format(amount/1000000L)+"m"; }
    if(amount < 1000000000000L ) { return format(amount/1000000000L)+"b"; }
    if(amount < 1000000000000000L ) { return format(amount/1000000000000L)+"t"; }
    if(amount < 1000000000000000000L ) { return format(amount/1000000000000000L)+"q"; }
    return String.valueOf((long) amount);
}
mental pebble
#

I've been using https://crafatar.com to get player skins for my plugins. Is there a Bedrock alternative to this site?

tardy delta
#

i have vault as a soft dependency on my plugin, can i make sure that if the server doesnt have it, the plugin loads like normal?

ivory sleet
tardy delta
#

but i'm using a part of their economy

#

so i have an error every time i want to enable my plugin

chrome beacon
earnest sonnet
ivory sleet
#

Then you will have to check if an economy implementation is present

stone sinew
tardy delta
#

i have this code for it now

private void dependenciesSetup() {
      // Setup Economy
        if (instance.getConfig().getBoolean("requires_vault") &&
                Bukkit.getPluginManager().getPlugin("Vault") == null)
            getServer().getPluginManager().disablePlugin(this);
        RegisteredServiceProvider<Economy> economy = getServer().getServicesManager()
                .getRegistration(net.milkbowl.vault.economy.Economy.class);
        if (economy != null)
            eco = economy.getProvider();
        if (eco == null) {
                Utils.logInfo("You must have Vault installed and an Economy plugin!");
        }
#

ah that first if is kinda wrong

ivory sleet
stone sinew
high pewter
#

Entity.setVelocity(Vector vector) seems to have no effect if the entity is in water; anybody have any ideas how to get around this?

ivory sleet
#

doubles can be much greater than longs

earnest sonnet
stone sinew
ivory sleet
#

Nope

tardy delta
earnest sonnet
#

yes

tardy delta
#

and by default its false

ivory sleet
#

But if you use large doubles, precision and presumably calculation problems may be encountered

earnest sonnet
wraith rapids
#

yes, but they represent data differently

ivory sleet
#

Yeah but it has something called a scaling factor or an exponent

#

Works quite differently from int/long

wraith rapids
#

a double sacrifices some of the 64 bits of precision in order to be able to represent values of arbitrary scale

earnest sonnet
#

So, long should be bigger, no ?

wraith rapids
#

they are the same size

#

but double can represent larger numbers at a lower precision

reef wind
wraith rapids
#

or smaller numbers at a higher precision

#

you can think of it as using 48 bits to represent an integer number

#

and then use the remaining bits to determine the position of the radix dot

#

12345.6789

earnest sonnet
#

Yes, that's what I was thinking

wraith rapids
#

you can move the dot around, but the actual number of digits you can have is still fixed

#

123456789000000000.0

tardy delta
#

how can i prevent this
Caused by: java.lang.ClassNotFoundException: net.milkbowl.vault.economy.Economy

wraith rapids
#

0.0000000000123456789

tardy delta
#

when vault isnt installed

wraith rapids
#

don't try loading the class if it isn't installed

ivory sleet
#

anyways by looking from the code above it seems like you want to add a return; if the first branch is true

wraith rapids
#

i don't remember if that is enough

chrome beacon
wraith rapids
#

just referencing the class in the method might make it explode

#

i don't remember the exact semantics of when classes are prompted to be loaded

earnest sonnet
#

yea, no, never mind, I'm an idiot

ivory sleet
#

null checking PluginManager#getPlugin(name) should be enough I think

chrome beacon
#

Make sure you have the repositories in your POM

tardy delta
#
 if (instance.getConfig().getBoolean("requires_vault") &&
                Bukkit.getPluginManager().getPlugin("Vault") == null) {
            getServer().getPluginManager().disablePlugin(this);
        } else if (instance.getConfig().getBoolean("requires_vault") && 
        Bukkit.getPluginManager().getPlugin("Vault") != null) {
            RegisteredServiceProvider<Economy> economy = getServer().getServicesManager()
                    .getRegistration(net.milkbowl.vault.economy.Economy.class);
            if (economy != null)
                eco = economy.getProvider();
            if (eco == null) {
                Utils.logInfo("No economy plugin found!");
            }
        }
wraith rapids
#

tht is illegible

#

what am I even looking at

#

space your lines apart

chrome beacon
#

Show POM and full error

chrome beacon
tardy delta
#

i also want to let the plugin work without vault installed

ivory sleet
#

Then why disable your plugin if vault is absent?

tardy delta
#

if in the config file require_vault is set to true then it disables

#

otherwise it just dont load the vault classes

ivory sleet
#

Sounds very odd to have as a feature but I guess

wraith rapids
#

i generally prefer to isolate soft dependencies and their classes entirely

#

plugin.getDependencies().VAULT.doVaultThing()

tardy delta
#

it does work but its strange code yea

ivory sleet
#

public final?

wraith rapids
#

myeah

#

i suppose I could or should use a method, but I like the enum-esque declaration

ivory sleet
#

Lmao fair

wild marten
#

Hi, i have been tryna do this for a while and I am confused on why its not working. My config is not saving what i am setting, LinkedHandler is my config handler and it is just a basic yml config handler.
Code:

        new LinkedHandler().saveConfig();```

Config Handler:
```public static File configFile;
    public static FileConfiguration config;

    public void base(Main m){
        if(!m.getDataFolder().exists()){
            m.getDataFolder().mkdirs();
        }
        configFile = new File(m.getDataFolder(), "linked.yml");
        if (!configFile.exists()) {
            m.saveResource("linked.yml", false);
        }

        config = YamlConfiguration.loadConfiguration(configFile);
}

public void saveConfig() {
        try {
            config.save(configFile);
        } catch (IOException e) {
        }
}
opal juniper
#

is it in maven central?

wraith rapids
#

learn java

opal juniper
#

lemme open an ide

#

Works fine for me

#
<dependency>
    <groupId>xyz.xenondevs</groupId>
    <artifactId>particle</artifactId>
    <version>1.6.3</version>
    <scope>provided</scope>
</dependency>
wild marten
#

Tomato, what is your issue?

wraith rapids
#

inb4 using dialup

opal juniper
#

There must be something that is causing that issue on your end then...

tardy delta
#

then dont press it ๐Ÿคก

#

is this a good way to check in the inventoryClickEVent if the clicked inventory is one i made myself? (the TrailsGui class)

if (event.getInventory() instanceof TrailsGui/*trails*/) {
opal juniper
#

Use the inventory holder

tardy delta
#

ah thats why i'm encountering the same problem as before

wraith rapids
#

inventory holder or the inventory instance

#

i don't think it's a good idea to implement the bukkit inventory

#

doing that can generally cause shit to explode

tardy delta
#

this is my gui class

opal juniper
#

replace null

#

with this iirc

tardy delta
#

instead of owner?

wraith rapids
#

yes

#

inventoryholder doesn't mean the person who is looking at the inventory

#

it means the thing that holds the inventory

tardy delta
#

yes

wraith rapids
#

for a chest inventory, it will be the chest

#

for your custom gui, it will be whatever handles your custom gui

tardy delta
#

ah okay

#

ah yes it works

#

thanks

#

but is there some way to push new contents of a file to the plugins datafolder with every new update?

opal juniper
#

what?

#

what file

tardy delta
#

there is a folder in plugins for every plugin's files

wraith rapids
#

wut

main dew
#

How clone object without implements cloneable and without constructor?

wraith rapids
#

do you mean an embedded resource in the jar?

tardy delta
#

aah i just want to write new text to the existing config files

#

like when there is an update or other things

wraith rapids
#

you'll have a difficult time if you want to preserve comments

#

consider using a real config api or framework, like configurate

opal juniper
#

just pass all the data in and BANG you have another object but with the same data

#

oh wait you said without

#

idk

#

What is your usecase?

main dew
#

I need copy packet

opal juniper
#

Hm ok

eternal oxide
#

What packet and why do you need to copy it?

chrome beacon
main dew
#

I need send to other players others packet about someone things

chrome beacon
#

Why don't you want to use the constructor

main dew
opal juniper
#

???

#

Those two reasons are not actually issues afaik

#

who told you that?

chrome beacon
tardy delta
#

well how can i "disable" my class when vault isnt installed?

opal juniper
#

Just dont instanciate it ๐Ÿ™ƒ

main dew
opal juniper
#

Not true

chrome beacon
tardy delta
#

just put an if inside my methods that looks if vault is installed?

main dew
#
    public static <T extends Object> T copyObject(T sourceObject) {

        T copyObject = null;

        try {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
            objectOutputStream.writeObject(sourceObject);
            objectOutputStream.flush();
            objectOutputStream.close();
            byteArrayOutputStream.close();
            byte[] byteData = byteArrayOutputStream.toByteArray();
            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteData);
            try {
                copyObject = (T) new ObjectInputStream(byteArrayInputStream).readObject();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return copyObject;
    }``` yestarday I find this but this is bad I think
opal juniper
#

if you find another way it almost 100% just uses the constructor under the hood

chrome beacon
#

You can't create another instance without creating another instance

opal juniper
wraith rapids
#

you can not safely create an object without invoking a constructor

main dew
#

see on this source I don't understand it but this work

wraith rapids
#

you have been asking for this shit for fucking months

#

its time to start listening

tardy delta
wraith rapids
#

fucking 1.8 users smh

tardy delta
#

and thats enough?

wraith rapids
#

just use the constructor

opal juniper
main dew
wraith rapids
#

you clearly are

opal juniper
chrome beacon
#

Just use a constructor

wraith rapids
#

nobody other than a 1.8 user could be this persistent about something this stupid

hardy swan
#

What is the issue

chrome beacon
#

He wants to create an instance without a constructor

opal juniper
#

he wants to clone an object without the constuctor

hardy swan
#

?

#

Huh?

opal juniper
opal juniper
#

no - that is just something he gave

hardy swan
#

This has a constructor inside

chrome beacon
#

Yeah

opal juniper
#

Try telling him that

chrome beacon
#

All other constructors are fine exept the constructor of the object he's cloning

main dew
chrome beacon
#

;/

opal juniper
tardy delta
#

do you had a nightmare about constructors?

hardy swan
#

Ok whenever you see an instance popping out from no where, you can safely assume there is a constructor implemented somewhere

chrome beacon
#

^^

earnest sonnet
#

^^

opal juniper
#

^^

main dew
chrome beacon
#

._.

#

I give up with you

opal juniper
main dew
#

I don't want to use just the constructor of the class I want to clone

opal juniper
#

YOU CANNOT DO IT SAFELY ANY OTHER WAY

chrome beacon
#

There is no reason to work around the constructor

opal juniper
#

USE IT

earnest sonnet
main dew
earnest sonnet
#

Not a valid one

chrome beacon
hardy swan
#

Lol

opal juniper
#

lmao

earnest sonnet
#

๐Ÿ˜‚ ๐Ÿ˜‚

chrome beacon
#

;/

#

You were slightly faster

opal juniper
#

If you can give a good reason we may help you more

#

but if not - use the constructor

opal juniper
main dew
#

see this constructor

opal juniper
#

yes

#

its the x & y

main dew
#
 public PacketPlayOutMapChunk(Chunk var1, int var2) {
        this.a = var1.locX;
        this.b = var1.locZ;
        this.f = var2 == 65535;
        boolean var3 = var1.getWorld().worldProvider.m();
        this.d = new byte[this.a(var1, var3, var2)];
        this.c = this.a(new PacketDataSerializer(this.g()), var1, var3, var2);
        this.e = Lists.newArrayList();
        Iterator var4 = var1.getTileEntities().entrySet().iterator();

        while(true) {
            TileEntity var7;
            int var8;
            do {
                if (!var4.hasNext()) {
                    return;
                }

                Entry var5 = (Entry)var4.next();
                BlockPosition var6 = (BlockPosition)var5.getKey();
                var7 = (TileEntity)var5.getValue();
                var8 = var6.getY() >> 4;
            } while(!this.e() && (var2 & 1 << var8) == 0);

            NBTTagCompound var9 = var7.d();
            this.e.add(var9);
        }
    }```
opal juniper
#

wait no it isnt

#

nvm ignore me

hardy swan
#

ok i didn't know there is a provided nms code lol

main dew
#

one constructor for each on all blocks check all NBT and check all entity on chunk

opal juniper
#

i think you have to bare in mind that the server sends hundreds of these per second

#

it is not that inneficient

main dew
#

calling this constructor causes high CPU usage

opal juniper
#

nope

#

not true

#

thank you very much

#

dont come again

chrome beacon
#

If you really want to make it faster create your own packet

#

And no we won't guide you with that

main dew
opal juniper
#

Nope

#

So little of the server tick is spent sending these

#

you are over thinking this

main dew
chrome beacon
#

Why are you sending 10 times more

opal juniper
#

wtf

#

why

earnest sonnet
#

I have so many questions

opal juniper
#

what plugin are you making @main dew

main dew
#

sending this packet does not only generate new chunks but also refresh old ones

#

the server then creates one package for all players that have that chunk loaded

#

but if I want to send a slightly changed package to each player, I have to clone it

opal juniper
#

I finally understand

#

what are you changing

#

in the packets

main dew
#

blocks and nbt

opal juniper
#

why dont you send them packets seperately

#

rather than changing the chunk send blockchange packets

main dew
#

what do you mean?

opal juniper
#

if you are changing blocks in the chunk packet

#

just send blockchange packets after and un-modified chunk packet

#

which will have a lower over-head

chrome beacon
#

Also why not just use Protocollib or smth

opal juniper
#

^^

chrome beacon
#

I see little reason to remake things that already exists and is almost installed everywhere regardless...

main dew
smoky oak
#

This the right place to ask why config files aint working?

chrome beacon
#

Depends on which config files

smoky oak
#

a config file which stores player data

hardy swan
#

if plugin config yes

chrome beacon
#

Your plugin or someone elses

smoky oak
#

mine

#

thing is

chrome beacon
#

Then this is the right place

smoky oak
#

config: ```yml
<some_uuid>:
<first_key>: Alpha

code:```java
//MainClass
public FileConfiguration cfg = null;
File dataFolder = this.getDataFolder();
//OnEnable
cfg = YamlConfiguration.loadConfiguration(new File(dataFolder, "config.yml"));
//Other Class, same package:
sender.sendMessage(Bukkit.getPluginManager.getPlugin("MyPlugin").cfg.getString(player.getUniqueId() + ".first_key", null));

result:
null
Why isn't it the saved value? There's no error in the console either, and the plugin is has read/write permissions

hardy swan
#

firstly

#

if this is your plugin

smoky oak
#

yes

hardy swan
#

JavaPlugin#getConfig()

smoky oak
#

part of it at any rate

#

ah no there are two configuration files

hardy swan
#

oh

smoky oak
#

i just shortened it to make it easier to read

chrome beacon
#

Also why are you using the plugin manager to get your instance

smoky oak
#

different class?

chrome beacon
#

You should pass it along in the constructor

smoky oak
#

that is in a command call

chrome beacon
#

and?

dense goblet
#

static instance is what I see used

hardy swan
smoky oak
#

no

#

i shortened the name

hardy swan
#

oh ok

main dew
hardy swan
#

then you dun need Bukkit.getPluginManager.getPlugin("MyPlugin") infront of cfg

dense goblet
#

Not sure if that's bad practice tho

smoky oak
#

its in a different class

#

and that class handles commands

main dew
#

and sometimes another plugin to refresh the chunks and then everything goes to waste (worldedit etc)

chrome beacon
#

In the constructor of you command class pass your plugin instance and save that to a variable

opal juniper
#

idk man i cannot help u anymore

smoky oak
#

will do but that still doesnt tell me why it returns null instead of the string i want

opal juniper
#

their internet shouldn't matter

chrome beacon
smoky oak
#

onyl the relevant parts but yes. Give me a moment

dense goblet
chrome beacon
#

A static refrence is fine too

dense goblet
#

Okay good to know

smoky oak
#

wait.
what happens on String s = null;
if(s == null)

#

is that the issue?

chrome beacon
#

Well that if check would be true

#

Not much more we can tell from that

smoky oak
#

dammit then heres the code

#

main class (named Echo):

    FileConfiguration config_players = null;//YamlConfiguration.loadConfiguration(new File(dataFolder, ""));
    @Override
    public void onEnable() {
        //File cFile= new File(this.getDataFolder(), "config.yml");
        //if(cFile.exists()) {
        //    cFile.delete();}
        //getConfig().options().copyDefaults(true);
        //saveDefaultConfig();
        
        loadPlayerConfig();
        
        getCommand("getrace").setExecutor(new GetRaceCmd());
    }

    public void loadPlayerConfig() {
        File pdf = new File(dataFolder, "config_players.yml");
        if(!pdf.exists()) {
            pdf.mkdirs();
            try {
                pdf.createNewFile();
            } catch (IOException e) {
                Bukkit.getLogger().log(Level.SEVERE, "Could not save Log file due to: "+e.getMessage());
            }
        }
        config_players = YamlConfiguration.loadConfiguration(pdf);}

command class, relevant part:

public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if(args.length == 0)
            return false;
        Player p;
        p = Bukkit.getPlayer(args[0]);
        if(p==null) {
            sender.sendMessage("Player not online, checking offline.");
            p = (Player) Bukkit.getOfflinePlayer(args[0]);
            if(p == null) {
                sender.sendMessage("Could not find offline player. Does a player with that name exist?");
                return true;
            }
        }
        //Standard return value null
        String race =  Echo.Instance().cfg.getString(p.getUniqueId() + ".race", null);
        if(race == null) //This always trigg
            sender.sendMessage("The player has no race assigned. Did he ever join?");
        else
            sender.sendMessage("The player has the race '"+race+"' assigned.");```
chrome beacon
#

More specifically the creating custom configs part

smoky oak
#

I read that and tried

#

which still isnt helping much since i just cant find the issue

chrome beacon
#

Does your config actually contain anything

smoky oak
#

yes i checked

#
ba091b51-a21c-4710-a4d5-799f240ccd6a:
  race: Arachnid
chrome beacon
#

Aight

smoky oak
#

that uuid is that of the player im checking too

chrome beacon
#

Looks fine

smoky oak
#

thats the issue lol

chrome beacon
#

Could you show me the cfg variable