#help-development

1 messages ยท Page 824 of 1

slender elbow
#

it don't hurt nobody

#

god forbid you write one extra line of code

quiet ice
#

Wouldn't you need to obtain the service instance on load anyways (basically have both systems at the same time, just have neither throw exceptions) in case the plugin is restarted

lost matrix
#

Arent there priorities for services as well? PS: Didnt read

#

Ah, this. So prio doesnt help.

slender elbow
#

yeah

astral pilot
#

is there a better way to create Entity without knowing the type of entity yet

lost matrix
astral pilot
#

So, currently im doing this

Zombie theEntity = GetWorlds().get("world").spawn(p.getLocation(), Zombie.class);

NamespacedKey sample = new NamespacedKey(getPlugin(), "woo-random-key-go-brrr-23jIODfj3");         theEntity.getPersistentDataContainer().set(sample, PersistentDataType.STRING, "internal_name");       theEntity.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(2000);
theEntity.setHealth(2000);  theEntity.setCustomName(colorStr("&6Bob"));
#

The problem with this tho

#

I would have to repeat

#

those code

#

for every mob

#

that i want

#

which doesn't seem to be feasible

#

as it repeats code

#

what are the best ways to address this

lost matrix
#

Write a method. If you have to repeat code, then thats the point where you create new methods.

lost matrix
# astral pilot So, currently im doing this ```java Zombie theEntity = GetWorlds().get("world")....

Here are some examples

  public Entity spawnEntity(Location location, EntityType type) {
    Entity entity = location.getWorld().spawnEntity(location, type);

    // Do some stuff to your entity here

    return entity;
  }

  public Entity spawnEntity(Location location, Class<? extends Entity> type) {
    Entity entity = location.getWorld().spawn(location, type);
    
    // Do some stuff to your entity here
    
    return entity;
  }

  public Entity spawnEntity(Location location, Class<? extends Entity> type) {
    return location.getWorld().spawn(location, type, preSpawn -> {
      // Do some stuff to your entity here
    });
  }

  public <T extends Entity> T spawnEntity(Location location, Class<T> type) {
    return location.getWorld().spawn(location, type, preSpawn -> {
      // Do some stuff to your entity here
    });
  }
astral pilot
lost matrix
#

With the last method it would look like this:

Location location = ...;
Zombie zombie = spawnEntity(location, Zombie.class);

But it doesnt matter which method you use.

#

They all can be used to spawn a Zombie

astral pilot
hazy parrot
#

LivingEntity ig

lost matrix
astral pilot
#

o living entity has sethealth

astral pilot
#

this rn

#

using LivingEntity

#

anyways thanks a lot

lost matrix
#

Then you should expand a bit. Possibly in a safe way.

 public Entity spawnEntity(Location location, EntityType type) {
    Entity entity = location.getWorld().spawnEntity(location, type);
    if(!(entity instanceof LivingEntity) {
      entity.remove();
      throw new IllegalArgumentException("Type needs to be a LivingEntity");
    }
    LivingEntity living = (LivingEntity) entity;
    // Do some stuff to your entity here

    return entity;
  }
molten hearth
#

is anyone able to give me a TLDR of how the patching system works? say the vanilla server jas has java @Override public BlockState getStateForPlacement(BlockPlaceContext context) { // blabla }, it would be possible to modify this method using the patching system, right?

river oracle
#

Not in a plugin

#

You'd probably need to fork the server

molten hearth
#

no i didnt mean in a plugin lol

#

yeah thats what i meant thanks

river oracle
#

Alr

molten hearth
#

i wasnt sure if thats what the patching system was for or if it was just to make bukkit changes

river oracle
#

Have you clone cb?

#

Because it gives you 2 shell files for this

molten hearth
#

if I say what i did

#

ima get slapped with a

#

?whereami

molten hearth
icy beacon
#

Well you are prepared so say it

molten hearth
#

right now I used https://github.com/PaperMC/mache/ just to view the NMS code, but i wasnt sure if patches are what one uses to actually modify it but it seems like the right thing

river oracle
#

You're going to want to ask paper tbh they have dif admitedly somewhat better tooling

twin venture
#

hi just a question will this work for :

  • SQLITE
  • MYSQL

?
INSERT OR REPLACE INTO

icy beacon
#

?tas

undone axleBOT
river oracle
twin venture
#

i did , both didn't work xd

icy beacon
#

There are also syntax validators for sql

icy beacon
twin venture
#

alr thanks

molten hearth
#

thats good enough i guess i'll yolo and figure it out thanks

icy beacon
#

Good luck you two

river oracle
#

Don't worry about the actual patches

molten hearth
#

me giving up on the patching system and using ByeBuddy 2 nanoseconds later:

molten hearth
river oracle
#

Since your making your own version

molten hearth
#

pretty epic

#

yeah i thought it would force me to make some patches it applies to the server

river oracle
#

Then you can just compile that from source

river oracle
#

Patches are for saving and posting to a git repo

molten hearth
#

to be fair the docs here are docless

#

Step 1) setup

#

Step 2) compile patches

river oracle
#

If you wanna commit to github you'll need yo make patches though

#

You'll get dmcad if you commit the server code

molten hearth
#

try me

#

nah im kidding yeah thanks for the help

#

ill go and try to make it run

#

๐Ÿ‘ ๐Ÿ˜Ž ๐Ÿ‘

lost matrix
#

Well there is not much more to it. You just setup a version, write some code, and generate patches...

molten hearth
#

so I need patches

river oracle
#

Not necessarily unless you plan to distribute them

lost matrix
#

I mean... You can also just change the source and compile it.

river oracle
#

If you're just fucking around don't even bother with the patch system

molten hearth
#

ah okay thats what i wanted to know

#

yeah I mean I wanna add a debug message so ๐Ÿ’€ ๐Ÿ™

icy beacon
#

Not that I'm affiliated with Spigot in any way

twin venture
icy beacon
#

Just out of spite

molten hearth
#

I will send you an inbox full message personally

#

with a 3 day delay

icy beacon
#

Actually nvm

#

No it's not

#

My bad

#

Well yeah it looks fine

twin venture
#

its keep giving me this error

#

it works just fine for the first element i added into the table

#

when i try to click on another map [arena] it should work .

icy beacon
#

Are you sure it's for this query

twin venture
#

yes

icy beacon
#

I don't see any ON in your query

twin venture
#

me too xd

lost matrix
icy beacon
#

^

twin venture
#

i found out why , thanks .\

molten hearth
#

ladies and lentlemen

#

i have been told macha is NOT used to generate a jar ๐Ÿ’ฏ

#

bytebuddy it is

grim hound
#

How can I disable any saving of a particular World

#

and save it only once to the file, right after it was enabled?

icy beacon
#

I finished my commission ๐ŸŽ†

grim hound
#

I'm overriding my JavaPlugin#getLogger to return this

rare rover
#

Yay!

grim hound
#

but for some reason it works on Paper (the prefix is shown) but not on bukkit

#

I'm viewing the two on different console types but it doesn't bother other plugin, so it shouldn't really matter

#

no prefix (Spigot)

#

with prefix (Paper)

#

Help. Spigot = Broken.

novel dragon
#

I'm making a client but can not find a way to implement optifine to the client the only thing i found is for 1.19.2 and i need it for 1.20.1

novel dragon
#

mcp

cloud walrus
#

did you try the 1.19.2 way on the client?

novel dragon
#

mhm started freaking out and crashed with too many errors

#

I think I should switch to fabric wouldnt be easier for everything

chrome beacon
#

Do know you can't release anything you make with MCP since the jars that it generates contain Mojangs code

molten hearth
novel dragon
#

lmao thats right but hmm idk how to start with fabric i know nothing about it

chrome beacon
#

๐Ÿคทโ€โ™‚๏ธ Just warning you to not break copyright laws

grim hound
#

Why does everybody ignore me?

cloud walrus
icy beacon
#

?cba

undone axleBOT
#

pluggg definitely regrets to for the most part inform you that unfortunately, they essentially are unable to definitely assist with definitely your enquiry, which essentially is fairly significant. Please simply really ask again later or possibly kind of ask someone else about this enquiry, demonstrating that the person that ran this command generally regrets to kind of inform you that unfortunately, they for the most part are unable to generally assist with actually your enquiry in a subtle way. Thank you very sort of much for kind of your time and the person that ran this command specifically wishes you a really good day, so the person that ran this command really regrets to actually inform you that unfortunately, they literally are unable to definitely assist with very your enquiry, or so they particularly thought.

grim hound
# icy beacon

I frequently ask questions here and nobody ever answers

icy beacon
#

Take a look at the screenshot 1 more time

cloud walrus
cloud walrus
#

Threads

grim hound
cloud walrus
#

also try to avoid nature food like fish if there normaly eat supermarket food

icy beacon
#

If your question went unanswered, either:

  1. The channel was already busy with a discussion so no one even noticed
  2. No one has an answer for your question yet
  3. No one is currently in the channel and has noticed your question
    How to solve? Either:
  4. Open a thread in this channel
  5. Create a thread in the Spigot Plugin Development Forum
  6. Wait patiently until there is no discussion going on in this channel and ask again so that your question becomes the centerpiece
icy beacon
grim hound
novel dragon
icy beacon
#

I'm genuine with my words

#

This was not sarcasm

grim hound
#

and help me figure out my priomordial question

icy beacon
#

I do not have the answer to your question

quaint mantle
icy beacon
#

Do I need to reiterate that

cloud walrus
#

xD

grim hound
#

got it

quaint mantle
#

Nope you need object to be PluginLogger

chrome beacon
grim hound
chrome beacon
#

Wouldn't PluginLogger work for both?

grim hound
grim hound
#

I'm setting the prefix

#

so I need 2 seperate

cloud walrus
#

Primoral Question V2

How would you Pull like libaries from a Plugin withoud decompiling it and then get the libaries as Java files?
Need it for a Project

chrome beacon
#

Shade it with a shade plugin for maven or gradle

cloud walrus
chrome beacon
#

shade plugin

cloud walrus
#

never heard of it

chrome beacon
#

Maven shade plugin or Shadow specifically

cloud walrus
#

ahh

#

so i want to prevent the need of decompiling

#

doesnt maven need srcs?

chrome beacon
#

No it just needs the compiled jar

cloud walrus
#

so how would you do it?
i never worked with Maven or Gradle accept building

chrome beacon
#

Start by setting up a maven or gradle project

cloud walrus
#

so gradle init?

#

for example

eternal night
#

gradle init --dsl kotlin for the cool kids

cloud walrus
#

kk

#

what now ? xd

eternal night
#

well, basic setup would demand setting up java version and basic config

#

idk if spigot has a tutorial for gradle

chrome beacon
#

I believe there is one

eternal night
#

yea

#

there we go

cloud walrus
#

i just need the libaries from a plugin without decompiling it
and then afterwards i need them as jars

novel dragon
#

im so confused after reading some stuff so to make a fabric client im baso making a fabric mod right?

chrome beacon
#

Kotlin is pain though

#

Groovy > Kotlin

cloud walrus
#

jupp

eternal night
cloud walrus
eternal night
#

yea that is just the spigot-api

#

it transitively includes all dependencies you need for a basic plugin

cloud walrus
#

what if like webhook stuff if soemone usess that i need the libarie

eternal night
#

Yea then you just find the library

shadow night
eternal night
#

and add it with a single line

cloud walrus
eternal night
river oracle
eternal night
#

literally is automated you just need the reference

shadow night
#

Oh that's nice, didn't know that

#

Oh wait

#

Is JavaPlugin#getLogger() log4j?

inner mulch
#

does somebody know how many blocks are the default swing range? (multihit attack)

cloud walrus
eternal night
#

no

#

read the wiki I sent

#

you don't download anything

#

gradle does it all for you

cloud walrus
#

i need the libary for obfuscation xd

eternal night
#
compileOnly("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT")
cloud walrus
chrome beacon
#

There isn't a different one for sweeping

inner mulch
eternal night
#

what library do you need for "obfuscation"

#

chances are, there is a gradle plugin for it

chrome beacon
cloud walrus
eternal night
#

??

inner mulch
inner mulch
#

so 1.25?

chrome beacon
#

No that's the bounding box

eternal night
#

you shade that stuff into your jar

#

not with a random ass lib folder

cloud walrus
#

ong

#

i need to pull them out of there xd

#

and PUT them into the lib folder

eternal night
#

why

#

what kind of fucked obfuscator are you using

#

that fails to not fuck up libs

cloud walrus
#

nearly every obfuscator IS DOING THAT ?! xD

chrome beacon
#

Not if you configure them not to

cloud walrus
chrome beacon
#

Depends on the obfuscator

cloud walrus
eternal night
#

no idea if that works

#

not that I really care for people that think obfuscation is useful

#

but that should basically do everything for you

cloud walrus
#

how do i use this with a jar?

eternal night
#

you don't, the plugin does everything

#

gl ๐Ÿ‘

cloud walrus
#

uhhh... okay

blazing ocean
#

hi, is there a way to disable collision with boats?

chrome beacon
#

Have you tried adding them to the same team and disabling collision

minor junco
#

whut? just send a spawn packet to the player when they reconnect

#

the same way you "show" an NPC to the player in the first place

brisk estuary
#

does anybody know any npc lib I can use to spawn a simple npc? It must support multiple versions (1.19+) and I'll basically use this npc to open a menu on right click

inner mulch
#

hello im currently trying to register wether an attack is a crit or not in the EntityDamageByEntityEvent, my current approach is to check if the player is jumping or not but player#isJumping never fires even though im jumping during the attack

pseudo hazel
#

well first of all the player will crit when hitting something when they fall

#

be it through a jump or just by falling from a cliff

inner mulch
#

i didnt think of that

#

thanks :)

pseudo hazel
#

you need downwards velocity on the player to know if they can even crit

inner mulch
#

okay thank you :)

charred blaze
#

quick question

#

will .getDisplayName() return luckperms prefix + username?

chrome beacon
#

Probably not

#

but

#

?tas

undone axleBOT
charred blaze
#

public void reloadArenaConfig() {
configFile = new File(getDataFolder(), "config.yml");
config = YamlConfiguration.loadConfiguration(configFile);
}

#

why doesnt this reload config work?

eternal oxide
#

why not use the built in methods?

#

Plugin#reloadConfig()

#

and Plugin#getConfig()

charred blaze
#

i just want to know how reload mechanic work

eternal oxide
#

it will load it into config, but that is not the getConfig() of plugin

charred blaze
#

aaah

#

so im using getConfig somewhere

eternal oxide
#

probably

charred blaze
#

thanks

#

got it

#

World world = Bukkit.getWorld(plugin.config.getString("arenas.arena.world"));

#

O Caused by: java.lang.IllegalArgumentException: name cannot be null

twin venture
#

maybe you could do :

#

for (String key : config.getKeys(false)) {
String name = config.getString(key + ".world");
}

charred blaze
#

but why

#

have i written something wrong in the code

twin venture
#

do you want multi arena?

charred blaze
#

why is it returning null

twin venture
#

or only 1 arena?

charred blaze
#

hm

#

one arena for now

#

plugin.config.getString("arenas.arena.world")

#

is this incorrect?

#

is config incorrect?

twin venture
#

is the world loaded ?

charred blaze
#

arenas:
arena:
world: "pvp"

#

yeah my brother is currently playing on the world

#

how can it be not loaded right?

twin venture
#

ok is the world name set in :
server-proprties: ??

#

what is the value of that?

#

make it pvp , and check .

#

backup your worlds first.

charred blaze
twin venture
#

idk why exactly , but i got that problem before ..

its in server-prprties file of the main server

charred blaze
#

yeah but if i replace it with "pvp" wouldnt pvp become the main world instead of "world"?

twin venture
#

generate-structures=false

#

set this to false too

#

so it won't break your pvp world

#

yes set it to pvp

charred blaze
#

it will break the survival world

#

i also have survival world

#

i think i found the solution

#

getServer().createWorld(new WorldCreator("name"));

twin venture
#

try that out and see

charred blaze
#

the thing that is weird is that it was working before and teleporting me in that world

steel swan
#

hello, any one would know how to create a one biome world with WorldCreator?

charred blaze
steel swan
#

wait

#

i might have found the error

#

if its not it ill show u the code

orchid trout
charred blaze
#

what

#

now its saying on this line

#

if (Bukkit.getWorld(plugin.config.getString("arenas.arena.world")) == null) {

#

Caused by: java.lang.IllegalArgumentException: name cannot be null

steel swan
remote swallow
#

?paste the error

undone axleBOT
steel swan
#

``
public static void onCommandPregen(){

    WorldCreator uhc = new WorldCreator("uhc");
    uhc.type(WorldType.NORMAL);
    uhc.biomeProvider(String.valueOf(Biome.DARK_FOREST));
    uhc.createWorld();
    Location loc = new Location(Bukkit.getWorld("uhc"),0,100,0);
    Bukkit.getPlayer("98lop").teleport(loc);


}

``

steel swan
#

my bad i dont remember how to paste code here

remote swallow
#

what is DuelRequest.java line 88

charred blaze
remote swallow
#

does that config exist on the server

charred blaze
#

its in "Duels" folder

#

"config.yml"

eternal oxide
#

did you actually save it on the server?

charred blaze
#

yeah

eternal oxide
#

the world is null, so it's not loaded

proud badge
#

What should I do if I require both CommandExecutor and Listener implementations?
implements Listener implements CommandExecutor? or with only 1 implements?

eternal oxide
#

world name

charred blaze
#

im using this in my onenable

eternal oxide
#

why

#

just use the plugin config

remote swallow
proud badge
#

Rip

charred blaze
#

to check

#

and load if needed

eternal oxide
#

no you are doing all kinds of crap with yoru own config

proud badge
#

Then how tf is my other plugin still functioning ๐Ÿ’€
It was my first ever plugin ever so I put everything in the main class

eternal oxide
#

all you need in your main class onEnable() is daveDefaultConfig()

charred blaze
#

later

#

so

eternal oxide
#

ok

charred blaze
#

thats what i need my own config for

#

hm

eternal oxide
#

you are trying to load ignoresconfigfile not configFile

charred blaze
#

ill try to

#

System.out.println(plugin.config.getString("arenas.arena.world"));

eternal oxide
#

lookj at yoru screen shot

steel swan
#

so anyone has any idea how to generate a one biome world? what i found didnt really help me

charred blaze
#

so like this?

zealous osprey
#

Heya, I got a Git issue and hope someone could help:
In the image, there is one blue repo. From all that I could gather, it's a "sub-module". However, that is causing quite some issues. For some reason I cannot commit to it or rather, my changes aren't considered.
So, either, how do I remove its sub-module status or how do I turn all of them into sub-modules, but with the ability to commit to them?

charred blaze
#

also do i even need these

covert notch
#

anyone here has mounted a spigot server on kubernetes? i got some questions

#

or just vanilla minecraft on kubernetes, im having some issues with rcon

steel swan
#

Hello ! Im here asking again if anyone could help me with world generation !
I used to use presets but they don't really work the way i want them here is what i need :
be able to define 1 biome that will be the whole world itself
be able to modify the number of ores per chunk
be able to modify the number of lakes

chrome beacon
#

Use the world creator in single player

#

and copy over the properties

steel swan
chrome beacon
#

copy them from or to?

steel swan
chrome beacon
#

generatorSettings

steel swan
#

and i put preset like this :

#

{"useCaves":true,"useStrongholds":true,"useVillages":true,"useMineShafts":true,"useTemples":true,"useRavines":true,"useMonuments":true,"useMansions":true,"useLavaOceans":false,"useWaterLakes":false,"useLavaLakes":true,"useDungeons":true,"fixedBiome":25,"biomeSize":4,"seaLevel":63,"riverSize":1,"waterLakeChance":4,"lavaLakeChance":80,"dungeonChance":8,"dirtSize":33,"dirtCount":10,"dirtMinHeight":0,"dirtMaxHeight":255,"gravelSize":33,"gravelCount":8,"gravelMinHeight":0,"gravelMaxHeight":255,"graniteSize":33,"graniteCount":10,"graniteMinHeight":0,"graniteMaxHeight":80,"dioriteSize":33,"dioriteCount":10,"dioriteMinHeight":0,"dioriteMaxHeight":80,"andesiteSize":33,"andesiteCount":10,"andesiteMinHeight":0,"andesiteMaxHeight":80,"coalSize":17,"coalCount":20,"coalMinHeight":0,"coalMaxHeight":128,"ironSize":9,"ironCount":20,"ironMinHeight":0,"ironMaxHeight":64,"goldSize":9,"goldCount":2,"goldMinHeight":0,"goldMaxHeight":32,"redstoneSize":8,"redstoneCount":8,"redstoneMinHeight":0,"redstoneMaxHeight":16,"diamondSize":8,"diamondCount":1,"diamondMinHeight":0,"diamondMaxHeight":16,"lapisSize":7,"lapisCount":1,"lapisMinHeight":0,"lapisMaxHeight":32,"coordinateScale":684,"heightScale":684,"mainNoiseScaleX":80,"mainNoiseScaleY":160,"mainNoiseScaleZ":80,"depthNoiseScaleX":200,"depthNoiseScaleZ":200,"depthNoiseScaleExponent":0.5,"biomeDepthWeight":1,"biomeDepthOffset":0,"biomeScaleWeight":1,"biomeScaleOffset":1,"lowerLimitScale":512,"upperLimitScale":512,"baseSize":8.5,"stretchY":12,"lapisCenterHeight":16,"lapisSpread":16}

#

?

chrome beacon
#

Yeah

steel swan
#

so smth like this

chrome beacon
#

yeah

steel swan
#

thx

#

ill try it

steel swan
chrome beacon
#

Should work

#

It only applies to new worlds so don't forget to delete the old one

steel swan
steel swan
chrome beacon
#

oh did they get removed

steel swan
#

yep

covert notch
#

where do i find plugin ids?

chrome beacon
#

?

#

Which ids are you looking for

covert notch
#

from several plugins

chrome beacon
#

???

mellow edge
#

so basically in ProjectileLaunchEvent I check if(list.contains((Player)e.getEntity().getShooter().getItemInHand()) and the condition is false even though the player is holding a snowball
while in PlayerInteractEvent: (non-null) if(list.contains(e.getItem()) it is true and I am SO confused

chrome beacon
#

Are they holding it in the offhand

#

also that cast doesn't look right

river oracle
#

I just realized too that cast is cursed

#

You can't cast an ItemStack to a player

mellow edge
#

getShooter is ProjectoleSource, thus the itemstack or what

chrome beacon
#

no

#

getItemInHand returns an ItemStack

#

and you're casting it to a player

mellow edge
#

I typed it wrong sorry, in code it is:

If(e.getEntity().getShooter() instanceof Player) {
Player player = (Player) e.getEntity().getShooter();
...

grim hound
#

ItemStack to a Player cast?

#

Good luck with that.

chrome beacon
#

Why are you typing your code by hand

#

just copy paste it

#

and use a paste obv

#

?paste

undone axleBOT
mellow edge
#

Lol I have no internet because and I am offline

chrome beacon
#

You're chatting with us

mellow edge
#

On pc

#

I have no internet

chrome beacon
#

No wifi?

mellow edge
#

Nope

paper viper
chrome beacon
#

You can hotspot from phone if your pc has a wifi card

mellow edge
#

It doesnt thats sad

paper viper
#

use uuids instead of player

#

Player object changes a lot unpredictably

chrome beacon
#

They're trying to check the itemstack

#

not the player

paper viper
#

Oh wait nvm i cant read

#

Lol

covert notch
#

know i need the spigot download url to tell my server where to download it from

#

idk where to get it from idk

chrome beacon
#

Use Spiget

#

Spigot is protected by cloudflare so downloading it directly will be a pain

covert notch
#

right

mellow edge
#

So rewritten:

public void onSnowballLaunch(ProjectileLaunchEvent e) {
     Player player = (Player);
     if(list.contains(player.getItemInHand()) {
      projectiles.add(e.getEntity()); //projectile launched by the event
}
}

So i debugged this code and it actually returns the itemstack type of snow ball and same lore but for some reason check does not work unlike in PlayerInteractEvent

minor junco
chrome beacon
mellow edge
#

Could you tell me if player's (shooters) item in hand is removed before or after launch event

chrome beacon
#

Would probably be faster to check yourself

mellow edge
#

I think I will just cancel the interact event and simulate the launch, this will be easier

chrome beacon
#

Doing it properly is a good idea if you plan on releasing the plugin

mellow edge
#

Yeah... it is pretty big at this point

covert notch
#

Downloading Spigot from
(link) ...

curl: (22) The requested URL returned error: 523

#

error 523 server is unreachable lol

chrome beacon
#

Yeah use Spiget

subtle folio
#

trying to use hover events to send commands, how can I get around "[20:56:40 WARN]: Failed to validate message acknowledgements from Ntdi" as its kicking me whenever i try and use it

TextComponent component = new TextComponent(CC.GOLD + p.getName() + CC.GREEN + " sent you a " + CC.RED + type + CC.GREEN + " duel request. \n" + CC.GREEN + "[Click to Accept]");
        component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.GREEN + "Accept Duel Request").create()));
        component.setClickEvent(new net.md_5.bungee.api.chat.ClickEvent(ClickEvent.Action.RUN_COMMAND, "/duel accept"));

        target.spigot().sendMessage(component);```
steel swan
covert notch
young knoll
slate tinsel
#

Hi, when I change glowing to false the enchantments disappear, is it possible to make the enchantments not disappear?

chrome beacon
#

Which part are you having troubles with

inner mulch
#

When creating custom items, how do i efficiently assign a unique identifier to each of them? (how do i make sure this uuid doesnt exist on any item)

chrome beacon
#

You can just create a new UUID and assign it

#

There's almost no chance there will be duplicates

inner mulch
#

hmm

subtle folio
inner mulch
chrome beacon
#

You are using legacy colors

#

in a text component

subtle folio
#

ughhh itโ€™s so much easier thoooo

#

and i doubt thatโ€™s the reason thereโ€™s the issue

chrome beacon
#

worst case you'll have two items that behave in the same way

inner mulch
eternal oxide
#

however it is also possible to generate a duplicate in one try

inner mulch
#

yeah it is

#

but in the worst case there will be a broken item

eternal oxide
#

yep, if in the PDC you'd just have two items that stack

#

assuming everything else is identical

young knoll
worldly ingot
#

I mean if youโ€™re using components then build components

#

fromLegacy() should only really be used if you have a reason to use it. โ€œIโ€™m too lazy to properly use a component builderโ€ should not be one of those reasons

subtle folio
#

can you link me a resource on them

worldly ingot
#

I think just the component wiki uses them in its examples

#

?components

undone axleBOT
worldly ingot
#

Yeah it does

weak meteor
#

To get a head ItemStack

#

i need to have Material.SKULL or Material.SKULL_ITEM

#

(to use SkullMeta)

worldly ingot
#

item

weak meteor
#

thanks

subtle folio
#

How do I set the hover and click event of a basecomponent?

molten hearth
#

what would be the best way to provide a virtual server from a spigot server instead of through bungee

wide cipher
river oracle
#

relead your project

wide cipher
#

i did

#

worked it out, it was breaking because of bstats

weak meteor
#

hello, im working on a PlayerMoveEvent

short pilot
#

Anyone know why my date isnt parsing correctly? Here's the actual dateformatter line i'm not sure what i'm missing

SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS");

Caused by: java.text.ParseException: Unparseable date: "11/12/2023 14:13:51.000" does not match (
\p{Nd}++)\Q-\E(\p{Nd}++)\Q-\E(\p{Nd}++)\Q \E(\p{Nd}++)\Q:\E(\p{Nd}++)\Q:\E(\p{Nd}++)\Q.\E(\p{Nd}+
+)

weak meteor
#

and same with getTo()

eternal oxide
#

yes, the location ius of your feet

weak meteor
#

oh

eternal oxide
#

an air or water block

weak meteor
#

so y-1 will give me the block that im stepping on?

eternal oxide
#

yes

weak meteor
#

k thanks

eternal oxide
#

so long as you are not holding shift over an edge

weak meteor
#

i got it covered

wide cipher
#

@eternal oxide how do i set up the spigot thing properly in maven? <repository> <id>spigotmc-repo</id> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> </repository> its not importing the ServerPlayer class or some of the ClientBound packets

eternal oxide
#

did you run buildtools with --remapped?

#

?nms

wide cipher
#

yeah

young knoll
#

Show the dependency

wide cipher
#

im going to retry

#
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.20.4-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
            <classifier>remapped-mojang</classifier>
        </dependency>```
young knoll
#

You technically donโ€™t need the repository when using the NMS dependency

#

Since itโ€™s all in mavenLocal

weak meteor
#

is this the right way to check if a player stepped on a pressure plate?

#

cause i tried and i dont event get past the first if statement

#

nvm its not

#

gotta recode

wide cipher
#

oh, well i just started building it

split dagger
#

Hi, I want to make a plugin for my server (simple leveling system), but there is a problem of creating this project with a database (simple JDBC).

I don't know if I should create a completely separate plugin that connects to the database (keeps the connection open) and offers methods like executeQuery or executeUpdate, or connect to the database and create methods DIRECTLY in the leveling plugin (and then in any other plugin, that will use query methods).

What are good practices in this case? Any tips? What should I be doing?

river oracle
split dagger
split dagger
#

I've moved on from monolithic projects, so I'm still trying to understand how it's supposed to work in practice having multiple minecraft plugins

river oracle
#

its okay if you wanna have some library that allows you to more easily implement a database but that doesn't mean it should be its own plugin

#

just shade it into your project and go

wide cipher
eternal oxide
#

entityplayer is old

young knoll
#

ServerPlayer is the Mojang mapped name

eternal oxide
#

don't use

split dagger
river oracle
quaint mantle
#

How should I make this situation?

a bunch of custom items with custom events like:

    @EventHandler
    public void onDamage(CustomItemEquippedEntityDamageEvent event) {
        if (!event.getReferenceNames().contains("noonie")) {
            return;
        }
        event.getEntityDamageEvent().setDamage(0);
    }

Now let's say I have one special item that has the ability to "disable all other abilities", this would make refactoring a pain, but is there really a good way to do this?

split dagger
river oracle
split dagger
weak meteor
#

how can i make a location centered?

#

like 0.5, 100, 0.5?

#

well

#

X.5, Y.5, Z.5

#

no matter what

#

like if its x = 4, pass it4.5
x = 4.7, pass it 4.5
but if its x = 6, pass it to 6.5

paper viper
#

maybe that is what you are searching for?

weak meteor
#

thankss

slender elbow
#

๐Ÿงป

weak meteor
#

yeah that doesnt exist on 1.8

#

lol

#

i hate working on old versions

paper viper
#
public Location toCenterLocation() {
        Location centerLoc = this.clone();
        centerLoc.setX((double)this.getBlockX() + 0.5);
        centerLoc.setY((double)this.getBlockY() + 0.5);
        centerLoc.setZ((double)this.getBlockZ() + 0.5);
        return centerLoc;
    }
#

thats the code behind it

weak meteor
#

k thanks

weak meteor
#

thank you so much

paper viper
#

np

molten hearth
#

are step sounds server-side?

#

or does the client calculate step sounds for other entities

#

it seems insane to me that the server calculates step sounds wouldnt this be far too resource intensive

weak meteor
#

which # of build is BungeeCord 1.8.8?

river oracle
#

the latest build

wide cipher
#

what do i do with the byte section?

#

@eternal oxide

weak meteor
#

okay

rare rover
#

decided to use a stream cuz why not its async not a huge deal

#

if i need too i can just do a normal loop

#

also just noticed this whole thing can be async so let me fix that rq

worldly ingot
#

Is there any reason you're scheduling another task inside of the repeating one?

#

Nothing seems immediately obvious

rare rover
#

i was originally just setting the block but i dont need to do that

worldly ingot
#

I mean to be fair, the whole thing could be synchronous. There's no explicit reason for it to be async imo

rare rover
#

and you cant do that async

worldly ingot
#

Looks like rather trivial logic

#

Nothing blocking

rare rover
#

ig

#

i feel better with it async

#

but i get it

#

should i use a stream though?

#

or just a normal loop

#

i dont believe these's a huge difference to performance

worldly ingot
#

Streams are usually imperformant in hot code, but your stuff is running once every 6 seconds so you're probably not going to notice any difference whatsoever

quaint mantle
#

If you care about performance then use the traditional for loop, but streams can also make your code look pleasant

wide cipher
#

how can i fix this, ik it says skript but it is not a skript error, its just because it is using the effect with skript [14:44:25 WARN]: [Skript] Task #4278 for Skript v2.7.3 generated an exception java.lang.NoSuchMethodError: 'net.minecraft.server.level.WorldServer net.minecraft.server.level.EntityPlayer.z()' at ca.nagasonic.skonic.elements.skins.EffFakeSkin.execute(EffFakeSkin.java:39) ~[Skonic-1.0.4.jar:?] at ch.njol.skript.lang.Effect.run(Effect.java:50) ~[Skript (3).jar:?] at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:62) ~[Skript (3).jar:?] at ch.njol.skript.lang.TriggerItem.walk(TriggerItem.java:90) ~[Skript (3).jar:?] at ch.njol.skript.command.Commands.handleEffectCommand(Commands.java:200) ~[Skript (3).jar:?] at ch.njol.skript.command.Commands$2.lambda$onPlayerChat$0(Commands.java:299) ~[Skript (3).jar:?] at org.bukkit.craftbukkit.v1_20_R2.scheduler.CraftFuture.run(CraftFuture.java:88) ~[paper-1.20.2.jar:git-Paper-309] at org.bukkit.craftbukkit.v1_20_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480) ~[paper-1.20.2.jar:git-Paper-309] at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1470) ~[paper-1.20.2.jar:git-Paper-309] at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:446) ~[paper-1.20.2.jar:git-Paper-309] at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1379) ~[paper-1.20.2.jar:git-Paper-309] at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1156) ~[paper-1.20.2.jar:git-Paper-309] at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[paper-1.20.2.jar:git-Paper-309] at java.lang.Thread.run(Thread.java:1583) ~[?:?]

remote swallow
wide cipher
young knoll
#

Make sure you are remapping for the right version

wide cipher
#

like what version, same as plugin or server?

remote swallow
#

remap to server ver

torn oyster
#

ServerPlayer needs client options now

#

what are they?

#

it's for my custom npcs

#

should ClientInformation.createDefault() be sufficient?

young knoll
#

Probably

#

Itโ€™s just info about client settings

#

Obviously NPCs donโ€™t have clients

torn oyster
#

i just updated from 1.20.1 to 1.20.4

#

i'll try default one

remote swallow
#

npcs can have options if they want

torn oyster
#

I replaced it with ClientboundAddEntityPacket but now it doesn't work

young knoll
#

It should

torn oyster
#

actually i think its this line

#

sendPacket(sp, new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, entity));

#

java.lang.NullPointerException: Cannot invoke "net.minecraft.server.network.PlayerConnection.l()" because "player.c" is null

young knoll
#

Fake players have a null connection

torn oyster
#

how would i fix it?

young knoll
#

Give them a connection

#

Or do some reflection stuff

torn oyster
#

how do i give them a connection

#

lol

river oracle
#

Can probably just make a dumby object

#

And use reflection to set it

torn oyster
#

i have no clue where to even start with that

torn oyster
#
        CraftPlayer craftPlayer = (CraftPlayer) player;
        ServerPlayer sp = craftPlayer.getHandle();

        GameProfile profile = getEntity().getGameProfile();

        profile.getProperties().remove("textures", profile.getProperties().get("textures").stream().findFirst().orElse(null));
        profile.getProperties().put("textures", new Property("textures",
                skin.texture(),
                skin.signature()));
        // Add info
        sendPacket(sp, new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, entity));

        // Spawn entity
        sendPacket(sp, new ClientboundAddEntityPacket(entity));

        // Add data (second skin layer)
        sendPacket(sp, new ClientboundSetEntityDataPacket(entity.getId(), entity.getEntityData().getNonDefaultValues()));

        float yaw = getOptions().getLocation().getYaw();
        float pitch = getOptions().getLocation().getPitch();

        // Move head yaw
        sendPacket(sp, new ClientboundRotateHeadPacket(entity, (byte) ((yaw % 360) * 256 / 360)));
        // Move body yaw and head pitch
        sendPacket(sp, new ClientboundMoveEntityPacket.Rot(entity.getBukkitEntity().getEntityId(), (byte) ((yaw % 360) * 256 / 360), (byte) ((pitch % 360) * 256 / 360), true));```
#

that's my current code

#

I changed add player packet to add entity packet

torn oyster
#

it worked fine in 1.20.1

#

error is on the line with ClientboundPlayerInfoUpdatePacket

spark lynx
# torn oyster it worked fine in 1.20.1

My solution was

  1. create playerconnection
  2. send packets (add player, update list)
  3. spawn player to world
    if you spawn the player first then send packets in 1.20.2, it will cause some error
torn oyster
#

not sure how to create one

spark lynx
#

if you are trying to spawn a actual player, just set player.connection = new fake player connection

torn oyster
#

like npcs

#

don't know where to get the connection from

spark lynx
#

can you give more codes?

torn oyster
#

is it safe to just set the connection to the player it is displaying it to's connection?

#

is there any unwanted effects from that?

#

that'd mean the npcs share the same connection as the player

#

it works

eternal oxide
#

not safe

#

first, why do you have NPC's duplicating players?

torn oyster
#

i have no clue where to get one from

#

java.lang.NullPointerException: Cannot invoke "net.minecraft.server.network.PlayerConnection.l()" because "player.c" is null

without one this happens

eternal oxide
#

they don;t they needs a network manager to consume packets is all

torn oyster
#

how do i create one

eternal oxide
#

in 1.19 this was teh constructor```java
public class Npc extends ServerPlayer {
Npc(MinecraftServer minecraftServer, ServerLevel worldServer, GameProfile gameProfile, ProfilePublicKey publicKey) {

    super(minecraftServer, worldServer, gameProfile, publicKey);

    this.connection = new NetworkHandler(minecraftServer, new NetworkManager(PacketFlow.CLIENTBOUND), this);
}```
#

public class Npc extends ServerPlayer {

torn oyster
#

NetworkHandler and NetworkManager don't exist

#

are they something you made

eternal oxide
#

yes

torn oyster
#

what are they

eternal oxide
#
public class NetworkHandler extends ServerGamePacketListenerImpl {
    
    public NetworkHandler(MinecraftServer minecraftserver, Connection networkmanager, ServerPlayer entityplayer) {
        super(minecraftserver, networkmanager, entityplayer);
    }
    
    @Override
    public void send(Packet<?> packet) {
        // Empty as we never want to try an send packets to a fake player.
    }
}```
#
public class NetworkManager extends Connection {
    
    public NetworkManager(PacketFlow enumprotocoldirection) {
        
        super(enumprotocoldirection);
    }
}```
torn oyster
#
    public NetworkHandler(MinecraftServer minecraftserver, Connection networkmanager, ServerPlayer entityplayer) {
        super(minecraftserver, networkmanager, entityplayer, CommonListenerCookie.createInitial(entityplayer.gameProfile));
    }``` would that work?
eternal oxide
#

that would be something new, so not in 1.19

torn oyster
#

i'll try

quaint mantle
#

yo, have an NMS question if anyone is free, trying to make a rideable mob change its head direction etc, i've tried to look for another class where it takes it's passengers direction and just copy that but i cant find it, anyone have a good place to look or know the solution straight up for 1.20.1?

eternal oxide
#

In your ridable mob you shoudl be able to simply set it's pitch a YHeadRot

quaint mantle
#

only that?

torn oyster
#

would PacketFlow.SERVERBOUND break anything?

eternal oxide
#

then your cookie is wrong

#

yes

#

this is to consume client bound packets so it doesn;t crash your server

eternal oxide
# quaint mantle only that?
        this.setPos(location.getX(), location.getY(), location.getZ());

        float yaw = Location.normalizeYaw(location.getYaw());
        float pitch = Location.normalizePitch(location.getPitch());

        this.setYRot(yaw);
        this.setXRot(pitch);
        this.yRotO = yaw;
        this.xRotO = pitch;
        this.setYHeadRot(yaw);```
#

thats what I do to sync NPC heads

quaint mantle
#

ill try it out

torn oyster
eternal oxide
#

no

wide cipher
remote swallow
#

maven multi module

remote swallow
quaint mantle
#

damn u are right @eternal oxide

#

i think my movement code is just wrong tho

eternal oxide
#

is yoru head movement inverted?

quaint mantle
#
public void g(Vec3D vec3d) {
        if (this.isAlive()) {
            if (this.getPassenger() != null) {
                if (this.isOnGround() && passengerJumping()) {
                    this.jump();
                    this.playSound(SoundEffects.qh, 1, 5);
                }
                EntityLiving passenger = this.getPassenger();
                float yawRot = passenger.getYRot();
                this.setYRot(yawRot);
                float pitchRot = passenger.getXRot();
                this.setXRot(pitchRot * 0.5F);

                this.setYawPitch(this.getYRot(), this.getXRot());

                this.aX = this.getYRot();
                this.aZ = this.aX;
                float f = passenger.bo * 0.5F;
                float f1 = passenger.bq;
                if (f1 <= 0.0F) {
                    f1 *= 0.25F;
                }

                if (this.z && this.fK() && !this.cw) {
                    f = 0.0F;
                    f1 = 0.0F;
                }

                this.bb = this.ew() * 0.1F;
                this.r((float)this.b((AttributeBase) GenericAttributes.d));
                super.g(new Vec3D((double)f, vec3d.c, (double)f1));
                this.a(this, false);
                this.as();
            } else {
                this.bb = 0.02F;
                super.g(vec3d);
            }
        }
    }

this is what i have from ages ago but yeah i dont think it will be easy upgrading

#

nah its like

#

if i press W it always goes north

#

S it always walks slowly backwards

#

no matter where its turning

eternal oxide
#

are you listening to the steer packet?

quaint mantle
#
   @Override
    public void move(MoverType enummovetype, Vec3 vec3d){
        if(this.isAlive()){
            if(this.getPassenger() != null){
                if (this.onGround() && passengerJumping()) {
                    this.getJumpControl().jump();
                    this.playSound(SoundEvents.SHEEP_AMBIENT, 1F, 5F);
                }
                LivingEntity passenger = this.getPassenger();

                float yaw = Location.normalizeYaw(passenger.getYHeadRot());
                float pitch = Location.normalizePitch(passenger.xRotO);

                this.setYRot(yaw);
                this.setXRot(pitch);
                this.yRotO = yaw;
                this.xRotO = pitch;
                this.setYHeadRot(yaw);

                float f = passenger.xxa * 0.5F;
                float f1 = passenger.zza;
                if (f1 <= 0.0F) {
                    f1 *= 0.25F;
                }

//                if (this.onGround() && this.fK() && !this.cw) {
//                    f = 0.0F;
//                    f1 = 0.0F;
//                }

//                this.bb = this.ew() * 0.1F;
                super.move(MoverType.SELF, new Vec3((double)f, 0.0, (double)f1));
//                this.a(this, false);
//                this.as();
            }else{
                super.move(enummovetype, vec3d);
            }
        }
    }

this is my code now but im kinda just taking a shot in the dark guessing waht was what

quaint mantle
#

never needed to

wide cipher
remote swallow
#

Hi there! Today Iโ€™m going to explain how to setup a multi-module project using maven to support different NMS versions. Important notes about this tutorial: Every step will have detailled screenshots using IntelliJ. I explicitly chose not to include everything as copy/pastable source code, but normal screenshots (you can click on them to show th...

torn oyster
# eternal oxide no

com.mojang.authlib.GameProfile gameProfile,
int i,
net.minecraft.server.level.ClientInformation clientInformation

do you know what i is?

eternal oxide
#

need more context

torn oyster
#

constructor for CommonListenerCookie

#

that's all i know

eternal oxide
#

no clue I've not done anything with 1.20

#

whats the package for teh cookie listener?

spark lynx
#
public static CommonListenerCookie createInitial(GameProfile var0) {
        return new CommonListenerCookie(var0, 0, ClientInformation.createDefault());
    }

use this static method

torn oyster
torn oyster
eternal oxide
#

zoo gave you what you need

torn oyster
#

that's what i have been doing

#

it gives that error

eternal oxide
#

have you tried 1 instead of zero?

torn oyster
#

that's just latency

eternal oxide
#

only guessing here

torn oyster
#

i found what it is

eternal oxide
#

ok

torn oyster
#

and createInitial only needs gameprofile

eternal oxide
#

Can;t help, not used 1.20

spark lynx
eternal oxide
#

nope

torn oyster
#

apparently that would break it

eternal oxide
#

he's creating a fake player so needs to consume clientbound

spark lynx
#

what is the method of spawning the fake player

torn oyster
#
 CraftPlayer craftPlayer = (CraftPlayer) player;
        ServerPlayer sp = craftPlayer.getHandle();

        GameProfile profile = getEntity().getGameProfile();

        profile.getProperties().remove("textures", profile.getProperties().get("textures").stream().findFirst().orElse(null));
        profile.getProperties().put("textures", new Property("textures",
                skin.texture(),
                skin.signature()));

        entity.connection = new NetworkHandler(sp.getServer(), new NetworkManager(PacketFlow.CLIENTBOUND), entity);

        // Add info
        sendPacket(sp, new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER, entity));

        // Spawn entity
        sendPacket(sp, new ClientboundAddEntityPacket(entity));

        // Add data (second skin layer)
        sendPacket(sp, new ClientboundSetEntityDataPacket(entity.getId(), entity.getEntityData().getNonDefaultValues()));

        float yaw = getOptions().getLocation().getYaw();
        float pitch = getOptions().getLocation().getPitch();

        // Move head yaw
        sendPacket(sp, new ClientboundRotateHeadPacket(entity, (byte) ((yaw % 360) * 256 / 360)));
        // Move body yaw and head pitch
        sendPacket(sp, new ClientboundMoveEntityPacket.Rot(entity.getBukkitEntity().getEntityId(), (byte) ((yaw % 360) * 256 / 360), (byte) ((pitch % 360) * 256 / 360), true));```

sp is the player it's showing it to (ServerPlayer)
slate tinsel
#

When I change glowing to false the enchantments disappear, is it possible to make the enchantments not disappear?

eternal oxide
#

no

#

inextricably linked

spark lynx
#

using native method in nms is safer

torn oyster
#

where is it from

#

also the error is from the NetworkManager line and stuff

#

setting connection

spark lynx
#

net.minecraft.server.players.PlayerList
sp.server.getPlayerList().placeNewPlayer();

spark lynx
#
public void setListener(PacketListener packetlistener) {
        Validate.notNull(packetlistener, "packetListener", new Object[0]);
        PacketFlow enumprotocoldirection = packetlistener.flow();
        if (enumprotocoldirection != this.receiving) {
            throw new IllegalStateException("Trying to set listener for wrong side: connection is " + this.receiving + ", but listener is " + enumprotocoldirection);
        }
        ...

add this line to your extended Connection.class

@Override
    public void setListener(PacketListener packetListener) {}
eternal oxide
#

is spigot 1.20.4 now R4 or R3?

torn oyster
#

R3

eternal oxide
#

k

wide cipher
#

i can't import the 1.18.2 dependency <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.18.2-R0.1-SNAPSHOT</version> <scope>provided</scope> </dependency>

remote swallow
#

have you ran builtools

eternal oxide
#

thats only available if you ran buildtools

torn oyster
#

that is included in bukkit.getonlineplayers()

#

it breaks a few of my things

#

they should only be client-sided

wide cipher
#

i have to do it again???

#

such a pain

#

does it have to be remapped?

spark lynx
torn oyster
#

nah it's fine i figured it out using the old packet

torn oyster
smoky oak
#

is there a java internal Pair<A,B> ?

#

im trying to find a way to parse two generics in one method signature

#

should i just ask for a list?

hazy parrot
#

Pair is part of javafx afaik

#

Just make your own pair if you want

smoky oak
#

yea no

#

ill just ask for two lists and make a single value alternative method

hazy parrot
#

Pair is literally

class Pair<K, V> {
   K key
   V value
   constructor(K, V)
   getters... 
}
smoky oak
#

eh fair

#

different question, is it possible without the use of generics to say to two values in the constructor 'you two are the same', e.g. method(Object<? extends A>, Object<? extends A>)
I know its possible with generics and just defining T or smth in the class signature, but using them here would mess up other parts of my code

#

i can just check after the method call, but i was wondering if there's a higher-level approach

minor junco
#

You could define a generic in the constructor really that's it afaik without the usage of wrappers

#

<T> YourClassCtor(T a, T b)

#

@smoky oak

smoky oak
#

noted, thanks

quaint mantle
#

what do you need the entity data for

torn oyster
#

its solved

short raptor
#

How do you unban players after the ban changes

#

I can only find unbanIP

#

I've got an offlineplayer

valid burrow
#

i dont think its in the offlineplayer object

#

getServer#getbannedplayers

minor junco
#

I dont know if this questions is the right for this channel, but I wanted to ask if it is possible to update the resource icon on spigotmc's website

#

since I don't see any edit buttons for that

short raptor
#

So I dunno what I'm meant to do with that

#

All the old banlist and banentry thingies are giving me errors and deprecated

smoky oak
#

you need to grab the profile from offlineplayer and unban it over the profile banlist iirc

eternal oxide
#

are you trying to unban a player?

#

if so probably OfflinePlayer#ban(null, Date.now(), null)

#

or Instant.now()

austere cove
#

BanList#pardon(T) exists

eternal oxide
#

that works too ๐Ÿ™‚

smoky oak
#

btw

#

whats the better way to keep a single instance of a list

#

static or singletron holder object

#

open to better solutions on this one

eternal oxide
#

it depends

#

a static list is not really OOP

smoky oak
#

well neither are singletrons

short raptor
eternal oxide
#

a singleton shoudl be, it's just an object

austere cove
eternal oxide
#

getBanList().pardon(OfflinePlayer)

#

probably

smoky oak
short raptor
#

intellij wants me to wrap it with string.valueof and then it becomes deprecated

quiet ice
#

What are you depending on

austere cove
#

Cast the banlist to profilebanlist

short raptor
upper hazel
#

will it be critical to store state in a static class if the class is not used in โ€œserious codeโ€
in bukkit api?

#

i was use cooldown static class

austere cove
#

The idea behind static is that it is supposed to be stateless

upper hazel
#

oh ok

smoky oak
#

How do i check if a Class<?> object is of an abstract class?

#

im doing recursion upwards to find the first abstract superclass

eternal oxide
#

Modifier.isAbstract(clazz.getModifiers())

valid burrow
#

mb forgot the last part

smoky oak
#

sanity check: if i put the same object into multiple lists, it still is just one object with multiple references, correct?

eternal oxide
#

usually yes

smoky oak
#

wdym usually lol

eternal oxide
#

there are cases where some Collections will produce a copy

#

a generic List is fine

smoky oak
#

can u be a bit more specific on those cases?

#

or is it some weird edge case where you need to deliberately do it

eternal oxide
#

things like a CopyOnWriteArrayList

smoky oak
#

so if its deliberate in some way, then. ill not worry bout that

eternal oxide
#

yep

smoky oak
#

wont impact functionality either way, just memory footprint lol

#

@eternal oxide this look fine to u? believe u gave me the idea with the map

Class<?> clazz = eventClass;
do{
  consumerMap.computeIfAbsent(eventClass, k -> new ArrayList<>()).add(listener);
  clazz = clazz.getSuperclass();
} while(!Modifier.isAbstract(clazz.getModifiers()));
#

i dont think i should do this when the event parsing happens cuz its probably leagues slower than just 'give me the list of this event'

eternal oxide
#

looks fine

smoky oak
#

yea, im trying to figure out how to do this without exceptions and without declaring the class

#

since this code only runs once thats not an issue but idk if this looks right

#
public void addConsumer(Consumer<? extends Event> consumer){
        try{
            Class<?> clazz = (Class<?>) ((ParameterizedType) consumer.getClass().getGenericInterfaces()[0]).getActualTypeArguments()[0];
            //call register method
        } catch (ArrayIndexOutOfBoundsException | ClassCastException ignored){}

    }
austere cove
dry hazel
eternal oxide
austere cove
#

The idea behind copyonwrite is that if you do a write, it creates a copy of the list so all iterators n stuff working on the old list wont throw exceptions

#

Which is nice for when you have concurrent reads an not a lot of writes because you avoid a lot of synchronization overhead

smoky oak
#

uh, can someone explain ? vs T? I can call signatures with <T extends Event> ... (Consumer<T>) and (Consumer<? extends Event>) with the same consumer, but it's saying i cannot call one from the other because its ? capture of vs T

smoky oak
rotund ravine
# smoky oak uh, can someone explain ? vs T? I can call signatures with <T extends Event> ......

Bing is funny.

Hello, this is Bing. I can try to explain the difference between ? and T in Java generics. ๐Ÿ˜Š

? is a wildcard that represents an unknown type. It is used when we don't care about the exact type of a generic parameter, or when we want to specify a range of possible types using upper or lower boundsยน. For example, List<? extends Number> means a list of some subtype of Number, such as Integer or Double.

T is a type parameter that represents a specific type. It is used when we want to declare a generic class, interface, or method that can work with different typesยน. For example, public interface Comparable<T> means that any class that implements Comparable can compare itself with another object of the same type T.

The reason why you cannot call one from the other is because of the capture conversionยฒ. When you use a wildcard, the compiler creates a fresh type variable (called capture of ?) that is a subtype of the upper bound of the wildcard. This type variable is unique and distinct from any other type variable, even if they have the same upper bound. Therefore, Consumer<? extends Event> and Consumer<T extends Event> are not compatible, because they have different type parameters.

I hope this helps you understand the difference between ? and T in Java generics. If you have any more questions, feel free to ask me. ๐Ÿ˜Š

Source: Conversation with Bing, 12/12/2023
(1) What is the difference between 'E', 'T', and '?' for Java generics?. https://stackoverflow.com/questions/6008241/what-is-the-difference-between-e-t-and-for-java-generics.
(2) Type Parameter vs Wildcard in Java Generics | Baeldung. https://www.baeldung.com/java-generics-type-parameter-vs-wildcard.
(3) java - how to use "tab space" while writing in text file - Stack Overflow. https://stackoverflow.com/questions/2585337/how-to-use-tab-space-while-writing-in-text-file.

Baeldung

A detailed explanation about generics, how and when to use type parameters, and when wildcards are more appropiate.

austere cove
austere cove
smoky oak
rotund ravine
#

Ignore this

#

?di

undone axleBOT
smoky oak
#

relevant code```
public <T extends Event> void addConsumersUnsafe(Consumer<T>... consumers){
Class<T> clazz = (Class<T>) ((ParameterizedType) c.getClass().getGenericInterfaces()[0]).getActualTypeArguments()[0];
addConsumer(clazz, c);

ivory sleet
#

And will pretty much never do

austere cove
#

^ tru

smoky oak
#

im not doing THAT anywhere

#

i do either <? extends event> or <T extends Event> ... (<T>)

austere cove
#

unchecked cast basically means the compiler cannot be sure that that cast is safe, but in most cases if the programmer knows what they're doing it will still be safe (albeit not statically checkable)

ivory sleet
#

^ that due to type erasure meaning generic types are not fully preserved during runtime

smoky oak
#

bleh
should i just not bother with a collective register method

austere cove
#

heap pollution is that because generics are not preserved at runtime, casting to a different generic type can allow you to 'pollute' the heap by introducing new objects of the incorrect type, e.g.

List<Integer> myIntList = new ArrayList<>();
List<String> myStringList = (List<String>) myIntList;
myStringList.add("Hello, world!"); // this works fine
Integer myInt = myIntList.get(0); // only now will an error be thrown
#

if required, one can get a typesafe collection by using Collections#checkedXYZ(..., Class)

smoky oak
#

wouldnt the (List<String>) make a copy? This looks like the reference is retained

austere cove
#

no it's just a cast

smoky oak
#

howd the int turn into a string then

austere cove
#

generics are syntax sugar

ivory sleet
#

Basically if u have the class hierarchy
Car extends Vehicle
Vehicle extends Object

<T extends Vehicle> func1(Supplier<? extends Vehicle> supplier) {
//
}

<T extends Vehicle> func2(Consumer<? super T> consumer) {
//
}

in func1 you can pass a Supplier<Car>, Supplier<Vehicle>, Supplier<? extends Car> and Supplier<? extends Vehicle>, what you canโ€™t so is a Supplier<Object> because func1 might actually take the result of the supplier and consume something that has to be at least of type Vehicle

in func2 you can pass a Consumer<Vehicle>, Consumer<Object>, Consumer<? super Vehicle>, and Consumer<? super Object>, what you cant do here is to pass a Consumer<Car> because we might pass consumable object that is of type Vehicle but not of type Car, thus the consumer canโ€™t consume anything that assumes Vehicle.

#

Producer (Supplier) extends, Consumer supers, PECS

austere cove
#
List<Integer> myIntList = new ArrayList<>();
Integer i = myIntList.get(0);

is actually just

List myIntList = new ArrayList(); // typeless
Integer i = (Integer) myIntList.get(0); // here the cast happens
#

so yes you can put anything in the list

ivory sleet
#

if you have something that produces and consumes we call it novariant or sometimes invariant (at times bivariant>

#

Often Map, List and other collections become invariant meaning you donโ€™t use ?extends and ?super on them

#

Since you both produce on the map and consume the map

#

For instance

smoky oak
#

i think i at least partially understand this. I'll just keep that pasted somewhere as a memo. What about Consumer<T>? Is it equivalent to Consumer<? extends T>?

Also, what'S the 'Possible heap pollution from parameterized vararg type' here referring to? the fact that the different consumers may have different input types?

ivory sleet
#
  1. No
  2. thatโ€™s with varargs
smoky oak
#

well yea, i thought i was being smart, im clearly not

#

need to know both of those though

ivory sleet
#

Basically

#

method(X<Y>โ€ฆ)
compiles down to
method(X<Y>[])
then
merhod(X[])

#

Thatโ€™s what it basically warns you about

#

Because its fully possible to mess it up with type erasure and cause โ€œheap pollutionโ€

#

Secondly about the first question

#

as function parameters we usually want Supplier<?extends O> or Consumer<?super O> since that allows for a range of type constructed producers and consumers

#

Consumer<O> is if u wanna specify that its only a Consumer<O> and canโ€™t be assumed as a Consumer<I>
if O extends I

#

for supplier it would be I extends O

lost matrix
restive mango
#

Aye, but I meant specifically that value

#

Iโ€™m not predicting velocity

#

I just want to know for the tick where your velocity was set to 0,1,0, do you move one block in one tick?

#

I assume yes based on the things you sent

#

It sends like t = ticks

lost matrix
smoky oak
restive mango
#

Are you saying that within the time of one tick those things are calculated?

restive mango
smoky oak
ivory sleet
#

Thatโ€™s good

smoky oak
#

im pretty sure if i hit a zombie the entityDamageEvent fires

ivory sleet
#

Thatโ€™s bad

#

Well imo ofc lol

smoky oak
#

well spares me from calling the event handler for every single event

#

i can just redirect the 8 super events

ivory sleet
#

Well youโ€™d want to be specific in event handling

lost matrix
ivory sleet
#

In a good and well designed event system, there is a supported generic event

#

Like
GenericEntityEvent
EntityEatEvent
EntityFartEvent
etc

smoky oak
#

ah so i need to do that ? extends T thing?

ivory sleet
#

you just need type awareness I think smile was hinting at

smoky oak
#

wait how tf does it pass a T into a ? extends Event

#

ah

#

type cast right

smoky oak
lost matrix
#

This only makes sense if you have something like

public class PlayerConsumer implements Consumer<Player> {
  ...
}

It would then spit out Player.class

smoky oak
#

cuz it forces it through the type in the class. doing that would be more or less walking backwards, no reflection consumer registration then

#

bleh deleting code in this case doesnt feel good lol

lost matrix
#
public class SomeEventHandler {

  private final Map<Class<? extends Event>, List<Consumer<? extends Event>>> listeners = new HashMap<>();

  public <T extends Event> void registerListener(Class<T> eventClass, Consumer<T> listener) {
    listeners.computeIfAbsent(eventClass, k -> new ArrayList<>()).add(listener);
  }

  @SuppressWarnings("unchecked")
  public <T extends Event> void handleEvent(T event) {
    List<Consumer<? extends Event>> eventListeners = listeners.get(event.getClass());
    if (eventListeners != null) {
      eventListeners.forEach(listener -> ((Consumer<T>) listener).accept(event));
    }
  }

}

What about this example bothered you? ๐Ÿ™‚

orchid gazelle
#

I am too dumb for consumers

#

My brain cannot process the logics

smoky oak
#

oh nothing, its the stuff around it thats annoing me

orchid gazelle
#

I kinda know how it works, but I don't know how to use it properly

smoky oak
#

also im trying to understand it, not just copy-paste it

orchid gazelle
#

Like, I always just wrap shit instead of using consumers

lost matrix
orchid gazelle
#

Yeah, I am really OOP based

#

@lost matrix btw. your code for the displayentities works out great, my custom guns are already pretty far and cool

#

I just need it to somehow feel more like a bullet when shot lol

#

Also, I need a brutal fire sound that hits different

smoky oak
#

low pitch on end crystal explosion sound?

orchid gazelle
#

And gotta finish my custom hitbox intersection algorithm, I guess. Well, it's more likely that the issue is the rotation of the hitbox itself

orchid gazelle
#

Well, I finished the algorithms and shit but my system is buggy as fuck

young knoll
lost matrix
young knoll
#

Yeah ik

#

It just makes me sadge when I have to use it

smoky oak
#

btw are all events a subclass of Event? knowing java, theres a chance theres some for which that aint the casae

chrome beacon
#

I believe so

rotund ravine
smoky oak
#

i have recently seen something like that though i cannot remember where

#

ah

#

factorio character prototypes

#

someone didnt set the 'all characters' flag correctly in a mod

#

thats what i was salty about

worldly ingot
junior geyser
#

with 1.20.4 I heard it is now possible to remove the red numbers on the scoreboard, but I cannot figure out how that is possible with the API, is not possible with API yet?

I know before it actually was a limitation of the game itself, but now it is theoretically possible. Is that true?

chrome beacon
junior geyser
chrome beacon
#

I don't think the API has been updated with that feature yet

#

You can always make a PR adding it yourself

junior geyser
chrome beacon
#

๐Ÿคทโ€โ™‚๏ธ I don't keep track of the active PRs

junior geyser
#

ok

chrome beacon
#

If you know it's being worked on you can wait a while

#

or use nms

junior geyser
#

Thanks though for the help

near mason
#

why cant we pass primitive types as generics?

shadow night
#

hmmm

echo basalt
#

Because they aren't objects

#

it's weird

lost matrix
echo basalt
#

Basically in runtime it's all an Object which is then magically casted

#

Which results in fun cast exceptions if you're doing serialization and stuff

near mason
#

ok ty

shadow night
proud badge
#

nvm (i think)

chrome beacon
#

UUID.fromString

proud badge
#

hmm

echo basalt
#

what you're referring to is just bytecode

shadow night
#

Well, I mean

proud badge
#

I dont think it exists

echo basalt
#

learnjava moment

proud badge
#

"uuid" is a string

echo basalt
#

fromString is a static method

#

not a local method in the string class

proud badge
#

Ah Ok

#

I will localify it now then. ๐Ÿ‘

eternal night
#

wtf

proud badge
#

I meant staticify

shadow night
#

UUID -> Class
uuid -> Variable

proud badge
#

ok I staticified it

echo basalt
#

you mean Refactored the method call to invoke the static method present in the UUID class rather than the local method present in the String class

proud badge
#

bru why does player.getUniqueID() exist but uuid.getPlayer() doesnt

eternal night
echo basalt
#

because a player has a uuid, a uuid does not have a player

chrome beacon
#

Because UUID has nothing to do with player

#

._.

echo basalt
#

UUID is also a java class