#help-development

1 messages Ā· Page 2260 of 1

sterile token
#

Shity sql

#

😔

subtle folio
#

Postgres >

ivory sleet
#

==> <==

#

Shity nosql

sterile token
#

Yeah you only know sql right

ivory sleet
#

šŸŒž

#

I know Mongo

sterile token
ivory sleet
#

Well I haven’t messed w/ it for some time

sterile token
#

How are you bussy?

ivory sleet
#

Yeah I’m going to sleep now

sterile token
#

lmao mi englis 10/10

ivory sleet
#

But I might be available tomorrow

sterile token
#

Oh you are sleeping >:sad:

#

OH ait

ivory sleet
#

Soon ye

sterile token
#

ait ait

#

dont go 1 sec

#

Have you worked with mongo pojos?

ivory sleet
#

Ye

sterile token
#

OH

#

You will save mi life tommorrow

ivory sleet
#

The mongo java lib is a bit overwhelming at times tho

#

Will I?

sterile token
#

I will put an alarm to get up together

ivory sleet
#

Lol

#

No don’t

sterile token
#

hahaha

#

I need you help

ivory sleet
#

You’ll need that extra sleep tomorrow

sterile token
#

3d fuck day with this

#

I cannot understand how doing the MongoCollection#UpdateOne

#

On a pojo class

#

Because i was casting the pojo into Bson

#

That is totally wrong

ivory sleet
#

Sounds very erroneous

sterile token
eternal night
#

Btw

#

Why does that not work for you ?

sterile token
#

I was reading the oficial docs to understand

#

But i will look that url

#

lmao i have atm opened 300 page son Opera > Chrome

quaint mantle
#

txt > db

sterile token
#

Txt is the wors thing you can do

quaint mantle
#

not true^^

pliant oyster
#

For some reason, player.getVelocity() is showing 0 for both X and Z even when I'm moving around, it only changes when I'm jump running, how do I get the actual velocity for X and Z?

sterile token
pliant oyster
#

hEH?

pliant oyster
#

the velocity should not be 0 if player is moving

sterile token
#

I think that the method

pliant oyster
sterile token
#

Is one the spigot api things i dont mostly like

#

If you want to get the distance the player move you can use that

#

I dont know what are you doing that why

pliant oyster
#

well I want to get the velocity X and Z because I want to know if player is moving left, right, forward or backwards

#

is there another way to check that other than checking player velocity?

sterile token
#

tho i aprecciate your trying to help

sterile token
#

I try that some months ago but for knowing which key was pressed either W, A, S, D

#

But i couldnt do it

pliant oyster
#

u cant check the keys the pressed lol

humble tulip
#

When ur jumping u got a velocity

#

But when walking, it's just like small teleportations ig

pliant oyster
#

breh

humble tulip
#

What are u tryna do?

pliant oyster
#

check which direction player is moving

#

like forward backwards left right

sterile token
humble tulip
#

In which event?

pliant oyster
#

I didnt use an event

#

I just did player.getVelocity()

sterile token
pliant oyster
#

getVelocity itself should literally tell u the velocity

#

whats the point in the method then

humble tulip
#

To tell u ur velocity

pliant oyster
#

I think I can use getFrom and getTo from playermoveevent

humble tulip
#

If u stop walking, ur character stops

pliant oyster
humble tulip
#

If u had a velocity, character would keep moving

pliant oyster
#

bru u dont get it

humble tulip
#

Pretty sure u don't

pliant oyster
#

I'm literally moving the character and velocity stays 0

humble tulip
#

Walking around is small tps

vital ridge
#

What would be a good way to remove enchantments from enchantsToAdd list in EnchantItemEvent? I can't just remove the enchantment from the hashmap since that gives me concurrentmodificationexception

pliant oyster
humble tulip
#

How does that not make sense?

pliant oyster
#

its dumb

#

nvm

humble tulip
#

Why don't u listen to playermoveevent?

sterile token
#

Instead of HashMap

#

Because when you are looping over a collection you cannot do some operations and then you get a ConcurrentException

#

Send your code please on

#

?paste

undone axleBOT
ornate patio
#

whats the convention for optional command parameters

#

[<quantity>] or [quantity]

sterile token
#

Okay

#

I use <> for arguments and if i add [] its because its optional

ornate patio
#

so the first one?

sterile token
#

Wait

#

Yeah

#

USe what fit you better

#

Oh lmao mongo docs are amazing

#

It doesnt explain how to updateOne the full Pojo document

#

Haha

#

Its so shity their docs

eternal night
#

Couldnt you do a replaceOne

#

With insert If missing option

wide dune
#

Anyone know why every time I apply even a minor amount of velocity I am insta kicked

#

that is the only error

sterile token
wide dune
#

its not a high amount of velocity either

sterile token
#

@eternal night sorry for ping but look this

#

So should be fine

#

what im doing..

#

Maybe is an issue related to the driver

#

I will check all

paper viper
#

You can’t remove from the map while iterating

#

You must use an iterator or stream

sterile token
#

wAL@pulse

#

aje

#

oh lmao

#

Orry my pc exploded

sterile token
fleet comet
#

@ivory sleet

sterile token
#

I dont know why in the example it doesnt cast it. But in my case it oblise me to cast it

sterile token
fleet comet
#

ooh

sterile token
#

Wait him for tomorro

#

What do you need?

fleet comet
#

im trying to figure out why i should use a di

sterile token
fleet comet
#

cause like im not sure how i add a di

#

im not entirely sure what it is

sterile token
#

?di

undone axleBOT
sterile token
#

You can start from there

umbral bear
#

Hi, i'm developing a chat moderator module for a plugin and i need to save regex strings to a config.yml file, but i keep getting compilation errors by gradle

#

i have enabled UTF-8 encoding

chrome beacon
#

?paste

undone axleBOT
fleet comet
#

im just super confused

umbral bear
#

i censored paths with *path*

chrome beacon
#

That's fine

sterile token
chrome beacon
#

Could you send your build.gradle

umbral bear
sterile token
chrome beacon
sterile token
paper viper
#

Verano, my only suggestion is to just keep researching. Sometimes you won’t get a super good answer here yet so just research your issue.

chrome beacon
paper viper
#

A lot of my own issues have been solved by linking all sorts of solutions together

#

You have to go on your own

sterile token
#

Allright 1 sec my pc is slow because 300 pages on explorer

chrome beacon
umbral bear
#

on what

chrome beacon
#

On what the issue is

fleet comet
#

@paper viper hey, so i still don't understand di's the spigot page wasnt that helpful. um i need help ;-;

paper viper
#

I’m on phone, but I guess I could give example

#

From my code

fleet comet
#

thank you so much

chrome beacon
#

From what I've seen you've already used it correctly

paper viper
#

Yeah you just need to remove the static singleton

#

That was what I was referring to btw

#

The JavaPlugin

fleet comet
paper viper
#

Your plugin main class extends JavaPlugin

#

You can just use that

#

And also DI is how you would do it

fleet comet
#

and i dont understand di's ;-;

paper viper
#

You used it correctly

#

It’s just you currently have both

fleet comet
#

where?

paper viper
#

Delete the static one

umbral bear
fleet comet
paper viper
#

You don’t need that

chrome beacon
#

Uh well wrong line but that variable

fleet comet
#

but if i delete it, theres going to be errors

paper viper
#

So fix the errors by replacing them with your plugin instance you passed into the constructor

chrome beacon
#

Use the instance variable instead of Cloud.plugin

fleet comet
#

huh

#

what instance var?

chrome beacon
#

CloudĀ instance;

#

That

fleet comet
#

i removed that

#

cause it didnt work

chrome beacon
#

But why

fleet comet
#

i cant access stuff

sterile token
#

@chrome beacon

My code its exactly the same as the one from mongo db github
In my case it oblise me to cast it whern in the example doesnt happen

public static void main(String[] args) {
        // Mongo connection
        MongoClient client = new MongoClient(new MongoClientURI(""));
        CodecProvider provider = PojoCodecProvider.builder().automatic(true).register(Vector.class).build();
        CodecRegistry codec = CodecRegistries.fromRegistries(MongoClient.getDefaultCodecRegistry(), CodecRegistries.fromProviders(provider));

        // Mongo database
        MongoDatabase database = client.getDatabase("test").withCodecRegistry(codec);
        MongoCollection<User> collection = database.getCollection("testing", User.class);

        // Mongo operations
        User user = new User("Alex", "alexito@gmail.com");
        user.setRole(User.Role.ADMIN);
        collection.insertOne(user);

        collection.updateOne(Filters.eq("name", user.getName()), (Bson) user); // Exception here       
    }
sterile token
#

Pulse any idea?

#

==> <==

chrome beacon
#

Also could you send the mongodb wiki youre following

sterile token
#

Ok

#

1 sec

fleet comet
#

@paper viperim so confused

paper viper
#

If you are confused, I recommend to at least learn about constructors and stuff

#

And some basic OOP

sterile token
#

OPP?

#

I never understand means

humble tulip
#

Pulsebeat what's the issue

#

Ur di is fine?

fleet comet
paper viper
#

No he is trying to implement it

fleet comet
#

idk what youre trying to tell me tho

paper viper
#

Ugh this is hard to explain on phone

fleet comet
#

private DeluxeMediaPlugin plugin;

onyx fjord
fleet comet
#

is this the thing?

chrome beacon
#

We're telling you to use the variable you created

onyx fjord
#

Aka what everyone hates

chrome beacon
#

Well the one that you removed

dusk flicker
#

OOP is the best

fleet comet
onyx fjord
hybrid spoke
#

sksksksk and i oop

fleet comet
#

but wait that one didn't work, i couldn't use anything on the addon. like get config or register command

sterile token
#

There olivo

fleet comet
#

@chrome beacon but wait that one didn't work, i couldn't use anything on the addon. like get config or register command

fleet comet
sterile token
#

ExamplePlugin example = getServer().getPluginMnager().getPlugin("ExamplePlugin");

chrome beacon
sterile token
sterile token
#

I will check it

fleet comet
#

ik

chrome beacon
fleet comet
#

thats horrible

sterile token
undone axleBOT
paper viper
chrome beacon
#

Also it's an addon

paper viper
#

He is just doing it within the same plugin

sterile token
#

Oh right so yeah

#

I didnt understand what he means

fleet comet
#

they*

sterile token
#

I thought he was trying to know how to access his addon plugin throw the Core one let say

sterile token
#

@chrome beacon so maybe the version is outdapted right, because the example repo was updated 7days ago

sterile token
#

I dont understand your english lmao

fleet comet
#

my pronouns are they/them

sterile token
#

šŸ¤”

chrome beacon
#

Veranos English is a bit limited it seems

fleet comet
#

i don't know how to explain this

chrome beacon
sterile token
#

I dont really know a s h**

paper viper
#

Nah it’s more like

sterile token
#

I dont know how i pas it with 80%

chrome beacon
#

Then how do you not know what pronouns are?

sterile token
#

šŸ˜‚

fleet comet
#

yikes

fleet comet
#

how about that

#

so since im not, you do not say he

#

or she. you say they/them

sterile token
#

Oh sorry

fleet comet
#

its fine

sterile token
#

You are a girl?

#

My fault

#

I got confused

fleet comet
#

LOL

paper viper
#

Lol

fleet comet
sterile token
#

Okay...

#

I dont know what other you can be

#

But meh dont worry

fleet comet
#

neither

#

so instead of saying he/him or she/her say they/them

sterile token
#

why

#

No need

fleet comet
#

??

sterile token
#

You should be either boy or girl

#

its simple

fleet comet
#

ur mom tought u bad

#

welcome to the us

sterile token
#

okay....

fleet comet
#

welcome to the complex world of not liking an oppisite gender lol

sterile token
#

too much help for today

fleet comet
#

LOL

sterile token
#

Oh you where meaning that

fleet comet
#

NO

#

thats sexuality

#

im talking about pronouns

sterile token
#

I dont understand you tho

fleet comet
#

im non-binary

#

im gonna die

paper viper
#

Jade take the internet with a grain of salt

sterile token
#

@paper viper translate me pelase im not understanding ==> <==

#

Sorry for ping

fleet comet
#

@paper viperback to the topic of this channel

sterile token
sterile token
#

Let him enjoy his vacations

#

😔

fleet comet
#

dude

#

i didnt fucking know

sterile token
#

jade

#

Do you have a tudio where u sell thingsĀ”

fleet comet
#

?

#

studio?

sterile token
#

Im interested on buying someone a custom tab api

fleet comet
#

dm me

chrome beacon
full forge
#

is there a specific directory i should be writing plugin data to

chrome beacon
#

Write to your plugin directory

sterile token
fleet comet
full forge
#

so ./plugins?

sterile token
#

You can get it via: getDataFolder()

full forge
#

ah nice thanks

sterile token
#

Your welcome

#

Also its recommend to learn tbe basics before start creating plugins

#

If not its really diff them

#

I say it cuz of personal experience

chrome beacon
full forge
#

i didnt bother looking in the docs since asking here is faster

#

and it might be better to write somewhere else than what i found in the docs

chrome beacon
#

That's fine

fleet comet
#

@chrome beaconheres what i did public Cloud cloud; in main class right, then set it to this onEnable, use Cloud as a paremter in the addonmanager construcer then send over that instance to the addon

chrome beacon
#

Sounds good

sterile token
#

He is doing static getter

chrome beacon
#

No

#

They're not

sterile token
#

Okay?

#

I dont have any this

#

On my main plugin class

fleet comet
#

@chrome beaconbut then i cant access anything from the addon, like for example the config

chrome beacon
#

Could you show how you try to access the config

fleet comet
#

@chrome beacon```java
package org.cloud.addon;

import org.eternitystudios.plugins.cloud.Cloud;

public class Addon {

Cloud instance;

public Addon(Cloud instance) {
    this.instance = instance;
}


public void addonMain() {
    instance.getConfig();
}

}

#

but getConfig doesnt work

unkempt peak
fleet comet
chrome beacon
#

Ah I see the issue

fleet comet
#

?

chrome beacon
#

Is that addon in another project

fleet comet
#

yes

pseudo flower
#

is there a way to play the sound not through the players, but on the server itself? I'm just adapting the plugin for 1.7 and there is a problem that 1.8 and higher and 1.7 have different return values of players on the network

chrome beacon
fleet comet
#

no

chrome beacon
#

Gradle?

full forge
fleet comet
chrome beacon
full forge
#

are you calling addonMain and its not giving you anything or something

fleet comet
#

addonmain is working

#

the method doesnt exist

#

see

fleet comet
chrome beacon
#

If that doesn't work try File > Invalidate Caches and restart

fleet comet
#

@chrome beaconits not that

#

the method just isnt there

#

and its up to date

#

is it because the instance is type Cloud?

chrome beacon
#

Actually wait did you add Spigot to the project

vocal cloud
#

Does it extend something that has getConfig?

chrome beacon
fleet comet
#

WAIT

chrome beacon
#

Let me handle this

fleet comet
#

should i change the type from Cloud to JavaPlugin in the addon constructer?

unkempt peak
#

no

chrome beacon
#

^

#

Is Spigot in your addon project?

#

Make sure that it is

#

And if you're on 1.18+

#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

fleet comet
#

its 1.19

#

so that wont work

unkempt peak
#

It's the same for 1.19

fleet comet
#

oh\

#

i dont have the spigot-api built tho

unkempt peak
#

You will have to build it with buildtools then

fleet comet
#

that takes forever

chrome beacon
fleet comet
#

can i just make another addon project with maven?

fleet comet
#

i used maven for the cloud project

unkempt peak
#

well that's your solution

chrome beacon
#

Ah use maven for addon

#

That will make things much easier

fleet comet
#

okay

chrome beacon
#

Anyways your issue is that Spigot is not in your project so it can't find getConfig

sterile token
#

You and the other man where shiting me

chrome beacon
#

It works yes

sterile token
#

And what i sent was correct....

chrome beacon
#

We never said it didn't work

#

We said it was bad

sterile token
#

WHy

#

There is no other way of getting a plugin instance from another plugin if you are using DI

#

šŸ˜‚

chrome beacon
#

It's not another plugin

#

šŸ™ƒ

sterile token
#

So they are diff plugins

#

šŸ˜‚

fleet comet
#

not plugins

#

projects

sterile token
#

Ohh ok

fleet comet
#

stupid

chrome beacon
#

It's an addon system using reflection to pass the plugin instance to the constructor

fleet comet
#

/jk

sterile token
#

Oh nice vocabulary

#

Reported

#

Hahaha

#

Also we are trying to help and you are shiting people from a non reason

#

So in fact you dont need help

#

Do it alone if you know everything...

chrome beacon
#

Verano I think you should take a break and do something else for a bit

sterile token
#

And only rename the clas and modify something thingand doesnt ork :/

chrome beacon
#

Take a break and come back to it later

sterile token
#

😔

#

I would like but i cannot

#

My friends are dm all time

#

When you finis ht eplugin and everytime

#

Nomatter if i tell them to be pacient

#

Soryr man

#

I know that you dont want to be listening me

#

But idk

#

it was something i need to say it

#

and take out from me

#

Oh mnice food is in the door i eat calm don and come bac

#

Thanks for all and see you later

chrome beacon
#

I'll get some sleep now since it's almost 1am

onyx fjord
#

Yeah

#

Same

sterile token
#

best wishes for all

#

See you tomorrow

onyx fjord
#

See ya

buoyant viper
#

šŸ³ļøā€šŸŒˆ

fleet comet
#

@buoyant viperhehe

fleet comet
humble tulip
river oracle
#

I'd just use a command framework already out there it saves you thr pain

dusk flicker
#

you just take your commands and just SHOVE them in /j

river oracle
#

E.g. I use lamp and I think acf Is a big onr

fleet comet
humble tulip
#

Then let the addons call a registerCkmmand method found in the plugin that registers the command into the commandmap

river oracle
river oracle
#

Lamp, acf etc I'm pretty sure some others in here have there own too

#

I never use bukkits command api

fleet comet
#

how would i use lamp in this case?

#

@river oracle

river oracle
#

Just have a register command in your core

fleet comet
#

a register command? or a register method?

river oracle
#

If you want to learn the framework look at examples and ask questions in the discord he's very helpful

river oracle
fleet comet
#

okay

#

what should the method do?

river oracle
#

Register a command

fleet comet
#

but the codes on the addon? how would i do that

river oracle
#

I'm not on my computer nor do I have access on it so I can only point you in directions no code

fleet comet
#

ik

river oracle
#

You'd call core.register(Object clsss)

fleet comet
#

whats the object?

paper viper
#

Some command node

river oracle
#

The command

#

Object is the most generic in Java

fleet comet
#

ik

#

but like

#

how can object be code?

river oracle
#

Do you not know what an object is?

dusk flicker
#

oh god

river oracle
fleet comet
dusk flicker
#

?learnjava

undone axleBOT
fleet comet
#

oh its an instance lol

dusk flicker
#

i mean

#

thats a part of it

river oracle
#

No it's an object

#

It could be an instance but doesn't have to be

fleet comet
#

thats what i meant

#

so the object should be the instance of the command method?

#

wait im confusing myself

humble tulip
#

When u register the object, it looks for all methods with @Command or SubCommand

#

And registers those methods as commands

#

The args or the method are tje args of the command

#

Args of the method*

fleet comet
#

?

humble tulip
#

?

humble tulip
#

You don't have to extend a class to make a command class

#

You just annotate the method

#

And then register an instance of the class

fleet comet
#

can i have an example?

river oracle
#

Lamp has official examples on there github

fleet comet
#

that adapt to this situation?

humble tulip
#

class CommandClass {
@Command("fly")
public void toggleFly(Player player) {
player.setFlying(!player.isFlying)
}
}

#

That's typed on phone

#

But like thay basically

#

When u do /fly it toggles fly for the executor

fleet comet
#

OHH

#

it should be another class with the command?

humble tulip
#

U register an instance of commandclass

fleet comet
#

as an object?

humble tulip
#

U can have multiple methods with different commands

#

Well yeah, all instances are objects

fleet comet
#

oh yeah lol

#

im dumb

river oracle
#

You can also annotate the top of the class with the command annotstion and use the default annotations for default with no args

fleet comet
#

what annotations

#

sry im dumb

river oracle
fleet comet
#

oh yeah

bold bough
fleet comet
#

@river oracleim gonna take a break, im so tired

delicate lynx
dusk flicker
#

oh my god the file formatting is horrible in those two files

bold bough
#

Uch thx,
I had to delete it by mistake

bold bough
bold bough
#

I have one more small problem. After overwriting the config and saving and restarting the server, the config is overwritten back and nothing is saved https://pastebin.com/sURPVEid

kind hatch
#

You are constantly overwriting sections in your #onEnable() method.

#

Essentially giving off the impression that nothing is saving.

bold bough
#

and how to fix?

kind hatch
#

Don't overwrite the sections in the onEnable method. Just make changes when you need to.

fleet comet
#

@river oraclewhat should the method in the main plugin look like?

#

@humble tulip?

#

nvm

echo magnet
#

Is there a way to send a webhook request when a certain resource is updated?

primal kite
#

is there a better way to get the net.minecraft chunk then using Chunk Chunk chunk = ((CraftChunk)event.getChunk()).getHandle();
NMS is not my strong point

paper viper
#

I don’t think there is a better way

#

That’s the horror of CraftBukkit lol

sterile token
#

Any tab api with heads that you can recommend?

river oracle
paper viper
#

Tab API with head?

#

Wdym

primal kite
# paper viper That’s the horror of CraftBukkit lol

more like horror of NMS but it is my only option. would you be able to point me to a tutorial or something to work around the crap with avoiding import org.bukkit.craftbukkit.v1_19_R1.CraftChunk; to try and make it compatible with as many versions as possible?

sterile token
#

Tablist that allow adding in lines heads

#

Basically an api for tablist that allow to add player heads into the lines

river oracle
paper viper
#

Try to always use the API, as it will be the best compatability

sterile token
#

Another dought do you recommend scoreboard api which uses NMS?

primal kite
paper viper
#

Here’s some tips

#

Make an interface with methods that you will call for NMS. Then make separate modules for each NMS version that has classes that implement the interface

#

And provide implementation

sterile token
#

+1 to pulse recommendations

iron glade
#
PlayerProfile profile = p.getPlayerProfile();
   profile.setTextures(target.getPlayerProfile().getTextures());
   profile.update();
   p.setPlayerProfile(profile);```
Any idea why this is not updating the player's skin?
primal kite
ornate patio
#

is camelCase or dash-space convention in config.yml

primal kite
# paper viper Wdym

i can coded it all individually, per version, but am lacking the java-foo to get the server version that will load the right nms class part.

paper viper
#

Ah

#

Let me show you

#

See what I did

#

I used the Minecraft version as my package

kind hatch
#
String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];```
This is one way to do it. People criticize it because it may become unreliable in the future, but it works well for now.

It'll return values like 

v1_17_R1
v1_18_R1
v1_18_R2
v1_19_R1

paper viper
#

Then I use reflection to load the class

#

And get the implementation

carmine nacelle
#

Can I store multiple things in an item's metadata? call it like "info" with a list of items inside it

carmine nacelle
#

like..

kind hatch
carmine nacelle
#

metadata

#

data stored inside the item

paper viper
#

Yeah just do PDC

kind hatch
#

There is metadata you can use, but it won't be persistent.

primal kite
carmine nacelle
#

such as

 List<MetadataValue> hiveMetaData = beehive.getMetadata("newHive");
paper viper
#

I then shade the separate NMS modules and stuff

#

For example, com.example.something.[version].NMSImplementation

#

And then example package class for implementation would be

#

com.example.something.v1_19_R1.NMSImplementation

#

I’m typing on phone so hopefully I didn’t mess up

primal kite
#

fyi... i hate the chunk.{random letter}() changing with each version....

ancient plank
#

NMSImplementation looks like NM Simplementation to me KEKWW

primal kite
#

NMS = No Minecraft Simplicity

paper viper
#

Lol

carmine nacelle
#

Anyone know an easy way to stream an item's lore and get the value if part of the string equals something?

echo basalt
#

Hey, I'm having some stupid issue with scoreboards.

Basically, I copied a scoreboard example from a gist online, did some modification to allow it to write a StringList and all lines are coming out blank

Code: https://paste.md-5.net/tekagifato.java

lost matrix
#

?pdc

sterile token
#

How does maven download the dependencies?

#

Anyone know the request format

lost matrix
sterile token
#

Yeah i know but the params

lost matrix
#

There is probably a different file transfer protocol as well

sterile token
#

Im replicating a simple maven server

lost matrix
sterile token
#

Lot of problems with Nexus

#

Im tired of nexus shity

eternal night
#

Try jfrog.i guess ?

#

Coding that yourself sounds like the dumbest idea in a while

sterile token
#

But our goal is to our own dashboard

eternal night
#

You can write a dashboard over an artifactory

lost matrix
eternal night
#

No need to reinvent the entire wheel.when you only wanna change tires

sterile token
#

I cannot use the normal ones

#

Because their need auth

lost matrix
sterile token
#

Hmn but other can access so

#

šŸ¤”

#

I need to access only throw my dashoard auth

#

But dont allow others to use the maven dashboard

eternal night
#

You mean a dashboard that magically for you doesn't habe auth ?

lost matrix
#

What even is a "maven dashboard"?

eternal night
#

But is available to the public

#

I presume just the web interface of nexus ?

sterile token
#

The maven dashboard is the one that have Nexu for example

#

Yeah i want to have 1 dashboard

#

Which contains maven things

lost matrix
#

smh

#

And you want the dashboard to be publicly available?

sterile token
#

I want to my dashboard be public but it must ask for authentification

#

And my dashboard should contains the maven one

lost matrix
#

Well thats just the default behavior of nexus. You usually have an admin account.

sterile token
#

I kno but i want to connect neus dashboard to my dashboard

#

Im think im not explaning

eternal night
#

You already have a dashboard but want to incorporate nexus into it ?

sterile token
#

And i cannot use nexus one, because it ask for authentfication

#

And i just want to use 1 auth system

#

So once you login into the dahboard you can either use my dashboard or nexus one

eternal night
#

Well you will always have to auth with nexus or another maven repo server. Your dashboard should be the one responsible for that.

#

Because writing your own maven server for this is synonymous with ending your project here unless you have a large developer team that can only work on that

cedar oyster
#

Hello. When I run public static MultiverseCore core = (MultiverseCore) Bukkit.getServer().getPluginManager().getPlugin("Multiverse-Core");, I get an error in the console saying :
Caused by: java.lang.ClassCastException: class com.onarandombox.MultiverseCore.MultiverseCore cannot be cast to class com.onarandombox.MultiverseCore.MultiverseCore (com.onarandombox.MultiverseCore.MultiverseCore is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @76eb238a; com.onarandombox.MultiverseCore.MultiverseCore is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @7050f8cc)

Does anyone know what would be causing this?

eternal night
#

Don't shade the multiverse API into your jar

cedar oyster
#

I didn't think I was... I'll check again

eternal night
#

That is usually the cause of these

cedar oyster
#

haha, that was it!

#

Thanks so much

eternal night
#

Nice XD

ornate patio
#

I'm trying to do some stupid thing with nms, and it requires me to somehow call a superclass's method indirectly

#

for example if AbstractHorse extends Animal, Horse extends AbstractHorse, and SuperiorHorseEntity extends Horse

#

I want to be able to call Animal#aiStep() from SuperiorHorseEntity#aiStep()

#

and skip over Horse and AbstractHorse

#

is this possible?

quaint mantle
#

How can i make an npc teleport randomly to any player (in a radius defined by me, that radius would be the map) and when he (the npc) is with the player there is a possibility that the npc will teleport to the front, back or to the sides of player and walk together with the person and after some time the np will teleport to another person and do the same? Help please

sterile token
lost matrix
torn oyster
#

how would i find the first available number within a range

#

for example, i have numbers 1, 3, 4, 5, 6

#

i want to get the first available number which is 2

#

and not 7

#

and if i had a range like 250 - 400
and had numbers 250, 252, 253, 254 ... 399 i would get 251

#

nevermind

lost matrix
stark wedge
#

I am trying to write a command that allows a user to grab the config file and load that memory into the server. Meaning if a server admin edits the config in the file manager, they can run a command /configreload and it will update the plugin with its new memory from the config. Everywhere I read it says just use reload config, but no matter which option I try, I just can't get it to work. Any help would be appreciated!

public class ConfigReload implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Player p = (Player) sender
        Main.plugin.reloadConfig();
        p.sendMessage(Main.plugin.getConfig().getString("Messages.Config"));

        return true;
    }
}```
quaint mantle
lost matrix
stark wedge
lost matrix
stark wedge
#

if you want, I can add the entire plugin to a repo on git and you can take a loot at it, but really I thought that is all I needed.

lost matrix
lost matrix
quaint mantle
lost matrix
stark wedge
# lost matrix Nothing happens in the sense that you get the old config entry sent?

For instance

First:
Original Blacklisted Words

  • test
  • anothertest

Second:
Plugin works fine and bans those words

Third:
I edit the config in the file manager to added

  • test
  • anothertest
  • anotherexample

Fourth:
I run the /configreload command

Fifth:
I receive the message it reloaded.

Sixth:
That data in the server still only has the two original words, not the added ones.

But if I reload the server or reload the plugin, the data is added to the server memory

lost matrix
stark wedge
#

Sorry if that didn't make sense šŸ˜…

#

This is the chat filter code

#
public class ChatFilter implements Listener {

    private static List<String> banned = Main.config.getStringList("Blacklisted");

    @EventHandler
    public void onMessageFilter(AsyncPlayerChatEvent e) {
        Player p = e.getPlayer();
        String msg = ChatColor.stripColor(e.getMessage());

//        if(p.hasPermission("moderationplus.chat.bypass"))
//            return;
        for(String bWord : banned) {
            if(msg.contains(bWord)) {
                p.sendMessage(Main.plugin.getConfig().getString("Messages.FilterTrigger"));
                e.setCancelled(true);
            }
        }
    }
}
#

wait

#

...

lost matrix
#

Yes

stark wedge
#

is it because the list is static.,

#

I honestly dont even know why I made that static in the first place.

lost matrix
#

It doesnt matter if its static or not.
Its in memory and it wont change unless you edit it.
Doesnt matter if somewhere you edit your config. You need to load the
data from your config into your list again.

stark wedge
#

hmm.. and how would I go about doing that?

lost matrix
#

First of all: This list does not belong here.

stark wedge
#

Okay

#

Im guessing it would go in the onEnable?

lost matrix
#

Your listener should only have on concern: Listening to events
Holding data should be done in a manager class which should be a singleton as well. Let me write you an example.

stark wedge
#

okay thank you so much homie

quaint mantle
#

Wisconsin šŸ§€

stark wedge
quaint mantle
ornate patio
#

dude i really dont feel like writing 500 lines for private methods and fields

lost matrix
# stark wedge okay thank you so much homie

First of all your manager:

public class FilteredWordManager {

  private final Set<String> bannedWords = new HashSet<>();

  public boolean isBanned(String word) {
    return this.bannedWords.contains(word);
  }

  public void reloadFromConfig() {
    this.bannedWords.clear();
    List<String> words = Main.config.getStringList("Blacklisted");
    bannedWords.addAll(words);
  }

}

Then the usage:

public final class SpigotSandbox extends JavaPlugin {
  
  private final FilteredWordManager filteredWordManager = new FilteredWordManager();

  @Override
  public void onEnable() {
    YourReloadCommand command = new YourReloadCommand(filteredWordManager);
    YourListener listener = new YourListener(filteredWordManager);
    
    // Register command an listener
  }

}

This is a very important design principle.
Your manager classes have only one single instance. And this instance is used everywhere.
This means you need to pass this instance through the constructor of your other classes.

In this case we pass the same filteredWordManager to our listener and to our command.
This means if the command class changes the manager then the listener "sees" the same changes
because it uses the same instance.

#

So your listener uses filteredWordManager.isBanned() and your command uses filteredWordManager.reloadFromConfig()

dim palm
#

How can a fix NullPointerException

lost matrix
#

But both access the same Set

stark wedge
lost matrix
ornate patio
#

😢

#

i really have to do this reflection then

stark wedge
lost matrix
#

Uh. New color indicators for chat in 1.19.1. Noice.

lost matrix
stark wedge
#

is that what the private final FilteredWordManager filteredWordManager = new FilteredWordManager(); is used for in the main class?

#

sorry im trynna catch up on everything and make sure im getting this all

lost matrix
stark wedge
#

would making a getter function in the main be a liable way to continue with it?

Like create a function that accepts a string and the returns a boolean

#

and then call that function in all the classes?

lost matrix
#

No this has no place in your JavaPlugin class. Your JavaPlugin class should only hold your managers.
What you could do is create a getter for your FilteredWordManager in there. Not as clean as the constructor injection but also viable.

lime moat
#

Very dumb question... how can I make my config.yml have spaces? Like this: yml mines-message: "&d&lRaidTheMine Mines &e/mines reset <mine>&f: Resets the specified mine &e/mines tp&f: Teleports you to the mines "

#

In theory, I want each line to be their new line in game.

waxen plinth
#

\n?

lost matrix
#

Either make a list or insert a newline character \n

lime moat
#

\n worked, thanks!

lost matrix
stark wedge
#

okay im trying to add the constructor injection into my config reload command class but I guess im a little confused as to how I still use it to run the isBanned method.

#

im sorry if im overloading you with questions xd

#

Wouldn't I want the new instance in Main of the filteredmanager to be public so I can access it everywhere?

#

as in that instance

ornate patio
#

so i never really understood

#

what even is NMS

#

is it code developed by mojang?

lost matrix
ornate patio
#

if so, why are there class names that start with "Spigot" in it

#

or methods like "getBukkitEntity"

lost matrix
stark wedge
#

OH

#

OKAY

#

thank you so much bro

lost matrix
ornate patio
#

oh, so its more like mojang code but changed a little by spigot?

lost matrix
#

Yes

#

"a little"

ornate patio
#

mm

#

alright thanks

stark wedge
#

reload*

lost matrix
stark wedge
#
public class ChatFilter implements Listener {

    private final FilteredWordManager wordManager;

    public ChatFilter(FilteredWordManager wordManager) {
        this.wordManager = wordManager;
    }

    @EventHandler
    public void onMessageFilter(AsyncPlayerChatEvent e) {
        Player p = e.getPlayer();
        String msg = ChatColor.stripColor(e.getMessage());

        if(this.wordManager.isBanned(msg)) {
            p.sendMessage(Main.plugin.getConfig().getString("Messages.FilterTrigger"));
            e.setCancelled(true);
        }

    }
}```

```java
public class ConfigReload implements CommandExecutor {

    private final FilteredWordManager wordManager;

    public ConfigReload(FilteredWordManager wordManager) {
        this.wordManager = wordManager;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Player p = (Player) sender;
        this.wordManager.reloadFromConfig();
        p.sendMessage(Main.plugin.getConfig().getString("Messages.Config"));

        return true;
    }```
#

also im not trying to copy your code.. just wanting to learn how this works, and then I can tweak and change later on

lost matrix
#

Currently you are loading from the same config again

stark wedge
#

wouldn't running the config reload command update the instance so that the chat filter will work with the new instance?

#

ohhh

lost matrix
#

reloadFromConfig gets the FileConfiguration from your main class and loads its content into the manager.
If you dont reload the FileConfiguration then you can call reloadFromConfig as much as you want but it will
always just get whatever is in this FileConfiguration.

So if you want to change the managers content you need to first let spigot update the FileConfiguration from disk
and afterwards you can call reloadFromConfig.

stark wedge
#

wait I think I get what your are saying

#

so I really just put Main.plugin.reloadConfig(); right before the reloadFromConfig file

stark wedge
#

ahh

#

okay

#

you have taught me more than I thought I was going to learn

#

File Configuration has been troubling for me.

lost matrix
#

It also took me some time to really understand the differences of File FileConfiguration YamlConfiguration and when which
data is on disk and when it is in memory.

stark wedge
#

yeah supper confusing

#

annnnd it broke completely

#

the chat filter doesn't even work anymore lmfao

lime moat
#

Hello, I have this as a tab completer: ```java
private static final String[] COMMANDS = {"reset", "tp"};
private Main main;

public Mines(Main main) {
    this.main = main;
}

@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
    final List<String> completions = new ArrayList<>();
    StringUtil.copyPartialMatches(args[0], Arrays.asList(COMMANDS), completions);

    Collections.sort(completions);
    return completions;
}``` How can I make a second one? Right now when I use `/mines` it shows `reset` or `tp`, but when I choose `reset` I want a few more tab completers to appear.
#

Do I just do this StringUtil.copyPartialMatches(args[1], Arrays.asList(COMMANDS2), completions);

lost matrix
#

So look at your isBanned(String) implementation

stark wedge
#

I mean even if I just type the word

#

it still isn't cancelling it

lost matrix
#

Add debug messages to check the state of your code.

lost matrix
stark wedge
#

would I say that it has to equals true when checking

#
if(this.wordManager.isBanned(msg) == true) {
            p.sendMessage(Main.plugin.getConfig().getString("Messages.FilterTrigger"));
            e.setCancelled(true);
        }
lost matrix
stark wedge
#

okay

lost matrix
#

A boolean expression is evaluated to either true or false
So
this.wordManager.isBanned(msg)
-> true

And
this.wordManager.isBanned(msg) == true
-> true == true
-> true

Its just one more step that does add no logic

stark wedge
#

yeah ran the debug and not getting ANYTHING after the if statement.

#

hmm

lost matrix
stark wedge
#

nope

lost matrix
#

show your listener method

#

*with the debug message

stark wedge
#

wait this might sound dumb

#

but when you debug your plugin, do you just have it shoot different debug messages out to you in game like a p.sendMessage("Debug 1")

lost matrix
#

You can use the logger or System.out
I would advise against messages to a player

stark wedge
#

okay let me try with logger real quick

lost matrix
#

Example:

  public void reloadFromConfig() {
    this.bannedWords.clear();
    List<String> words = Main.config.getStringList("Blacklisted");
    System.out.println("Loaded the following banned words:");
    words.forEach(System.out::println);
    bannedWords.addAll(words);
  }

This will show the loaded messages in console

lime moat
stark wedge
#
public class ChatFilter implements Listener {

    private final FilteredWordManager wordManager;

    public ChatFilter(FilteredWordManager wordManager) {
        this.wordManager = wordManager;
    }

    @EventHandler
    public void onMessageFilter(AsyncPlayerChatEvent e) {
        Player p = e.getPlayer();
        String msg = ChatColor.stripColor(e.getMessage());

        System.out.println("Debug 1 ");
        if(this.wordManager.isBanned(msg)) {
            System.out.println("Debug 2 ");
            p.sendMessage(Main.plugin.getConfig().getString("Messages.FilterTrigger"));
            System.out.println("Debug 3 ");
            e.setCancelled(true);
            System.out.println("Debug 4 ");
        }

    }
}

#

And only getting the Debug 1 message in console

lost matrix
lime moat
#
        if(args[0].equalsIgnoreCase("reset")) {
            StringUtil.copyPartialMatches(args[1], Arrays.asList(COMMANDS2), completions);
        }``` Like this?
lost matrix
stark wedge
#

ok

lost matrix
lime moat
#

What's a better way of doing this?

stark wedge
#
public boolean isBanned(String word) {
        System.out.println("Debug 5 ");
        return this.bannedWords.contains(word);
    }```
#

with this I am getting the debug 5 message

somber hull
#

Can someone help me and tell me the process i should go about cleaning up this code. I expect ill have to redo the complete insides, but im really struggling on figuring out where i should start. https://github.com/Silent-Program/BetterSpawners Its really old code that works but its all duct taped together. And i want to make it much more concise. Having a proper api would be nice, i just have no idea how to implement that (i have an api folder but its misleading)

GitHub

Contribute to Silent-Program/BetterSpawners development by creating an account on GitHub.

lost matrix
stark wedge
#

my apologizes

#

[05:18:21 INFO]: [ModerationPlus] [STDOUT] Checking: stupid
[05:18:21 INFO]: [ModerationPlus] [STDOUT] Filtered words: []
[05:18:21 INFO]: [ModerationPlus] [STDOUT] Is filtered: false

#

my yml

Blacklisted: # Add any words you wish to blacklist from your server. Make sure to add a TWO space indent and "-" before each word.
  - stupid
  - dumb
#

so its in there

lost matrix
#

This means your filtered list is empty

stark wedge
#

the config says its not empty?

#

so it must not be reading that config

lost matrix
lost matrix
stark wedge
#

yes

lost matrix
stark wedge
#
public void onEnable() {
        plugin = this;
        config = getConfig();

        // Plugin startup logic
        System.out.println("[ModerationPlus] has been enabled!");

        //register events
        pluginManager = getServer().getPluginManager();

        pluginManager.registerEvents(this, this);
        pluginManager.registerEvents(new ChatFilter(filteredWordManager), this);
        pluginManager.registerEvents(new SignFilter(), this);

        //register commands
//        getCommand("blacklist").setExecutor(new SetBannedWords());
        getCommand("configreload").setExecutor(new ConfigReload(filteredWordManager));

        plugin.getConfig().options().copyDefaults();
        plugin.saveDefaultConfig();
        plugin.saveConfig();
        filteredWordManager.reloadFromConfig(); ```
lost matrix
#

Ok looks fine

stark wedge
#

ok

#

running the other debugger now

lost matrix
#

Then lets see the debug result from the reloadFromConfig method

lost matrix
#

And not make a mutable field (gui) public

stark wedge
#

[05:22:35 INFO]: [ModerationPlus] [STDOUT] Loading the following words:
[05:22:35 INFO]: [STDOUT] [java.util.ArrayList] stupid
[05:22:35 INFO]: [STDOUT] [java.util.ArrayList] dumb

#

interesting

#

wait

#

it works now

#

what

#

lmfao

#

I must have had a typo in my reload config metho, and whenI just re-wrote it to add the debug, it fixed it? šŸ¤·šŸæā€ā™‚ļø

#

lol

lost matrix
#

This will filter out entire sentences.

stark wedge
#

ahh okay

#

I think I had something like this at the beginning of me coding this

lost matrix
#

You can see here how very important the naming of your variables/methods is.
Instead of having to deal with "p" "l" "i" or other nonsense, you can read this like a book

if(sentence.contains(bannedWord))

You dont even need to know how to program in order to understand this code

stark wedge
#

works perfectly, thank you!

somber hull
somber hull
lost matrix
somber hull
#

a

#

question

#

what would the downside to making those namespaced keys static

#

(Im one of those guys that doesnt understand static very well)

lost matrix
somber hull
#

idk y im replying lmao

somber hull
lost matrix
somber hull
#

Why?

#

Id like to understand better

#

thats why i ask lol

lost matrix
#

Exposing mutable fields breaks their encapsulation.
And it shouldnt be there because that violates the separation of concerns principle.
This JavaPlugin class is just a mess of scrambled objects. There is no real defined purpose for your class.

#

Matter of fact the namespaces should also not be in there

somber hull
#

Yea ik, thats why i said i need to redo the whole thing lmao

lost matrix
#

Yes

somber hull
#

Alr

lost matrix
#

DataManager is well placed here.
Just missing a GuiManager so the gui doesnt randomly float in there.

somber hull
#

wdym

#

What would GuiManager do?

lost matrix
#

Manage guis...

somber hull
#

Well

#

Isnt that what "SpawnerGui" does

#

poor naming i know

lost matrix
#

let me check what that class actually does

#

Are you using freaking tabs for spacing??

somber hull
lost matrix
#

Yes those are tabs. Its just an opinion but i would def change this to 4 spaces.

somber hull
#

lmao why?

#

tabs are one button

lost matrix
#

Everything is package private in here. No reason for that.

lost matrix
#

Just press tab and get 4 spaces

#

*If you IDE isnt total garbage

somber hull
lost matrix
#

Eclipse?

somber hull
somber hull
lost matrix
somber hull
#

huh

#

like what does that entail

#

diference from doing that and doing private?

crisp steeple
#

only other classes in the same package can access them

somber hull
#

Or public?

#

Is that actually a thing?

#

That seems so weird

lost matrix
#

effectively no. But it should be private for consistency sake.

somber hull
#

Ok ye

#

should i also make them all final?

#

intellij suggested it and it looks correct

lost matrix
#

Also this is a tiny plugin. Ive looked throgh all classes and you can probably just rewrite it from scratch in 2-3 hours.

lost matrix
somber hull
#

Should i redo from scratch?

lost matrix
# somber hull Ik, im just dreading it

You should never use configs on runtime like that

        for (String i : plugin.getConfig().getConfigurationSection("gui.groups.custom-groups").getKeys(false)) {
            if (plr.hasPermission("betterspawners.group." + i)) {
                group = "gui.groups.custom-groups." + i;
                break;
            }
        }
somber hull
lost matrix
somber hull
#

thank you ill read that rn

#

rq

lost matrix
# somber hull is that on runtime?

You should load this kind of data a single time into properly named variables when the server loads.
After that you dont use the config at all but rather your properly named variables.

eternal oxide
#

Well

lost matrix
eternal oxide
#

This data yes, but using the config is not terrible. Its just a Map backed data set.

#

Performantly its not bad. Design wise its terrible

lost matrix
eternal oxide
#

Yes, all access should use enum constants

somber hull
#

ok

#

@lost matrix Im gonna redo it

#

But im gonna need some help with naming conventions

#

And what to name and where to put my classes

lost matrix
quaint mantle
#

Horrible

quaint mantle
#

#general message

#

Use mine šŸ™‚

quaint mantle
#

My code style

#

Literally so sexy

somber hull
#

Oh

#

ew

#

wtf

#

no

quaint mantle
#

Are you crazy

somber hull
#

Yes

quaint mantle
#

I can tell

#

This is way better than google's style conventions

#

Fuckin two spaces

desert loom
#

that's some weird formatting

lost matrix
quaint mantle
#

Ok well mine still better so

lost matrix
somber hull
#

smile, you can see my project structure

#

Could you help me reorder stuff

lost matrix
#

Im gonna go work out now... maybe later

quaint mantle
#

wanna see mine

somber hull
#

one thing

#

I changed the gui class to GuiManager

#

Cause thats what it is

#

What package should i put that in?

lost matrix
somber hull
#

k

lost matrix
#

In a properly named one

somber hull
#

ok

#

imma stop asking questions

#

and just start

#

if (!itemStack.hasItemMeta() || (!itemStack.hasItemMeta())) return;

#

i just found this in my code lfmao

quaint mantle
#

if (itemStack.getItemMeta() == null)

#

intellij hates hasItemMeta

#

i also hate asserting

eternal oxide
quaint mantle
quiet ice
quaint mantle
#

If it is not null

quiet ice
#

Yes, but it is likely to Not be null