#help-development

1 messages · Page 1614 of 1

hasty prawn
#

Hm just a sec

hardy swan
#

click around on the sidebar

#

I can see it

covert valve
#

what

tranquil torrent
#

i cant see it

hardy swan
#

oh wait, sorry

hasty prawn
#

@covert valve ./.m2/repository/org/spigotmc/minecraft-server/<server version>',

Mojang -> Obfuscated is "maps-mojang.txt"
Obfuscated -> Spigot is "maps-spigot.csrg"

covert valve
#

ok thanks

hasty prawn
#

And then theres the maps-spigot-fields too

covert valve
#

yeah its not in my local repo for some reason

#

oh well

hasty prawn
#

Did you build Spigot with BuildTools

covert valve
#

no i grabbed the NMS mappings from the codemc repo but it's identical

#

im just trying to figure out what PacketPlayOutAutoRecipe is

#

otherwise i'm just going to go back to spigot mappings

hasty prawn
#

Oh lmao I can tell you

covert valve
#

which one

toxic hazel
#

is there an event to detect that rain falls on a block?

#

I can't seem to find it apart from MoistureChangeEvent, but that's good only for soil

hasty prawn
covert valve
#

ahh thanks

#

i hate that spigot ever had spigot mappings over nms mappings

#

because now i need to relearn the entire nms internals

#

great

hasty prawn
#

If that doesn't work the other packets relating to recipes are ClientboundRecipePacket and ClientboundUpdateRecipesPacket

#

Yeah it's frustrating but being able to use Mojang's names is kinda nice

#

Once you figure it out anyways

covert valve
#

yeah

vivid temple
#

in recipes, do spaces represent nothing?

covert valve
#

does reflection work with mojang mappings?

chrome beacon
#

No

#

You will need to use reflection on unmapped methods

ivory sleet
#

Believe it works with paperweight, no?

covert valve
#

ok

#

fantaaastic

eternal night
#

as if paperweight has reflection support 😂😂

covert valve
#

can i even use the mapped ones then if i can't use reflection? i use it quite often

ivory sleet
vale breach
#

anyone experience with ByteBuddy Advice ?

covert valve
#

how do i use reflection with it then? i can't use both mojang and spigot mappings

chrome beacon
#

You need one reflection for before 1.17 and another one for 1.17+

covert valve
#

that's fine

#

i mean can i use reflection with the mappings?

#

lemme show you

#
@Override
    public void modifyPacket(@NotNull final Object packet) throws NoSuchFieldException, IllegalAccessException {
        ClientboundPlaceGhostRecipePacket recipePacket = (ClientboundPlaceGhostRecipePacket) packet;
        ResourceLocation key = recipePacket.getRecipe();
        ResourceLocation newKey = new ResourceLocation(key.getNamespace(), key.getPath() + "_displayed");
        Field fKey = recipePacket.getClass().getDeclaredField("recipe");
        fKey.setAccessible(true);
        fKey.set(recipePacket, newKey);
    }
#

actually ill check the mapped output

hasty prawn
#

Yeah when using reflection you have to use the Spigot mappings names. yay

covert valve
#

you have to

#

great

#

that means i'm basically fucked

#

i think

#

or i have to use 2 modules for my 1.17 NMS

hasty prawn
#

Why

chrome beacon
#

1.17 only has Spigot mappings for classes methods are unmapped iirc

covert valve
#

that's just not helpful

#

there was nothing wrong with how 1.16.5 did it

chrome beacon
#

Eh I don't really mind. Mojmaps are great

hasty prawn
covert valve
#

they suck if i can't use reflection

#

which i need to do

#

to accomplish a lot of stuff

ivory sleet
chrome beacon
hasty prawn
#

You can use reflection, you just have to use the names that the Spigot JAR uses and not Mojmaps

ivory sleet
#

How complete is parchment?

covert valve
#

i just can't

hasty prawn
#

You can

chrome beacon
hasty prawn
#

You're supposed to remap your JAR at compile time

ivory sleet
chrome beacon
#

No

ivory sleet
#

Oh yeah good point olivo

covert valve
chrome beacon
#

Method names are more useful than param names

ivory sleet
#

param names are extremely useful if you for instance have 2 int params

#

Saves a lot of time (:

#

Thus yarn 😌

covert valve
#

conclusion

#

i'm not gonna use mojang mappings

#

because it's awful

ivory sleet
#

🤨

covert valve
#

i can't do what i need to do

#

i can't use reflection

#

which means i have to use unmapped as well

hasty prawn
#

You can. I've done it lmao

covert valve
#

which means i need 2 modules to do everything

#

link to your source code?

chrome beacon
#

Why 2 modules?

hasty prawn
#

Lemme get it

covert valve
#

one to use moj mappings

#

one to use reflection

#

i feel like a broken record

chrome beacon
#

You don't need 2 modules though you just have to figure out unmapped names

ivory sleet
#

Yeah well you don’t have to but I guess it saves hella lot of time

covert valve
#

spigot mappings worked great

#

why did they fucking change it

wild inlet
#

The fact you can't get title after creation of a custom inventory after it's created is some serious bullshit

#

There's no good reason to not allow access to it, I've looked at the source

chrome beacon
#

Because everyone is moving to Mojmaps

echo basalt
covert valve
dense goblet
covert valve
#

some classes just don't exist

wild inlet
dense goblet
#

For events etc

echo basalt
#

bruh just make a getter

wild inlet
dense goblet
#

Ah okay good

wild inlet
covert valve
#

and the stuff doesn't exist at runtime anyway

dense goblet
#

Is it not serialisable by default

covert valve
#

so what's the point

echo basalt
#

Spigot should make a getter

wild inlet
hasty prawn
#

Oof, can't find where I used reflection.

covert valve
#

can you link your repo

echo basalt
#

Mojang should rewrite the server code

dense goblet
#

So there's no inventory.getName()?

echo basalt
#

and also add a transfer packet

wild inlet
#

CustomInventories have their own instance where they could ridiculously easily store the string title, what a shitshow.

hasty prawn
wild inlet
ivory sleet
#

Does nms inventories store it liquake?

covert valve
#

fan fucking tastic

#

i can't do anything then

wild inlet
covert valve
#

no code examples

#

no reflection examples

#

i can't achieve what i need to do

ivory sleet
#

Yeah probably spigot api flop

covert valve
#

why can't i keep using spigot mappings

#

ie unmapped

ivory sleet
#

Cuz mojmaps good (:

wild inlet
echo basalt
#

At the server I work for, our utils use NMS inventories because spigot-api is limiting

covert valve
#

but they're not

#

because spigot doesn't use them internally

echo basalt
#

I see no reason for spigot-api to remove Inventory#getTitle

covert valve
#

so i can't reflect properly

#

so i have to use unmapped shit anyway

echo basalt
#

Because it used to exist

covert valve
#

so i have to download the non-existent mappings

ivory sleet
#

Someone just decided to yeet it illusion lol

wild inlet
#

@ivory sleet However - the custom spigot ones should have their name stored. It has it stored in their NMS implementor

covert valve
#

in order to use these non-existent mappings

#

so i can run some non-existent code

#

to do something

echo basalt
wild inlet
#

Take a look at CraftInventoryCustom for more details

ivory sleet
covert valve
#

this feels like it was intentionally done to make NMS as tedious and inconvenient as humanly possible

wild inlet
echo basalt
#

NMS isn't that hard

#

Mojang had no reason to yeet the multi_block_change packet and rewrite it entirely

dense goblet
#

I hate that every tutorial ever tells you to identify your custom inventory by title

ivory sleet
#

Yeah Liquake IdentityHashMap<Inventory,String> maybe altho Idk if spigot creates delegates sometimes

ivory sleet
#

Luzifer I want my code review

echo basalt
#

I gotta make a yt tutorial some day

hybrid spoke
dense goblet
echo basalt
#

"Illusion's masterclass - Colorful language towards static abuse (EP 1)"

dense goblet
#

I store them by reference in a manager

ivory sleet
dense goblet
#

And remove when there are no viewers left

ivory sleet
#

Here

wild inlet
#

@ivory sleet Literal excerpt:

public class CraftInventoryCustom extends CraftInventory {
    public CraftInventoryCustom(InventoryHolder owner, InventoryType type) {
        super(new CraftInventoryCustom.MinecraftInventory(owner, type));
    }

    public CraftInventoryCustom(InventoryHolder owner, InventoryType type, String title) {
        super(new CraftInventoryCustom.MinecraftInventory(owner, type, title));
    }

    public CraftInventoryCustom(InventoryHolder owner, int size) {
        super(new CraftInventoryCustom.MinecraftInventory(owner, size));
    }

    public CraftInventoryCustom(InventoryHolder owner, int size, String title) {
        super(new CraftInventoryCustom.MinecraftInventory(owner, size, title));
    }

    static class MinecraftInventory implements Container {
        private final NonNullList<ItemStack> items;
        private int maxStack;
        private final List<HumanEntity> viewers;
        private final String title;```
hybrid spoke
wild inlet
#

Would be so ridiculously easy to add a getter

dense goblet
#

It's a hashmap between inventory and a set of players iirc?

hybrid spoke
ivory sleet
#

Myeah liquake

dense goblet
hybrid spoke
#

i would not say its wrong. its better than identifying by the title. but i would prefer implementing inventoryholder

echo basalt
#

We gotta join forces and make "GoodSpigot" with a built-in Custom Entity API and easy access to pathfinders

ivory sleet
quaint mantle
#

how do i make it stop saying im typing

hybrid spoke
#

á ripcord

quaint mantle
#

betterdiscord breaks everything

#

ripcord looks horrible

ivory sleet
hybrid spoke
#

not recommending it since its not alowed from discord

hybrid spoke
quaint mantle
#

0/10 using pastebin

ivory sleet
#

Don’t judge bin 😦

quaint mantle
#

pastebin only good for standalone files

echo basalt
chrome beacon
ivory sleet
dense goblet
#

Is inventoryholder extendable?

hybrid spoke
# wild inlet

ik, saw that too. but it works and is a clean method to do it

echo basalt
ivory sleet
dense goblet
#

Since half the classes in spigot api are not

ivory sleet
#

The InventoryHolder api has been in the spigot api forever, doubt it’s subject to change for a long time

ivory sleet
hybrid spoke
wild inlet
#

Again though

hybrid spoke
#

is there any api-note in the javadocs to avoid using it to create custom guis?

wild inlet
#

Can't force incoming inventories I serialize to implement it

#

For now I've just added an overloaded method to provide the title seperately

#

If you need it saved

ivory sleet
wild inlet
#

But again, it's a joke spigot doesn't just have it for createInventory results.

#

If someone who's done a PR before wants to add it, please do

hybrid spoke
echo basalt
ivory sleet
#

🤣

echo basalt
#

before github had dark mode

ivory sleet
#

What a fine memory

vivid temple
#

this line errors me "Operator '==' cannot be applied to 'org.bukkit.block.data.BlockData', 'java.lang.String'"

if (e.getBlock().getBlockData() == "7") {
ivory sleet
#

Lmao

wild inlet
#

lol...

vivid temple
wild inlet
#

BlockData isn't a number, it's an object

ivory sleet
#

== is for primitive equality or instance/reference equality whatever you’d call it

wild inlet
#

I have a feeling you're trying to use old magic numbers.

#

Learn about the blockdata stuff, as it's how things are done now by mojang

echo basalt
#

Code I found on github

#

And forked

worldly ingot
echo basalt
#

Copypaste go brr

#

It sent a different login message depending on your game version

#

Except it was like 400 lines of copypaste

#

And when I made a PR to lower it to 1 line it got refused for "didn't work"

hybrid spoke
ivory sleet
#

No!

#

I did this as a commission for a server once lol

hybrid spoke
#

okay

#

so shorten answer: burn it

ivory sleet
#

🥲

echo basalt
#

Commission work is fun

#

I made 60$ in 1hr by just doing a basic trade gui

#

you gave 5 cobble and got 1 iron, for example

ivory sleet
#

Oo money in the bag duke

echo basalt
#

With configurable recipes or whatev

#

Nowadays I just charge a flat hourly fee and waste 8 hours debugging an int

quaint mantle
#

please tell me thats a joke

vivid temple
echo basalt
#

I legit found it like that on github

echo basalt
echo basalt
#

you gotta decompile the packets and watch the fields

hybrid spoke
#

using pastebin, ew

your instance and class vars looks horrible. a not static method above your constructor, which does not belong to the factory method pattern? EW

you ever heard of the final keyword when instantiating instance vars right away?

at least you use a switch instead of spaghettinating
EDIT: nvm

unnecressary comments, burn them.

i cant even look at what you are doing there with your files

split your code into several methods.

your code further down seems like you abused your CTRL+C/V

sometimes you use this, sometimes not ??

your formatting is bs

EventManger#getPlayer what da actually NM_Rude

echo basalt
hybrid spoke
#

how long has it been since you did that

echo basalt
#

at least 5 minutes

hybrid spoke
#

i mean my first spigot commission looked way worse than this

echo basalt
#

My first spigot commission was basically a shitty +-*/ math parser

maiden briar
#
Location newPoint = point.clone().add(0, 1, 0);
System.out.println("Location " + newPoint);
System.out.println("Drops " + newPoint.getBlock().getDrops());
System.out.println("Max " + maxAmount);

if(point.getBlock().getDrops().size() < maxAmount)
{
    final Item droppedItem = newPoint.getWorld().dropItem(newPoint, item.amount(amountToSpawn).build().make());
    droppedItem.setVelocity(new Vector(0, 0, 0));
}

Why does Drops print an empty array if there are actual drops? If I go 1 location down the list contains only the actual block (It are slabs)

dense goblet
hybrid spoke
#

mine was some faction shit to upgrade your pickaxe. i didn't even know what a loop was so i copy pasted one code block 1000 times to just change one int value up

hybrid spoke
dense goblet
#

So is pretty much anything in the API but 90% of it breaks

tiny belfry
#

das wut i did

dense goblet
hybrid spoke
#

dont mess with him

#

he has and is the commando

tiny belfry
#

XD

#

simple

#

pass along the job XD

dense goblet
#

Also reading up on InventoryHolder it's apparently supposed to only be used for blocks and not designed to be implemented?

tiny belfry
#

idfk

tiny belfry
#

i get friends to do the plugin making then say i made it

echo basalt
#

Create a class that extends InventoryHolder

#

and use it as the holder

#

You can do your checks

echo basalt
#

But proper use is to make a menu class that implements InventoryHolder

#

And then just check if inventory.getHolder instanceof Menu

hybrid spoke
#

but yes, its to identify f.e. if the inventory is a chest

chrome beacon
#

Print is one thing rest of code uses another

maiden briar
#

Yes, if I go 1 down it is point

#

If I print point, then it prints the actual block as 'drops'

dense goblet
#

So it should be pretty easy to switch from the implementation I have to using inventoryholders

echo basalt
#

Yeah

maiden briar
#

But I will print both

dense goblet
#

In my listener check if the holder is my base class and then call onClick() in my CustomGUI

hybrid spoke
#

yeah

dense goblet
#

I'll give it a go when I'm back home ty

hybrid spoke
#
        if(e.getView().getTopInventory().getHolder() instanceof LogGUI) {
            LogGUI logGUI = (LogGUI) e.getView().getTopInventory().getHolder();
            logGUI.handleEvent(e);
        }
maiden briar
#
[20:19:13 INFO]: Drops [] //newPoint
[20:19:13 INFO]: Max 12
[20:19:13 INFO]: Location old [ItemStack{SMOOTH_STONE_SLAB x 1}] //Point

@chrome beacon

chrome beacon
toxic hazel
#

So any way I could detect rain falling on specific block types?

maiden briar
chrome beacon
#

Like what are you expecting

maiden briar
#

I am expecting some iron ingots, but the list is just empty

chrome beacon
#

What block drops iron ingots?

opal juniper
#

A furnace

#

Silly Olivo

chrome beacon
#

.-.

fluid cypress
#

is there a way, with the spigot api, to keep a chunk loaded? at least for a period of time, not forever

opal juniper
#

Chunk Loading tickets iirc

stiff topaz
opal juniper
#

dont use the legacy api

stiff topaz
#

I mean

#

It works?

waxen plaza
#

I just downloaded Ubuntu and when I tried to test my plugin it didn't work.StringBuilder sb = new StringBuilder(); sb.append("jdbc:sqlite:"); String path = Bukkit.getServer().getPluginManager().getPlugin("PrivateVaults").getDataFolder().getAbsolutePath(); sb.append(path); sb.append("\\privateVaults.db"); url = sb.toString();

#

and this won't work on ubuntu only on windows

#

because windows uses for path \ and ubuntu uses /

#

how do I fix it?

dusk flicker
#

change \ to /

#

?...

waxen plaza
#

but will the / work on windows?

dusk flicker
#

use File.separator

#

and it will work on all

waxen plaza
#

Ok, I'll try

main dew
#

How I can disable phycics (sand, gravel etc.)

hasty prawn
#

Cancel BlockPhysicsEvent

main dew
#

How I remember this don't work ;/

dense goblet
#

It's buggy on client side iirc

#

At least cancelling EntityChangeBlockEvent is

#

PhysicsEvent gets called very often (every block update i think)

shadow gazelle
#

I'm confused, I have a hash map with an int and a player, I want to get the integer using the player, how can I do this?

#

nvm, I'm being stupid

#

Wait, no

#

No, I just want to get the integer the player is related to

dusk flicker
#

is there a reason you have integer first?

shadow gazelle
#

It makes it easier to check if they player has something selected

dusk flicker
#

What is the point of the integer

#

Like exactly

#

Does it change, etc?

shadow gazelle
#

The EntityID for the NPC

dusk flicker
#

Okay

shadow gazelle
dusk flicker
#

gotcha

covert valve
#

for consistency

#

can i use mojang mappings on 1.16.5?

fluid cypress
#

why is this running every tick? i literally specified every 12000 ticks

new BukkitRunnable() {
    public void run() {
        System.out.println(fillRtpLocationsTimer * 20L);
        fillRtpLocationsTimer();
    }
}.runTaskTimer(this, fillRtpLocationsTimer * 20L, fillRtpLocationsTimer * 20L);
[17:07:19 INFO]: 12000
[17:07:19 INFO]: 12000
[17:07:19 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:20 INFO]: 12000
[17:07:21 INFO]: 12000
[17:07:21 INFO]: 12000
shadow gazelle
#

Why are you running fillRtpLocationsTimer?

fluid cypress
#

bc thats another function that does a lot of stuff

#

one of them, starting a new different timer, is that a problem?

#

or i cant start more than one timer per plugin or something like that? that would be bad

shadow gazelle
#

Naming it the same thing as the interval you're trying to run right now possibly is

fluid cypress
#

right

#

youre right

#

im stupid, i didnt realize

#

but why isnt intellij saying anything about that?? wtf

shadow gazelle
#

Also, instead of multiplying it three times, make a variable that does it once

fluid cypress
#

that will just be multiplied once, and the print is temporary

#

and multiplication isnt a problem nowadays

#

i cant believe how i cant use integers in conditional checks, but mutiplying a function is totally fine

shadow gazelle
dusk flicker
#

I don't as a map should technically be the other way

#

I thought I had a util for it but I checked and didn't have one

shadow gazelle
#

Okay

shadow gazelle
#

hmm

#

Try making a variable with that multiplication and see if it changes anything

quaint mantle
#

hey i have a question

#

can i Bukkit.getOfflinePlayer(their uuid) to get an offline user, despite having them join or not?

#

because i imagine that's for every single mc player based off UUID

#

where Bukkit.getServer().getOfflinePlayer(etc)

#

gets the SERVER offline player

#

or am i stupid or

chrome beacon
#

Bukkit is just a wrapper for server

quaint mantle
#

thats what i thought

chrome beacon
#

They do the same thing

ivory sleet
#

Bukkit.setServer(null)

#

😌

quaint mantle
#

huh

#

what does that do

ivory sleet
#

Don’t try it (:

quaint mantle
#

ok

#

seems fair

covert valve
#

anyone know where i can get spigot -> mojang mappings?

hasty prawn
covert valve
#

i'm trying to find MojangsonParser

quaint mantle
#

i'm gonna look in Skript's source code

ivory sleet
quaint mantle
#

because when i used skript you could do "uuid string" parsed as offlineplayer

#

despite if the user has joined or not

#

so

#

therefore

#

yes

ivory sleet
#

Sounds like a terribly good idea

quaint mantle
#

lmfao

#

ghetto 😳

ivory sleet
covert valve
#

i'll check

#

i have to compile it because deployed version is brock

quaint mantle
#

hey how should i get an OfflinePlayer of somebody who has never joined before 😳

ivory sleet
#

By name or uuid

quaint mantle
round stone
#

I have a little question:

How can I do that you execute a method but the code continues underneath

smoky oak
#

um

quaint mantle
#

what

ivory sleet
quaint mantle
chrome beacon
quaint mantle
#

waitwaitwaitwait

#

im using Bukkit.getOfflinePlayer(

#

should i be using something else

chrome beacon
#

No

quaint mantle
#

yeah im getting them by UUID

#

actually in this specific instance i believe by name

#

i'll double check

smoky oak
quaint mantle
#

k theres my code:

round stone
ivory sleet
#

Same thing

covert valve
#

nope

#

minimapping doesn't help

smoky oak
#

thats something you as programmer would know

covert valve
#

it can't find what IChatBaseComponent is

smoky oak
#

alternatively you can call the method b as a sceduler task

ivory sleet
#

Methods are reusable instructions composed of other instructions

quaint mantle
#

i'll pastemd aswell

#

yeah

ivory sleet
#

?paste

quaint mantle
#

?pastemd

undone axleBOT
quaint mantle
#

ah

hasty prawn
quaint mantle
covert valve
#

it's just Component

#

thanks

hasty prawn
#

👍

shadow gazelle
#

Well, I think I got it, but it's probably a complete mess

quaint mantle
ivory sleet
#

Cuz the name was never cached

quaint mantle
#

owo?

chrome beacon
shadow gazelle
#

And it doesn't work

#

How did I guess?

quaint mantle
#

how should i get their name then

#

there's gotta be a way

chrome beacon
#

You will have to use MojangAPI

quaint mantle
#

ahh i c

shadow gazelle
#

Wait

quaint mantle
#

first time using JSON stuff :o

shadow gazelle
#

whaaat

ivory sleet
#

Yeah what olivo said and maybe create your own cache?

chrome beacon
#

^^

quaint mantle
covert valve
#

anyone have the txt file that spigot uses in special-source?

chrome beacon
covert valve
#

minimappings doesn't work

#

i can't find MojangsonParser

ivory sleet
#

Ah rip

chrome beacon
#

Wish I could help but won't have access to my PC for another week

covert valve
#

nvm its TagParser

main dew
#

How disable phycics?

shadow gazelle
#

Wearing as in armor/an offhand tool?

#

There's no armor equip or remove event

#

So you have to either use another plugin that adds an armor equip event

chrome beacon
#

||Paper||

shadow gazelle
#

Or like I did, make a loop that runs every second and checks for my enchantment

shadow gazelle
chrome beacon
shadow gazelle
#

I was wondering if you could somehow see if the server the plugin is running on is Paper so I could use Paper's event for it

#

How is magic stored? Lore?

smoky oak
#

Might i suggest keeping a map of online players and running a Sceduler function every 20 ticks instead? I'd imagine that would reduce the load massively

#

running anything once per tick isnt a good idea

shadow gazelle
smoky oak
#

that times twenty? If it's not supposed to happen per tick dont put it in a onTick event...
Also i now cant help but wonder what is called once per tick, aside from random ticks

#

that whole message sounds stupid

craggy cosmosBOT
quaint mantle
#

t

#

at

proud basin
#

Should grabbing data from a db be async?

paper viper
main dew
#

Always always

proud basin
#

ok thanks

gleaming grove
#

how can i send message to player?

proud basin
#

Player#sendMessage

gleaming grove
#

thx man you made my day

proud basin
#

@lost matrix since i'm getting multiple values from the player in the db that is under the same column I should be saving them in a list or array ?

opal juniper
#

Why ping?

proud basin
#

honestly idk I was talking to him about 3 days ago

#

about the thing I was doing

lost matrix
proud basin
#

ah that's what it was

#

What was the reason why I am using a map?

valid crag
#

you presumably want to associate your player data with a player

proud basin
#

see what I was doing before was using Getter and Setters

valid crag
#

which is done with a map

proud basin
#

Couldn't you do the same though with getter and setters?

valid crag
#

no

#

getters and setters don't store things

proud basin
#

But I'm not storing anything.

#

It's all stored in a db

valid crag
#

you don't want to run to your db every time you want to get something

#

you should cache it in memory

#

every request to the db can potentially take a round trip around the globe and several dozen ms to complete

proud basin
#

right

#

but

#

nvm

valid crag
#

and to cache the things, you need to associate the things with a player

#

which you use a map for

proud basin
#

hm ok

#

What's the reason for using the perimeter in the map for a class?

valid crag
#

perimeter?

proud basin
#

Sorry parameter

valid crag
#

what parameter

proud basin
#

Value

valid crag
#

what

proud basin
#

idk what to call them

#

Map<UUID, DataClass>

#

UUID and DataClass

valid crag
#

the shit in the <>

proud basin
#

yea

valid crag
#

type parameters

#

they parameterize your map instance

proud basin
#

close enough

valid crag
#

it means that the keys will always be UUIDs

#

and the values will always be DataClass's

muted idol
#

hey there is there way for somebody to explain why this error exists? this is my class A:

public class A
{
  System.out.println("Hello world");
}

and this is my class B

public class B
{
    public static void main()
    {
        A a = new A();
    }
}
``` for some reason im getting a `NoClassDefFoundError`
the only difference is that they are in different packages!
proud basin
#

I know what it does

#

but why am I putting a class there

valid crag
#

you aren't

#

your player has multiple bits of data, yes?

proud basin
#

Yea

#

wait

valid crag
#

what kind of data does the player have

proud basin
#

ohh

#

I see

#

I wanna replace it with a string

valid crag
#

you don't

#

you create a class that has a field for each of these bits of data

#

and then put instances of that class in the map

proud basin
#

The player has a cooldown name and a time

undone axleBOT
valid crag
#

then the data class should have 2 fields, a name and a time

proud basin
#

Why not cooldown?

#

why have time

muted idol
valid crag
#

i assumed "cooldown name" was a single entry

proud basin
#

no

valid crag
#

well, 3 fields; cooldown, name, and time

muted idol
valid crag
#

your player probably can have multiple cooldowns as well

proud basin
#

Yes

hybrid spoke
valid crag
#

what are your cooldowns identified by

quaint mantle
#

does Sound.valueOf("") for THE_SOUND_ENUM_NAMES_LIKE_THIS or the.sound.names.like.this

#

ok

#

i speak englihs i promise

proud basin
#

A String

valid crag
#

is that the name?

proud basin
#

Yes the name of the cooldown

valid crag
#

so then you have a field in the player data class that holds a map

quaint mantle
valid crag
#

that holds name -> cooldown data entries

proud basin
#

huh

valid crag
#

you're probably having an aneurysm right now

proud basin
#

yea

valid crag
#

this is because you're trying to convert relational data from a relational database to an object oriented type of data

#

it takes some hammering around to get it to turn from one to the other

#

and is the biggest pain with managing databases

proud basin
#

really

valid crag
#

in the db you have rows and columns

proud basin
#

yea

valid crag
#

in java you have maps and fields

#

you can consider each table of the db a map

#

and the primary key of the table is the key in the map

#

and all of the rest of the columns of the table are shoved in a single class

#

say you have a table with columns [playerId, playerName, lastPlayed]

#

in oop that'd correspond to a Map<UUID, PlayerData>

#

there UUID is the playerId

#

and the PlayerData class holds playerName and lastPlayed in fields

vivid zodiac
#

Can i mp anyone just to giving my screenshoot ? i just need information

quaint mantle
#

?

valid crag
#

consider learning english

vivid zodiac
#

he's insult my BIUTIFULLY english ?

quaint mantle
#

😬

proud basin
#

now is PlayerData method?

valid crag
#

PlayerData is a class

valid crag
#

public class PlayerData {
String playerName;
long lastPlayed;
}

#

PlayerData data = map.get(playerId);

#

String name = data.playerName;

proud basin
#

I think im understanding this a bit better with your examples

quaint mantle
#

lucky

#

nnyak never gives examples

#

its understand this or you're stupid

valid crag
#

i do give examples, i just keep them to a level that isn't spoonfeeding

proud basin
#

NNY has a crush on me that's why

vivid zodiac
#

Guys, who know how can i write here ? ^ screenshot top (i dont want spam screen)

quaint mantle
#

Player#sendMessage

proud basin
#

sendMussage

vivid zodiac
#

for sending message, i want write where point arrow

hasty prawn
#

Rename the item

proud basin
#

oh

quaint mantle
proud basin
quaint mantle
#

and you're complaining?

proud basin
#

lmao

valid crag
#

maybe it's just a really good plugin

quaint mantle
#

^

proud basin
#

maybe someone downloaded it 21,000 times

vivid zodiac
proud basin
#

ay you never know

vivid zodiac
proud basin
#

action bar?

valid crag
#

not exactly but pretty close

quaint mantle
#

oops

valid crag
#

the itemname bar is afaik completely clientside

quaint mantle
#

lmgtfy

valid crag
#

so you'll have to make do with actionbar

woeful moon
#

when would you make an event final and when wouldn't you? What's the benefit of making it final?

quaint mantle
#

why is it .app

valid crag
#

the benefit is that it can't be extended if it's final

quaint mantle
#

it makes no difference

valid crag
#

as for what that means for the particular event, who knows

woeful moon
#

Ok

vivid zodiac
#

i was fake pinged ? xD

quaint mantle
#

unless you're registering the subclass, the method is gonna be called for the superclass

vivid zodiac
#

player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(msg));
i finded !

proud basin
#

...

valid crag
#

spigot, hiding things under obscure .spigot() methods since 2015

vivid zodiac
#

😂

#

its my first plugin let me make my shit code 😂

shadow gazelle
#

why tf do you have spigot() in player.sendMessage?

valid crag
#

because that's where the sendMessage method for actionbars is declared

#

Player::spigot returns some sort of a spigot player or something

valid crag
#

someone had the brilliant idea of putting some random methods on that object instead of the actual player object

#

i'm sure there was some kind of reason for it initially

dusk flicker
#

but was it a good reason... No.

shadow gazelle
dusk flicker
#

Wellll

#

Elyras are cool

#

So not all

shadow gazelle
#

Anyway, why tf does my plugin not see my config was changed? I'm calling another function, waiting 20 ticks, then reloading the config and getting the field in a new variable after it was changed.

valid crag
#

are you pulling the value fresh from the config

shadow gazelle
#

Pretty sure, I'm reloading the config 20 ticks after the other code of the function it's in runs, then putting the config value that should be updated in a new variable

valid crag
#

by "putting the config value in a new variable", you mean you are grabbing the config from the plugin with plugin.getConfig()

#

and then calling config.getWhatever

shadow gazelle
#

Custom config, I'm pretty sure the reload code is fine

valid crag
#

show code

shadow gazelle
#
    public void reloadConfig() {
        if (this.configFile == null)
            this.configFile = new File(this.plugin.getDataFolder(), "NPCstorage.yml");

        this.dataConfig = YamlConfiguration.loadConfiguration(this.configFile);
        InputStream defaultStream = this.plugin.getResource("NPCstorage.yml");
        if (defaultStream != null) {
            YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultStream));
            this.dataConfig.setDefaults(defaultConfig);
        }
    }
valid crag
#

and you are retrieving the fresh instance from this.dataConfig

#

and calling getWhatever on it

#

and storing the return value in a field

shadow gazelle
#

Should be, I am, and I am

valid crag
#

it should by all means work then

lost matrix
valid crag
#

you and your singletons

lost matrix
# shadow gazelle No

Then make it one. If you create an instance of this class and save it in a field then the fields of that instance wont be updated if you call reloadConfig() on another instance.

shadow gazelle
#

But I'm trying to get the updated config from the other functions

valid crag
#

what bratwurst man is trying to convey is "are you creating more than one instance of this class"

lost matrix
shadow gazelle
#

Pretty sure none

lost matrix
valid crag
#

brilliant

shadow gazelle
#

Everything in it is used by a command or another function

valid crag
#

let's take a step back and make sure you know what instance means

lost matrix
shadow gazelle
#

For when someone sets look at nearby players to true with the command

                            if (args[2] != null && args[2].equalsIgnoreCase("true")) {
                                file.set("data." + npc + ".look", true);
                                Bedwars.saveData();
                                player.sendMessage(ChatColor.DARK_GRAY + "[" + ChatColor.AQUA + ChatColor.BOLD + "BW" + ChatColor.DARK_GRAY + "] " +
                                        ChatColor.BLUE + "NPC will now look at nearby players");
                                NPC.reloadNPCs(player);
#

FileConfiguration file = Bedwars.npCstorage.getConfig();

bright quartz
#

Caused by: java.lang.NoSuchMethodError: 'org.bukkit.util.Vector org.bukkit.util.Vector.rotateAroundY(double)'?

#

it seems to be fine, no errors in the code

#

no idea what i did wrong there

lost matrix
valid crag
#

are you compiling against the correct version of the api

#

inb4 you're building against 1.16 but running on 1.8

bright quartz
#

the server is 1.8.8 and that's what i'm building against

fading pulsar
#

hi

bright quartz
#

i believe so

fading pulsar
#

Why My Plugin Can't trigger Player Event?

lost matrix
fading pulsar
#

my server version is 1.12.2

valid crag
#

imagine if literally anyone was up to date

lost matrix
fading pulsar
#

emm where need i added?

lost matrix
fading pulsar
#

cry... have error

shadow gazelle
bright quartz
valid crag
#

i'm sure crying will help

lost matrix
shadow gazelle
#

Well

lost matrix
wild reef
#

Hey guys I have some trouble rn with getting an Service class of mine.
This is how I do it:

RegisteredServiceProvider<MyService> serviceProvider = Bukkit.getServicesManager().getRegistration(MyService.class);
        if(provider != null) {
            this.someService = serviceProvider .getProvider();
        }

I am running out of ideas, the serviceProvider returns null but I printed out Bukkit.getServicesManager().getKnownServices() which contains my services class

shadow gazelle
shadow gazelle
valid crag
#

but muh KNOCKBACK

lost matrix
valid crag
#

and muh TNT CANNUNS

lost matrix
shadow gazelle
#

?paste

undone axleBOT
valid crag
#

expect to happen: it work
observed: it not work

wild reef
lost matrix
valid crag
#

killed by watchdog

fading pulsar
lost matrix
valid crag
#

learning java is a good first step

fading pulsar
#

Emm have wiki?

wild reef
shadow gazelle
#

Because the function doesn't get the updated config for whatever reason, the values are still the same and it just does nothing when you try to run a command to modify an NPC again

fading pulsar
#

randomly cast classes? emm

wild reef
#

@lost matrix any idea?

lost matrix
#

Did you consider that?

shadow gazelle
#

That's why the config not seeing the changes is an issue

fading pulsar
#

i dont know xD

lost matrix
fading pulsar
wild reef
#

so get the service in onLoad and registering the service in onEnableif I got that right

lost matrix
# fading pulsar can tell me add to where before?

Before you cast something -> check if what you cast is actually the proper type
You can do this by checking if the object you are about to cast is an instance of the class you are about to cast to.
This can be done using if(object instanceof TheCastClass)

shadow gazelle
#

Is it maybe using the value from entityIdOld for entityIdNew because they're getting the exact same thing? Ignoring that the second one should have been updated.

valid crag
#

why are you even saving the eid in a config

shadow gazelle
#

Easier to get it and update it with the new ones that way

valid crag
#

eid is transient

lost matrix
valid crag
#

config is persistent

fading pulsar
#

So

   if(obj instanceof Double) {
   int DH = Integer.parseInt(DefaultHealth);  
   player.setMaxHealth(DH);
}```?
valid crag
#

the two shouldn't go together

shadow gazelle
lost matrix
fading pulsar
#

what

valid crag
#

learn java

lost matrix
# fading pulsar what

Also: Player#setMaxHealth(double) is deprecated. Use attributes instead.
What spigot version are you on?

wild reef
#

@lost matrix still getting the same result

fading pulsar
#

Spigot 1.12.2 and Spigot API 1.12.2

shadow gazelle
#

?paste

undone axleBOT
lost matrix
shadow gazelle
#

That's what is run if it sees the player running one of the commands has an NPC selected

wild reef
# lost matrix Hm. Mind showing both registering and retrieving the service provider?

Registration:

Bukkit.getServer().getServicesManager().register(PlayerRegisterService.class, this.registerService, this,
                    ServicePriority.Normal);

Getting the service:

@Override
    public void onLoad() {
        System.out.println("known services: " + Bukkit.getServicesManager().getKnownServices());

        RegisteredServiceProvider<PlayerRegisterService> provider = Bukkit.getServicesManager()
                .getRegistration(de.schmidi.playerRegistration.services.PlayerRegisterService.class);
        if (provider != null) {
            this.playerRegisterService = provider.getProvider();
        }
    }
shadow gazelle
lost matrix
lost matrix
wild reef
#

oh okay

vivid zodiac
#

why that dont work ?

@EventHandler
public void onProjectileHit(ProjectileHitEvent e) {
    Entity entity = e.getEntity();

    if(entity instanceof Arrow){
        if(e.getHitEntity().getType() == EntityType.CREEPER) {
            e.getHitEntity().isDead();
        }
        }
}
wild reef
# lost matrix Registration in onLoad(), lookup in onEnable()
@Override
    public void onLoad() {
        System.out.println("Registering service");
        Bukkit.getServer().getServicesManager().register(PlayerRegisterService.class, this.registerService, this,
                ServicePriority.Normal);
        System.out.println("regostering done");
    }

like this right?

valid crag
#

isDead doesn't do what you think it does

lost matrix
valid crag
#

again, consider learning english

#

isDead doesn't make the entity dead

#

it asks the entity "are you dead"

#

and returns whether the entity is dead or not

vivid zodiac
#

i just try, how kill him ?

valid crag
#

.remove()

vivid zodiac
#

lol, and remove entity that correct english ? XD

lost matrix
#

You is ded now minecraftsword

vivid zodiac
#

but thx

fading pulsar
lost matrix
shadow gazelle
lost matrix
fading pulsar
#

?paste

undone axleBOT
shadow gazelle
#

At least in English Java understands lol

lost matrix
fading pulsar
lost matrix
vivid zodiac
shadow gazelle
lost matrix
lost matrix
shadow gazelle
#

w h a t

#

bruh

lost matrix
shadow gazelle
vivid zodiac
#

i can't just make damage ?

shadow gazelle
#

You can set how much damage something should do iirc

vivid zodiac
#

iirc ?

fading pulsar
shadow gazelle
valid crag
#

can you just not go and learn java and try again when you have even an inkling of a clue as to what the fuck you are doing

#

@reef wind I am the most racist man

proud basin
#

NNY so in my player data class what should I consider having in it?

valid crag
#

what kind of data do your players have

proud basin
#

Player UUID, Cooldown, Time

valid crag
#

what do cooldown and time represent

proud basin
#

Right now I have it so when the player joins their data is loaded

#

Cooldown is the name of the cooldown and time represents the time of their cooldown

valid crag
#

but the player can have more than one cooldown at a time, yes

proud basin
#

Yes

valid crag
#

assuming there is no other data, your PlayerData class would only have a single field, then

#

that field holding a Map<String, Long>

#

that is, Cooldown, Time

#

each player can have multiple cooldowns; each cooldown has a time

proud basin
#

Yes

#

but doesn't one of them have to be their uuid

valid crag
#

uuid is the key

#

you can put that in the playerdata class too

#

but it isn't necessary

#

we already know the UUID, because we use the UUID to get the data

proud basin
#

so am I just holding variables in the player data class?

valid crag
#

that is its purpose yes

wild reef
proud basin
#

ah ok

valid crag
#

it holds data

wild reef
#

still getting the same result

proud basin
#

before this

vivid zodiac
shadow gazelle
#

wtf

proud basin
#

map.put inserts data correct?

valid crag
#

yes

proud basin
#

now I'd have to use that when the player joins

valid crag
#

myes

vivid zodiac
#

that work but idk if u want to make it like this

proud basin
#

so their data can be added

#

but if I have PlayerData in the type parameter do I just pass the class through it?

#

oh yeah

valid crag
#

if you have PlayerData in the type parameter, it means that the values can only be instances of PlayerData

proud basin
#

I need to replace UUID to string

valid crag
#

no, use an UUID

#

you may be storing it as a string in the database, but you should convert it to an UUID in your object code

proud basin
#

what can I use to return a uuid with ResultSet?

valid crag
#

UUID.fromString(string)

shadow gazelle
#

So, anyone have any idea why it just doesn't get the updated config contents?

forest edge
#

I'm looking to add a single line to a player nametag using armor stands. Does anyone know of an in depth tutorial of how to do this? I've searched endlessly for answers. I've tested with passengers and various entities like slimes. If something does happen to space correctly, like a slime of size -1 with a small armor stand, I can still hit the slime to kill it. Do I need to make it invisible with packets? Not sure.

wild reef
#

Can anybody help me with my issue? It's still about registering a Service?

proud basin
#

So NNY this is how I should be putting data when the player joins ```java
DataManager data = map.get(e.getUniqueId());
map.put(UUID.fromString(res.getString("Cooldown")), data);

wild reef
# quaint mantle Elaborate please

So this is how I register my service:

@Override
    public void onLoad() {
        System.out.println("Registering service");
        Bukkit.getServer().getServicesManager().register(PlayerRegisterService.class, this.registerService, this,
                ServicePriority.Normal);
        System.out.println("regostering done");
    }

This is how I am trying to use it

RegisteredServiceProvider<PlayerRegisterService> provider = Bukkit.getServicesManager()
                .getRegistration(de.schmidi.playerRegistration.services.PlayerRegisterService.class);
        if (provider != null) {
            this.playerRegisterService = provider.getProvider();
        }

Problem is: the provider for the service when getting it is null, plugin is also running on the server and marked as a dependency in the plugin.yml

valid crag
#

don't call it a manager

#

it doesn't manage anything

#

it just holds stuff

#

and isn't Cooldown supposed to be a name and not an UUID

quaint mantle
#

@wild reef are you trying to make a cooldown manager?

proud basin
#

Im adding their data when the player joins though

wild reef
quaint mantle
#

wait wrong @ sorry

valid crag
#

when the player joins, you get the data from the db

proud basin
#

right

valid crag
#

then you take the player's uuid, which is a string in the database

#

and you convert it into an UUID

proud basin
#

oh so im actually not using it in the map?

valid crag
#

not yet

proud basin
#

ok

valid crag
#

UUID playerUuid = UUID.fromString(string from db)

proud basin
#

OH Wait

valid crag
#

then, you create a playerdata instance

proud basin
#

I just noticed what I did

valid crag
#

PlayerData data = new PlayerData();

#

then, you put the data in the map

valid crag
#

map.put(playerUuid, data)

proud basin
#

mhm

quaint mantle
valid crag
#

now your data is in the map

#

and you are done

proud basin
#

alright

#

idk why I put Cooldown

#

I guess I didn't pay attention what I typed

valid crag
#

next, you need to write some code in the PlayerData constructor

#

that actually grabs all of the cooldowns of the player

#

and puts them in the cooldown map

wild reef
#

Is anybody else familiar with registering a service from an other plugin?

proud basin
#

hold up

#

so now I should be making a new map

#

for the cooldown

valid crag
#

yes, in the PlayerData class

#

each player will have their own map

#

each player will have their own cooldowns

#

each player can have multiple cooldowns, and each cooldown must have data associated with it

#

hence; a map

proud basin
#

so I'd want String, Long

valid crag
#

yes

#

if your cooldowns had more data, you'd do the same thing you did with the player's data

#

you'd create a CooldownData class and make the map a <String, CooldownData>

#

but as the cooldowns only have one bit of data, the time, you can get away with just a long for now

proud basin
#

ok

quaint mantle
#

It should be a map of <UUID, Integer>

proud basin
#

no

#

Why would you use a Integer??

valid crag
#

if cooldowns were identified by an uuid, maybe

#

but i guess they're identified by name

#

which, kind of subpar, but whatever for now

proud basin
#

what do you mean they're identified by name?

valid crag
#

what is the String

proud basin
#

Cooldown

valid crag
#

yes, but what does it contain

proud basin
#

The cooldown name

#

I'm storing their uuid as a string in the db

valid crag
#

and that is the identifying part of the cooldown

#

one player can only have one cooldown with the same name

#

they can't have two "enderpearl" cooldowns

proud basin
#

yea

valid crag
#

which means they are identified by name

proud basin
#

I have also the CONSTANT prim key btw on the cooldown and time I think

valid crag
#

you mean constraint

proud basin
#

yea that

#

ah I'm wrong

valid crag
#

that'd imply that the player can have multiple cooldowns with the same name

proud basin
#

i have it on uuid and cooldown

valid crag
#

right

quaint mantle
#

Saving as a string can be corruptable in my experience

proud basin
#

What else would I be saving it as?

quaint mantle
#

UUID, Integer

#

UUID.parseUUID(uuidstring)

#

or UUID.fromString()

#

i forget

valid crag
#

that would imply that every cooldown had an unique id

#

which isn't reliable

quaint mantle
#

how?

#

it's the players uuid

valid crag
#

it is not

quaint mantle
#

UUID.fromString(playerUUIDString)???

proud basin
#

also NNY in my PlayerData constructor I'm just passing through their uuid

valid crag
#

yes, that is the player's uuid

#

which has nothing to do with the cooldown

#

what we have is effectively a Map<UUID,Map<String,Long>>

proud basin
#

wait was I suppose to do that?

valid crag
#

or Player -> {Cooldown Name -> Cooldown Time}

#

no, but that is what we have effectively

proud basin
#

Didn't think that was possible

#

ok

valid crag
#

you could have done that but it would have been gay

#

nesting maps and collections is frowned upon

#

it leads quickly into unreadable and unmaintainable spaghetti

#

for the playerdata constructor, figure it out

#

you need the data of the player there somehow

#

so that you can put it in the cooldowns map

#

arrange it somehow

#

pass the resultset to it or do a db query or whatever

proud basin
#

slow down man

#

one step at a time

quaint mantle
#

@proud basin what are you trying to do?

#

like the big picture

proud basin
#

Having a cooldown system with my sql db

valid crag
#

an object oriented cache for a db that stores cooldown information

quaint mantle
#

so are you trying to save cooldowns to the database instead of a map?

valid crag
#

he already has that part done

proud basin
#

Yea

valid crag
#

he's having problems with caching it in-memory in an object oriented way

quaint mantle
#

okay let me think of a solution

valid crag
#

the solution is to simply map the relational data into a reference based model

#

which he is well on his way with

quaint mantle
#

okay but the problem he is having is that you are telling him 13 different steps at once

proud basin
#

ok so I have both class done and the constructor

valid crag
#

he can just read slower

#

it's not like you need to read the entire book all at once just because it's already written down

quaint mantle
proud basin
#

alright so in my PlayerData class I have ```java
public class PlayerData {

public Map<UUID, PlayerData> playerMap = new HashMap<>();

UUID playerUUID;

public PlayerData(UUID uuid) {
    this.playerUUID = uuid;
}

}

#

oh wait

valid crag
#

that map doesn't belong in the playerdata class

proud basin
#

was I

#

was about to say that

valid crag
#

the cooldown map goes in the playerdata class

#

since the cooldown map is part of the player's data

proud basin
#

ok

#
public class CooldownData {

    String cooldownName;
    Long time;

    public CooldownData(String cooldownName, Long time) {
        this.cooldownName = cooldownName;
        this.time = time;

    }
}
``` CooldownData class
#

should I be making time equal to 0L?

#

in the constructor?

quaint mantle
#

no so when you want to set cooldown

#

you do map.put(player.getUniqueId(), new CooldownData("cooldownname", time));

proud basin
#

true