#help-development

1 messages · Page 663 of 1

sage patio
#
private static final Map<Integer, List<UUID>> pages = new HashMap<>();
tender shard
#

wdym with "miss 1 uuid"?

sage patio
#

imagine i have 10 UUIDs in policeList

#

and each page can contain 12 uuids

#

the first page has 9 UUIDs instead of 10

tender shard
#

.get(0) is the first entry

#

.get(9) is the last if you got 10 entries

sage patio
#

i know, but where i did that wrong?

eternal oxide
#

0 to 9 is 10

smoky anchor
#

my guess would be to move the index++; after the if

tender shard
#

maybe that you index++ before actually using index?

hybrid turret
#

^^^

tender shard
#

that is also explained in my blog post

sage patio
tender shard
sage patio
#

so it should be fine

tender shard
# tender shard

e.g. group id for me is com.jeff-media because my domain is jeff-media.com

if you don't have any domain you can use com.github.yourgithubusername or me.yourusername @hybrid turret

smoky anchor
steady rapids
#

Hi, is there a onTick() event? or something similar that occurs every server tick? or am I forced to use the scheduler?

tender shard
hybrid turret
#

oh ic thanks

undone axleBOT
tender shard
#

runTaskTimer(..., 1, 1) runs every tick

steady rapids
#

oke

hybrid turret
#

does that have a reason?

tender shard
tender shard
hybrid turret
#

oh lol alright thanks

tender shard
#

in the end it doesn't really matter

hybrid turret
#

i tried so hard and got so far

tender shard
#

it's just an "identifier" - and it should be unique ofc

hybrid turret
#

ic thanks

tender shard
worldly ingot
#

Yeah, if you have domain though, it's preferred

tender shard
#

yeah at least if it's not a throwaway domain that you got for free for one year and then don't plan to renew lol

#

like almost everyone with their .dev domains

worldly ingot
#

Ain't no way I'm throwing away my .wtf domain

tender shard
#

i still got mfnalex.gay lol

hybrid turret
#

oh yeah 1 more thing just for testing purposes. can you differenciate between linux and windows in the pom.xml <outputDirectory>-tag?

tender shard
#

yes, with profiles

worldly ingot
#

I'm writing a mod for a friend of mine and she's a family friendly streamer. Little does she know that the code she's running has a swear word in it

tender shard
# hybrid turret oh yeah 1 more thing just for testing purposes. can you differenciate between li...

If you’re using maven for your Spigot plugins (which you should do), it’s easy to make maven automatically save your plugin’s .jar in your plugins folder. There’s two ways of doing this: 1. The lazy way (not recommended) If you only work alone on one computer, you can just directly declare the output location in...

#
  1. add an activation that's os specific, one sec
#
    <profiles>
        <profile>
            <id>export-to-test-server-windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <configuration>
                            <outputDirectory>C:\mctest\plugins\</outputDirectory>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>export-to-test-server-linux</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-jar-plugin</artifactId>
                        <configuration>
                            <outputDirectory>/opt/mctest/plugins</outputDirectory>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
hybrid turret
#

ohh that's super interesting, maven is really convenient

ivory sleet
#

I mean depends on how horizontally scalable you want it to be

#

But its probably gonna be fine for you

tender shard
lilac dagger
#

how do you make profiles?

lilac dagger
#

oof, i should've read a bit earlier haha

gusty parcel
#

Hey, can someone help me, I wrote a sumo plugin, the command of which does not work, if anyone can help me, write to me privately

ivory sleet
#

Or just ask here so way more people can help you? (:

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

gusty parcel
tender shard
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

obsidian shore
#

kek

tender shard
gusty parcel
#

the commands of the plugins themselves don't work either, I don't even know if I wrote them correctly

tender shard
#

you keep saying "don't work"

gusty parcel
tender shard
#

split it up

try (Response response = client.newCall(request);
     ResponseBody body = response.body()) {
  ...
}
tender shard
#

no, it's one block

gusty parcel
tender shard
#
try(
    Response response = ...;
    ReponseBody body = ...;
) {
    ...
}
ivory sleet
#

You declare each AutoClosable its own scoped variable within the try

tender shard
# gusty parcel nothing

it does not say "unknown command"? it does not print "/command"? It does not show any error message?

#

yeah correct

#

but I'd use one line per variable

gusty parcel
tender shard
gusty parcel
tender shard
#

so your plugin did not even compile

#

show a screenshot of that code

#

?img

undone axleBOT
#

Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.

Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org

quaint mantle
#
java.lang.RuntimeException: java.sql.SQLException: Statement.executeQuery() cannot issue statements that do not produce result sets.
    at me.vasir.manacore.commands.FriendCommand.execute(FriendCommand.java:97)
    at net.md_5.bungee.api.plugin.PluginManager.dispatchCommand(PluginManager.java:208)
    at net.md_5.bungee.api.plugin.PluginManager.dispatchCommand(PluginManager.java:158)
    at net.md_5.bungee.connection.UpstreamBridge.handleChat(UpstreamBridge.java:203)
    at net.md_5.bungee.connection.UpstreamBridge.handle(UpstreamBridge.java:165)
    at net.md_5.bungee.protocol.packet.Chat.handle(Chat.java:71)
    at net.md_5.bungee.netty.HandlerBoss.channelRead(HandlerBoss.java:114)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:286)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
    at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)```
#

what is this ?

tender shard
eternal oxide
#

you can not execute query on an insert/update

tender shard
#

which is not a query statement

quaint mantle
#

resultset

#

wait a second

tender shard
#

string

quaint mantle
#
            String sql3 = "SELECT * FROM friendrequests WHERE receiver = ?";
            try (Connection connection = HikariCP.getConnection(); PreparedStatement statement1 = connection.prepareStatement(sql3)) {
                statement1.setString(1, sender.getName());
                ResultSet resultSet = statement1.executeQuery();
                while (resultSet.next()) {
                    String receiverDb = resultSet.getString("receiver");
                    String senderDb = resultSet.getString("sender");
                    if (sender.getName().equals(receiverDb) && receiver.getName().equals(senderDb)) {
                        PreparedStatement addFriend = connection.prepareStatement("INSERT INTO friend(friend1, friend2) VALUES(?,?)");
                        addFriend.setString(1, receiver.getName());
                        addFriend.setString(2, sender.getName());
                        addFriend.executeQuery();
                        addFriend.close();
                        sender.sendMessage(handler.correctMessage("Arkadaşlık isteği kabul edildi!"));
                        return;
                    }
                }```
tender shard
#

you call executeQuery on an INSERT statement

#

INSERT does not yield a resultset

#

you have to use executeUpdate

#

not executeQuery

quaint mantle
#

ahh

#

.__.

tender shard
#

btw googling the error message would have instantly told you that

smoky anchor
quaint mantle
#

aight ty

gusty parcel
quaint mantle
#

am i check two column for delete ? with sql code ?

eternal oxide
#

can you? yes

quaint mantle
#

i mean like this

eternal oxide
#

yes

quaint mantle
#

but this not working

eternal oxide
#

you can do an inner select

#

using exists

tender shard
#

DELETE FROM table WHERE val1 = ? AND val2 = ?

quaint mantle
#

aigt i will try

tender shard
#

fast

#

very fast

eternal oxide
#

DELETE FROM 'settings.friendrequests' WHERE exists (SELECT 1 from 'settings.friendrequests' WHERE 'sender' = 'testname1' and 'sender' = 'testname2');

tender shard
#

why so complicated

eternal oxide
#

I used years ago for multi table checking

#

so probably not the best in this case

tender shard
#

but they only have one table

eternal oxide
#

yep

tender shard
#

why not just DELETE FROM table WHERE col1 = ? AND col2 = ?

eternal oxide
#

yep

#

head not on

#

mines over complex

tender shard
#

oh ok 😄 I already thought I was missing something

tender shard
#

?learnjava

undone axleBOT
tender shard
#

you are declaring a method inside a method

#

that's not possible and it also makes no sense

worldly ingot
#

Well just make sure your indentation looks somewhat sane and it should be more obvious 😛

tender shard
#

yeah lol

#

Ctrl+Alt+L

smoky oak
#

anyone know why this glitch happens with varargs?

lilac dagger
eternal oxide
tender shard
languid urchin
#

Yeah

smoky oak
#

ah

lilac dagger
#

are args booleans?

languid urchin
#

it will always be false

eternal oxide
#

if it's greater than 0 length true, else args[0], which will not exist

tender shard
#

yeah

smoky oak
#

yea i see

#

its the simple things lol

lilac dagger
#

ah yes

worldly ingot
#

D: What even are boolean operators

#

boolean replace = args.length > 0 && args[0];

#

pls I beg you

quaint mantle
languid urchin
#

also I hate the way that is indented

smoky oak
#

right i forgot its sequential, thanks choco

languid urchin
tender shard
worldly ingot
#

Honestly shocked your IDE didn't yell at you for that PES_Think I thought IJ would have caught that simplification

#

Yeah you've just gotta abstract out some of that SQL code

lunar wigeon
#

hello @worldly ingot

alpine urchin
#

how can i understand the complex ways 3 ints can be encoded to a long with bit shifting magic

#

i know how mc does it

#

i have the code

worldly ingot
#

hello @lunar wigeon

alpine urchin
#

but i have no clue how to understand it

smoky oak
alpine urchin
#

or produce something myself

worldly ingot
#

You can't encode 3 ints into a long. At least not full width integers

#

Ints are 32 bits, longs are 64

hybrid turret
#

Which folders are advisable to add to your .gitignore?

livid dove
#

*cousin

alpine urchin
#

im talking bout minecraft block positions

#

how it can be represented as a long

languid urchin
lunar wigeon
#

what I recommend to do with SQL:

  1. create seperate class that manages database
  2. create manager class that will keep users in memory map
  3. update SQL database by memory map every x minutes
tender shard
#

you can only fit 2 ints into a long

alpine urchin
#

whatever magic mc is doing

tender shard
#

not with integers

livid dove
alpine urchin
#

yes with integers

tender shard
#

where?

livid dove
#

Me and my team worked with the anvil files extensively

eternal night
#

no

alpine urchin
#

maybe since the y is a smaller range

eternal night
#

not with ints

worldly ingot
#

It's because Minecraft doesn't pack more than 30 million. They drop a few bits

eternal night
#

yea

quaint mantle
eternal night
#

26 bits for x and z

#

12 for y

worldly ingot
#

Correct

tender shard
#

8 / 4 = 2

tender shard
#

fancy math

worldly ingot
#

return (((long) x & 0x3FFFFFF) << 38) | (((long) z & 0x3FFFFFF) << 12) | ((long) y & 0xFFF);

languid urchin
hybrid turret
#

Ah icic

hybrid turret
#

Thanks

eternal night
#

what

lilac dagger
eternal night
#

that is just a normal bitmask

livid dove
#

Minecraft's anvil file format does has a list of binary longs that represent the position of blocks. The issue is the bits are represented by an X bit binary within that long, and that binary value is determined by the palette for that chunk section

worldly ingot
#

You're truncating the x and z values to 0x3FFFFFF, truncating the y values to no more than 0xFFF, then oring them together

#

It's not overly complicated

lilac dagger
#

x z are pushed furter and then y comes and mask the remaining bits

tender shard
eternal night
#

0x3FFFFFF, or 67108863, or 2^26 - 1

worldly ingot
eternal night
#

is rather straight forward

worldly ingot
#

Thank you for doing the maffs for me, lynx

#

I was, frankly, way too lazy lol

livid dove
#

Lmao I get where the guys coming from though.

#

The anvil format is erm

#

interesting

#

Genius

#

But interesting

worldly ingot
#

Among a few others

smoky oak
#

actually @worldly ingot wouldnt that need to be length > 0 && args[0] || true; to get the default value properly

worldly ingot
#

There's some weird unsignededness magic

livid dove
tender shard
#

yikes that wasnt done yet

smoky oak
#

i mean if its length 0 then it'd not return true but false

livid dove
#

They manage to fit chunk sections into 64 bit binary longs as a list (Usually you'll get 10-16 ish blocks per 64 bits)

#

Which also by design allow you to determine the coordinates

#

of each block

#

Its an absoloute mind melter first time you dabble with it

alpine urchin
#

understanding what the bit operations do is simple, but i’m struggling to understand when to “truncate” or “or”

livid dove
#

But it is reallyh clever

alpine urchin
#

or why it works

eternal night
#

I mean

#

the | is just there to join them back

#

you take the 32 bits of x, trunace the first 6 ones

#

you have 26 bits of x value

#

you shift it by 38 to the left, so now you have them in the "front" part of your 64 bits of the long

livid dove
#

*or you could use the Anvil method and have up to 16 of them, coordinates and all, in 64 bits

eternal night
#

so you have a long that is 26 bits of "x" information and then 38 bits of 0

alpine urchin
#

what is trunace mean

eternal night
livid dove
#

?.....

eternal night
#

well, if you have 32 bits of an int

#

and you and them

alpine urchin
#

what

alpine urchin
eternal night
#

yea you do that by creating a number that looks like this 000000111111111111111

#

so when you have this "bit pattern"

#

and you number & pattern

#

then obviously the first 6 bits in this case will be 0

tender shard
#
first number is 7, second number is 20.
assume 16 bits per number.

 7 in binary is 0000000000000111
20 in binary is 0000000000010100

now bitshift one of those numbers by 8 bits (move the actual number to the left)

20 << 8 is      0000011100000000


7 OR 20 << 8:
  0000000000000111
| 0001010000000000
= 0001010000000111
eternal night
#

because the pattern has 0s there

worldly ingot
#

Truncate just means chop off

eternal night
#

so whatever your number has there

#

is discarded

worldly ingot
#

When you put 69.420 into an int, it's truncated to 69 :p

eternal night
#

in the back, it has 1s, meaning that if the number has a 1 at a specific bit, the result would have a one there, if the number has a 0, there is a 0

#

😏

worldly ingot
eternal night
#

I mean, it isn't math

#

don't think of it as math KEKW

worldly ingot
#

It's 1s and 0s! :D

hybrid spoke
#

i always hated bit shit in subnetting class

worldly ingot
#

Maybe this graphic will help a little, @alpine urchin?

#

I hope you appreciate my graphical skills

valid kestrel
#

I need help with a plug-in

#

Where I go

worldly ingot
#

Getting rid of 6 bits from x and z (because they're unnecessary - worlds only go to 30 million), and getting rid of 20 bits from y (because the y vallue only goes so high/low), and pack it all together

wet breach
#

someone not understanding how bits work?

worldly ingot
#

retrooper didn't understand how 3 coordinate ints were packed into a single long

wet breach
#

just squish them together

worldly ingot
#

Big squish

wet breach
#

were they not understanding like where they all go?

worldly ingot
#

Yeah because ints are 32 bits, longs are 64

#

3 x 32 != 64

#

= confusion

zealous osprey
worldly ingot
#

Shifting by less and &ing the result by the maximum value

#

So z would be (long >> 12) & 0x3FFFFFFF

zealous osprey
#

ahh

wet breach
worldly ingot
#

Right. You could in theory also just & mask a 64 bit value lol

zealous osprey
wet breach
#

Choco said it

worldly ingot
#

value & 0b111111111111111111111111110000000000000000000000000000000000000000000000

wet breach
#

lol

worldly ingot
#

One may be a liiiiittle bit more readable is all

zealous osprey
#

So a bitmask of 0000000000000000000000000011111111111111111111111111000000000000
26x0 26x1 12x0 ?

zealous osprey
ivory sleet
#

Yeah

zealous osprey
#

neat

smoky oak
#

do amplifiers count from 0 or 1? the doc doesnt say and i dont have my server rn

tall dragon
#

from 0

#

1 would actually be 2 ingame

smoky oak
#

lright thanks

#

different topic, can i directly copy over another method's javadoc with annotations? i dont think @inheritdoc works

carmine mica
#

Yes, it does. If you just omit the Javadoc entirely it copes everything, if you omit part of it, it copies that part

#

You only need inheritDoc if you want to add stuff to a section but also include stuff from a super method

#

Are you actually building the Javadoc to see if it works?

smoky oak
#

its building automatically

#

but i mean methods in the same class

#

i meant it as 'i dont think it works here'

carmine mica
#

Oh, well no. Two methods in the same class have to have their own annotation. I thought you meant from a method you override

smoky oak
#

@link it is

carmine mica
#

If they are related like they are overloads, @ see is better

smoky oak
#

whats the syntaxx

#

i tried #signature and package.path#signature but neither worked

#

it just got eaten as plain text

alpine urchin
worldly ingot
#

<< = go left, >> = go right

alpine urchin
#

nice graphic

worldly ingot
#

ty am graphic artist

alpine urchin
#

is it a png

#

or jgp

#

im tryna save it

worldly ingot
#

probably png idk lol

#

It's a small resolution too

#

because I was too lazy to change it

alpine urchin
#

ok

#

lets say we have these coordinates

#

xyz: 3, 3, 3

#

the long is 0 for now

#

how do we know how much to shift it by again?

#

im starting to understand

#

its shifting to the left

#

so its all together

#

in a long

#

i dont understand the & operation

#

inside the code

#
return (((long) x & 0x3FFFFFF) << 38) | (((long) z & 0x3FFFFFF) << 12) | ((long) y & 0xFFF);
#

does the & limit x to 67108863

eternal oxide
#

& means only copy bits which are set in both args

alpine urchin
#

why would we do that

eternal oxide
#

to limit which bits can be copied and which are ignored

alpine urchin
#

i dont understand

eternal oxide
#

X & 0x0F says only copy the last 8 bits, if set in both X and the mask.

smoky oak
#

that hex number is a bunch of zeroes then a bunch of ones. the '&' makes all bits of the input 0, except where the mask has 'one' bits.
So, simplified:

  0b01101101
& 0b00001111
= 0b00001101

which you then move to the left, to process and add the next bunch of bits

alpine urchin
#

since 0x3FFFFFF is just bits filled with 1s

worldly ingot
alpine urchin
#

ok thx

worldly ingot
#

No, it can be 1s or 0s, but it's the amount of bits that that number represents that matters

#

Actually, I lied, they are all 1s lol

alpine urchin
#

what was the math of the shifting 38 bits and 12 again

#

let me look for it

worldly ingot
#

0x3FFFFFFF in binary is 111111111111111111111111111111

#

Which happens to be 26 bits 🙂

alpine urchin
#

how did they decide to limit it to 26 bits

#

yes i know it all has to add up to 64

#

but how'd they come up with 26

worldly ingot
#

Because 30 million is just their upper limit for world size which can fit in 26 bits

alpine urchin
#

it coulda been

smoky oak
alpine urchin
#

whats the link between 67108863 and 30 million

smoky oak
#

both directions

#

worlds 60 mil wide

#

30 mil is border

worldly ingot
#

Right, first bit is a negative

#

The sign bit, then 25 additional bits for the number which sum to a maximum of 33,554,431

#

Then they left about 2k for the y value (with one sign bit)

alpine urchin
#

aha, 2^25

#

ok

worldly ingot
alpine urchin
#

last thing i dont understand is how they knew they gotta limit x and z to 67108863

#

i see no link in the 30 million

#

and 67108863

smoky oak
#

again

#

both positive and negative

alpine urchin
#

show me an equation

smoky oak
#

you need 60 million points to mark 30 million points positive and negative

#

there's 100 points from 0 to 100

#

theres 200 poins from -100 to 100

alpine urchin
#

yes

smoky oak
#

same thing here

#

just a bigger number

alpine urchin
#

according to what you said

#

they should be limiting it to 30 million

#

and not "67108863"

smoky oak
#

that's the AMOUNT of data points

#

the first bit of that marks if it's positive or negative

zealous osprey
smoky oak
#

the RANGE on that is -33 mil to +33 mil

alpine urchin
smoky oak
#

26 bits have 67 million combinations

#

if you use the first to say 'we're negative' that leaves half

alpine urchin
#

oh makes sense

#

ok

#

limiting it to 25 bits

#

if you were an idiot like me, you could replace the code with

zealous osprey
#

You're not an idiot, just a new topic; Don't beat yourself up about it :)

alpine urchin
#

if (x > 33554432) {
x = 33554432;
}
///...same with z
long encoded = (((long) x & 0x3FFFFFF) << 38) | (((long) z & 0x3FFFFFF) << 12) | ((long) y & 0xFFF);

#

obv

#

dont do that

#

but does it have the same behavior

#

yes right

smoky oak
#

minecraft just blocks things from existing in that area, so that's not a limitation they need to do

alpine urchin
#

oh ok

#

yeah i didnt account for negatives

#

but okay

#

thanks guys

#

the code looks less scarier now

#

XD

dense blaze
#

Got a design question of what is better:

I have a plugin in the works with a ability with cooldowns that actively update and change for the player. If a player uses the ability I want to display a cooldown bar and notify them of their cooldown if they try to use it. I wrote code to do this but want to know what is the better solution.

Should I run a constant running thread that checks to see who is in cooldown and update each player that needs to update or should I spawn an individual thread per player when they enter cooldown and cancel it when they are no longer in cooldown?

Not the most expierences dev so any advice is appreciated for approaching this.

quaint mantle
#

i can't ping but i need ur help guys
ElgarL, frostalf, mfalex, EpicEbic, ImIllusion

#

to split my method into methods

near mason
#

wdym?

smoky oak
livid dove
smoky oak
#

well do remember that having a hashset has O(1) check time

dense blaze
livid dove
smoky oak
#

the extra runnables' overhead might get absorbed into that one. keeping code complexity low is more important here imo

livid dove
#

A process that takes 1000 seconds regardless of number of things to check is still O(1)

pseudo hazel
#

just create a runnable task timer

near mason
pseudo hazel
#

and be done with it

livid dove
dense blaze
#

I didn't know if Java thread count was a concern on machines since I assumed threads were not virtual.

pseudo hazel
#

dont worry about threads

dense blaze
quartz anchor
#

is there a way to run spigot server with debugger so I can debug and hot reload part of my plugin?

pseudo hazel
#

you dont have to think about that when you just use bukkit runnables

livid dove
pseudo hazel
#

I would personally keep a map of all players and update all cooldowns in a single loop in 1 runnable

pseudo hazel
#

well yes

smoky oak
#

i mean, both of those would work, but itd be really hard to say which one would be faster. I really doubt you need that kind of performance in a discussion of '100 player loop' or '100 simple runnables'

livid dove
# pseudo hazel well yes

Always good to sanity check lol. Assumijg withiut elaboration is how singleton managers disappeared lol

smoky oak
#

you cant have that many players on a server at once

dense blaze
livid dove
smoky oak
#

ah true

dense blaze
#

Well I'm glad to hear that it sounds like I'm going relatively the right direction. Thanks everyone!

livid dove
#

No worries my mab

#

Man

#

If u ever need a code review hollar up

quaint mantle
#

i have a command

#

i wanna split my command features to methods

#

brb i will upload to paste md5

dense blaze
#

Are you okay if I add you for future reference?

livid dove
#

They always are mate

#

Sure

quaint mantle
#

i do this for line 28

    public void checkIfFriends(ProxiedPlayer friend1, ProxiedPlayer friend2) {
        String sql1 = "SELECT * FROM friends WHERE friend1 = ? OR friend2 = ?";
        try (Connection connection = HikariCP.getConnection(); PreparedStatement statement1 = connection.prepareStatement(sql1)) {
            statement1.setString(1, friend1.getName());
            statement1.setString(2, friend1.getName());
            ResultSet resultSet = statement1.executeQuery();
            while (resultSet.next()) {
                String senderDb = resultSet.getString("friend1");
                String receiverDb = resultSet.getString("friend2");
                if ((senderDb.equals(friend1.getName()) && receiverDb.equals(friend2.getName()) || (senderDb.equals(friend2.getName()) && receiverDb.equals(friend1.getName())))) {
                    friend1.sendMessage(errorMessage("Bu kişiyle zaten arkadaşsın!"));
                    return;
                }
            }
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }```
#

is it right ?

rain pier
#

What does private final InstanceAccess instanceAccess; do? I'm confused on why there are two instanceaccesses

tender shard
#

private final String name = "mfnalex";

#

String is the type

#

"I have a field called 'name' which is a String"

rain pier
#

but InstanceAccess is a class

remote swallow
#

yeah

tender shard
#

yes

rain pier
#

so does it call that class and name it as instanceAccess?

remote swallow
#

no

livid dove
#

Also that mega check might be worth it's own method to make the base code less messy

tender shard
#

it says "There's a field called instanceAccess and it holds a reference to an object that's of the type InstanceAccess" (whatever that is)

quaint mantle
livid dove
#

Missed that lol

remote swallow
#

so that is making a final InstaceAccess and you have called it instanceAccess

lilac dagger
#

if i set custom model data to 0 will that show no texture?

rain pier
#

I am still very confused

tender shard
rain pier
#

ok

tender shard
#

do you understand what this means?

rain pier
#

yes, it is creating a class named Person which contains a name and age with their types

tender shard
#

yeah and the same is true for your InstanceAccess field

rain pier
#

I think i understand it

#

but InstanceAccess is a class in another file

remote swallow
#

yeah, String is another class elsewhere

tender shard
#

?learnjava

undone axleBOT
rain pier
#

isn't a field a variable in a class?

tender shard
#

yes

livid dove
#

Or rather

#

An instance of a class

rain pier
#

ohh

livid dove
#

So when you make a string, you are actually making an object of the class "String"

pseudo hazel
#

learn basic programming please, it would be impossible to help you with your actual problems if you dont know what a class is

rain pier
#

ok

livid dove
# rain pier ohh

I'll do one better one min. There is a perfect video for this that has the "ooooohhhhhhhh" moment so many java tutorials miss

rain pier
#

Ok ty

livid dove
#

Imo this guy has the best "this is the point of OOP" reveal in any tutorial

#

Watch it fully without skipping and it'll be like a door opening

rain pier
#

ok

livid dove
#

And you'll be like "Oohhhh shit that's what the point of all this is"

pseudo hazel
#

there is no point wdym 💀

kindred sentinel
#

Is it possible to check using PlayerMoveEvent if the player has moved forward? I found only get from location and get to location but not to get direction

ivory sleet
#

I mean u can calculate the direction with those 2 locations

kindred sentinel
#

Oh really

#

Sorry

ivory sleet
#

no need to apologize :)

kindred sentinel
#

:)

pseudo hazel
#

you can use the difference between both positions to get the vector in the direction of the movement

opaque scarab
#

^

pseudo hazel
#

but "moving forward" would be decently hard to detect since you have to compare that to their camera angle, i.e. whwt way are they looking

#

look into the basics of vector math to understand the basic operations you can do

quaint mantle
#

Is there a way to control the invasions of pillagers?

languid urchin
rain pier
#

Ok the video explains a lot but I'm confused on why we can't do:
private final InstanceAccess instanceAccess = new InstanceAccess();
and have to a use a constructor.

languid urchin
rain pier
languid urchin
#

Keep in mind that this is probably not the best place to learn basic Java, and it's impossible to do so by watching a single 15-minute video.

tender shard
opaque scarab
#

This code randomly freezes the server. It appears to freeze at player.getWorld().getChunkAt() The goal of this code is to get a square of loaded chunks around the player, and return it in a list. Why is this happening and how can I get around this?

Code:


        Chunk center = player.getChunk();

        loadedChunks.add(center);

        int radius = radiusRaw; //don't ask

        int centerX = center.getX();
        int centerZ = center.getZ();

        for (int x = (centerX - radius); x <= (centerX + radius); x++) { //going - x to + x to get full radius of chunks
            for (int z = (centerZ - radius); z <= (centerZ + radius); z++) {
                  
                Chunk currentChunk = player.getWorld().getChunkAt(x * 16, z * 16); //converting chunk coordinates to block coordinates to access chunk

                if (currentChunk.isLoaded()) { //checks that the chunk is loaded
                    loadedChunks.add(currentChunk);
                }
            }
        }

        return loadedChunks;
opaque scarab
#

Sure 1 sec

tender shard
#

getChunkAt(...) will force-load the chunk

#

to check if a chunk is loaded without loading it yourself do NOT use getCHunkAt but World#isChunkLoaded(...)

languid urchin
#

You're probably loading a lot of chunks during that loop, which would lag the server

opaque scarab
#

Total code: ```public class ChunkUtils {
public static ArrayList<Chunk> getLoadedChunks(Player player, int radiusRaw) {
ArrayList<Chunk> loadedChunks = new ArrayList<>(); //the returned list of chunks

    Chunk center = player.getChunk();

    loadedChunks.add(center);

    int radius = radiusRaw; //don't ask

    int centerX = center.getX();
    int centerZ = center.getZ();

    for (int x = (centerX - radius); x <= (centerX + radius); x++) { //going - x to + x to get full radius of chunks
        for (int z = (centerZ - radius); z <= (centerZ + radius); z++) {
              
            Chunk currentChunk = player.getWorld().getChunkAt(x * 16, z * 16); //converting chunk coordinates to block coordinates to access chunk

            if (currentChunk.isLoaded()) { //checks that the chunk is loaded
                loadedChunks.add(currentChunk);
            }
        }
    }

    return loadedChunks;
}

}

#

I edited the indents so it would appear correct on discord, but it still doesn’t

tender shard
#

you still force load the chunk

#

you still do getChunkAt

#

do NOT use getCHunkAt

#

use World#isChunkLoaded before you do getChunkAt

opaque scarab
#

I will switch to World#isChunkLoaded

#

I’m just wondering if there is something else wrong, as loading the chunks should just cause severe lag, not a freeze that lasts several minutes

tender shard
#

well which radius did you call it with?

opaque scarab
#

2

tender shard
#

hm yeah that should be fine

#

or did you do it in ChunkLoadEvent?

rain pier
#
private final InstanceAccess instanceAccess;
```This makes an instance of InstanceAccess called instanceAccess

public DeathListener(InstanceAccess instanceAccess) {
this.instanceAccess = instanceAccess;
}```This makes an instance of InstanceAccess called instanceAccess and sets this.instanceAccess which was made from the first line equal to instanceAccess which is the InstanceAccess they just made.

#

Is that correct?

tender shard
#

no

opaque scarab
# tender shard or did you do it in ChunkLoadEvent?

It’s called in a player interact event. If the player is right clicking while sneaking with no items in the offhand or mainHand, the utility function I made (this) gets called. The total design of the code is to allow you to call a nearby horse you own. It checks loaded chunks around the player, and sees if a horse you own is in one of these loaded chunks. (This code is currently disabled for debug)

rain pier
#

bruh I don't understand

languid urchin
tender shard
tender shard
undone axleBOT
rain pier
#

idk my vocabulary

languid urchin
#

Which is why you need to learn basic Java before making a plugin

livid dove
livid dove
#

Easiest way to get off programming

#

You can learn through actual useful examples

opaque scarab
livid dove
#

that mean something to you personally

opaque scarab
#

Basic modding and plugin dev

rain pier
#

I made a plugin which shared hearts of two players and I'm trying to clean it up by "passing the instance" and creating listeners on seperate files instead one big file but I don't understand what the tutorial is telling me to do.

tender shard
languid urchin
tender shard
rain pier
#

Idc what you think about java learning everyone learns differently

tender shard
#

just read a book about java, it'll take like a few days and it's much better than watching stupid youtube videos or copy/pasting from somebody

// Plugin startup logic

opaque scarab
languid urchin
livid dove
icy beacon
#

in my opinion, get familiar with java, at least the very basic syntax, and then you can code plugins and learn everything else by doing

tender shard
icy beacon
#

you need to know the very very basics at the very least

tender shard
icy beacon
#

to actually write something coherent

opaque scarab
ivory sleet
#

From my experience when I was teaching people Java + Spigot, going off spigot and just practice Java basics on its own with my students helped a lot. Sure in the long run it can work, but you should learn a concept in Java on its own, then apply it. That’s at least what’ve worked best as a teaching method.

livid dove
#

Its what i believe leads to tutorial hell

#

Its like learning how to use a screw driver on a plank of wood and then being told to assemble a 7 set cabinet

icy beacon
#

true

languid urchin
#

Think of it like writing a book or an essay in a foreign language, if you don't learn the basic grammar and phrases of that language it's very likely you'll just write some nonsense.

livid dove
#

You need to see the screw do something you understand first

livid dove
#

How do you learn a langauge? With phrases that mean something to you

languid urchin
#

Exactly, you don't start by writing the book

#

you start with the basics

livid dove
#

Whats the first word you always learn when learning a new verbal langauge?

Is it a coincidence its the first bit of code you always write in an ew language

icy beacon
#

yeah you start by writing sentences

olive lance
#

Print

icy beacon
#

a plugin is quite a big undertaking if you are a very beginner

ivory sleet
#

sout hello world pepe_salute

livid dove
#

What world? 😉

#

Hello

icy beacon
#

you'll need to rely on your programming instincts (if you have programming experience but java is new to you) or on other people's help

livid dove
#

Context is king bois

icy beacon
#

which is why we need to start creating plugins in javascript 🤔

tender shard
# rain pier ``` private final InstanceAccess instanceAccess; ```This makes an instance of In...
public class House {
  private Person ownerOfTheHouse;

  public House(Owner owner) {
    this.ownerOfTheHouse = owner;
  }
}

public class MyPlugin {
  public static void main(String... args) {
    Person mfnalex = new Person("mfnalex"); // We create a new person
    House mfnalexHouse = new House(mfnalex); // We simply pass a reference to an existing perosn
  }
}

idk maybe this explains it. you should still check out a basic java tutorial or book

languid urchin
#

And then again, this is the help channel for spigot, not basic Java

livid dove
rain pier
tender shard
#

there is no field access in that line whatsoever

icy beacon
icy beacon
livid dove
#

Okay money where my mouth is. This sounds like a Spigot Thread article time ❤️

#

My goal is to make it into the java command on this discord ❤️

#

xD

opaque scarab
#

Does World#isLoaded(x, z) take World or chunk coordinates?

ivory sleet
#

Though tbh java is a troll when u first learn it, there is just a ton of shit you won’t understand, like just in the classic hello world example you need to understand static, classes, objects, access modifiers, fields and variables, methods, types, strings, arrays, inheritance and polymorphism etc

tender shard
languid urchin
icy beacon
livid dove
#

and then introduces String as their first Class

#

Boom

#

instant "oh shit yeah that makes sense"

small iron
#

Let me ask you, is this correct? I want this "NamePack" folder to be in the same directory (for example in the rightmost image).

livid dove
#

IMO Java is taking the idea of "I made a String class as Chars are a pain in the ass to use" and running with it

#

And taught like that

livid dove
#

is instantly beautiful and easier to grasp the language as a whoel

languid urchin
ivory sleet
#

Yeah definitely

languid urchin
#

Like learning music, you don't need to know exactly why those notes sound good together, they just do, play them.

icy beacon
#

offtopic but i just spent like 40 minutes debugging an error because kotlin only logs some exceptions

#

lol

#

i didn't know an exception was being thrown this whole time

ivory sleet
#

You sure its kotlins fault?

tender shard
icy beacon
#

it does with some and doesn't with some

tender shard
#

i don't like kotlin but I doubt that it randomly suppresses some exceptions

opaque scarab
#

Imagine spending 3 hours because a number was 0 instead of 1 😅

ivory sleet
#

Are you doing multithreading?

languid urchin
icy beacon
opaque scarab
#

To be fair, I was dealing with a huge amount of code tho

ivory sleet
#

Then that might be it

icy beacon
#

perhaps it is

#

though it's the second time that i'm getting a suppressed stack trace when working with mysql

#

maybe it's mysql doing something funny?

ivory sleet
#

oof

tender shard
#

EntityIgniteEvent i think

north nova
icy beacon
#

anyone knows how to setup command autocompletion for jda?

  override fun onCommandAutoCompleteInteraction(event: CommandAutoCompleteInteractionEvent) {
    println("HERE!!!!")
    println(event.focusedOption.name)
    println(event.name.lowercase())
    if (event.focusedOption.name != "reason") return
    // ...
  }

this code does not send any debug when trying to autocomplete as shown in the screenshot. the listener is registered

ivory sleet
#

Are u sure u can autocomplete that?

icy beacon
#

i hope so?

tender shard
#

have you set OptionData#setAutoComplete to true?

icy beacon
#

oh I have not, one sec

tender shard
#

check the wiki I sent, there's also example code in java and kotlin

#

you want this right?

icy beacon
#

yup

tender shard
#

yeah

icy beacon
#

alright let me test it now

#

i completely missed it in the wiki haha

#

oh yeah it works just fine now

#

thanks alex 🙂

tender shard
#

np!

gusty parcel
#

I would like to ask for help, I wrote a sumo plugin with which there is one major problem, mom, that it does not recognize the command I wrote in it

tender shard
#

?paste your whole main class and plugin.yml

undone axleBOT
gusty parcel
tender shard
#

pls paste it on the website

#

?paste

undone axleBOT
gusty parcel
#

name: sumo
version: 1.2
main: hu.sumo.Sumo
api-version: 1.18
commands:
startsumo:
description: Sumo játék elindítása
usage: /startsumo

tender shard
#

why do you have two classes that extend JavaPlugin?

#

the whole main class is flawed

#

you have a class called "sumo" and an inner class called "SumoPlugin"??

pseudo hazel
#

remove your outer class and rename your main to SumoPlugin

#

there is no need for this sumo class you have

upper hazel
#

bytebenders how i can get world in schematic

tender shard
icy beacon
#

also the plugin shouldn't even be able to launch, main class is "hu.sumo.Sumo" and in reality it's completely different

#

shit i got sniped

tender shard
#

yeah it wouldnt even enable

river oracle
upper hazel
#

o

tender shard
#

what do you need a location for?

upper hazel
#

eheh

tender shard
#

this makes no sense whatsoever

ocean hollow
#

If somehow the server crashes, will onDisable pass?

gusty parcel
north nova
#

so what is your problem

#

what

pseudo hazel
#

you place schematics in a world

tender shard
pseudo hazel
#

not teh other way around

pseudo hazel
tender shard
#

intel? NSA?

icy beacon
river oracle
icy beacon
#

intellij perhaps?

tender shard
#

i thought "intel" as in secret service stuff

#

CIA

north nova
#

TRUE the intel as a company is sabotaging your code

#

I've had this thought for years and im not schizophrenic

pseudo hazel
#

oh that makes sense actually, thats why my code never works

tender shard
#

the intel is manipulating my code, why CPU company is sabotaging my plugin D:

north nova
#

yes

#

that is true

#

ESPECIALLY minecraft plugins

#

they dont give a shit about anything else

icy beacon
#

i knew it, they are the ones that make my plugins not work on the first attempt and then somehow work after recompiling

#

those sick bastards

north nova
#

motherfuckers

icy beacon
#

sisterbreeders

tender shard
#

that's why I switched to an M2 macbook

#

get rekd intel

icy beacon
#

i'd too but money is not really easy

north nova
#

Amidst your code's harmony, Intel's mischievous bit-dance emerges. Binary secrets sway, hinting at their digital meddling.

pseudo hazel
#

right since apple uses your info without letting you know so it feels like ur in control

icy beacon
#

lmao

gusty parcel
tender shard
#

it's just a pastebin

shadow night
upper hazel
gusty parcel
#

ok

gusty parcel
pseudo hazel
#

it would allow us to read your code better

icy beacon
upper hazel
icy beacon
#

uhh pretty much nobody does this

gusty parcel
upper hazel
#

really?

icy beacon
#

either way do not ping me without a valid reason

pseudo hazel
#

stop aguing xD, just use the paste link to show your code

#

thats the easiest way for us to see your code and talk with you at the same time

upper hazel
#

hah without traslate "pingount"

gusty parcel
#

k

pseudo hazel
#

if its only a few lines its fine to just put it in chat but for bigger files putting in the file itself is just a bit annoying

tender shard
# gusty parcel but how would this help me with my problem?

I already told you what your problem is. YOu have two classes, one is called "sumo" and doesn't do anything. This is the one that spigot instantiates. Then yo uhave another calss called SumoPlugin that has your actual logic, but it never gets instantiated

#

I wonder how you'd even come up with that

shadow night
#

this is what happens when people use IDEs not knowing what they do

pseudo hazel
#

chatgpt probably

remote swallow
#

thats probably it

shadow night
#

can I say something so people just quote me? or is that not possible in modern time

pseudo hazel
#

wdym

#

ofc its possible

#

it would just have to be something everyone will hate you for

remote swallow
#

they will hat you

pseudo hazel
#

u saw nothing

remote swallow
#

i see everything

shadow night
pseudo hazel
#

well that'd be way harder considering the current state of social media

sage patio
#

anyway to check if a OfflinePlayer has a permission or not?

#

OfflinePlayer#getPlayer?

pseudo hazel
#

probably not automatically

#

I mean if you get the Player object that means they are online

#

in which case its fine

shadow night
sage patio
pseudo hazel
#

I dont see why you need a permission of a player that is not there

sage patio
#

well its complicated

#

(i'm checking for something which it is stored as a permission)

tender shard
sage patio
tender shard
#

you can't?

kind hatch
#

It'll always be null if the player isn't online.

sage patio
#

so the only way is Vault? (how?)

tender shard
#

yes

sage patio
#

thanks

tender shard
#

basically you just get the registered service provider for Permission.class and then use playerHas(String world, OfflinePlayer player, String permission) http://milkbowl.github.io/VaultAPI/

sage patio
#

why it needs a world name? weird

tender shard
#

for per world permissions?

sage patio
#

hmm

digital nova
#

anyone know which NMS class handles sending chunk data to the client, i'm asking as I want to rewrite it to send data from my custom world save format

vital sandal
#

how can I include lib into the jar?

#

this is my pom

tender shard
#

you don't need the maven-assembly-plugin

vital sandal
tender shard
#

np

haughty pewter
#

how to make plugin where u write /rp it adds prefix in tab and if write again it removes it

sacred saffron
icy beacon
#

hey, this isn't spigot related, but does anybody know where rustfmt.toml happens to be located on linux?

#

is it project-based or global, even?

tender shard
icy beacon
#

tyty 🙂

smoky oak
#

?paste

undone axleBOT
sacred saffron
smoky oak
#

with the output, it shows that it's where it prints 'Protocol1'

#

and the function aint called

#

this just prints the exception far as i can see

#

this not plain java?

tender shard
#

why are you not printing the full stacktrace

#

cause.printStackTrace()

sacred saffron
#

ok wait a moment

tender shard
#

what's PacketBuffer lines 616 and 52?

sacred saffron
wind timber
#

Whats the best plugin to prevent xray

tender shard
#

wrong channel

wind timber
#

Bro i just need a name

tender shard
#

ask in the correct channel

sacred saffron
#

wrong channel

wind timber
tender shard
#

also that's for paper only

sacred saffron
tender shard
#

are you sure that strings even are prefixed with their length?

sacred saffron
#

Mir ist grad aufgefallen das du aus Deutschland kommst also können wir auch deutsch schreiben

sacred saffron
smoky oak
#

its in the rules i think

sacred saffron
#

no?

tender shard
#

it's english only

smoky oak
#

also why isnt this image loading

sacred saffron
#

bruh

#

can we switch pls to dm?

smoky oak
tender shard
#

even if it's only in the channel description of #general , it applies to the whole server

smoky oak
#

he?

#

the rules link to this

#

i dont think md_5 means the #general channel saying 'General rules'

sacred saffron
dawn plover
#

anyone using intelliJ that understands something about themes and stuff XD
its not really coding, but i cant think of any better place to ask so idk what else
if anyone wants to help, then i will make a thread to show the problem

waxen jackal
#

Is it possible to ignite a moving tnt block? this behaviour isn't enabled by default but it plagues my server.

Current code:

    @EventHandler
    private fun onListenArrowGroundHit(event: ProjectileHitEvent) {
        val entity = event.entity
        if (entity !is Arrow) return

        if (event.hitBlock?.type == Material.MOVING_PISTON) {
            val data = event.hitBlock!!.state as MovingPiston
            val movingBlock = data.movingBlock
            if (movingBlock !is TNT) return
            movingBlock.isUnstable = true
        }

        entity.remove()
    }

It does reach the movingBlock.isUnstable = true part, but it doesn't ignire

#

got it fixed

elder wren
#

Hello guys, i would like to setup spigot and maven for Minecraft 1.7.10 but I don't know how to write the dependencies, can someone know how to do it ? Thanks for your answers

undone axleBOT
elder wren
#

Can I use Bukkit?

smoky oak
#

i mean

#

maybe

#

buildtools should still support bukkit but i dont know if modern versions still build to it

elder wren
#

I actually couldn't find anything

smoky oak
#

--compile-craftbukkit ?

remote swallow
smoky oak
#

wait thats a space?

#

why

remote swallow
#

yeah

remote swallow
#

probably a java internal

queen niche
#

hey guys! Is there a efficient way to check if a block is a valid block where an item frame can be placed on?

lilac dagger
#

i have shaded an api and relocated it inside my own api, how do i make javadocs with the relocated packages?

#

hmm, i think i found something

#

i'll try it

remote swallow
#

normally you will just add the other libs docs to yours with the link stuff, and not include their docs inside yours

lilac dagger
#

well, in my case this other api is mine also, it's the game engine api, so it's best to shade it/relocate in

remote swallow
#

does it also have javadocs hosted

lilac dagger
#

not yet

#

i can't keep the engine in the root as it would clash with other minigames of mine

#

so relocating it is the best

remote swallow
lilac dagger
#

i could make a separate plugin for it

#

i'll try, thank you

remote swallow
#

you can reloacate it fine, just link javadocs for it to attach the variables from

kindred sentinel
#

I can't figure out how to check if a person is going right or left using the PlayerMoveEvent, I know that this can be calculated somehow, but I can't figure out how

#

I mean to the right or left of the direction

smoky oak
#

vector math is dumb

tender shard
# kindred sentinel I can't figure out how to check if a person is going right or left using the Pla...

that's basic trigonometry.

  1. get the vector between old and new location, let's call the old location A, the new one B, and the difference AB
  2. get the yaw as radians, I think it should be yawRad = yaw * pi / 180. we'll turn that into a vector called yawVec with the three values cos(yawRad), 0, -sin(yawRad)
  3. get the dot product of AB and yawVector.

and then comes step 4 but I don't remember how that works lol

#

maybe ask chatgpt

smoky oak
#

actually i realize its probably much simpler than that

tender shard
#

is it?

smoky oak
#

i mean, the rotation is available, so you have that

tender shard
#

do you mean yaw with rotation?

smoky oak
#

ye

#

you should be able to calculate the rotation of the movement direction too

#

then its just some numbers

tender shard
#

hm idk

#

what do you even need this for @kindred sentinel ?

smoky oak
#

also the 'to' location in the playermoveevent may have the yaw of the direction youre moving into

kindred sentinel
#

:/

tender shard
#

people could be pressing W+D without moving the camera - they are going right. but what if they only move the mouse to the right and press W? Does this count as straight-forward, or as going right? what if they are going straightforward but in a diagonal direction, etc

tender shard
#

you can just do

Location old = event.getFrom();
Location to = event.getTo();
to.setYaw(old.getYaw());
event.setTo(to);

or sth

smoky oak
#

id really recommend doing a check on that if you do that tho, setting it without checking if needed will be more glitchy

kindred sentinel
smoky oak
#

good luck on that matjh

lilac dagger
#

yeah you could check if he turned left enough by comparing the old and new

#

and if he passed a threshold in a period of time you could consider it a left turn

kindred sentinel
#

chat gpt wrote that

    public void onPlayerFly(PlayerMoveEvent event) {
        Player player = event.getPlayer();
        Vector from = event.getFrom().toVector();
        Vector to = event.getTo().toVector();
        Vector movementVector = to.clone().subtract(from);

        Vector cameraDirection = new Vector(
                Math.cos(player.getLocation().getYaw() * Math.PI / 180),
                0,
                Math.sin(player.getLocation().getYaw() * Math.PI / 180)
        );

        double dotProduct = movementVector.normalize().dot(cameraDirection);

        if (dotProduct > 0.5) {
            player.chat("Right");
        } else if (dotProduct < -0.5) {
            player.chat("Left");
        }
    }```
#

and it's really working

lilac dagger
#

yes but it's easier with the way i said it

#

yaw being in degrees is awesome

#

you don't need to complicate movements with sin and cos 😄

#

oh nvm, i forgot to take in the account the player movement

austere cove
tender shard
#

also shouldn't it -Math.sin

kindred sentinel
#

:/

#

wait

smoky oak
#

honestly i wouldve just taken the numbers and tested where what side is lol

kindred sentinel
#

i'm too stupid for that

#

,_,

#

i don't know vectors from math ,_,

livid dove
tender shard
#

a justifiable explanation for pinging him, instead of doing it randomly

kindred sentinel
#

that's why i understood this only after doing that

#

sorry for bothering you

#

the idea was good to make something like hoverboard that can't move right or left but using this way it's really lagging that's why it became useless

near mason
#

how to set a players skin to offline player's skin?

grim hound
#

Or you can override the GameProfile texture property after sending a texture http request and refreshing that skin by sending the player info (remove), OutRespawn, and player info (add) packets

lilac dagger
#

Wait, how do you send a texture http request?

whole surge
#

Hello. Im trying to add animation on usage of custom item with resourcepack and this code doesn't seem to be working:

ItemMeta hand = p.getInventory().getItemInMainHand().getItemMeta();

hand.setCustomModelData(22813372);
Bukkit.getScheduler().runTaskLater(Alcotester.getPlugin(Alcotester.class), () -> {
      hand.setCustomModelData(2281337);
      tester.setItemMeta(hand);
}, 20L);

``` (it's intended to change modeldata to a different picture and then back)
Can you help me a little please?
lilac dagger
#

I have custom npca and sometimes when the sertver starts they lack the skin

grim hound
lilac dagger
#

Ohh

grim hound
#

You can do that using Gson

#

And spigot also uses it so no need to compile it with the plugin

near mason
#

wouldn't OfflinePlayer.getPlayerProfile().getTextures() work?

grim hound
#

OfflinePlayer#getPlayerProfile is a thing?

near mason
#
Player p = Bukkit.getPlayer(args[0]);
                    OfflinePlayer offlineP = Bukkit.getOfflinePlayer(args[1]);
                    
                    p.getPlayerProfile().setTextures(offlineP.getPlayerProfile().getTextures());
#

ye

#

maybe bec im using Paper

grim hound
#

Must be new

remote swallow
#

thats in spigot

grim hound
remote swallow
#

it was added in 1.18.1

grim hound
#

You still probably need to refresh the textures

near mason
#

ok

near mason
near mason
#

ohh ok

grim hound
#

Player info (remove), OutRespawn & player info (add)

#

These packets

near mason
#

ok

grim hound
#

There may be other ways now

near mason
#

maybe hide player from all players and show him back?

grim hound
#

Ye that should send the remove and add packets

#

Now just throw a respawn packet in that

#

You can either teleport the player into another world

#

get the player's channel and use Channel#writeAndFlush

near mason
#

i will use ProtcolLib

grim hound
#

Or use the sendPacket method in I think the Entity Player class

grim hound
near mason
#

ok thank you you helped a lot

marsh crater
#

Is there a clean method of taking a world in the servers root folder (ie, "duel_map"), creating an instance of it and teleporting people to it? Then deleting the instance when it's done. I'd want to create multiple instances, and I'd like to avoid plugins designed for this (for learning purposes) unless the code required is grotesquely long/complicated

grim hound
#

Or do you want to use an existing world?

marsh crater
#

I want a template that I can make multiple instances of

grim hound
#

I don't get what you're saying

remote swallow
#

you would need to clone the folder then load it

grim hound
#

So copying worlds?

marsh crater
remote swallow
#

no clue

marsh crater
#

I want "duel_map" world that I build (same as "world", "world_nether") and I want to load an instance of it for each duel that players start, then I want to remove the instance when they leave

remote swallow
#

you shouldnt load a world for each duel

obsidian shore
#

that's not a great idea

marsh crater
#

How is it usually done?

obsidian shore
#

would be pretty laggy, creating worlds is an expensive operation

remote swallow
#

1 world and just spreading them appart

grim hound
marsh crater
#

So just modify the player list and chat so it only shows people in current match?

obsidian shore
#

you could async paste the arena in different regions as needed, that is what I did for a practice pvp server

obsidian shore
#

That works if you don't want terrain interations

#

like fire etc..

spare hazel
#

so im using intellij idea for plugin development and when i added my other plugin's jar as an external library file and used it, there was no errors in the IDE but when i packaged it using maven, there was this error:

package com.amirparsa.hypixelcustomitems does not exist

this is the code where i used my other plugin's code:

private static HypixelSkillCore plugin;
    private static HypixelCustomItems customItemsLib;

    @Override
    public void onEnable() {
        plugin = this;
        customItemsLib = (HypixelCustomItems) getServer().getPluginManager().getPlugin("HypixelCustomItems");

how can i fix this and no i dont wanna use interfaces for api

grim hound
spare hazel
grim hound
#

Uggh I haven't been using maven for so long I don't actually remember.

spare hazel
#

why? maven is way better than gradle

obsidian shore
#

🤮

grim hound
#

I mean gradle is faster

remote swallow
spare hazel
remote swallow
#

imo its not

grim hound
#

But builds 2 minutes

obsidian shore
#

bazel better

grim hound
#

IntelliJ compiler better

spare hazel
#

oh maven is older...

#

and also, do i have to use the RUN button for getting a build for plugins or the BUILD buttton? when using maven and the minecraft dev extension

grim hound
#

In maven I think it was the build button in the maven section

remote swallow
whole surge
#

but the texture in game doesn't change

grim hound
#

Why is the number so high?

vital ridge
#

Why does setItemMeta remove all nbttags that I previously added to my item?

whole surge
grim hound
#

Makes sense

austere cove
#

because you're replacing meta lmao

spare hazel