#help-development

1 messages · Page 152 of 1

torpid sapphire
#

for example i have 3 events that all relate to a custom gui im making

#

and 4 events that remove mending from the game

#

so i split all of those into their separate handlers?

tender shard
#

if you have the PlayerInteractEvent twice, and they both start with the same 10 different lines for checking (e.g. was a block clicked, is the player OP, does the player have a certain item, ...) then I'd have one eventhandler and then decide which of my other methods to call

#

if however both eventhandlers are totally different, I'd just use two event handlers

torpid sapphire
#

well i dont have any duplicate events yet

tender shard
#
    @EventHandler
    public void onInteract(PlayerInteractEvent event) {
        // 10 lines of if statements that doLeftClickThing and doRightClickThing would have in common...
        // ...
        if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK) {
            doLeftClickThing(event);
        } else if(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
            doRightClickThing(event);
        }
    }
torpid sapphire
#

yea i see

tender shard
#

but if they do TOTALLY different things, e.g. one InteractEvent is to check whether a block was clicked, the other is to check whether a player uses some very special item, then just make two event handlers

#

in the end, it doesn't really matter. unless you register A SHIT TON of event handlers since ofc if the HandlerList gets very long, this is not very good for the server performance

#

but I doubt that you wanted to register 5000 eventhandlers in one plugin

torpid sapphire
#

yeah im weirdly obsessed with small performance things so i try to optimize even the smallest things even if they dont matter at all

tender shard
#

readability > getting the last 0.00001% of performance

torpid sapphire
#

which is usually a good thing but it does take time away from actually doing anything productive

torpid sapphire
wet breach
torpid sapphire
#

im not experienced enough in java to optimize anything small anyway

torpid sapphire
#

and it might take me a few minutes to do

#

which could be spent doing something more productive

#

when doing some embedded low level stuff its definitely important

wet breach
#

even in high level it matters

#

that one extra allocation, means another object for the JVM keep track of, another pointer being used, space in the stack being used, and now the GC at some point might need to handle it

#

but is it really going to matter for a small plugin, most likely not. But it does matter on systems where they have like thousands of players though

tender shard
#

GC? The listener is only created once

wet breach
#

because mass amounts of resources are already spent for those players

tender shard
wet breach
tender shard
#

Okay but we only talked about listeners

torpid sapphire
#

but it really doesnt make a noticable difference on modern hardware

wet breach
#

ok, my point was that all objects whether small or not do have an impact, just the impact is not seen until you hit a certain point

torpid sapphire
#

exactly

wet breach
#

so, yes 1 extra allocation of an object can make a difference, just doesn't for small plugins

torpid sapphire
#

exactly my point

#

what i meant was that its not worth it spending 10 mins on optimizing a single allocation away when you could spend that time doing other stuff

tender shard
#

I sometimes even listen to the same event for every priority separately lol

wet breach
#

because while small plugins generally don't see such benefits, if you get enough small plugins together

#

then it does matter

#

this applies if you are making public plugins

#

because what some devs forget, your plugin isn't the only one going to be on the server lol

torpid sapphire
tender shard
#

LOWEST gets called first, HIGHEST second latest and MONITOR is latest

#

e.g. imagine you wanna check if a player is trying to place a block on NORMAL priority

#

a plugin on LOWEST might have already cancelled it

#

so on normal, you can just ignore it if the event was already cancelled on LOWEST

torpid sapphire
#

how does it handle multiple handlers on the same level

tender shard
#

the first registered listener gets it first

torpid sapphire
#

fair

tender shard
#

the HandlerList is basically nothing more than a list of methods to call, ordered by priority, or ordered by "time of registering" when same priority

#

okay in fact it's an EnumMap, but still, same idea

torpid sapphire
#

its 2:30am and youre on light mode

tender shard
#

yeah and I'll go to sleep now, have to get up at 9am D:

#

good night everyone

torpid sapphire
#

good night

prime reef
#

found the issue with hex colors- you have to use ComponentBuilder from 1.19 onward

fresh timber
#

im tryina make a method for my hashmap so I can access it in another class and not have to use static but its not working at all

HashMap<UUID, String> particlesMap = new HashMap<>();
public String getParticlesMap(UUID uuid) {
   return particlesMap.get(uuid);
}

When I try to use getParticlesMap(uuid in here) it doesn't work just red in IntelliJ and no options to import anything

torn oyster
#

i used a method that converts it into the &x format

#

but it still rounds

wet breach
#

class files are objects

#

you would need to hold a reference to the class that is accessible to access the methods within it

fresh timber
#

uh

#

how do I do that

torn shuttle
#

really quick question, you should be able to get the location off of a dead living entity right?

fresh timber
#

dead living

#

...

fresh timber
#

how is it dead and living ;-;

hasty prawn
#

LivingEntity is a class

#

Thats what he meant

fresh timber
#

oh ok

fresh timber
river oracle
#

learn basic java and OOP principles some helpful links below 🙂

#

?learnjava

undone axleBOT
fresh timber
#

lol knew someone would do that

#

every time

#

and I literally remember none of it

#

so uh im not doin it again

river oracle
#

probably because you didn't take time to apply between each lesson

fresh timber
#

exactly

river oracle
#

you learned incorrectly

fresh timber
#

yep

#

thats why ima learn how to do this here ig

fresh timber
#

mk ig ima be reading for a while

river oracle
#

OOP can be a hard to grasp concept at first so it may take a bit

fresh timber
#

lol

#

for sure

#

makes me so confused

#

why we cant just use static

#

so much easier

river oracle
#

honestly took me my first 6 months for it to finally click

fresh timber
#

mk

river oracle
# fresh timber mk

two primary uses for static Constants (Never changing Variables)
and Singleton Classes (An instance where only one object of a certain class should exist at one time) This principle is generally used for something like Databases as you wouldn't want to open multiple connections
https://www.geeksforgeeks.org/singleton-class-java/

river oracle
# fresh timber mk

Also I reccomend skipping all the basic shit and gimicky projects and jumping straight into OOP design polymorphism etc

fresh timber
#

in freecodecamp?

river oracle
#

no just in general

fresh timber
#

hm?

river oracle
#

I taught myself how to code using google and stack overflow idk any of those websites

fresh timber
#

omg ppl on stack overflow are so confusing

#

or im just stupid

#

prob that

#

but

#

I dont understand anything they say on there

hasty prawn
#

Like what

river oracle
#

also a shitty practice wtf

fresh timber
#

oh ok

river oracle
#

oh nvm I see he explained it but the code example is poor

hasty prawn
#

I mean it's fine I guess it just depends on the use case

sterile token
#

Hi

#

Dessie and your pink color what happened?

hasty prawn
#

It's still pink for me

fresh timber
#

same

sterile token
#

Weird im seeing al people with white name

fresh timber
#

ur color blind

#

o.o

river oracle
# fresh timber https://stackoverflow.com/questions/29197899/accessing-a-hashmap-from-a-differen...

again matters on usecase but i'd, model it something like so

public class DataStorage {
  private static DataStorage instance;

  private final Map<String, Integer> people;
  private DataStorage(){
    this.people = new HashMap<>();
  }

  public int getPerson(String person){
    return this.people.get(person);
  }

  public static DataStorage getInstance(){
    if(instance == null){
       instance = new DataStorage();
    }
    return instance;
  }  
}  
public class PluginName extends JavaPlugin {
    
    @Override
    public void onEnable(){
      final DataStorage dStore = DataStorage.getInstance();
      System.out.println(dStore.getPerson("Miles"));
    }
  }
}```

In this use case I'm assuming you'd never want another instance of DataStorage under any circumstances thus it being singleton
wind tulip
#

Hey, is it possible to make an async task run on the same tick? (The bukkit scheduler "schedules" the task to run on the next tick, but I need to cancel an event on the same tick that it happens, and it needs to happen inside an async task)

If not, can someone teach me how to make my own scheduler, and if schedulers generally cannot run tasks on the same tick by definition, is there any alternative? Maybe a java thread?

hasty prawn
#

?di

undone axleBOT
river oracle
#

I use DI for pretty much everything else

hasty prawn
#

Oh, I didn't mean to say your way was wrong or less right, I was just saying that DI is another way to achieve the same thing.

river oracle
#

ahh I see

#

yea no DI would be good here too if you don't want to break your pattern

fresh timber
hasty prawn
wind tulip
#

shouldn't matter though

river oracle
hasty prawn
#

^

river oracle
#

it allows the use of restriction to define what people are able to do

fresh timber
#

uh

#

ok

hasty prawn
undone axleBOT
wind tulip
#

the reason why is not related to the problem

river oracle
# fresh timber uh

it may seem unintuitive by it does make sense once you better understand patterns

wind tulip
#

I'm just generating code

young knoll
#

The getter makes sure the instance isn’t null, for one

wind tulip
#

I'm basically taking code from a language built inside of minecraft and generating java code for it through a website

#

the reason why I need an async thread is for synchronous waiting (Thread.sleep in this case)

#

that is no way related to what I need though

young knoll
#

Can’t you wait sync with schedulers

wind tulip
#

and stacking schedulers will not work specifically inside if statements and loops, unless I use a pointer-like system where each action points to the next, but I don't want to do that

wind tulip
hasty prawn
#

Well as far as I know you can't cancel events async at all

fresh timber
river oracle
hasty prawn
#

The only way you can cancel an event is within the handlers themselves, anything async and the event would be finished by the time you went to cancel it.

wind tulip
#

what I'm asking is if I can run an async thread on the same tick instead of scheduling them for the next

#

if not with the bukkit scheduler then with my own or any alternative

hasty prawn
#

Uh, I doubt it.

fresh timber
#

im using it for a command /particles and in particles if u use the cmd it adds a ur user and a string of the particle u used in an arg in a hashmap and in another class listener it makes particles at ur feet if the hashmap contains that key with that value when u walk

hasty prawn
#

That's not really how async works afaik

wind tulip
#

The bukkit scheduler just waits for the next tick and executes the runnable there

#

I just want it to run on the same tick instead of waiting, and this is probably not doable with the bukkit scheduler itself but are there any alternatives

#

What about the thread class?

river oracle
#

you should also make it more advanced but you can worry more about that later

wind tulip
young knoll
#

You can’t just cancel the event on the same tick

#

It has to be at the precise time

wind tulip
#

I know, I didn't mean it literally

#

I just want the async code to run instantly rather than scheduling it

#

is what I meant

fresh timber
#

that makes no sense at all um isnt a cache like a hidden away stash im confused

hasty prawn
#

Even if you somehow achieved that, there's no guarantee that your async task will cancel it before the server checks for cancellation.

fresh timber
river oracle
#

which means as soon as the java program terminates its emptied

wind tulip
fresh timber
#

oh

#

how do I create a storage file for my plugin

hasty prawn
wind tulip
#

it doesn't have to

river oracle
# fresh timber oh

Basically all variables in your program are emptied when the server shutdown

fresh timber
#

oh uh

#

I had no idea

#

thats why everyone loses progress ;-;

hasty prawn
#

Sync, yes. That's why cancellation works the way it does currently. You start adding async into the mix and everything falls apart.

wind tulip
#

as mentioned, code runs instantly, so the second the async task is triggered it is done

fresh timber
#

how do I fix that

river oracle
fresh timber
#

yea

river oracle
#

all that data is stored in RAM

fresh timber
#

ye

river oracle
#

as you may know RAM is temporary storage you need to do FileIO to write to the disk

fresh timber
#

u lost me on fileIO

#

whats that

hasty prawn
river oracle
fresh timber
#

...

river oracle
#

yk how some plugins have config files

fresh timber
#

oh ye

river oracle
#

thats an example of them using fileIO

fresh timber
#

so I store it in config file?

river oracle
wind tulip
#

the async thread is created instantly I assume though?

hasty prawn
#

Sure, the Thread is. But that doesn't mean it's run instantly.

#

That's what async is

torn oyster
#

bungeecord hex colours aren't working

hasty prawn
#

Order is un-determined when you're working with async.

river oracle
quaint mantle
#

databases would generally be easier imo, use mysql and do it. It is far easier and better for the future than using config file types

torn oyster
#

hex colours aren't working
non-hex colours are fine, hex colours round to another colour (e.g. a maroon hex colour becomes aqua)
(bungeecord not spigot)

river oracle
hasty prawn
#

Cancel event async

quaint mantle
river oracle
#

going back and redoing it a lot is what I did 🤷‍♂️

#

it got me more familiar and writing more code

#

anyways yea if you wanna learn SQLite which is probably best for this small-scale project you can do that but you can also check out my config api

#

the annotations have no usecase for you so I reccomend just grabbing the ConfigUtils class

fresh timber
#

I am prob gonna need smthin for uh larger storage

#

im usin this for my server

#

network

river oracle
#

hmmm okay yea that changes things

fresh timber
#

and ima do some stuff with lots of variables

#

like rpg game

river oracle
#

@quaint mantle I know literally nothing about SQL so your in charge here i've only ever used NOSQL

fresh timber
#

nosql and sql thats weird

river oracle
#

no sql just means its not a type of sql database which is table based afaik

#

I've only ever used MongoDB as thats whats used at work

fresh timber
#

ok

#

so much to learn lol

river oracle
#

MongoDB has a JSON like structure but for something as you have table based works fine

#

SQL is also wildely more popular afaik

young knoll
#

Yes

fresh timber
#

so sql is better for what im tryina do

young knoll
#

I would use something like SQLite so you don’t need to host anything

torn oyster
#
    public static String colourize(String message) {
        String prefix = "&#";
        final Pattern hexPattern = Pattern.compile( prefix + "([A-Fa-f0-9]{6})");
        Matcher matcher = hexPattern.matcher(message);
        StringBuilder buffer = new StringBuilder(message.length() + 4 * 8);
        while (matcher.find())
        {
            String group = matcher.group(1);
            matcher.appendReplacement(buffer, COLOR_CHAR + "x"
                    + COLOR_CHAR + group.charAt(0) + COLOR_CHAR + group.charAt(1)
                    + COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3)
                    + COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5)
            );
        }
        return ChatColor.translateAlternateColorCodes('&', matcher.appendTail(buffer).toString());
    }```
#

that's my method

#

i copied it off the internet because my previous method was having an issue too

river oracle
# torn oyster a

do you even need to use ChatColor for bungee? I was under the assumption that was all handled by components

torn oyster
#

oh?

#

what do I use for that then?

river oracle
#

atleast in my experience I just used ComponentBuilder#color 🤷‍♂️

#

and that takes in an RGB value iirc its pretty simple to get RGB from HEX vise versa

fresh timber
#

hm oh wait yes

river oracle
#

granted I'm not a bungee dev I've just tinkered with it

torn oyster
#

huh I just use new TextComponent(String) to get rid of the deprecated thing

river oracle
#

they are hella useful

fresh timber
#

I remember when I used to use Skript for my servers it had a file that stored all of the variables

river oracle
#

also more functional

river oracle
young knoll
#

Yeah you can’t just use ChatColor inside a TextComponent

fresh timber
#

bro it was so slow

#

I hated it

#

but this is so hard

#

like

#

so hard

#

compared to it lmao

#

like the logic of the code is so hard to understand

torn oyster
#

why does ComponentBuilder.create() return BaseComponent[]?

#

why is it an array?

river oracle
#

ComponentBuilder#append

#

you can append more components to the builder

torn oyster
#

so if I only use ComponentBuilder.color()

#

can I get [0]?

young knoll
#

You could

river oracle
#

Just send the component array as a message np reason not to

young knoll
#

but generally you can just send the array

torn oyster
#

does ChatColor.of() translate hex?

#

or do I just append

#

and it translates the hex

fresh timber
#

so I use luckperms for my server permissions... which one of these stores the variables and stuff for like ranks of players etc.? I think its the .mv.db one but idk im just wondering

#

oop hold on

river oracle
#

Idk how hex works with components I use rgb but you could probably just do the math if there's nothing

fresh timber
#

or is it not even in there

#

cus im feelin like im wrong lmao

young knoll
#

You should be able to translate the text with ChatColor.of

young knoll
fresh timber
#

hm

#

does it use sql?

young knoll
#

It uses h2

fresh timber
#

ok

young knoll
#

Which is a form of sql

fresh timber
#

is sql the most popular

#

I could ask like so many questions rn

torn oyster
#

java.lang.IllegalArgumentException: Could not parse ChatColor &#691f2b

#

bruh

young knoll
#

No &

torn oyster
#

it still is blue

#

its meant to be dark red

#

but its blue

wet breach
#

take a look at that

#

feel free to look at any other projects in my repo

#

I am not claiming I am the best, but you are free to use my projects as references

torn oyster
#

is there a way to get a ChatColor from something like "&c" or "&f"

wet breach
#

you would need to have your own mapping of such things

#

which isn't hard since MC doesn't have that many colors for chat well not counting hex

#

they use ANSI colors

ebon coral
#

is there a way to update a skin on a tablist in nms

#

like i can set the textures just fine but i assume i need to send an update packet of some type to change it

warm light
#

Is there any event that get called when an item added/removed in inventory?

ebon coral
#

theres one when you pick up an item i believe

warm light
#

InventoryPickupItemEvent?

ebon coral
#

Called when a hopper or hopper minecart picks up a dropped item.

#

doesn't sound like it

#

or wait

#

if that's what you're wanting

#

but if you're thinking player wise, PlayerPickupItemEvent is your go.

warm light
#

Nah. its a custom inv. so.......

#

Something like any interaction with inv

ebon coral
#

OH

#

InventoryMoveItemEvent

#

Called when some entity or block (e.g. hopper) tries to move items directly from one inventory to another.

warm light
ebon coral
#

hmm not sure then

#

what is this for?

warm light
#

Want to run a task when player put/remove items in inv

fluid river
#

InventoryEvent

#

Eats all of the events related to inv

#

All other events extend it

wet breach
#

doesn't mean the generic event is called itself

quiet ice
compact haven
wet breach
#

but doesn't hurt to have your own mapping

#

I mean its ANSI

compact haven
#

just another thing to maintain when it's already in the spigot lib 🤷‍♂️

wet breach
#

yes and no, JANSI provides it

torn oyster
#

how come my NMS NPC players don't have 2nd layers on their skins?

fluid river
#

woke up btw

#

where are noobs

#

show me

chrome beacon
torn oyster
fluid river
#

PacketPlayMeDumb

#

PacketPlayGamesForFun

torn oyster
#

i'm using mojang mappings

fluid river
#

sorry i'm just on my flow

wet breach
# fluid river it's stated in javadoc

it doesn't say the generic event is implemented, just tells you what the interface represents. Also don't always believe everything from the javadoc. Just because it says it, doesn't necessarily mean it is implemented or implemented in the way you think.

#

always should check the source code

fluid river
#

shouldn't it be like this

#

for every

#

most of the events state that they are getting called

#

and calling sub events as i can see

wet breach
#

probably should check the implementation before assuming

fluid river
#

isn't code like half-hidden

wet breach
#

Generic events are not necessarily made to be used

wet breach
fluid river
#

can you send me a link

wet breach
#

?bt

undone axleBOT
fluid river
#

to spigot repo

#

alr what should i do with bt?

#

compile spigot jar and decompile with JD-GUI or smth

wet breach
#

use it to get the spigot server source?

fluid river
#

or there is a link

wet breach
#

why would you decompile

#

when buildtools gives you the source

#

the server source is the implementation of the API

fluid river
#

i only used buildtools to literally build server jar of latest version

wet breach
#

can't build server jar without source

#

isn't magic you know

fluid river
#

it's downloading it

#

and then building jar

young knoll
#

No abstract events are listenable

fluid river
#

isn't it

young knoll
#

Afaik

wet breach
#

all the downloading

#

is mostly the source code being downloaded

fluid river
#

i probably even tested it

#

and it was getting called

#

normally

#

same as it's 2 subs

#

so it's saved to some folder

#

when bt downloads it

#

can i just ask bt to download sources and not build spigot jar

#

with flag or smth

wet breach
#

how are you commenting on API implementation and not know how java compiles crap

#

yes there is a flag

#

for just sources I think

fluid river
#

java -jar BuildTools.jar --rev latest --iwannakillmyself

compact haven
#

bruh are you okay

#

like at all

fluid river
#

yeah

#

are you scared?

compact haven
#

no

fluid river
#

are you disgusted or smth

compact haven
#

if that's the right word?

torn oyster
#
        // Add data
        SynchedEntityData data = npc.getEntityData(); // DataWatcher
        data.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE), (byte) 126);
        sendPacket(sp, new ClientboundSetEntityDataPacket(npc.getId(), data, true));```
#

i've tried that

#

but it doesn't seem to work

#

the 2nd layer doesn't show up

#

:-:

fluid river
#

¯_(ツ)_/¯

compact haven
#

mfw "where are noobs" but no knowledge on bt

wet breach
#

also no knowledge on implementation either

fluid river
wet breach
#

just going off what some words say

fluid river
#

i never used bt

#

for something other than building jar

wet breach
#

because it literally helps you obtain the source

#

which is how you check how the API is implemented

drowsy helm
#

works for me

fluid river
#

i never really needed that

#

so i never used it

wet breach
#

until now when someone actually is questioning whether or not have you ever looked at the implementation

torn oyster
drowsy helm
#

its just a byte

torn oyster
#

what byte ??

drowsy helm
#

idk its on the remap

wet breach
drowsy helm
#

look at the src

fluid river
#

just remember some guys suggested it to me probably

#

never really had to use it

wet breach
#

that is fine, but you should have checked to see if that was true

fluid river
#

well if i want to check i just write and run

wet breach
#

there is like a couple generic events if I recall that are indeed implemented, but it doesn't hold true for them all

torn oyster
drowsy helm
#

yep

#

DATA_PLAYER_MODE_CUSTOMISATION = SynchedEntityData.defineId(Player.class, EntityDataSerializers.BYTE);

#

they use this

torn oyster
#

oh wait

#

bruh momento

#

nvm

#

i'm using the nms player thing

#

wait no i'm using bukkit one

#

i'm mentally broken

torn oyster
#

whats the package for nms player

fluid river
#

i definitely remember a lot more events like Piston one

#

which are getting called

drowsy helm
#

moj mappings?

wet breach
fluid river
#

oh shit i just saw that it's abstract class

#

on javadoc

#

sheeeeit

torn oyster
#
        EntityDataAccessor<Byte> DATA_PLAYER_MODE_CUSTOMISATION = SynchedEntityData.defineId(net.minecraft.world.entity.player.Player.class, EntityDataSerializers.BYTE);
        data.set(DATA_PLAYER_MODE_CUSTOMISATION, (byte) 0xFF);
        sendPacket(sp, new ClientboundSetEntityDataPacket(npc.getId(), data, true));```
#

good?

#

i'll try it anyway

wet breach
#

?tas

undone axleBOT
torn oyster
#

i predicted that

#

not even kidding

drowsy helm
#

dont think that will work

torn oyster
#

isn't that literally what you showed me?

#

well it didn't

drowsy helm
#

i showed you how they do it, doesn't mean if you do the same it will work

torn oyster
#

oh

#

java.lang.NullPointerException: Cannot invoke "net.minecraft.network.syncher.DataWatcher$Item.b()" because "datawatcher_item" is null

fluid river
#

InventoryEvent isn't abstact btw

#

and to check if it's getting called

#

i would just prefer writing a listener

#

not downloading bt, then downloading sources, then viewing them

#

sounds like a great waste of time

harsh totem
#

how to check if an entity is in the end?

torn oyster
fluid river
#

or at least

torn oyster
harsh totem
torn oyster
fluid river
#

entity.getWorld().equals(plugin.getServer().getWorldConrainer().get(2));

drowsy helm
#

entity.getWorld().getEnvironment() == World.Environment.THE_END

fluid river
#

or smth like this

#

iirc

fluid river
#

if end is world 2

fluid river
#

but still

drowsy helm
#

yes but also require the name to be fixed or it to be the second world

#

neither are reliable

fluid river
#

yah

torn oyster
#

bonus: check all 3 things

#

(don't actually)

fluid river
#

when forgot chcp 1251

#

waiting 99 hours for buildtools to do it's work

#

maven does not exist

#

writing own maven

#

pliz wait

#

hey @wet breach

#

how do i actually check if event is getting called

#

in sources

#

first time looking through sources

#

isn't it really getting called

#

even has own handlers

#

and actually just a base for other events to extend from

drowsy helm
#

what are you trying to do?

#

you can just listen to InventoryEvent if that's what you're asking

fluid river
#

yeah

#

is it gonna work like combined event of it's subs

#

listening to everything

#

related

drowsy helm
#

yeah

fluid river
#

so i was right

#

from the beginning

drowsy helm
#

so any event that extends InventoryEvent will also get called

wet breach
drowsy helm
#

ah doesn't it?

wet breach
#

no, there is some generic ones that are implemented but not all of them

fluid river
#

i was right

#

you can easily call InventoryEvent

#

so the guys who suggested it to me were right too

fluid river
#

i just ignored it

#

never used

#

and never really had to

wet breach
fluid river
#

it has handlers and you can listen to it, and it's not abstract of course

wet breach
#

I never said specifically that you couldn't use it either

wet breach
#

I can put a handler in any class I want

#

doesn't mean it is used

torn oyster
#
        SynchedEntityData data = npc.getEntityData(); // DataWatcher

        EntityDataAccessor<Byte> DATA_PLAYER_MODE_CUSTOMISATION = SynchedEntityData.defineId(net.minecraft.world.entity.player.Player.class, EntityDataSerializers.BYTE);
        data.set(DATA_PLAYER_MODE_CUSTOMISATION, (byte) 126);
        sendPacket(sp, new ClientboundSetEntityDataPacket(npc.getId(), data, true));```
fluid river
#

spigot devs be like

torn oyster
#

anyone know why it's not working?

fluid river
#

let's put this thing here for no reason

wet breach
fluid river
#

i remember i listened to it already in my multipaged gui plugin

wet breach
#

anyways I never said you couldn't specifically listen to that event

#

all I said is that generic events generally are not implemented

#

and really should check to make sure that it is

fluid river
#

my point was there are several

wet breach
#

there isn't several

fluid river
#

which are both implemented and have subs

fluid river
wet breach
#

having subs has nothing to do with being implemented

#

you can have a sub, and the parent not be used

fluid river
#

i said both

#

implemented and have subs

#

&&

wet breach
#

but there isn't several that are implemented

#

its more like a few

fluid river
#

isn't it like the same

wet breach
#

no

fluid river
#

sorry for my bad eng

#

it sounds literally the same for me

#

several like more than one

#

but not much

wet breach
fluid river
#

well reverse translation

#

sorry

#

they translate the same

wet breach
#

few means not many but more then one

fluid river
#

sounds cringe

wet breach
#

isn't English fun 🙂

fluid river
#

i heard several times

#

which basically meant 2

wet breach
#

well 2 is a couple

fluid river
#

somewhere

#

truuuue

#

for russian it's more translated to PAIR of

wet breach
#

seems accurate

fluid river
#

not like a "few"

#

russian be like

#

translating several as pair

#

and several as few

wet breach
#

well russian language doesn't have many words like English

#

or rather have varying definitions for words

fluid river
#

we just have forms for all that

torn oyster
#

The Displayed Skin Parts bit mask that is sent in Client Settings
Bit mask Meaning
0x01 Cape enabled
0x02 Jacket enabled
0x04 Left sleeve enabled
0x08 Right sleeve enabled
0x10 Left pants leg enabled
0x20 Right pants leg enabled
0x40 Hat enabled
0x80 Unused

#

how would i enable all of them

#

with those bytes

#

agh

wet breach
#

add up the bits

fluid river
#

russian dirty slang has so much forms

torn oyster
#

well what is that

fluid river
#

ya know cyka bl

torn oyster
#

no idea how to add them

#

0x7F?

#

google said that

#

so i'll use that

earnest forum
#

can i set entities' pathfinder goals after they have been spawned?

fluid river
#

so well we were both kinda right

wet breach
fluid river
#

today i learned how to download sources without compiling

drowsy helm
#

whats the usecase

torn oyster
earnest forum
#

need it to pathfind to a spot

drowsy helm
#

use a custom goal

torn oyster
#

pro tip: calling someone "dummy" will make them not want to help as much

earnest forum
wet breach
#

0xA4 = 164 0xA5 = 165

drowsy helm
#

why do you need to change it then?

wet breach
torn oyster
drowsy helm
#

just have the goal be dynamic so you can set the location whenever

earnest forum
#

ah ok thanks

smoky oak
#

can u sort a collection<integer> without casting it to a sortable x implements collection

earnest forum
#

Do I save my pathfind goal to a variable or can i access it through the goal selector?

smoky oak
#

well treeset exists

kindred valley
#

You can bubble sort

echo basalt
#

So does HashSet

smoky oak
#

hashset isnt sortable

echo basalt
#

Yet it's still a Collection

#

So it wouldn't make sense

#

Just check instanceof

torn oyster
#

bruh moment

#
        // Add data
        SynchedEntityData data = npc.getEntityData(); // DataWatcher

        data.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE), (byte) 0xA5);
        sendPacket(sp, new ClientboundSetEntityDataPacket(npc.getId(), data, true));```
green prism
#

Could you help me please?
I have a bridge that sends commands to be executed to bungeecord and this is the way it sends them:

ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF(executor.getExecutable().replace("%player%", player.getName()));
System.out.println(executor.getExecutable().replace("%player%", player.getName()));
player.sendPluginMessage(plugin, "hqueue:inventory", out.toByteArray());```

The commands arrive this way (as attached) in the bungeecord channel and, rightly, are not dispatched 
```java
    @EventHandler
    public void onPluginMessageReceived(PluginMessageEvent event) {
        System.out.println("Data received: " + new String(event.getData()) + " --r");
        if(!event.getTag().equals("hqueue:inventory")) return;
        System.out.println("Data received: " + new String(event.getData()));
        ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), new String(event.getData()));


    }

Do you have any idea to fix this problem?
(That char before queue randomly appears in the String)

smoky oak
echo basalt
smoky oak
#

ah

green prism
torn oyster
#

agh, still doesn't work

#

it's just not showing

rough basin
#

How to get distance of entity that I'm facing?

earnest forum
#

really confused on entity navigation, can anybody help? I've just set something up as a test, on PlayerInteractEvent i run this:

public void goTo(Location loc){
    tracking.getNavigation().createPath(loc.getX(), loc.getY(), loc.getZ(), 1);
    Bukkit.broadcastMessage(tracking.getNavigation().isInProgress()+"");
}

this returns false though

remote swallow
#

Anyone know some good config libs?

echo basalt
#

So yikes

green prism
smoky oak
#

if i know the exact size of a collection, should i set the initial capacity to max * 1.33, or the load factor to 1 ?

green prism
wet breach
smoky oak
#

aint that just byte bitmask = (byte) 0xff

#

or does or work differently with hex

wet breach
#

have no idea, but it should automatically add up the bits properly

#

don't have my cheat sheet for bitmask calculations lol

torn oyster
#
        SynchedEntityData data = npc.getEntityData(); // DataWatcher

        byte bitmask = (byte) (0x01 | 0x04 | 0x08 | 0x10 | 0x20 | 0x40 | 0x80);

        data.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE), bitmask);
        sendPacket(sp, new ClientboundSetEntityDataPacket(npc.getId(), data, true));```
#

so that will work?

#

i'm gonna try it

wet breach
#

it should yes

torn oyster
#

waiting for someone to do ?tas

remote swallow
#

?tias

torn oyster
#

fail

remote swallow
#

?tas

undone axleBOT
remote swallow
#

when did it get changed to tas not tias

torn oyster
#

nope it still doesn't give the 2nd layer

#

agh my server ip showed in it

wet breach
#

did you add it to the datawatcher?

torn oyster
#

oh well it's no secret

torn oyster
#

data.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE), bitmask);

wet breach
torn oyster
#

1.19.2

wet breach
#
Location loc = new Location(world, x, y, z, 0, 0);

MinecraftServer minecraftServer = ((CraftServer) Bukkit.getServer()).getServer();
WorldServer worldServer = ((CraftWorld) main.getVotingUtils().world).getHandle();
GameProfile gameProfile = new GameProfile(UUID.randomUUID(), "Random");

for (Player all : Bukkit.getOnlinePlayers()) {
  EntityPlayer allEntity = ((CraftPlayer) all).getHandle();
  GameProfile allGP = allEntity.getProfile();
  Property skin = allGP.getProperties().get("textures").iterator().next();

  gameProfile.getProperties().put("textures", skin);
  EntityPlayer npc = new EntityPlayer(minecraftServer, worldServer, gameProfile, new PlayerInteractManager(worldServer));
  npc.setLocation(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());

  PlayerConnection connection = ((CraftPlayer) all).getHandle().playerConnection;
  connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc));
  connection.sendPacket(new PacketPlayOutNamedEntitySpawn(npc));
  Bukkit.getScheduler().scheduleSyncDelayedTask(main, () -> {
    connection.sendPacket(new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, npc));
  },5);
}```
#

try this maybe?

torn oyster
#

that's not mojang mappings though

wet breach
#

you could translate to the mappings

#

but I don't bother with mapping stuff lol

torn oyster
#

in the protocol wiki it says unused

wet breach
#

and just didn't really read what you had there

#

try it again without x80 then? lol

torn oyster
#

yep

#

what does >> do

#

and <<

#

also still doesn't work

#

ffs

#

why are packets so bad

wet breach
#

is signed right shift << is left shift

smoky oak
#

and with three its unsigned iirc

wet breach
#

>>> is the same as << but right shift

wet breach
smoky oak
#

it moves the bits of a value around, in the direction the arrow's pointing

#

so for example

#

0b00001101 is 13 (8 + 4 + 1)

#

if u do << on that

#

it turns into 0b00011010, which is 26 (16 + 8 + 2)

torn oyster
#

what's the difference between signed and unsigned??

wet breach
#

fun fact, you only notice the difference between >> and >>> when the number is negative

#

with >> it will shift a 1 into the least significant bit area, where as >>> shifts a 0 there regardless

#

so >> can literally change a negative to a positive or vice versa because of a 1 being the next digit to shift over regardless if it is suppose to be negative or not

smoky oak
#

reason for that is that the first bit of a number is usually the sign bit (the marker if its positive or negative), and its a 1 for negative due to math reasons
bitshifting unsigned and signed does not or does account for that one bit

torn oyster
#

anyways how do i fix this stupid ahh npc thing

wet breach
#

well I gave you some code above to try

torn oyster
#

but i already basically do that

#

no that's literally what i do

#

and that doesn't add metadata

wet breach
#

then I am not entirely sure then 😦

torn oyster
#

?paste

undone axleBOT
torn oyster
#

hold on

wet breach
#

I do know cape won't work unless you actually do have a cape for said UUID though

wet breach
wet breach
torn oyster
#

it's npc.getId()

#

what other method is there

#

oh

wet breach
#

that isn't the ID I am referring to

torn oyster
#

17?

wet breach
#

no, the byte

#

17 in the index, says it is 0 if its absent, otherwise it should be 1+id

#

117 is player

#

so 1+117 is what that byte should be

#

so are you certain it is appropriate? o.O

torn oyster
#

idk if it's relevant

#

but

#

17 is what it says

wet breach
#

hmmm

#

not sure then

smoky oak
# torn oyster

maybe try not using 0x80 in ur mask. I doubt thats the issue, but you shouldnt flag stuff thats marked as unused

torn oyster
#

without 0x80

smoky oak
#

yea no idea

onyx fjord
#

What you tryna do @torn oyster

torn oyster
onyx fjord
#

Are you using a packet wrapper

torn oyster
#

i'm using mojang mappings

onyx fjord
#

Ah

torn oyster
#

but no wrapper like ProtocolLib if that's what you meant

#

i would rather not switch to it either

onyx fjord
#

I don't like plib either

#

You could see how citizens do it

torn oyster
onyx fjord
#

Haha

torn oyster
#

it doesn't seem to do it the same way as i do it either

torn oyster
floral drum
#

That’s to enable all of the layers

#

Because I solved this when I made my own npc’s too ahaha

#

What version is this for though? @torn oyster

torn oyster
#

1.19.2

floral drum
#

hm alr

#

you just tryna get the whole 2nd layer to work or?

floral drum
#

try 127

torn oyster
#

doing that atm

glossy venture
#

yeah thats all true except last

#

you could also do 0b11111110

torn oyster
#

😭

floral drum
#

weird

torn oyster
#

this has consumed the last two hours of my life

floral drum
#

does it show the 2nd layer at all?

torn oyster
#

// Add info
sendPacket(sp, new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, npc));
// Add data
SynchedEntityData data = npc.getEntityData(); // DataWatcher

    data.set(new EntityDataAccessor<>(17, EntityDataSerializers.BYTE), (byte) 127);
    sendPacket(sp, new ClientboundSetEntityDataPacket(npc.getId(), data, true));
    // Spawn entity
    sendPacket(sp, new ClientboundAddPlayerPacket(npc));
#

that's my code

floral drum
#

try set the data above the player info packet

torn oyster
#

oka

smoky oak
#

on a different topic, does anyone know if hex code can be read as an int via ConfigurationSection? I'm doing Color stuff

floral drum
# torn oyster oka

ye cuz im pretty sure the player info packet carries some data with it

torn oyster
#

still doesn't work

#

ffs

floral drum
#

weird

torn oyster
#

i'm gonna genuinely just throw the whole entire codebase away at this point

floral drum
#

noo 😭

fluid river
#

Synched

#

?

torn oyster
fluid river
#

why

floral drum
#

damn I wish I had 1.19.2 buildtools rn

fluid river
floral drum
#

fuckkk

#

at college haha

fluid river
#

isn't it present?

floral drum
kindred valley
#

Stop static abusing

floral drum
#

wont work

#

blocked

kindred valley
#

What is your nickname

#

What do i have to call you

#

zacken02

#

I am reminding people to not using static

#

No, i even not use static on my main method

#

I dont have good thoughts regarding static keyword anymore

#

Can you code at school

#

Fuck man i wish i could study as a trial

#

I want to code at school

cobalt thorn
#

How i can block some enchant in one item on anvil and enchanting table but with a specific item

undone axleBOT
harsh totem
#

I used this event to make a custom enchantment and for some reason when I click on the result slot, nothing happens and I can't get the enchanted shulker box.
any ideas?
I used event.setResult(resultItemStack); to make the resulted Shulker appear in the result slot

fluid river
fluid river
#

imagine

undone axleBOT
fluid river
#

and probably learnjava

fluid river
#

aren't you cancelling invClickEvent somewhere else

#

in your plugin

#

or in other plugins on your server

#

cuz like if you can't take item from inventory it's probably cuz of e.setCancelled(true) somewhere

harsh totem
#

I couldn't have canceled it

#

and I don't have any other plugins in the server

fluid river
#

hmm

crimson terrace
#

what events are you listening to? list them

harsh totem
crimson terrace
#

i think in older versions the prepareAnvilEvent can prevent you from picking up the resulting item if the event is cancelled

harsh totem
#

but it is not canceled

#

I don't have any cancelation line anywhere in the plugin

#

in any event

crimson terrace
#

and you cant pick up items out of the anvil?

harsh totem
#

I just can't pick up the resulted item from the anvil

fluid river
#

can you pick other 2?

#

back from anvil inv

harsh totem
fluid river
#

mc version?

harsh totem
#

1.19.2

crimson terrace
#

2 questions:
why is your enchant method capitalized
what does it do

harsh totem
crimson terrace
#

there is no way that throws an exception?

#

or something?

fluid river
#

sounds like a client-server desync

young knoll
#

How does it make it appear enchanted

crimson terrace
floral drum
#

uwu

crimson terrace
harsh totem
fluid river
#

on using setResult

#

have you tried same thing on paper?

harsh totem
#

wdym

crimson terrace
#

how about you try and output the item you set the result to before the listener is done

cobalt thorn
#

I have some problem with Player#teleport the player have some sort of invincibility for 2 second how i can fix it?

young knoll
#

I’m pretty sure the glowing effect just doesn’t appear on some items

floral drum
#

search teleport and you should find it

fluid river
#

it's laggy bruh

#

invincibility after teleport

floral drum
#

probs

fluid river
#

actually

#

throw your pc out of the window

#

gonna fix 99% of life problems

#

or i'm gonna nuke your house

floral drum
#

L bozo

#

:uwu

fluid river
#

rip

floral drum
#

emoji fail

#

LOL

fluid river
#

same thread about ur problem

young knoll
#

Tf is an akuma and a meed

fluid river
#

event.getInventory().setRepairCost(0); @harsh totem

#

to fix ur issue i guess

floral drum
#

F

fluid river
harsh totem
#

there is no problem with this

#

it's exactly what is should be

harsh totem
#

i'll try

kindred valley
crimson terrace
#

oof XD

kindred valley
#

Its public static' void main(String[] args){

}

harsh totem
#

it didn't fix it

young knoll
#

What about setting it to 1

harsh totem
young knoll
#

Int

echo basalt
#

ew array

#

use a list

harsh totem
#

i am

#

i have

echo basalt
#

make a list wrapper

#

lol

#

pass a stack

floral drum
#

uwu varargs

crimson terrace
young knoll
#

Oh god

#

A vararg of lists

floral drum
echo basalt
#

I have that guy's discord iirc

#

he replaced me at a previous job

young knoll
#

What about List<List[]>…

echo basalt
#

List[] 💀

floral drum
#

ima kns

#

kms

young knoll
#

Throw some maps in there

floral drum
#

if it’s not List<List<List<List<String>>>> don’t talk to me

young knoll
#

4D lists

echo basalt
#

Tuple<List<T>, Vector<K>, Stack<O[]>>

sage dragon
#

What will OfflinePlayer#getLastPlayed return if the player never played?

floral drum
#

dude that looks confusing

undone axleBOT
echo basalt
#

read the damn docs

#

fuckin

sage dragon
echo basalt
#

Hereforth

young knoll
#

RTFM

echo basalt
#

this

sullen wharf
#

HE ALLISON @echo basalt

fluid river
#

Arrays.asList(varargs)

echo basalt
#

Collections.singletonlist

tall dragon
#

just doing some research. for the guys using Redis. what library do you use and why do you feel like its the best one?

echo basalt
#

I use jedis but people hatin

fluid river
#

Collection.solidQueue

floral drum
#

jedis

fluid river
echo basalt
#

people like lettuce

crimson terrace
tall dragon
#

i currently use Jedis as well but i heard some people saying the other ones are way better

floral drum
crimson terrace
#

it hurts so much. I go away from my screen for 3 minutes and here you guys are breaking the geneva conventions on java

tall dragon
#

yea i just find the jedis api a little bit weird in some parts

fluid river
#

keep myself safe you mean

echo basalt
#

jedis is special

echo basalt
sullen wharf
#

«AGREED

tall dragon
#

i mainly use Redis for pub sub. do yall know if the other libraries do that better?

fluid river
#

i prefer MongoSQL over MyDB

#

💩

echo basalt
#

InfluxDB, Redis, MongoDB

floral drum
#

college go brt

#

mongodb is pog

fluid river
#

college is poopy

floral drum
young knoll
#

Pac-Man

floral drum
#

yes

fluid river
#

university is great

fluid river
echo basalt
fluid river
#

L

floral drum
fluid river
#

same here

echo basalt
#

based mousepad

fluid river
#

but my phone has no charge

young knoll
#

Both uni and college kinda succ

fluid river
#

So i can't take a photo

young knoll
#

Don’t @ me

fluid river
echo basalt
#

powerbank go brr

floral drum
#

these college computers are poggers tho

echo basalt
#

10k mAH for like 7 bucks

floral drum
#

RTX2070 in all of em

fluid river
floral drum
#

sheesh

fluid river
#

charging laptop from wire under the table

young knoll
#

Nah the best room in my college was when I walked into a bathroom and discovered a swimming pool with a water feature

floral drum
#

btw @torn oyster is no longer in pain

#

he sent the metadata packet before the spawn packet

#

😭

fluid river
#

i just made Etalon yesterday

floral drum
#

never!

fluid river
#

The cleanest sexy code

floral drum
#

Fuck

torn oyster
#

yo is anyone able to join my server rq and give me some feedback?

floral drum
#

pog

torn oyster
#

i'm re-launching late november but need some feedback before i move onto the next minigame's development

fluid river
torn oyster
fluid river
#

easy

#

you're welcome

floral drum
#

you think that’s gonna be pain

#

imagine making what I’m making 😭

torn oyster
fluid river
#

Ban Hammer which makes you ride invisible armor stand on top of pen*s made from orange wool

#

Then pen*s goes to the sky with you

#

You get banned

torn oyster
#

yall are planning your servers? i just say "random bullshit go" and it somehow works out

#

sometimes

fluid river
#

and there are a lot of fireworks exploded at ban location

torn oyster
#

dang

#

i just do everything as i go

#

i only make minigames though

fluid river
#

who gonna code ban hammer for me

#

i'm gonna review

#

give negative feedback

#

block + win