#help-development

1 messages ยท Page 1402 of 1

crude charm
#

I didnt see that

stone sinew
#

This can actually just be

String winMessage = plugin.getConfig().getString("win-message").replaceAll("%outcome%", String.valueOf(outcome)).replaceAll("%wonamount%", String.valueOf(wonamount));
crude charm
#

aight

#

thanks

stone sinew
#

๐Ÿ‘

young knoll
#

replaceAll is for regex

#

If you donโ€™t need regex, use replace

crude charm
#

I am a math NOOB ok like math NOOB NOOB. say the int is 6, how do I get 4, 5, and 6 but then if I change the number to 10 5, 6, 7, 8, 9, 10 and so on


                int outcome = random.nextInt(plugin.getConfig().getInt("gamble-between"));

                if (outcome < outcome / 2) {

                    String winMessage = plugin.getConfig().getString("win-message")
                            .replaceAll("%outcome%", String.valueOf(outcome))
                            .replaceAll("%wonamount%", String.valueOf(gambledAmount * 2));

                    economy.depositPlayer(player, gambledAmount * 1);
                    player.sendMessage(ChatColor.translateAlternateColorCodes('&', winMessage));
                    return true;
                } else {
                    String looseMessage = plugin.getConfig().getString("loose-message")
                            .replaceAll("%outcome%", String.valueOf(outcome))
                            .replaceAll("%wonamount%", String.valueOf(gambledAmount));

                    economy.withdrawPlayer(player, gambledAmount);
                    wonamount = (int) (gambledAmount);
                    player.sendMessage(ChatColor.translateAlternateColorCodes('&', looseMessage));
                    return true;

                }

this is context if you need it

sage swift
#

outcome < outcome / 2

#

this will only be true for numbers <= 0

crude charm
#

ik

#

its wrong

#

but idk how I should do it

sage swift
#

what do you want to do

#

your question does not make sense

#

you want the numbers from the number/2 to the number?

crude charm
#

so I generate a random number between one and six right

#

if that number is 4, 5, or 6

#

then do smth

#

else

#

1, 2, 3

sage swift
#

well you could just say if the number is >= 4 to encompass everything 4 and up (in this case 4, 5, and 6)

crude charm
#

but I cant

#

because I need it to be configurable

sage swift
#

so you're not generating a number between one and six

crude charm
#

yes

sage swift
#

just say x instead of 6

#

now explain the problem again

#

also generating a randomInt will generate from 0 to the number you give it - 1

crude charm
#

if x is 4, 5 or 6 then run the first method (but for example if its set to 10 then it would be 5, 6, 7, 8, 9, 10)

#

else for the first half

sage swift
#

well 5 6 7 8 9 10 is not half

crude charm
#

yes it is

#

wat

sage swift
#

1 2 3 4
4 numbers

#

5 6 7 8 9 10
6 numbers

crude charm
#

ik

#

I said if the number is 10

#

5 if half of 10

sage swift
#

and 3 is half of 6

crude charm
#

yes

sage swift
#

why didnt you say 3 4 5 6 then

crude charm
#

because its out of 10

sage swift
#

for the first case

crude charm
#

u know what I mean

sage swift
#

in any case, you will be generating from 0 to the number - 1

#

so generating with config value 6 will give you either 0, 1, 2, 3, 4, or 5

crude charm
#

ik

sage swift
#

luckily enough you can divide by two

crude charm
#

I do that

#

if (outcome < outcome / 2) {

sage swift
#

well you're comparing the outcome to itself

#

you want to compare it to the actual number in the config still

crude charm
#

the outcome is the config

#

int outcome = random.nextInt(plugin.getConfig().getInt("gamble-between"));

sage swift
#

so if you get 4 youll just get 4 < 2

candid galleon
#

lmao

sage swift
#

which will pretty much always be false

candid galleon
#

if(outcome < outcome / 2)

#

love it

crude charm
sage swift
#

you want to use the original number that you used to generate the random choice

candid galleon
#

got a laf lol sry im mean but i laffff

sage swift
#

no, you use the outcome (the random choice itself)

crude charm
#

the original number is the config value

candid galleon
#

I'm just reading this channel, can I see your code Zoi?

sage swift
#

its at the top

candid galleon
#

ty

sage swift
#

quite a ways up

candid galleon
#

so to simplify that code

#
int outcome = random.nextInt(plugin.getConfig().getInt("gamble-between"));
if (outcome < outcome / 2) { } else { }
crude charm
#

yes

#

but I need the other stuff

sage swift
#

plugin.getConfig().getInt("gamble-between") is what you want to compare the outcome to

crude charm
#

cant just delete it - ik

candid galleon
#

right so

sage swift
#

but instead of copying the retrieval over, set it to a variable first so you can use it twice

candid galleon
#

plugin.getConfig().getInt("gamble-between") @crude charm what does this return? what is its purpose?

crude charm
#

#The max gamble amount in 0-value in this case, 0-6
gamble-between: 6

candid galleon
#

great so it's the max gamble amount right?

crude charm
#

yes

candid galleon
#

and random.nextInt picks a random number from 0 - that number

#

so say the max is 10

crude charm
#

and I want to get the last half of that number

candid galleon
#

outcome = rnd(10)

crude charm
#

5, 6, 7, 8, 9, 20

candid galleon
#

let's say that results in outcome = 2

crude charm
#

1

#

2

candid galleon
#

so you're comparing if(2 < 2/2)

sage swift
#

numer

#

mm

candid galleon
#

it doesn't matter what the numbers are rn

crude charm
#

ok

candid galleon
#

so what are you comparing with the max gamble?

crude charm
#

the max gamble

#

rn atleast

candid galleon
#

so you're comparing the max gamble to the max gamble?

crude charm
#

yea /2

candid galleon
#

why / 2?

crude charm
#

oh im dumb

#

lmfao

#

if (outcome < outcome / 2) {

#

yeah ok

#

still dont know how to fix it, knew it was wrong because it wasn't working how I want

candid galleon
#

well what are you trying to do exactly

#

something with gambling? what is it?

crude charm
#

ye

#

if 4, 5, 6 then double or 1, 2, 3 loose

candid galleon
#

what will be 1-6?

#

is it a number that a player gives?

crude charm
#

no its the random number

candid galleon
#

i see

crude charm
#

the max number

candid galleon
#

so it's like rolling a die?

crude charm
#

yes

candid galleon
#

and the "max number" is the number of sides

crude charm
#

yup

candid galleon
#

and you were doing / 2 because you want the value to be higher than the half of the die

crude charm
#

yes

candid galleon
#

for ex 1-5 on a 10 sided die would lose, and 6-10 would win

#

right

crude charm
#

exactly

candid galleon
#

but what you're doing is you're:
rolling a number from 0 to MAX, and assigning it to current
and then comparing if current is less than the current / 2

#

do you see where you're going wrong?

crude charm
#

yes? it can only check for 3?

candid galleon
#

current is less than the current / 2

#

that's a big hint ^

sage swift
#

but isnt it just either win or lose? Random#nextBoolean()

candid galleon
#

Here zoi

#

you're a dealer

#

you win if i roll above half

#

i roll a 6 sided die, it returns 2

#

is 2 less than 2 / 2?

crude charm
crude charm
candid galleon
#

is 2 less than 2 / 2? @crude charm

sage swift
#

less than

#

true or false

crude charm
#

this calculator is shit

#

lmfao

candid galleon
#

here her

#

say I roll a 100 sided die

#

it rolls 43

crude charm
#

0

candid galleon
#

is 43 < 43 / 2

#

now pause

#

is that the correct question you want the computer to evaulate?

#

or do you want
is 43 < 100 / 2

#

what is the difference between:
is 43 < 43 / 2
is 43 < 100

crude charm
#

oh yeah

#

I see

#

yup

#

OH

#

YEAH

#

OK

#

the value not rando,m

#

AIGHT

candid galleon
#

๐Ÿ‘

#

I hope you do lol

crude charm
#

I feel like coding math is a whole different thing, theres school math and then computer math

limpid veldt
#

is there a way to get the actual enchantment name rather than the key such as the pic below? So instead of DAMAGE_ALL it would be sharpness

#

Using a lambda expression to loop through the enchs

#

item is an itemstack

#

enchants is a string ArrayList

chrome beacon
#

You can use TranslatableTextComponents they're quite neat

limpid veldt
#

only ever used it for chat formatting to add click actions etc

#

how would I use it to convert DAMAGE_ALL or another enchantment key to a display name?

chrome beacon
#

You get the Namespaced key iirc
and then put that together with enchantment.minecraft so you get enchantment.minecraft.sharpness for example

crude charm
#

@candid galleon how can I do it so that as I said before 4, 5, 6 and 1, 2, 3

#

like the other way compared to what I have rn

candid galleon
#

have you changed your code at all?

crude charm
candid galleon
#

can we see the new code?

crude charm
#

its working

#

but I want 4, 5, 6 is win

#

oh wait

candid galleon
#

is it not?

crude charm
#

IM DUMB

#

LMFAO

#

dw

#

im just dumb

limpid veldt
#

using just .toString returns this. hmm

candid galleon
#

so

#

substring the minecraft: part

#

capitalize the first letter

#

ezpz

limpid veldt
#

doing substring feels kinda hacky

candid galleon
#

it is

#

but it works and it's the simplest way

limpid veldt
#

:/

candid galleon
#

should check if it doesn't start with minecraft:

limpid veldt
#

did getkey and it returns "minecraft:sharpness"

#

so doing a substring on that is better imo

candid galleon
#

yeah that's what I meant?

#

oh you didn't know getKey was a thing lol

limpid veldt
#

you meant substring on this mess of text xD

candid galleon
#

nah nah lmao

#

I mean it is still just as hacky

limpid veldt
#

.replace("minecraft:","") lmao

mortal hare
#

how the tf #NMSPlayerInventory.setItem(int index, ItemStack newItemStack); updates the inventory inside the client while there's no code for that inside the method???

limpid veldt
#

also is there a good way to capitalise the first letter of a string?

candid galleon
#

@mortal hare this.f looks like it holds inventories?

mortal hare
#

yes

#

its a list

#

which holds inventory slots

#

but there's nothing inside them

#

that cause client update

#

its just a nonnull list

candid galleon
#

where did you get that code?

mortal hare
#

fernflower

#

decompiling

candid galleon
#

ah

mortal hare
#

intellij

candid galleon
#

i'd look for references of this.f

#

there's probably an event being called or other method that sends the packet to the client

mortal hare
#

private final List<NonNullList<ItemStack>> f;

#

that's a simple nested list

candid galleon
#

that or it doesn't update the item til the player interacts with it

#

can you make a test case?

mortal hare
#

and prevented it from chaining

candid galleon
#

what are you trying to do exactly?

mortal hare
#

me?

candid galleon
#

yes

mortal hare
#

im just trying to learn

#

some aspects of nms

candid galleon
#

gotcha

#

I'd need to see the actual classes to fully understand unfortunately

mortal hare
#

this is getting more and more strange

#

nmsViewContainer.getSlot(int slot).setItemStack(ItemStack itemstack);

#

sets item inside slots

#

sends the packet

#

but causes client not to update

#

even tho it sends the packet PacketPlayOutSetSlot

hidden oasis
#

I have a doubt

quaint mantle
#

Someone know a trick to convert an array string to array player ? ``` ArrayList<Player> list = new ArrayList<>();
String query = "SELECT * FROM " + ReportDatabaseSetup.Reporttable;
try (Statement stmt = BanDatabaseSetup.getConnection().createStatement()) {
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
list.add(rs.getString("Username"));
}
Inventory bangui = Bukkit.createInventory(player, 45, ChatColor.BLUE + "Report List");
for (Player value : list) {````

hidden oasis
#

Why some of my commands returns just the usage D:

mortal hare
hidden oasis
chrome beacon
hidden oasis
#

it is though

mortal hare
#

code?

chrome beacon
#

Make sure you return true in the command exectutor

hidden oasis
#

this is my main
`public class Main extends JavaPlugin {
@Override
public void onEnable() {
ItemManager.innit();
getCommand("detector").setExecutor(new commands());
getServer().getPluginManager().registerEvents(new Listeners(), this);
}

@Override
public void onDisable() {

}

}`

mortal hare
#

command executor class

#

also use
``` java
code
```

hidden oasis
#

oo

summer scroll
#

*```*java

```

chrome beacon
#

or just

#

?paste

queen dragonBOT
main dew
mortal hare
#

You can't change the type of array

chrome beacon
#

Yeah you'd need to call getOfflinePlayer on each of those names

mortal hare
#

you can only copy the array with predicate

chrome beacon
#

But you shouldn't store user names

#

Store UUIDs

#

Names can change

hidden oasis
mortal hare
#

that one support syntax highlighting while this doesnt

#

and tabbing

quaint mantle
summer scroll
chrome beacon
mortal hare
#

why

chrome beacon
#

Fetch the username from the mojang servers with the UUID

mortal hare
#

what if its cracked

#

and you need to fetch offline player data huh

chrome beacon
#

I don't support cracked server

#

So I have no intention of helping writing code for them

mortal hare
#

also mojang api has a request limit

#

so i would better use the db to store player names

summer scroll
#

You can just Bukkit.getPlayer() right?

mortal hare
#

just like all of the plugins do

summer scroll
#

Using UUID.

mortal hare
#

that works if its online player

chrome beacon
hidden oasis
chrome beacon
#

Just add some caching to prevent requesting the same user too often

mortal hare
#

return false

#

at the end

#

you're returning true in the both ends

#

return true means that something interrupted

hidden oasis
#

but

#

what does it mean to return true xd

chrome beacon
mortal hare
#

ok

#

its the opposite then

chrome beacon
#

true if a valid command, otherwise false from Javadocs

mortal hare
#

i've used the commandexecutor long time ago

quaint mantle
mortal hare
#

since i use my own handler

quaint mantle
#

hey how do i check if the server is fully started like when it says this in console "[08:46:52 INFO]: Done (15.216s)! For help, type "help" or "?"" how do i check for it in plugin

chrome beacon
#

What are you trying to do

quaint mantle
#

or like not how do i check for the message i mean how do i check if the server is started

#

just change motd

#

from STARTING to STARTED

sullen dome
#

changing the motd multiple times isn't that easy if i remember correctly

quaint mantle
#

it is

sullen dome
#

then that was a bungee only issue, nvm

main dew
#

@quaint mantle

public static List<Player> convert(ArrayList<String> list)
    {
        return list.stream().map(s -> {
            return Bukkit.getPlayer(s);
        }).collect(Collectors.toList());
    }```
hidden oasis
sullen dome
hidden torrent
#

I made a plugin for myself that is capable for printing a formatted time string based on the tick count of the server. I can display that when the server is pinged.

I would like to:
a) print that onto a sign and update it periodically. how would I do that?
b) display it if a clock is in a frame and the name tag is displayed above the item. can I even do that?

Any references where I can read how to accomplish that?

sullen dome
#

you probably would have to remove the time on line-start, but yeah, thats the first idea that i have

sage swift
chrome beacon
# quaint mantle okay

What RealRivex says does work but the easier approach is to use a BukkitRunnable scheduled for the first tick

sage swift
#

set display name of the clock

main dew
#

@quaint mantle

public static List<Player> convert(ArrayList<String> list)
    {
        return list.stream().map(s -> Bukkit.getPlayer(s)).filter(Objects::nonNull).collect(Collectors.toList());
    }```
This better
sullen dome
#

i mean, you could also check for the latest loaded world, that's probably the last event that is fired

#

or idk if there's a pluginLoadEvent

quaint mantle
sage swift
hidden torrent
sullen dome
#

here

#

that looks like its perfect

quaint mantle
#

oh ill try it

chrome beacon
#

Also yeah I saw that event but I'm not sure when it is fired

sullen dome
#

This event is called when either the server startup or reload has completed.
looks good

quaint mantle
#

no i dont have that event in 1.16.5

hidden torrent
quaint mantle
#

1.12.2*

#

ill try the olivo method

sage swift
#

why would you do that

#

just make a repeating task

sullen dome
#

1.12.2, i'm out

quaint mantle
hidden torrent
#

does spigot have an api to queue tasks?

quaint mantle
sage swift
hidden torrent
#

didn't know that. my heavy time in old bukkit development was 8 years ago

mortal hare
#

ok wtf

sullen dome
mortal hare
#

nmsInventory.setItem(hotbarSlot)

#

updates the slot to the client

#

while if its not hotbar slot

sullen dome
#

sidojg

mortal hare
#

it doesnt

sullen dome
#

gecko, thin ice lol

sage swift
#

waah

quaint mantle
#

yeah we use like different versions like 1.16.5, 1.12.2, 1.17 (when it will release)

sage swift
#

you should use 1.8

mortal hare
#

1.17.1 - 1.17.2

sullen dome
#

oh god

#

please no

sage swift
#

1.8 is the best version!

sullen dome
#

please no nononoonno

quaint mantle
#

xdd

hidden torrent
#

when an item is on a frame, it displays its name (if renamed) right?

sage swift
#

it is least lag!!

sullen dome
#

yeah but... lmao

sage swift
#

yes isfirs

quaint mantle
#

okaay

hidden torrent
#

thanks =)

sullen dome
#

just get a decent host

sage swift
#

but 1.8 30000000 player

#

!!!

#

awsom mony!!

#

rich

sullen dome
#

i wait for people saying but 1.8 has best pvp!!!!111111!!11

sage swift
#

peevpn

sullen dome
#

yeah, there's not so many plugins to fix this

hidden torrent
#

I would probably have to store which items I want to update, right? is there an instance ID on items to know which item I want to update?

quiet ice
#

those that do are garb anyway

naive knoll
#

Do I have any additional license that I have to fulfill for my plugin to be on spigotmc?

sage swift
chrome beacon
#

So yeah even Cubecraft had to shutdown 1.8 because they only had 0.7-1.2% users running 1.8

#

It's time to move on from 1.8

sullen dome
#

wonder why lol

#

1.8 is just outdated shit

sage swift
#

1.16/2 = 1.8 = 1/2 the lag

sullen dome
#

oh god

quaint mantle
#

rip hive too

sullen dome
#

hive has moved to bedrock right?

quaint mantle
#

yes

sullen marlin
#

entirely?

sullen dome
#

yeah

quaint mantle
sullen marlin
#

its madness that there is no bedrock for mac

sullen dome
#

their java-servers are just online to show the message

sullen marlin
#

they literally have education edition which is bedrock code running on mac

sullen dome
#

there's no trash bin emoji lmao

#

but yeah, i think when 1.20 or smt comes out, it's the last update... they are near to the border of opportunities on java

#

thats why they delayed the 1.17 part 2

sage swift
#

then we can go back to 1.8

sullen dome
#

NO

#

md_5, ban gecko pls

mortal hare
#

@sullen marlin why does NMS method #PlayerInventory.setItem() doesn't translate slot while sending new PacketOutSetSlot() packet?

hidden torrent
mortal hare
#

it sets the item properly

#

but it sends incorrect packet for that slot

sullen dome
#

oh god, md5 ping

sullen marlin
#

idk use the api

mortal hare
#

unless its hotbar item

sage swift
#

you can use PersistentDataAPI to give the item frames special tags to have the clocks

sullen dome
#

if he's not on 1.12 xd

sullen dome
#

The first time i saw the holder-api, i thought smt like god, that looks complicated af

#

its not tho xd

sage swift
#

it's really fuckin annoying to work with is what it is

#

but then again storage between restarts without external files, can't complain

sullen dome
#

many

#

obfuscated

#

methods

hidden torrent
sullen dome
#

yeah, then use the persistentdata-api

hidden torrent
#

I assume I can query that to get my items from it?

mortal hare
sullen dome
#

nah, thats obfuscated mc-code

#

iirc

#

methods that didnt got mapped

mortal hare
#

is this the client?

#

or nms

sullen dome
#

yeah, 1.16.5 client

mortal hare
#

well yea

#

client can be actually

sullen dome
#

its like rotateAngles() from EnderDragonModel

#

MATH

sage swift
#

this.jaw

sullen dome
#

lol

#

i hate looping through rgb colors

hidden torrent
#

server is a singleton, right? so if I pass the server to some object it should always be the same server

sullen marlin
#

yes

hidden torrent
#

thanks. :)

mortal hare
#

a wild md_5 pokemon has appeared on the server

visual tide
#

anyone know why this doesnt work

BukkitScheduler scheduler = getServer().getScheduler();
        scheduler.runTaskTimer(this, new Runnable() {
            @Override
            public void run() {

                System.out.println("task has run");

                for(Player player : getServer().getOnlinePlayers()){
                    //PlayerInventory playerinv = player.getInventory().getContents();

                    player.sendMessage("checking...");

                    Inventory inv = player.getInventory();
                    ItemStack stackToRemove = null;
                    for (ItemStack stack : inv.getContents()) {
                        if (stack.getType() == Material.BARRIER) {
                            stackToRemove = stack;
                            break;
                        }
                    }
                    if (stackToRemove != null) {
                        inv.remove(stackToRemove);
                        player.sendMessage(ChatColor.RED + "Illegal items were removed from your inventory!");
                    }


#

it only removes stuff from the hotbar

stone sinew
hushed pasture
#

hello just wanted to ask does a paper server works without IP4 adress

visual tide
hushed pasture
#

soo yeah can anyone ans

hidden torrent
#

I found this player.getInventory().getStorageContents()

quaint mantle
#

how do i change server motd without using ServerListPing

stone sinew
hidden torrent
#

^ also that.

#

if that code is expected to work, I would try this because I am lazy:

                final PlayerInventory inventory = player.getInventory();
                Arrays.stream(inventory.getContents())
                      .filter(stack -> stack.getType() == Material.BARRIER)
                      .forEach(inventory::remove);

Iterate over all elements and remove only barriers

stone sinew
stone sinew
quaint mantle
#

how do i change server motd without using ServerListPing

visual tide
visual tide
#

does that give the offhand itemstack?

visual tide
silver shuttle
#

Where is there an error in this MySQL statement?

#

it says in line 4

quaint mantle
#

could u show the error too?

silver shuttle
#

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'You have an error in your SQL syntax' at line 1

#

hold on let me check if desc is reserved

quaint mantle
#

okay

silver shuttle
#

bruh

#

why is desc reserved

#

wtf

#

descr works

#

made me loose like half an hour

drowsy helm
#
private void sendTabPackets(PacketPlayOutPlayerInfo.EnumPlayerInfoAction action){
        List<GameProfile> removeList = new ArrayList<>();
        for(Player pl : Bukkit.getOnlinePlayers()){
            GameProfile profile = ((CraftPlayer)pl).getHandle().getProfile();
            removeList.add(profile);
        }

        Packet<?> packetRmv = TabListHelper.getPlayerInfoPacket(false, removeList.toArray(new GameProfile[0]));
        //Packet<?> packetAdd = TabListHelper.getPlayerInfoPacket(true, profileList.values());

        //Get subset of packets to not go over buffer limit
        List<Packet<?>> addPackets = new ArrayList<>();
        List<List<TabListProfile>> subLists = Lists.partition(new ArrayList<TabListProfile>(profileList.values()), 1);

        for(List<TabListProfile> subList : subLists){
            addPackets.add(TabListHelper.getPlayerInfoPacket(action, subList));
        }

        for(Player player : Bukkit.getOnlinePlayers()){
            sendPacket(player, packetRmv);
            sendPacket(player, addPackets.toArray(new Packet[0]));
        }
    }``` I'm using this method to update tab packets every so often, and when player joins, which works 100% fine. However, after some time (not sure how long exactly) when I try to join the server it tell me the packets are too large?

I am partitioning them into just 1 profile chunks and it still seems to give me this error have no clue how to reproduce, without having to wait 30 mins
visual tide
untold onyx
#

how to glowing player plugin in 1.8 and make it work on viaversion for 1.9+

silver shuttle
#

^^ cant as effect doesnt exist

#

pl
[10:26:35 INFO]: Plugins (2): BileTools*, dynampclaims
b unload dynmapclaims
[10:26:41 INFO]: [Bile]: Couldn't find "dynmapclaims".

Why is it not detecting my plugin? In /pl it shows green

silver shuttle
#

BileTools is the newer version of Plugman

#

unload, uninstall plugins on the go

#

no restarts or reloads

untold onyx
#

biletools isnt newer

#

i researched easy

#

also like everyone says

silver shuttle
#

biletools is a newer better fork

untold onyx
#

"you are using 1.12.2 and lower very outdated get out of my life i never want to see you again i hope you (redacted) you (redacted) 1.12.2 and under person"

#

^ -everyone

silver shuttle
#

I am also not using 1.12.2

untold onyx
#

what version

silver shuttle
#

1.16.4

untold onyx
#

no wonder its a 1.12 and under plugin

silver shuttle
#

and yes it works perfectly on 1.16.4

#

and above

untold onyx
#

ok

silver shuttle
#

there is no reason it would not work

quiet ice
#

well, it does trigger legacy mode

silver shuttle
#

and it works fine on my 16.5 server

quiet ice
#

which is like 6 seconds of slowdown

silver shuttle
#

in a development environment I am fine with that

quaint mantle
#

Help me

silver shuttle
quaint mantle
#

How would you get Player's online time

#

Not by counting the login twith the system time

#

if theirs any other way

drowsy helm
#

theres no other ways

quiet ice
#

wdym?

left swift
#

can I somehow hide the entity including its hitbox so that I can't hit it? I tried

        for (Player players : Bukkit.getOnlinePlayers()) {
            PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(slime.getEntityId());
            ((CraftPlayer) players).getHandle().playerConnection.sendPacket(packet);
        }```and the slime hides, but I can still hit it and kill it
quiet ice
#

At that point it is something that is done serverside; you'd need to do the raytracing on your own (for Player Interation)

brittle nova
#

When I want to add a file named "Name" and then want to add a file named "name" it says that this file already exists. How can I make that this file is created?

#
              p.sendMessage("ยง4This already exists");
} else {
              file.setValue("name", name);
              file.save();
              p.sendMessage("ยงaSuccessfully added " + name);
}``` My code
primal vortex
#

Hello how to code an Vanish plugin

#

can everyone give the code of it

chrome beacon
#

Bruh

primal vortex
chrome beacon
#

We're not just going to spoonfeed you a plugin

#

This is for help not getting people to write things for you

brittle nova
#

Olivo can you help me?

stone sinew
stone sinew
primal vortex
#

i am new at coding either

stone sinew
primal vortex
brittle nova
primal vortex
#

you are also not verified xD

brittle nova
stone sinew
stone sinew
#

๐Ÿ‘

brittle nova
stone sinew
brittle nova
#

ok

mortal hare
#

Hello how to code an Vanish plugin
@primal vortex
Depends what kind of vanish plugin you want

mortal hare
#

You can do packet one where hacked clients cant see it

#

And you can do simple one

#

With potion effects

quaint mantle
#

i

mortal hare
#

Just use vanish plugin from spigot

#

Its too simple

#

To code your own

summer scroll
#

Or with player.hidePlayer()

severe zenith
#
public class SettingsCommand extends Command {

    private static HashMap<String, Setting> settings;

    public SettingsCommand(String name) {
        super(name);
    }

    @SuppressWarnings("deprecation")
    @Override
    public void execute(CommandSender sender, String[] args) {
        if (!(sender instanceof ProxiedPlayer)) {
            sender.sendMessage("Dieser Befehl kann nur von Spielern ausgefรผhrt werden.");
            return;
        }
        ProxiedPlayer player = (ProxiedPlayer) sender;
        if (args.length != 0 && args[0].equals("show")) {
            sender.sendMessage(Utils.MapToString(settings));
        }
        ProxyServer.getInstance().broadcast(sender.getName());
        Setting setting = settings.get(player.getName());
        if (setting == null) {
            settings.put(player.getName(), new Setting());
            setting = settings.get(player.getName());
        }

        player.getServer().getInfo().sendData("bungeecord:spigot", setting.getArrayOutput("Settings"));
    }

    public static void setSettings(HashMap<String, Setting> s) {
        settings = s;
    }
}

This is the code to one of my Proxy commands. When I execute it, the spigot plugin gets the wrong reciever. it always send the first online player as reciever to the spigot plugin. what is wrong?

mortal hare
#

Syntax highlinting please

#

Add java near grave signs

severe zenith
#

i did

mortal hare
#

Why do you use deprecated methods?

#

Then my phone doesnt support it

severe zenith
quaint mantle
#

Hey guys! I want to make a pickaxe, which shoots arrows. I made it work. BUUT, I want that the the block breaks, which gets hit from the egg. Here's my code:

    @EventHandler
    public void onClick(PlayerInteractEvent e) {
        Player p = e.getPlayer();
        if(p.getItemInHand().getItemMeta().getLore().contains(ENCHANTMENT.VASER(1))) {
            if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                Egg egg = p.launchProjectile(Egg.class);
                egg.setFireTicks(Integer.MAX_VALUE);
                egg.setBounce(true);
                p.playSound(p.getLocation(), Sound.SHOOT_ARROW, 2F, 2F);
            }    
        }
    }
hidden torrent
#

I wonder if you could restrict nether portals to locations where these nether structures spawn.

hidden torrent
quaint mantle
#

an egg is no vehicle, right?

hidden torrent
#

it is a projectile which iirc is an entity. and entities can collide afaik

#

so, a collision event is my best bet.

quaint mantle
#

Projectile hit event

#

I'll try that

hidden torrent
#

store the ID if you egg in some list so you know that is an egg you spawned. and on hit compare it if it is in that list and then do your action

#

idk if there is a more elegant way of doing it

eternal night
#

not that I know of

#

pdc might work for the egg thing

quaint mantle
#

@hidden torrent it isn't working ๐Ÿ˜ญ

    @EventHandler
    public void onClick(PlayerInteractEvent e) {
        Player p = e.getPlayer();
        if(p.getItemInHand().getItemMeta().getLore().contains(ENCHANTMENT.VASER(1))) {
            if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                Egg egg = p.launchProjectile(Egg.class);
                egg.setFireTicks(Integer.MAX_VALUE);
                egg.setBounce(true);
                p.playSound(p.getLocation(), Sound.SHOOT_ARROW, 2F, 2F);
            }    
        }
    }
    @EventHandler
    public void onHit(ProjectileHitEvent e) {
        if(e.getEntity().isOnGround()) {
            e.getEntity().getWorld().createExplosion(e.getEntity().getLocation(), 1);
        }
    }
eternal night
#

why is on ground check o.O

hidden torrent
#

sounds wrong, somehow

quaint mantle
#

ok wait

#

I try without onground

#

omg working now

#

Thanks to you two!

eternal night
#

just, this will explode arrows too xD

#

any projectile really

hidden torrent
#

yea. I said to check if this is your projectile.

#
    private final List<UUID> projectiles = new ArrayList<>();

    @EventHandler
    public void onClick(PlayerInteractEvent e) {
        Player p = e.getPlayer();
        if(p.getItemInHand().getItemMeta().getLore().contains(ENCHANTMENT.VASER(1))) {
            if(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                Egg egg = p.launchProjectile(Egg.class);
                egg.setFireTicks(Integer.MAX_VALUE);
                egg.setBounce(true);
                projectiles.add(egg.getUniqueId()); // this
                p.playSound(p.getLocation(), Sound.SHOOT_ARROW, 2F, 2F);
            }
        }
    }
    @EventHandler
    public void onHit(ProjectileHitEvent e) {
        final Projectile projectile = e.getEntity();

        if (projectiles.contains(projectile.getUniqueId())) {
            e.getEntity().getWorld().createExplosion(e.getEntity().getLocation(), 1);
            projectiles.remove(projectile.getUniqueId());
        }
    }

Like I said, no idea if that is the best way of detecting if that ID is yours.

eternal night
#

nice edit ๐Ÿ‘

#

๐Ÿ˜…

hidden torrent
#

?

#

I forgot to add the remove line

eternal night
#

yeah

#

was about to write it

#

lol

#

speed

hidden torrent
#

important, or else you store too many invalid IDs

#

Idk if storing the actual object might be better. having a List<Projectile>.

#

but since its about identifying if the projectile is managed by your code, I think this is fine.

#

@quaint mantle still there? :D

quaint mantle
#

yes

#

I don't store the egg id's

hidden torrent
#

yea. you will not know if that egg is yours if you don't have a way to identify it

#

p.getItemInHand() is deprecated. maybe consider using the inventory. Idk which API you are using, but I can't resolve neither ENCHANTMENT.VASER or Sound.SHOOT_ARROW, the enum for me was ENTITY_ARROW_SHOW

eternal night
#

concerning that it is part of isSimilar that seems rather complex

#

especially with the inheritance based nature of item meta

#

you could do some reflection shenanigans and temporarily store itemmeta a's pdc in itemmeta b, then compare and revert after that

#

well yes

#

the durability is stored on the item meta

#

don't know what would change then tbh

severe zenith
#

is there a not deprecated method instead of ProxiedPlayer.getUUID();?

acoustic palm
#

getUniqueId

severe zenith
#

thanks

eternal night
#

can read these things in the javadocs usually btw

severe zenith
#

how to get uuid of uuid.toString() back?

eternal oxide
#

UUID.fromString

quaint mantle
#

stupid question but my ide says to me "integer number too" im writing this "1622113500000" how do i then put it into new Date()

eternal night
#

use a long

quaint mantle
#

i do use it

eternal night
#

oh plug a L at the end

quaint mantle
#

oh ty

eternal night
#

๐Ÿ‘Œ

quaint mantle
#

oh so thats what the L means

eternal night
#

long xD

quaint mantle
#

yeah xd never knew what it meant

eternal night
#

there is also F for float

#

D for double etc

quaint mantle
#

smth to learn everyday more

wraith rapids
#

there's also F and D

#

sadly no b for byte or s for short, which grinds my gears

mild agate
#

How to get player by UUID on the bungee?

quaint mantle
#

ProxyServer.getInstance().getPlayer(uuid);

mild agate
#

thhanks!

weary fossil
#

someone can help me?

daring sierra
#

?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.

daring sierra
#

just ask m8

weary fossil
#

i need to make a glowing entity (llama) with rainbow colors

#

but I'm not getting it, it is only white

#

sorry for bad english, im using translator

daring sierra
#

Wdym by this?

weary fossil
#

Why?

daring sierra
#

?

#

wut

weary fossil
#

i dont understand

daring sierra
#

yeah

weary fossil
#

i dont speak english very well, sorry

daring sierra
#

what are you trying to do

#

and how would you go about doing it

weary fossil
#

i can send my code here?

daring sierra
#

yea

weary fossil
#

i'm usign this:

Random random = new Random();
        List<ChatColor> colors = new ArrayList<ChatColor>();
        colors.add(ChatColor.DARK_BLUE);
        colors.add(ChatColor.AQUA);
        colors.add(ChatColor.LIGHT_PURPLE);
        colors.add(ChatColor.YELLOW);
        colors.add(ChatColor.GOLD);
        colors.add(ChatColor.GREEN);
        colors.add(ChatColor.DARK_AQUA);
        colors.add(ChatColor.DARK_GRAY);
        colors.add(ChatColor.DARK_GREEN);
        colors.add(ChatColor.DARK_PURPLE);
        colors.add(ChatColor.DARK_RED);
        colors.add(ChatColor.GRAY);
        colors.add(ChatColor.RED);
        colors.add(ChatColor.BLACK);
        ChatColor team1 = colors.get(random.nextInt(colors.size()));
        team1_color.add(team1);
        Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
        Team lhama = board.registerNewTeam("pinhata");
        lhama.setColor(team1);
        lhama.addEntry(llama.getUniqueId().toString());
#

but, dont work

#

team1_color code:

private static List<ChatColor> team1_color = new ArrayList<ChatColor>();```
daring sierra
#

Why u makin the llama colorful doe

weary fossil
#

it is for aesthetics

#

i need to make llama rainbow

daring sierra
#

oki one sec im lookin at the docs to see if something could work here

weary fossil
#

right, thanks

daring sierra
#

im on mobile might take abit sorry

weary fossil
#

no problem, thank you

mild agate
#

how to get player UUID in PreLoginEvent?

eternal oxide
#

Are you trying to make the entity itself rainbow or an entry on the scoreboard?

daring sierra
#

hmm you could use the glowing effect @weary fossil

#

one sec ill dig somthn up

weary fossil
#

I'm trying to get on the scoreboard to be able to let her rainbow

daring sierra
#

Rainbow with glowing?

#

Or rainbow like jeb sheeps

weary fossil
#

rainbow with glowing

daring sierra
#

oki

eternal oxide
#

You understand that setting a scoreboard colour is not going to affect the entity in the world. Also only Players can be members of Teams

weary fossil
#

But, i can set the only color of those to llama in the scoreboard teams

#

but, rainbow I am not getting at all

daring sierra
eternal oxide
#

Your current code picks a random color and sets your team to that color. It has no in game representation to the entity

weary fossil
#

i have others methods to represent a entity

#

i show examples for you

#

now my code show me this:

#

i want to change a glowing for rainbow

weary fossil
daring sierra
#

oh welp one second lemme seee somethin

weary fossil
#

right

eternal oxide
#

I'm going to guess (as I've not done it) you are going to have to cycle the colors for the team in a runnable

weary fossil
#

runnable for alternate colors?

#

you can show me a example? please

eternal oxide
#

teams have a single color. There is no rainbow setting.

solemn shoal
#

@lost matrix hey, you still have that code for the color map stuff?

weary fossil
solemn shoal
#

did you get it working?

eternal oxide
#

so to have the color flash different colors you are going to have to set teh color on a timer

quaint mantle
#

i have a question how do i get the main world like the one thats written in the server.properties?

eternal oxide
#

either read teh properties or Bukkit.getWorlds().get(0)

quaint mantle
#

oh ty

weary fossil
#

but how i do this?

eternal oxide
#

new Bukkitrunnable

summer scroll
#

If I have a Map like this, does the Map in the value need to be intialize? idk what im saying but I'm kinda confused.

Map<UUID, Map<String, Integer>> somethingMap = new HashMap<>();
eternal oxide
#

111java

daring sierra
#

you could probably use Team#setColor(ChatColor.WHATEVERCOLORHERE);
as glowing colors depend on teams and their color @weary fossil

eternal oxide
#
new BukkitRunnable() {

            @Override
            public void run() {

                //code in here to change color of the Team.
            }}.runTaskTimer(plugin, 0, 20L);```
weary fossil
#

but with my random, it's not changing the color

weary fossil
#

thanks

daring sierra
queen dragonBOT
daring sierra
#

paste the full code

weary fossil
#

the method of llama?

#

to make a glowing?

daring sierra
#

yeah

#

to see if you missed somethin

#

';./

weary fossil
#

llama.setGlowing(true);

daring sierra
#

cant you paste the full code?

weary fossil
#

of course

daring sierra
#

?paste

queen dragonBOT
daring sierra
#

pls

weary fossil
#

right

daring sierra
#

wher r ur import statments?

weary fossil
#

sorry, i forget to put in paste

summer scroll
daring sierra
#

brb

ivory sleet
#

Table<UUID,String,Integer> table = new HashBasedTable.create();

#

@summer scroll

silver shuttle
#

Can somebody help me figure out a weird server crash?

weary fossil
silver shuttle
#

no its not

weary fossil
#

show me the crash reports

silver shuttle
#

one sec

summer scroll
drowsy helm
#

whats the need for a tabl when its in it's own class

weary fossil
#

me.konstanius.konstanius.commands.claim.onCommand(claim.java:98)

#

show me line of code

silver shuttle
#

testcoordz = resulttest.getInt("z");

#

that exists

#

I can describe when it happens for you

ivory sleet
weary fossil
silver shuttle
#

So the code basically is:
You do /claim (description text)
It checks through 2 databases if there is a position in a given radius or a radius specified in the data entry
If there is no other position in radius (aka the spot is valid) it creates a new database entry

#

the first claim worked fine

dusty herald
#

couldn't you show us the code

silver shuttle
#

then claiming inside the first claim worked fine (prevented it)

silver shuttle
#

and claiming outside of the first claim causes the crash

#

thats the code

summer scroll
# ivory sleet Ye

alright thanks, it's basically the same as the Map that I sent above and it's easier to manage yeah?

silver shuttle
#

apart from my main thats the only instance there is

wraith rapids
#

don't do database queries on the main thread

silver shuttle
#

i only have the create table there

wraith rapids
#

that is still a database query

silver shuttle
#

it works fine and is not the issue

wraith rapids
#

they can be slow and take up to several seconds or like 30 seconds if the control connection times out

#

and doing it on the main thread means that your server will be doing literally nothing for all of that waiting time

silver shuttle
dusty herald
#

I can see why your server crashed lmao

wraith rapids
#

that has nothing to do with not doing database queries on the main thread

dusty herald
#

all those while(true) statements

#

on top of the database shit all on the main thread

wraith rapids
#

even if your database query only takes 50ms, that is one entire skipped tick

silver shuttle
#

the query takes 0 ms

ornate heart
#

๐Ÿ˜ฎ

silver shuttle
#

because I only use localhost connetions

wraith rapids
#

but it isn't guaranteed to take 0 ms

silver shuttle
#

in one in more than a million pings maybe one takes 1 ms or 2

wraith rapids
#

that doesn't mean that you should be doing database queries on the main thread

silver shuttle
#

okay Ill change it

#

now why does the server crash tho

dusty herald
#

your server noticed your code was hanging and since it was on the main thread

#

it crashed

weary fossil
#

@dusty herald u can help me?

dusty herald
#

no

silver shuttle
#

and why does the code hang?

weary fossil
#

oh

#

right

dusty herald
#

have u seen how many while statements u have

ornate heart
#

Wait why do you why true statements

silver shuttle
dusty herald
#

have u tho

silver shuttle
#

i have 5

dusty herald
#

while(true) statements never stop unless directed to

#

first one doesn't stop

wraith rapids
#

and doing it on the main thread means that the entire server halts and waits for it to exit

#

and if it never exits, the watchdog terminates your server

silver shuttle
#

the first one does have a break built in

wraith rapids
#

either your database shat itself

#

or one of your breaks isn't being reached

dusty herald
#

does while statements care if breaks are in try blocks I'm not sure

#

also you can just.. while(ResultSet.next())

weary fossil
#

someone can read?

dusty herald
#

also prepare your damn statements

wraith rapids
#

and don't do queries on the main thread

dusty herald
#

unless you want injection then don't do that

late ledge
#

is there a way to check if a BukkitTask has already been executed?
I need a safety measure on a BukkitTask field which means:

    public void setScheduledPointTask(@NotNull BukkitTask scheduledPointTask) {
        if (this.scheduledPointTask != null)
            cancelTask();
        this.scheduledPointTask = scheduledPointTask;
    }```
I am not sure what happens when you try to cancel a task that has already been executed. Does it have an effect?
*for context:* The task is a delayed task. When registering a new task, I need to prevent that task from running when the delay ends. 

Another way to do it would be to set `this.scheduledPointTask` to null as soon as the delay ends but that would require some hacky workaround which i would like to avoid
wraith rapids
#

so you just want to have a delayed task

#

and whenever you schedule a new instance of that delayed task

#

you want to check if there is a delayed task that has been previously scheduled

#

but not yet executed

late ledge
#

correct

wraith rapids
#

and if so, you want to cancel the old task from running

late ledge
#

yep

wraith rapids
#

iirc bukkittask has a hasRun method or something to see if it has been run yet

#

or not, apparently

#

in the class that schedules the task, have a field for the BukkitTask

late ledge
#

i can cancel it just fine, im just not sure whether or not .cancel() is safe to call on a task that has already been executed. Cause if it is safe, I can just call cancel whether it has ran or not and be on my merry way

wraith rapids
#

when you schedule a new task

#

check if that field is not null

#

if it is not null, cancel the task and replace its value with the newly scheduled task

#

when the task runs, set the field to null

#

if you're doing it concurrently, make the field volatile

#
if (task != null) task.cancel();
task = Bukkit.getScheduler().runTaskLater(plugin, () -> { task = null; }, delay );
sleek pond
late ledge
#

thats the thing. The same class generates multiple tasks for different players so I would like to avoid having to store it in the class that generates it. There can only be one task/player which is why I am storing it in my player wrapper class.
The documentation doesn't say anything about calling .cancel on a task that has ran already so I guess I can just try.

wraith rapids
#

well, it won't explode

late ledge
#

meh true

silver shuttle
#

Whats the best way of making a command with optional arguments identified by things like "p:(player)" or so like this:
/forceclaim <description> p:(Player) x:(X) y:(Y) r:(Radius)
So that I can get the variables from it

#

but description can be multiple arguments long and the order of arguments can be arranged in any way

summer scroll
#

wouldn't the command will be too long? and maybe it'll reach the max characters on the chat.

silver shuttle
#

i limited description to 32 characters

late ledge
#
String[] split = args.split(" ")
for (String string : split) {
    switch (string.substring(0, 1)) {
    case "p:" :
        //trim the "p:" and work with the trimmed version
        break;
    case "x:" :
        //trim the "x:" and work with the trimmed version
        break;
    }
}
silver shuttle
#

args.split doesnt work

late ledge
#

You would need to do a lot of checking that arguments have at least 3 characters etc so you dont get out of bounds errors but this is the basic pattern I use sometimes

late ledge
silver shuttle
#

says doesnt work on strings

#

cannot resolve method split in String

late ledge
#

do you work with your arguments as an array or a string?

#

String[] or String?

silver shuttle
#

I dont have anything edited yet I only have what you gave me and a bunch of non involved code

#

and I have String[] args

late ledge
#

okay then you do not need to split

#

you can do for (String string : args) ....

silver shuttle
#

okay

#

and with the min length of the arguments does that apply to description aswell?

late ledge
#

do you understand what my code does?

silver shuttle
#

kinda

#

i dont know what the switch thingy does

#

but the rest yes

late ledge
#

alright, then you need to do a check before you run the chunk of code that the string.length() > 3

What the switch/case statement does is it evaluates whatever is in the switch statement (here string.substring(0.1)) and it "jumps" to the label (the cases) that is equal to the value in the switch statement.

So lets say you do:

int nr = 5;
switch (nr) {
    case 1:
        System.out.println("foo");
    break;
    case 5:
        System.out.println("bar");
    break;
}```
"bar" will be printed (cause nr = 5 = case 5)
silver shuttle
#

ok

#
        for (String string : args) {
            switch (string.substring(0, 1)) {
                case "p:" :
                    string.replace("p:", "");
                    Player owner = myplugin.getServer().getPlayer(string);
                    break;
                case "x:" :
                    string.replace("x:", "");
                    int x = Integer.parseInt(string);
                    break;
                case "z:" :
                    string.replace("z:", "");
                    int z = Integer.parseInt(string);
                    break;
                case "r:" :
                    string.replace("r:", "");
                    int radius = Integer.parseInt(string);
                    break;
            }
        }

So thats how I have it now

wraith rapids
#

Whats the best way of making a command with optional arguments identified by things like "p:(player)" or so like this:
using a command framework that does that

#

i don't remember if acf does

late ledge
#

I have my own framework ๐Ÿ˜› not public yet but it will be at some point xD

silver shuttle
#

and how do I get the description from that now?

wraith rapids
#

writing your own framework for things is good practice

#

personally I would use a regex

#

it'd let you grab the user input with a capture group ez

late ledge
#

hint:
you want to block players from doing:
/forceclaim <description> p:

wraith rapids
#

manually writing switch blocks for the different parameters seems uninspired

silver shuttle
wraith rapids
#

i'd oop'ify it and create a Parameter class and then a String -> Parameter -> Input mapping

late ledge
late ledge
wraith rapids
#

would still imply the intent that not all of the parameters may be present

#

and that they may be in any order

late ledge
#

thats what the switch/case does too though

ivory sleet
#

Definitively use regex challenger (as NNY said), I donโ€™t know but that would cut the most verbosity it feels like making it clean.

late ledge
#

the man doesnt know switch case ๐Ÿ‘€ I doubt he can write a decent regex ๐Ÿ‘€

wraith rapids
#

lmao

late ledge
#

no offense

ivory sleet
#

Then he may be able to learn something extra, canโ€™t see the downside

late ledge
#

meh true

wraith rapids
#

and we might be here 4 more hours explaining what a capture group is

ivory sleet
#

๐Ÿฅฒ

late ledge
#

eeeuuh I gotta go do important stuff SSEEE YYAAAA xD

eternal oxide
#

Ok I think I'm going crazy.java @EventHandler public void onCreatureSpawn(CreatureSpawnEvent event) { event.getEntity().setGlowing(true); }No glow effect when spawning mobs (used Spawn Eggs. code is running, listener is registered)

wraith rapids
#

uh

ivory sleet
#

What if you try adding the glowing effect instead

eternal oxide
#

My thoughts exactly

wraith rapids
#

try spawning them via summon, maybe spawn eggs are weird somehow

#

that definitely shouldn't be the case but you never know with bukkit

eternal oxide
#

The event fires adn the code runs, just no glow

wraith rapids
#

myeah my guess was that the spawn egg code is doing something dumb with it after it's added to the world

eternal oxide
#

I'll stick it in a delay but its behaving very oddly

wraith rapids
#

dunno though I don't think I've ever used glowing on anything

eternal oxide
#

I even tried manual spawn loc.getWorld().spawnEntity(loc, hatchingType);

#

still no glow

#

Well I'm baffled ```java
@EventHandler
public void onCreatureSpawn(CreatureSpawnEvent event) {
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {

        @Override
        public void run() {
            System.out.println("Set Glow!");
            event.getEntity().setGlowing(true);
        }
    }, 50L);
}```No Glow
wraith rapids
#

i'm more baffled by the anonymous runnable with an override instead of a lambda

ivory sleet
#

Elgar did u try with LivingEntity::addPotionEffect

vital ridge
#

Hey

#

what does setFallDistance mainly do?

#

does this cancel the fall damage

#

when set to - values

eternal oxide
wraith rapids
#

it's probably set to 0 every tick while the entity is onGround

ivory sleet
#

Ah well weird then

wraith rapids
#

and incremented by some value while it's not

#

fall damage does depend on it iirc but i'm not sure

vital ridge
#

Ik theres an event for that

eternal oxide
#

I was actually messing around with an idea someone else had earlier, but in testing I can't get teh basic glow to happen

vital ridge
#

But yea just wondering if i could cancel falldamage with that

#

ill try tho

eternal oxide
#

There isn't some client setting that can disable glow?

ivory sleet
#

Afaik no

eternal oxide
#

Damn it! it was seus shaders

wraith rapids
#

i was going to suggest checking the entity data next

#

to see if it was a client issue

late ledge
#

ping?

olive lance
#

0

eternal oxide
#

Still open ticket from 2020

cerulean valley
#

when cancelling PlayerInteractEvent and changing the item in the players hand, the interaction will be run despite being cancelled - any idea what i can do about it?

ivory sleet
#

useItemInHand(Event.Result.DENY) mb

cerulean valley
#

that will still run the interaction

#

.setCancelled on PlayerInteractEvent is just short for setting both useInteractedBlock and useItemInHand to DENY

ivory sleet
#

Oh yeah I was unsure whether setCancelled works anymore

dusty herald
#

what is it like being Async conclure?

cerulean valley
#

the interaction will only be executed if the item in the players hand changes

ivory sleet
#

Jochyoua youโ€™re pretty async also lol

dusty herald
#

thank u

ivory sleet
#

Actually Aqua, it might be a different event

cerulean valley
#

mh?

#

PlayerInteractEvent does get called and cancelled, i can 100% confirm that - for the replaced item, no PlayerInteractEvent is called, however if the item has its own event (e.g., PlayerBucketEmptyEvent), that one will be called

ivory sleet
#

Oh you mean like that, Idk what item are we talking about specifically then?

#

Worst case scenario would be that you have to setup a packet interceptor hopefully you can skip that

wraith rapids
#

bucket events are fucked

#

there was a patch on paper that made them slightly less fucked

#

but even their bucket events are still somewhat fucked

cerulean valley
#

it happens with all items that have an action, replacing the item in the players hand with a fishing rod will cause the player to throw the fishing rod (not only on the client, the server actually does it instead of what the original PlayerInteractEvent intended), or when replacing it with a water bucket it will place the water

#

yeah, i specifically have to deal with the bucket events because i'm trying to cancel the event for a bucket, but set some metadata on it

#

sadly cancelling PlayerBucket*Event will still replace the item in the players hand with a fresh bucket, instead of keeping it, losing all metadata

#

so i wanted to cancel the interaction before, but the changed item in the players hand will still run the bucket event

#

i don't really know what i can do about it - my first idea was replacing it with a fishing rod instead and setting a variable to "the next fishing event is actually the bucket", and replacing the item inside PlayerFishEvent instead - but in very rare cases PlayerFishEvent will not be called after PlayerInteractEvent, resulting in the player losing their bucket^^

eternal oxide
#

@weary fossil Did you get it working?

sharp bough
#
    public void onBedPlacedEvent(BlockPlaceEvent event){
        Bukkit.getLogger().info("test");
        if(event.getBlock().getType().equals(Material.LEGACY_BED)){
            Bukkit.getLogger().info("test1");
            Bukkit.getLogger().info(event.getPlayer().getName());
        }
        if(event.getBlock().getType().equals(Material.LEGACY_BED_BLOCK)){
            Bukkit.getLogger().info("test2");
            Bukkit.getLogger().info(event.getPlayer().getName());
        }
        if(event.getBlock().getType().equals(Material.BLACK_BED)){
            Bukkit.getLogger().info("test3");
            Bukkit.getLogger().info(event.getPlayer().getName());
        }
    }```
how can i check if a bed is placed? the only one working is black bed
eternal oxide
#

Tag.BED.isTagged(event.getBlock().getType())

#

Will tell you if its a bed of any type

wraith rapids
#

don't use the bukkit logger

#

use your plugin's logger

sharp bough
#

that works thank you

sharp bough
#

i need to know wich one works or not

wraith rapids
#

for tests you might as well use stout

sharp bough
#

i usually use getServer sendmessage

sharp bough
#

its literally the same thing with different words

wraith rapids
#

stout has autocompletions in most IDE's so it's more ez to write

#

but for any actual logging and messages, you 100% should use plugin.getLogger

#

because that indicates that the message comes from your plugin

#

anything else is haram

sharp bough
#

aight ig

wraith rapids
#

there is nothing more fucking annoying than a plugin that pours dumb shit into the console and you have no clue which plugin it is because it uses the wrong logger

sleek pond
#

i only sysout when I am debugging something

#

and I know it's my plugin doing the debugging

main dew
#

posible create packet ProtocolLib with constructor?

ivory sleet
#

Wat

#

Can you elaborate

wraith rapids
#

are you still trying to clone a packet

#

it's been like 3 days

main dew
wraith rapids
#

yes, you can instantiate packets with protocollib

quaint mantle
#
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'Points' in 'field list'

How to fix this $hitty problem i was trying to fix it about 3 hours

#
      public static void createTables()
      {
        if (isConnected())
          try
          {
            con.createStatement().executeUpdate("CREATE TABLE IF NOT EXISTS PSQL (Playername VARCHAR(100), Level INT(100), XP INT(100), Points INT(100))");
          }
          catch (SQLException e)
          {
            e.printStackTrace();
          }
      }
#

i already added the Points on the Table

#

' ' ?

mortal hare
#

there's syntax error somewhere in codeprobs

worldly ingot
#

(1) Found the .NET developer
(2) Your database clearly says otherwise PES_Think

wraith rapids
#

yes

eternal oxide
maiden briar
#

java.lang.IllegalArgumentException: Don't know how to serialize io.papermc.paper.adventure.AdventureComponent@15bc7e69 as a Component
How is this possible when I try to serialize ServerPing's?

#

This line: serverPingJson.add("description", jsonSerializationContext.serialize(serverPing.getMotd() == null ? motd : Class.forName("net.minecraft.server." + TvheeAPIPlugin.getInstance().getNMS() + ".IChatBaseComponent$ChatSerializer").getDeclaredMethod("a", String.class).invoke(null, "{\"text\": \"" + serverPing.getMotd() + "\"}")));

quaint mantle
#
      public static boolean exists(String playername)
      {
        ResultSet rs = MySQL.getResult("SELECT * FROM PSQL WHERE Playername='" + playername + "'");
        try
        {
          if (rs.next())
            return true;
        }
        catch (SQLException localSQLException) {
        }
        return false;
      }

      public static void createPlayer(String playername)
      {
        if (!exists(playername))
            MySQL.update("INSERT INTO PSQL (Playername, Level, XP, Points) VALUES ('" + playername + "', '1', '0', '0')");
      }
#

the biggest problem is here ^^

sharp bough
#

why does this work? ```
Main.get().getConfig().set("test", 123);
Main.get().getConfig().set(event.getPlayer().getUniqueId().toString(), event.getBlock().getLocation());
Main.get().getConfig().set(event.getPlayer().getUniqueId().toString(), event.getBlock().getLocation().toString());

worldly ingot
#

does?

sharp bough
#

doesnt

#

lol

worldly ingot
#

saveConfig()

sharp bough
#

oh so i have to set it and save it

worldly ingot
#

Though there's a setLocation() you might want to use instead

#

Yes

#

saveConfig() writes it from local memory into file

wraith rapids
#

Location::toString doesn't do what you expect it to do

mortal hare
#

is it possible to lock specific object, not a codeblock from accessing in another thread, like synchronize but for the object instance and not the codeblock

wraith rapids
#

wut

mortal hare
#
synchronize(object) {

}
#

would lock the object instance to not access this code in another thread

#

is it possible to do this for all of the code, not only for synchronized codeblock

vital ridge
#

yo, does anyone know how can i change particle render distance?

quaint mantle
vital ridge
#

so if im 5 blocks away from a particle it disappears

eternal oxide
#

Everything that wants to access that "Object" must sync on it

vital ridge
#

and if i come back it reappears

young knoll
#

Youโ€™d probably need to check the players distance and just not spawn them if they are too far

wraith rapids
#

i repeat wut

mortal hare
wraith rapids
#

synchronize (x) just grabs the monitor of x

eternal oxide
#

then its not synchronized and could break

wraith rapids
#

only one thread can lock on x at the same time

mortal hare
wraith rapids
#

therefore only one thread can run the shit in the code block at the same time

#

there is no such thing as synchronizing an instance