#help-development

1 messages · Page 2012 of 1

cosmic pelican
#

Yeah.. tried a lot of things. It's just math but that isn't exactly my strong suit.

simple anvil
#

i do kinda like math

cosmic pelican
#

You will not like this math KEKHYPER

simple anvil
#

why

hexed hatch
#

Get the difference of the starting yaw and ending yaw, and the same for the pitch

simple anvil
#

mmmm ok bye

#

i do indeed dont like this math

hexed hatch
#

Then divide it by the amount of frames you want it to have

#

Then add and set it

cosmic pelican
#

I also wrapped it so it couldn't go into negatives.

hexed hatch
#

I’d be willing to explore this further at another time but currently I’m “””writing an essay”””

cosmic pelican
#

fair, gl man

nova fossil
#

I’m looking for a gui lib that can open guis asynchronously. I need to populate it with stuff I pull from sql. Does anyone know of one that can do that? None of the ones on spigots list of gui libraries could do that (at least without modification as far as I saw). It would also be nice if after clicking a button it would prevent it from being pressed again for a couple seconds (I could probably modify the lib to add this behavior but I would really like the asynchronous part

tender shard
#

ugh I need help. why is the memory usage of my bot constantly rising, and also the number of tasks? both tasks and memory increase by about 1 every second and I don't know why. full source code: https://github.com/JEFF-Media-GbR/DiscordSpigotUpdateBot

I am confused and need heeeeelp D:

hollow aspen
#

Problem With Build Path?

tender shard
cursive herald
#

I got it using

Dispenser dispenser = (Dispenser) block.getState();
bsBlock.setType(itemType);
dispenser.getInventory().removeItem(item);
event.setCancelled(true);
dispenser.getInventory().removeItem(item);

But I have an issue
If there are only 2 blocks in the dispenser it wont remove any.
How do I fix this?

#

and the 2ed removeItem doesnt seam to do anything

tender shard
young knoll
#

Java does tend to do that now

#

If you give it ram, it’ll use it

tender shard
#

yeah but

#

I set Xmx to 128M

sterile token
#

xd

quaint mantle
#

I realized

cursive herald
#

bro did he just

quaint mantle
#

I wasnt using DecimalFormat

#

I was using NumberFormat

tender shard
#

instead of just reusing the existing object

sterile token
#

Oh

#

Big problem

tender shard
#

well normally no problem

#

no idea why it keeps in memory

#

it should normally be garbage collected

#

I'll go back to regular inputstreams

#

OkHttpClient sucks

sterile token
#

Why dont use the Java ones

#

Its really good

tender shard
#

I'm on java 8

sterile token
simple anvil
#

how would i get the current item held by the player?

simple anvil
#

public class CompassHub implements Listener {
    @EventHandler
    public void CompassClick(PlayerItemHeldEvent e){
        Player p = e.getPlayer();
        p.get

        if (p.getInventory().getItemInMainHand().getType() == Material.COMPASS && p.getInventory().getItemInMainHand().getItemMeta().getDisplayName().equalsIgnoreCase("hubtp")){
            p.sendMessage(":hi");
        }
    }
}
tender shard
#

PlayerInventory#getItemInMainHand()

#

or inOffHand

simple anvil
#

i have this, it works, but it only says hi after i move slots

hexed hatch
#

That's PlayerItemHeldEvent

#

The event is sent when a player changes hand items

#

what are you trying to do?

simple anvil
#

well, when a player clicks with a compass in there hand i want it to say hi

tender shard
#

then why are you listening to PlayerItemHeldEvent

hexed hatch
#

then use PlayerInteractEvent

tender shard
#

you want to listen to

#

yeah

#

as giz said

sterile token
#

So we should not use it?

tender shard
sterile token
#

I rember someone told me

tender shard
#

no

hexed hatch
#

I don't mean to be condescending, but you should really make use of the javadocs

sterile token
#

When i was doing my menu api

tender shard
#

no

hexed hatch
#

learning to read the documentation will clear up a lot of confusion for you

#

and help you understand what events to use and the methods made available by them

sterile token
#

I rember that i was doing my menu api and someone told me that InteractEvent was abstract and that i shouldnt be using it

hexed hatch
#

InteractEvent yes

#

PlayerInteractEvent, no

sterile token
#

Oh

#

That why

#

Forget what i said

quaint mantle
#

Sorry if im an idiot, but its still not working.
Is there a reason why my chance is 0.00, instead of its actual chance?

Number percent = ((conf.getInt(rewardData+s+".Weight")/chance) * 100);

                String form = new DecimalFormat("###.##").format(percent);
                itemLore.add("Chance: " + form + "%");
#

chance = 85

#

weight = 15

tender shard
quaint mantle
#

Cant figure out why

hexed hatch
#

lol

tender shard
#

oh I see what they meant

#

InventoryInteractEvent exists

#

and it's abstract

hexed hatch
#

Ah

young knoll
sterile token
simple anvil
#

i did player interact event and nothing is happaning

sterile token
quaint mantle
#

@young knoll Your amazing. Why do it like that however?

simple anvil
#

no

quaint mantle
#

Is there a reason why they make it formatted like that

#

Seperating doubles to numbers to integers

#

they seem the EXACT same

young knoll
#

Because when dividing two integers

#

You get an integer back

#

So anything from 0 to 0.999999 will just be 0

#

Integers do not have decimals

#

Doubles do

earnest forum
#

float too

young knoll
#

Yes float and double have decimals

#

Byte short int and long do not

quaint mantle
#

Huh

simple anvil
#
public class CompassHub implements Listener {
    @EventHandler
    public void CompassClick(PlayerInteractEvent e){
        Player p = e.getPlayer();
        if (p.getItemInUse().getType() == Material.COMPASS && p.getItemInUse().getItemMeta().getDisplayName().equalsIgnoreCase("hubtp")){
            ItemMeta m = p.getItemInUse().getItemMeta();
            m.addEnchant(Enchantment.VANISHING_CURSE,1,true);
            p.getItemInUse().setItemMeta(m);
        }
    }
}
quaint mantle
#

That seems weird though, for example: Is there a difference between float and double

young knoll
#

Yes

earnest forum
#

double has a larger number limit

young knoll
#

It’s complicated to explain, floats will be more precise closer to 0

hexed hatch
#

Again

#

the documentation

#

getItemInUse is not the method you want

simple anvil
#

get main hand?

quaint mantle
hexed hatch
#

That, and there's a method from the event itself that should provide the ItemStack that was clicked

young knoll
#

As for the others, byte is 8 bits, short 16, int 32 and long 64

hexed hatch
#

I really urge you to familiarize yourself with reading the documentation because you're just going to have a bad time throwing stuff at the wall and hoping it sticks

quaint mantle
#

Just so you know xd

tender shard
#

I don't like OkHttpClient

hexed hatch
#

then give up

#

give up now

tender shard
#

I got it working, I just find it weird that creating a new client stays in memory forever and is not GCed

#

I thought that if I create one and then derefence it, it'll be gone

#

but that's not true

young knoll
#

Did you check that you fully de-referenced it

tender shard
#

yes, but it schedules its own tasks

young knoll
#

Ah

tender shard
#

I never had it in any fields, only in local vars

young knoll
#

So I imagine it has a close method or soemthing

tender shard
#

yeah but I used in in try with resource blocks

#

so it's auto-closed

young knoll
#

Yep

tender shard
#

even closing it manually didnt do anything

young knoll
#

Auto closeable is nice

tender shard
#

everytime you create a new OkHttpClient, it stays in memory forever

#

I just didn't know that and it still feels weird that it does

#

imho it should be disposed of as soon as it's no longer references but yeah of course that won't happen if it decides to create its own tasks

young knoll
#

You know what isn’t nice, the fact that the minecraft server is closable

#

Which means you get yelled at for not closing it when you use it

tender shard
#

I recently get people on my discord claiming one of my plugins is at fault when their world breaks

#

then in 99% of cases it's them force closing the server every time

#

"I dont want to wait for it to shutdown everytime"

#

then somehow they think it's related to some of my plugins

#

lol

young knoll
#

Well duh

#

Your plugin should stop them from force closing

#

Gosh

tender shard
#

all I can say is Unsafe.getUnsafe().putAddress(0,0);

young knoll
#

Unsafe: because java neutered reflection :(

regal carbon
#

im trying to send a pluginmessage to bungeecord and use completablefuture to wait for its response, but the thread never continues, even after a response was received:

https://paste.md-5.net/afukojayoh.cs

sterile token
undone axleBOT
regal carbon
#

sorry, didnt know that

sterile token
#

No problems

#

Just join there, paste your code, press CTRL + S, copy the url and send it here

tender shard
#

am I stupid?

This must-have library lets you reliantly and instantly crash the JVM.
is there a typo in "reliantly"?

#

IntelliJ says there's typo but doesn't suggest any better spelling

sterile token
#

i didnt understand mfalex

night torrent
#

i forgot which ones the name of the project, artifcatID or groupID

night torrent
#

thanks

tender shard
#

group = "username"
artifact = "plugin"

#

e.g. one group can have many artifacts / one developer can have many plugins

#

so a "group" groups different artifacts

#

idk, maybe this helps you remember

#

maybe it doesnt

young knoll
#

Reliantly

#

According to my phone

#

You could also use reliably

tender shard
young knoll
#

IntelliJ bad then

#

:p

tender shard
young knoll
#

Is it async

tender shard
#

oh

#

shit

#

not yet

#

feel free to PR

young knoll
#

Lol

#

Don’t wanna be halting the server while you crash it, that would be terrible

tender shard
#

this is my favorite part

sterile token
#

Please every picture burns and fries my eyes

tender shard
sterile token
#

Lamo i dont know how you can develop on white : thinking:

young knoll
#

Alex will get made fun of for light mode for all eternity

tender shard
#

it's a github screenshot

#

I am using Intellij dark mode since a week or so now

young knoll
#

Back in my day we didn’t have dark mode!

sterile token
#

ait

#

Github isnt white

#

Its black lmao

tender shard
#

no

young knoll
#

It has a light mode

sterile token
#

Ahh

#

That why

tender shard
#

in porn mode (+ not logged in) it defaults to white

young knoll
#

Yeah

sterile token
#

Its amazing, to be all dark with rbgs and mfalex with all light things

tender shard
#

it's because I am a happy mind

sterile token
#

My bedroomhas the light off my mouse, keyword, headphones, and table have rgbs on

#

I wish i had rgbs on bathroom to dont turn on the light and get literally shocked

tender shard
#

I don't even have a bedroom

sterile token
#

Isnt a way to setting a global runnable on Intellij for running things? Because everytime i change the project i have to configure again the Spigot path, ram, etc

#

😮‍💨

tender shard
#

I dont even know how to make intellij start spigot at all lol

sterile token
#

Its pretty simplier

#

I can explain you if you want

twilit wharf
#

I have a few classes for storing player data. Mainly two, NetworkPlayer, which holds things like rank and gold for players that are offline, and OnlinePlayer, which holds a ton of other data for only players that are online, OnlinePlayer extends NetworkPlayer. I have a system, so that when a player joins, it checks if there is a currently cached NetworkPlayer for their uuid, and if so, turn it into a OnlinePlayer, if not, make a new OnlinePlayer. for some reason, when a player joins for the second time none of the stuff in OnlinePlayer effects the player, like sending text to their title. I did some debugging and the caching works, idk what is the issue. HEre is the code: https://paste.helpch.at/nokibapixo.cs
Thanks in advance!

sharp flare
#

try running it in the main thread instead of async

twilit wharf
#

wdym

tender shard
twilit wharf
#

the issue isnt with async tasks

#

I have a method, getCachedPlayer, java public static OnlinePlayer getCachedPlayer(OfflinePlayer p) { for (OnlinePlayer sp : cachedPlayers) { if (sp.getPlayer().getUniqueId() == p.getUniqueId()) return sp; } return null; }and this is returning null

earnest forum
#

.equaks'

twilit wharf
#

even though the arraylist has stuff in it

earnest forum
#

.equals()

#

dont use ==

tender shard
twilit wharf
#

yeah

tender shard
#

a bukkit player is only valid as long as the player is online

#

once they reconnect, they get a new player object

twilit wharf
#

yeah

tender shard
#

so you have to get the new player object everytime they rejoin

twilit wharf
#

the online player object gets yeeted when they leave

#

and gets recreated when they join

tender shard
#

hm

twilit wharf
#

hence the removeplayer method in the code provided

#

its been so fustrating

#

cause I cant find the issue

tender shard
#

well hard to say without seeing more code or without you telling us what EXACTLY doesn't work, like - what line of the code you sent, etc

earnest forum
#

in the loop print both

#

uuids

#

try that and if 2 are the same

#

sp.getPlayer().getUniqueId().equals(p.getUniqueId())
as opposed to
sp.getPlayer().getUniqueId() == p.getUniqueId()

sterile token
# tender shard that'd be nice

Allright (On intellij):

  1. Click on the button called "Add Configuration"
  2. Add new and select "Jar Application"
  3. Configure your spigot jar path and vm options
tender shard
#

yeah but how would that use maven to compile my plugin and also copy it there?

tender shard
earnest forum
#

^

#

that could be the issue

sterile token
#

And if its a shaded jar you put the path + jar name.jar

tender shard
sterile token
#

The jar will still bein inside the target folder

#

The outputfile just copy and the paste the jar

#

Or at least in my case does that

#

The vm options its: -Xmx or just Xmx?

#

I dont rember if it contains the "-" first

earnest forum
#

yes

#

needs -

sterile token
#

Allright thanks

quaint mantle
#

So, im trying to create a class where I store all my data, instead of all in config.
Is this a good or bad idea?

earnest forum
#

good idea

#

as long as u save it to config

#

when the server stops

#

or do it periodically

quaint mantle
#

I meant more or less like, for example, what crates have in them but yea

#

Also, how would I do this?

night torrent
#

how would i make it so i run a command, and that activates an event listener?

quaint mantle
#

It doesnt let me update a HashMap right inside a class

#

do I have to do it inside a function

earnest forum
#

only bukkit can

quaint mantle
#

like private static void setupData()

earnest forum
#

yes

eternal oxide
#

you can run an event, if you are careful

night torrent
quaint mantle
#

alr

earnest forum
#

ur not supposed to do that

eternal oxide
#

depends on the event

earnest forum
#

what kind of event u wanna run

night torrent
#

I have a plugin that spawns a creeper everytime you break a block. How would I make that toggleable through commands?

earnest forum
#

store a hashmap somewhere

#

of a <Player, boolean>

#

and then when the command is ran

eternal oxide
#

you don't need to run an event. just set a boolean toggle to early exit from the listener

night torrent
#

ok

earnest forum
#

set the player's value in the hashmap to true/false

#

and then in the blockbreakevent

#

check what the player's value in the hashmap is

#

if its true, spawn creeper

#

if its false, don't

night torrent
#

ohhhh

quaint mantle
#

How do I allow a HashMap to contain multiple key types

#

like:

"A" = 1
"B" = "C"
"C" = 1.0

#

and so forth

#

HashMap<String, ?> basicCrate = new HashMap<>();

#

This doesnt seem to work, and research got me nothing

#

Yes I did search this issue up first

young knoll
#

Object

#

But this sounds like bad design

quaint mantle
earnest forum
#

id make a custom CrateData object

#

or something of the sort

quaint mantle
#
cratesMain = new HashMap<>();
        HashMap<String, Object> basicCrate = new HashMap<>();
        ArrayList<String> basicCrateList = new ArrayList<String>();

        basicCrate.put("Items",basicCrateList);
        basicCrate.put("Amount",5);
        basicCrate.put("Name", ChatColor.GREEN + "Basic Crate");

        cratesMain.put("basicCrate", basicCrate);
#

Am I creating this wrong?

#

Like is this inefficent

young knoll
earnest forum
#

u would have to cast

#

back to the String or integer object or whatever

#

really bad practice to use object

young knoll
#

Make a class called crate

#

That holds a name, amount, and list of items

quaint mantle
# young knoll That holds a name, amount, and list of items
public static HashMap<String, HashMap> cratesMain = null;

    public void setupData(){
        cratesMain = new HashMap<>();
        HashMap<String, Object> basicCrate = new HashMap<>();
        ArrayList<String> basicCrateList = new ArrayList<String>();

        basicCrate.put("Items",basicCrateList);
        basicCrate.put("Amount",5);
        basicCrate.put("Name", ChatColor.GREEN + "Basic Crate");

        cratesMain.put("basicCrate", basicCrate);
    }
#

I mean I kinda already did

#

CrateData.cratesMain

#

or should I do CrateData.Data

#

idk lol

twilit wharf
young knoll
#

No

waxen plinth
#

just make a Crate class

young knoll
#

A class

#

Not a map

waxen plinth
#

And then store that in the map

quaint mantle
#

Can somebody send me a site to learn that?

young knoll
#

See

quaint mantle
#

Confused on what you mean

young knoll
#

?learnjava

undone axleBOT
quaint mantle
#

ty

young knoll
#

Class is a very basic concept

waxen plinth
#

java is a very classy language

young knoll
#

Heh

#

The hashmap enthusiast is disgusted by your use of a hashmap

#

That’s not a good sign

waxen plinth
#

lol

shy finch
quaint mantle
#

Oh wait I think I see what you mean to do

#

wait no now im lost

waxen plinth
#

stop trying to make your thing work

earnest forum
#

can someone walk me through adding nms to maven?

quaint mantle
#

im trying to figure out how to do what you said

waxen plinth
#

..how to make a class?

vocal cloud
quaint mantle
#

I know how to make a class

#
public class CrateData {

    
}
#

Thats already done, im confused on what I need to add to the class

#

Exactly

waxen plinth
#

What data does a crate need

#

Its name, presumably

quaint mantle
#

Heres the config.yml file

Crates:
  basicCrate:
    Items:
      0: DiamondRewardBasic
      1: EmeraldRewardBasic
      2: GoldRewardBasic
      3: IronRewardBasic
      4: TNTRewardBasic
    Amount: 5
    Name: Basic Crate
    Color: GREEN

  rareCrate:
    Items:
      0: DiamondRewardBasic
      1: EmeraldRewardBasic
      2: GoldRewardBasic
    Amount: 3
    Name: Rare Crate
    Color: BLUE

  crateRewardData:
    DiamondRewardBasic:
      Material: DIAMOND
      Weight: 3
      Amount: 2
    EmeraldRewardBasic:
      Material: EMERALD
      Weight: 5
      Amount: 5
    GoldRewardBasic:
      Material: GOLD_INGOT
      Weight: 20
      Amount: 16
    IronRewardBasic:
      Material: IRON_INGOT
      Weight: 45
      Amount: 32
    TNTRewardBasic:
      Material: TNT
      Weight: 10
      Amount: 16
waxen plinth
#

The items it can roll

earnest forum
#

put a string object

#

"name"

#

List<ItemStack> items

waxen plinth
#

Man that's not a good way to structure that

eternal oxide
#

if a crate is fixed once created use a record not a class

waxen plinth
#

Yeah records are great

earnest forum
#

never heard of that before

quaint mantle
#

so how do i make it actually work however?

#

this entire time i thought classes were just to hold functions

#

so now im extremely lost

eternal oxide
#

basically it handles all the field setting and gives you a read only object back

waxen plinth
#

I don't think you should be messing around with the spigot api if you don't understand the fundamentals of java

#

So make a playground workspace that is just plain java, not a spigot plugin

quaint mantle
waxen plinth
#

Find a tutorial you can follow and learn the basics of OOP and mess around with it in your playground

#

No you clearly don't understand how java works

eternal oxide
#

read up on records, they are handy

earnest forum
waxen plinth
#

If you understood how java works then you wouldn't be running into this issue

earnest forum
#

do i need to do all of this?

#

for nms in maven

quaint mantle
#

Ill watch it, and learn that

#

At this point id rather watch a 2 hour tutorial on all of that

#

Then have to be confused

#

This video on Java OOP Basic Concepts. This Object-Oriented Programming Java video will help you understand the fundamentals of Object-Oriented Programming in Java with practical examples for a better learning experience. 🔥Enroll for Free Java Course & Get Your Completion Certificate: https://www.simplilearn.com/learn-java-basics-skillup?utm_cam...

▶ Play video
#

found one

#

lol

ancient jackal
earnest forum
#
public class data {

  String name = "";
  List<ItemStack> items = new ArrayList<>();
  int amount = 0;

}
waxen plinth
#

12 hours lol

earnest forum
#

@quaint mantle

quaint mantle
#

12 HOURS

earnest forum
#

something like this

#

and then create getters

ancient jackal
#

almost half of it is over java swing

vocal cloud
waxen plinth
#

ew

earnest forum
#

ehhh its just an example

quaint mantle
vocal cloud
#

At least capitalize it

earnest forum
#

mike

earnest forum
waxen plinth
#

You need to understand what a class is

earnest forum
#

do i need all this

waxen plinth
#

A class is a template

earnest forum
#

in my pom

waxen plinth
#

A blueprint

quaint mantle
waxen plinth
#

You can create multiple instances of a class

#

Each one has its own values in the fields

quaint mantle
#

in a sense

#

class as in the classes name

waxen plinth
#

That's how you create an instance of a class, yes

quaint mantle
#

.. Okay but how would I know if its a Basic, rare, etc crate?

#

How would it return the correct info?

waxen plinth
#

Stop worrying about that right now

quaint mantle
#

Yknow nvm ill watch the video

waxen plinth
#

Yeah please do

#

It will be much easier to approach once you understand OOP

#

But don't expect it to click immediately

#

For some people it takes weeks or months to really click

#

The best way to get a handle on it is to follow some tutorial(s) and then mess around with it in a playground just to get a feel for it

quaint mantle
#

Same thing happened to me in LuaU

#

learning how modules work (which is VERY SIMILAR to java classes and OOP)

#

took a while before it clicked

waxen plinth
#

What

#

I don't think it's similar to oop lol

#

Lua is not an oop language

quaint mantle
waxen plinth
#

You can model oop behavior with metatables but it's not an oop language

quaint mantle
#

In very small parts of it

quaint mantle
#

@waxen plinth wait so

#
public class CrateInfo {
    String name;
    int version;

    public CrateInfo(String name, int version){
        this.name = name;
        this.version = version;
    }

    public static CrateInfo newCrate(){
        CrateInfo newCrate = new CrateInfo("basicCrate",1);
        return newCrate;
    }
}
#

This would be considered oop correct?

#

If im learning this correctly

eternal oxide
#

no

quaint mantle
#

updated hold on

#

i typed stuff wron

ancient jackal
#

remove newCrate, you can overload methods

eternal oxide
#

if you want yoru static method to be useful it shoudl return a new CrateInfo

ancient jackal
#

and constructors

quaint mantle
#
return new CrateInfo("basicCrate",1);
ancient jackal
#

so you can make another constructor with no params that sets the name and version to basicCrate and 1

quaint mantle
#

so like that correct?

ancient jackal
#

polymorphism goes hard

night torrent
#

how do i make a boolean public?

drowsy helm
#

public boolean

night torrent
#

I mean acssesible from another class

drowsy helm
#

public boolean

night torrent
#

oh

#

ok

#

Thanks

eternal oxide
#

You could do this using record java public record CrateInfo(String name, int version) {}

quaint mantle
#

HOLY CRAP I UNDERSTAND THIS NOW

ancient jackal
#

only use records when it's just for holding data

#

no changing it

quaint mantle
#

yea i may make stuff to update it in the future

#

so ill leave it as it is

#

wait so.. this also supports lists and such

#

correct?

ancient jackal
#

it's the same thing as a regular class but with a private final var and no setters

eternal oxide
#

and it handles setting all vars for you, also creating hash. toString and equals method

quaint mantle
#

well damn

#

didnt know class could be used like this

#

at all

sterile token
#

What do you think? :D

Message senderMsg = Message.builder().text("&3Active players &f" + Bukkit.getOnlinePlayers().size()).build();
Message playerMsg = Message.builder().open("&3Follow us :D", "Hover message", "url link here").build();
        
senderMsg.send(sender);
playerMsg.send(player);
tender shard
#

otherwise you'll have to pay me

#

9 billion $

quaint mantle
#

what currency

earnest forum
#

why isnt there a delete button in intellij

tender shard
#

zimbabwe dollars

vocal cloud
#

German dollars

tender shard
#

taco dollars

#

idk, I just want money

vocal cloud
#

Don't we all. Probably in the wrong place to make that tho

tender shard
young knoll
#

Stop putting the $ after the amount

#

Ahhhhhhhh

earnest forum
#

nothing i got it working

sterile token
earnest forum
#

i was just asking if i need all of that

#

turns out i dont

autumn frigate
#

I have a problem and i want to ask that how to stop silent joining in my server?

tender shard
autumn frigate
#

ok

sterile token
#

Wrong channel

tender shard
#

if you need NMS, you definitely want to do the stuff from that post

earnest forum
#

what does it actually do?

#

i added the dependency only, and I had all of the classes imported

tender shard
#

as said - are you using NMS?

earnest forum
#

1sec

vocal cloud
#

If you say you need NMS for something dumb enough you can summon MD_5.
NMS is for using base MC stuff outside the scope of the API.

tender shard
#

tbh NMS is still needed for so much stuff that should be API

#

e.g. creating a simple hologram

ancient jackal
#

they dont call it no mans sky for nothing

tender shard
#

*client side hologram

vocal cloud
#

Yeah but it's outside the API's stuff

#

Even if it should be in it

tender shard
#

exactly, so doing holograms is a valid reason for NMS

vocal cloud
#

Like opening a book for a player

#

Requires NMS

tender shard
#

huh? really?

#

opening books is not possible? are you sure?

#

Player#openBook

#

smh, everyone here still thinking in 1.8 API lol

night torrent
#

Start start = new Start();

would this line acsses the class named Start? Im using "if(start.boolName)", but its not working

young knoll
#

Is the boolName public

earnest forum
#

or static

young knoll
#

Hey

night torrent
young knoll
#

It doesn’t have to be an “or”

tender shard
#

so trolling

night torrent
young knoll
#

Why

#

Whatever doesn’t matter right now

vocal cloud
earnest forum
#

can u send the start class

young knoll
#

If you have an instance of Start, and start has a public bool named boolName that should work

night torrent
#

huh

tender shard
tender shard
vocal cloud
young knoll
#

openBook isn’t super new

earnest forum
#

how does that have 2.9m views

young knoll
#

openSign is 1.18

tender shard
#

I wish the API docs would have a @since tag

earnest forum
#

Bro code coming in clutch 🥶

young knoll
#

Fun fact, open book very briefly changes your held item to the book

#

And forces you to right click

#

Essentially

night torrent
#

my start class:

my other class:

earnest forum
#

that should be fine

night torrent
#

it's not working

earnest forum
#

have u registered the listener?

#

show us your main class

#

and use this

#

?paste

undone axleBOT
quaint mantle
#

im very happy rn

tender shard
#

no

#

that's bullshit

#

you have to Start classes

quaint mantle
#
public class CrateInfo {
    String name;
    int version;

    public CrateInfo(String name, int version){
        this.name = name;
        this.version = version;
    }

    public String getName(){
        return this.name;
    }

    public int getVersion(){
        return this.version;
    }

    public static CrateInfo newCrate(String name, int version){
        return new CrateInfo(name,version);
    }
}
#

i learnt OOP

#

lol

tender shard
#

you created one start object for your listener

#

and obviously you made another instance of it for your command

night torrent
tender shard
#

so whenever someone does the command, your listener's start class object will never change

earnest forum
#

you need a singleton

#

or make the boolean static

tender shard
#

I am pretty sure they want it toggleable per player

ancient jackal
tender shard
#

erm yeah

quaint mantle
tender shard
#

the static constructor is 100% useless lol

quaint mantle
#

also one question

#

how would I return a list of every available Crate?

#

in the class?

ancient jackal
#

getters and setters

earnest forum
#

make a list of crateinfo

tender shard
#

in what class

earnest forum
#

put it in like main

#

and whenever u create one put it into that

quaint mantle
#

oh

#

alright

regal carbon
earnest forum
night torrent
#

i want it so one player runs the command and it effects the hole server

earnest forum
#

ah

#

make the boolean a static

night torrent
#

so public static creeperSpawns

earnest forum
#

public static boolean creeperSpawns = false

tender shard
earnest forum
#

yes

night torrent
#

thanks

tender shard
#

but

#

@night torrent

#

do you know what static does?

#

because it's important to tell people what it actually does

#

before telling them to use it

night torrent
#

yes

#

I did game dev with c# for a year or 2

tender shard
#

okay, well if you know it, I wonder why you didn't then make it static right away 😛

night torrent
#

im not very smart

earnest forum
#

also

sterile token
earnest forum
#

nvm

night torrent
#

i looked for abt 15 mins

quaint mantle
#

@earnest forum How would I remove a crate from the class?

#

this = null?

#

or

tender shard
quaint mantle
night torrent
#

ngl i do struggle with it

tender shard
#

Okay I'll try to explain

night torrent
#

i looked it up once but i didnt retain it

earnest forum
#

you wanna remove a crate from the list of crates?>

quaint mantle
#

remove a crate from a list

earnest forum
#

list.remove(crate object)

quaint mantle
#

oh.

#

ty

sterile token
ancient jackal
#

some people like registry classes for stuff like that but personally I just have a private static var

tender shard
#

@night torrent Imagine you have a Human class that has three fields: Name, Age, and Planet. Of course, we have 8 billion different humans. They can all have different names and different ages. But all humans that we know have the same planet, which is earth. So. in this case, "Planet" is the same for every human. No Human (as we know of) will ever have a different Planet. That's why Planet does not refer to any individual human, but to all humans. so Planet can be static, meaning it belongs to the class itself. Age and name differ between humans so it must be changable PER individual human, so those are not static

earnest forum
#

7 billion

#

!!

sterile token
shy finch
tender shard
#

static = belongs to the class
not static = belongs to the invidiual instance of this class

sterile token
night torrent
#

that was actually a really good explanation thanks

tender shard
#

np 🙂

quaint mantle
#

OOP, where have you been all my life

#

half my coding wouldnt have been so hard if i was using oop

#

im disappointed

shy finch
tender shard
quaint mantle
earnest forum
#

professor mfnalex

#

!!

tender shard
#

yeah I try my best

sterile token
earnest forum
#

the idea of oop is so cool to me

sterile token
tender shard
#

if someone cannot explain something in 2-3 easy sentences, the person trying to explain hasn't understood it themselves

quaint mantle
#

oop is godly is the basis of it lol

quaint mantle
# earnest forum the idea of oop is so cool to me

By the way, related to oop, so by a list of crates this right?

public CrateInfo(String lowName, String detailName){
        this.lowName = lowName;
        this.detailName = detailName;
        crateList.put(lowName, true);
    }

    public HashMap<String, Boolean> getAllCrates(){
        return crateList;
    }

    public Boolean getCrate(String lowName){
        return crateList.get(lowName);
    }

    public boolean removeCrate(String lowName){
        if(crateList.get(lowName)){
            crateList.remove(lowName);
        }
        return true;
    }
hexed hatch
quaint mantle
#

oh hey Redempt

#

i learnt oop

waxen plinth
quaint mantle
#

because I dont need a value for it

waxen plinth
#

..what

quaint mantle
#

so to make it easier to find

#

im using a string, by using a hasmap

waxen plinth
#

Ok what you're describing is a HashSet

#

Which doesn't map keys to values, only holds them and you can check contains

quaint mantle
#

?

waxen plinth
#

But that also doesn't make sense in this context

#

I don't get why you're doing it that way

quaint mantle
#

without creating a new crate

#

and access the data

waxen plinth
#

Right and how does a Map<String, Boolean> help with that

ancient jackal
waxen plinth
#

That is a really bad comparison

quaint mantle
#

wait.. i just realized how dumb i am in this context

#

hold on

waxen plinth
#

A hashmap is not like two lists side by side

earnest forum
#

when in doubt, watch Bro Code

ancient jackal
#

say that one more time I dare you

quaint mantle
#

@waxen plinth

HashMap<String, CrateInfo> crateList = new HashMap<String, CrateInfo>();

    public CrateInfo(String lowName, String detailName){
        this.lowName = lowName;
        this.detailName = detailName;
        crateList.put(lowName, this);
    }

    public HashMap<String, CrateInfo> getAllCrates(){
        return crateList;
    }

    public CrateInfo getCrate(String lowName){
        return crateList.get(lowName);
    }

    public boolean removeCrate(String lowName){
        if(crateList.get(lowName) != null){
            crateList.remove(lowName);
        }
        return true;
    }
#

there it returns this

#

so the value itself returns it

earnest forum
#

also

#

for remove crate

#

just do

waxen plinth
#

That makes more sense, yes

earnest forum
#

if (crateList.contains(lowName)

young knoll
#

A map links two things together, a key to an object

earnest forum
#

containsKey*

waxen plinth
#

But you really need to make that map static

quaint mantle
young knoll
#

Idk how to go more laymen than that

waxen plinth
#

And all the methods too

earnest forum
quaint mantle
waxen plinth
#

Basically everything there should be static since it doesn't belong to any one specific crate

#

You also don't need to check contains in order to call remove

#

Just call remove, and it will return the old value if there is one

quaint mantle
#

oh alright

earnest forum
#

why does remove return a bool?

waxen plinth
#

Classes in and of themselves are not oop though

quaint mantle
#

god @waxen plinth tysm for telling me about OOPing in java

#

you have NO IDEA

#

how happy I am

waxen plinth
#

Keep looking

quaint mantle
#

I had to make so many workarounds for code

waxen plinth
#

You're far from done

quaint mantle
#

ah

waxen plinth
#

You are only scratching the surface

quaint mantle
#

Wait.. this is only the surface use of it?

#

Jesus

earnest forum
#

unless u have a singleton

quaint mantle
waxen plinth
#

You can get a hell of a lot deeper with it

quaint mantle
#

oh its not letting me chance the ones that contain "this" into static

waxen plinth
#

This is literally just one class

quaint mantle
#

also it works fine without static lol

earnest forum
waxen plinth
#

What no

#

That's not how anything works

#

Are you trying to make the constructor static

quaint mantle
#

why was that wrong

waxen plinth
#

.-.

earnest forum
#

i mean the hashmap, getter and remover

quaint mantle
#

ah

earnest forum
#

not the constructor

waxen plinth
#

Yeah you can't make the constructor static

quaint mantle
#

there

waxen plinth
#

Make all the other methods you showed and the map static

#

Do you understand what static means

quaint mantle
#

not 100%

#

ill research it a bit more

earnest forum
#

theres only 1 instance of that variable and it belongs to the class

tender shard
quaint mantle
#

oh so everything has the same value

#

basically

#

every person has the same “Planet” attribute in common, so “Planet” actually has the same value for ALL humans.

#

based on how you stated it means lol

earnest forum
#

its just so you dont have 2 different versions of the hashmap

#

there is only ever 1

quaint mantle
#

so it doesnt allow duplicates

earnest forum
#

no

waxen plinth
#

What

ancient jackal
#

if it's not static it's individual to each object

waxen plinth
#

That's not a good analogy

quaint mantle
#

oh i read that ENTIRELY wrong

waxen plinth
#

"planet" is still a property of a person

#

The fact that it's the same for every instance doesn't make it static

ancient jackal
#

that was a great analogy what are you talkin about

waxen plinth
#

No it's really not

tender shard
waxen plinth
#

So?

#

It still would not be static unless there is literally no possibility of a human ever being born elsewhere

#

Man it's frustrating helping people here sometimes

shy finch
#

lol

tender shard
#

so we could easily say stuff like
Human has a static field Planet = EARTH
and non-static fields Age and name

ancient jackal
#

it gets the point across, even including name and age that aren't static in comparions

waxen plinth
#

No you wouldn't make that static

#

It gets the wrong point across

#

That's not what static means

#

Static means it is a property of the type itself, not each instance

ancient jackal
#

tell us then

#

exactly

tender shard
#

do you now want to tell me that some humans ever went into space 2000 years ago or what

waxen plinth
#

Being born on earth is not a fundamental property of being a human

earnest forum
#

property of the class, not instance

waxen plinth
#

If someone was born on mars they would still be human

#

If someone was born in the ISS they would still be human

tender shard
waxen plinth
#

And you're really just making it seem like a static field is a constant

#

Which is not the case

ancient jackal
#

okay, call the variable "homePlanet"

waxen plinth
#

Yes it's not a good analogy

ancient jackal
#

now what

earnest forum
#

honestly we should all just go watch Bro Code's explanation on static

tender shard
waxen plinth
#

Call it homePlanet and make it an instance field

quaint mantle
#

im more confused on static now cause of this lol

waxen plinth
#

🙃

quaint mantle
#

but i do know the difference between private and public

#

public means it can be viewed by other code

#

private means not

#

from what ive seen

earnest forum
#

yesd

ancient jackal
tender shard
#

I think my Human.Planet explanation is preeeeetty good to explain it

waxen plinth
#

It's not

earnest forum
#

?paste

undone axleBOT
tender shard
#

oh fun fact, never ever was any human on another planet

waxen plinth
#

It falls apart if you think about it past the surface level

tender shard
waxen plinth
#

Dude I am really not in the mood for going in circles about this right now

tender shard
#

it is to explain it to beginners

waxen plinth
#

Yeah and giving them an analogy like that will make them think about static in the wrong way

#

Static =/= constant

tender shard
#

as said, I'm waiting here for a better real life example

waxen plinth
#

Sure

tender shard
waxen plinth
#

Let's say you have a similar setup

#

A Person class

tender shard
#

which is true, no human was ever born outside of earth

waxen plinth
#

All of its instance fields are what you would expect

#

Name, age, place of birth, whatever else

tender shard
#

and no human ever visited ANY other planet at all too lol

waxen plinth
#

A static field you might use in this case could be population

#

Which would keep track of how many humans there are

ancient jackal
#

let's hear out what Bro Code had to say about this:

You have a class, Friend. In this class there is public static int numberOfFriends. Everytime there is a new friend, this number increments. Everytime someone does, it decrements

waxen plinth
#

It would be incremented when the constructor of Human is called, and decremented when you call Human#die or whatever

earnest forum
#

in the planet class a static field could be "solar system"

tender shard
#

well I guess my explanation made them understand static while yours doesn't really

earnest forum
#

no?

waxen plinth
#

Name, age, place of birth are all properties of an individual

ancient jackal
#

no

waxen plinth
#

The population is a property of the class

#

It's more abstract and describes the type itself

ancient jackal
#

planets belong to all kinds of solar systems

waxen plinth
#

And the information does not belong to any one individual

earnest forum
#

im copnfusing myself

#

you could do like

tender shard
#

there wasn't a single human who ever visited another planet so I guess it's kinda safe to say that planet right now can be a static field

waxen plinth
#

Alex

#

Can you please stop

#

You're just saying the same thing over and over and it doesn't make your analogy correct

#

It's misleading

earnest forum
#

human has age, name, dob, but a static field is like their kingdom

waxen plinth
#

And it's getting very frustrating

earnest forum
#

like animalia

#

or mammal

ancient jackal
#

yeah

waxen plinth
#

Population is such an easy analogy

tender shard
#

it is not misleading, it may not be 100% correct but it explains it to someone who cannot differentiate between classes and instances yet

ancient jackal
#

because every human belongs to the kingdom, as they do earth

waxen plinth
#

...

tender shard
#

and someone who can differentiate between classes and instances doesnt need an explanation anymore anyway

waxen plinth
#

And population is 100% a valid usage of static

tender shard
#

why would population be a property related to human, it should more like belong to the planet

waxen plinth
#

Planet is not because it breaks as soon as a human is born anywhere but earth, and it also conflates the idea of a constant with a property of the type

quaint mantle
#
CrateInfo crate = CrateInfo.newCrate("basicCrate", "Basic Crate");
crate.addItemToList(new ItemStack(Material.TNT,16));

@waxen plinth cant thank you enough seriously

earnest forum
#
public class Human {

    public static String kingdom = "Animalia";

    public String name;
    public Date dob;
    public int age;
    
}
#

all humans belong to animal kingdom

quaint mantle
#

this is so helpful its not even funny

waxen plinth
#

Sure, that works too, but it's also a constant

#

If you want people to understand static you shouldn't use a constant as your analogy

#

Because they might conflate the idea of static with constants

earnest forum
#
public class Human {

    public static String kingdom = "Animalia";
    public static String type = "Mammal";

    public String name;
    public Date dob;
    public int age;

}
young knoll
#

public static float gayPercentage

waxen plinth
#

Which is why population is a much better analogy

earnest forum
#

All humans are mammals, and belong to animalia

#

not all humans have the same name, dob, age

waxen plinth
#

Yes, but again, those are constants

tender shard
waxen plinth
#

So you agree that it's better to not use a constant

ancient jackal
#

I'd use the private keyword over public for the individual fields

tender shard
waxen plinth
#

But you also disagree that my analogy which doesn't use a constant is better

earnest forum
#

yeah

tender shard
waxen plinth
#

You could make that argument, sure

tender shard
#

you also wouldn't store the amount of produced cars in a car but more in the car factory

waxen plinth
#

You can almost always make the argument that some static property could instead belong to a manager class

#

But for the purpose of analogy, population works perfectly fine

#

It could be universal population rather than population on a single planet

earnest forum
#

yeah

waxen plinth
#

It's not conflating it with constants, and it's not breaking the design of the class

tender shard
#

you wouldn't do someVwCar.amountOfProducedVwCars but more like VwFactory.amountOfProducedVwCars

waxen plinth
#

Sure, it's not perfect

#

But it's way better than planet

tender shard
#

I am german, I have to use VW

#

it's a law

ancient jackal
#

what about beamers

tender shard
#

they are called BMW here

#

and that's one letter longer

#

and germans are efficient

waxen plinth
#

Seriously though please don't use the planet analogy, you're only going to confuse beginners

tender shard
#

okay Redempt

waxen plinth
#

You don't have to use the population analogy either

tender shard
#

lets think of an example we both think is perfect

ancient jackal
waxen plinth
#

I don't think you're really going to get something simpler and more analogous than population

#

Like you can make something that is more technically correct

#

But it's going to be more complicated and potentially go over their heads

ancient jackal
#

that's only going to confuse beginners on where to store their statics then

waxen plinth
#

And you can almost always make the argument that some static property could belong to a manager class instead of being a static member of a pojo class

ancient jackal
#

population count isnt a property of human, it's a property of planet

waxen plinth
#

Not necessarily

earnest forum
#

depends

waxen plinth
#

It could be the universal count of all humans

earnest forum
#

population of all humans ever?

waxen plinth
#

^

earnest forum
#

yea exactly

waxen plinth
#

"how many humans currently exist?"

#

It's perfectly valid to make that a static field

#

Making it a property of a planet would complicate things a lot

ancient jackal
#

it wouldnt

waxen plinth
#

Yeah it would

#

Are you gonna just have numberOfHumans?

ancient jackal
#

the definition of population would not complicate that at all

waxen plinth
#

The analogy becomes more needlessly complicated by doing that

#

So why would you

ancient jackal
#

to properly portray your analogy

waxen plinth
#

...

tender shard
#

Human.numberOfHumans would make total sense to me

waxen plinth
#

You're just being pedantic

tender shard
#

but not population

waxen plinth
#

Okay then call it numberOfHumans

tender shard
#

that'd make definitely make more sense to me

waxen plinth
#

Great I'm sick of this argument

#

Call it numberOfHumans and let's move on, this has been so pointless

tender shard
#

but I doubt that people would understand it as well

waxen plinth
#

How

#

It's so simple

#

You have a static field keeping track of the number of humans

tender shard
waxen plinth
#

It's not a property of any one human

tender shard
#

somehow the planet thingy helped someone undertsand it immediately

waxen plinth
#

They said they understood it, you mean

#

But that doesn't mean they understood it correctly

earnest forum
#

lets say you are making a multiplayer video game. you have a "server" class, which you need to store a list of players. this would be non static, as the game could have multiple servers. but if you wanted to store all the players across all servers it would be a static list

tender shard
#

what they understood is that static belongs to the class and is the same for all instances

#

and that's everything I tried to explain

waxen plinth
shy finch
#

honestly all beginners need is that static vars are shared

tender shard
ancient jackal
tender shard
#

because

#

beginners do not understand the difference between class and instance

#

that's exactly the hardest part for many people

earnest forum
shy finch
#

I remember my teacher used students at a school, where the school is the static var

quaint mantle
#
public class CrateItems {
    String findName;
    ItemStack item;
    Integer weight;

    static HashMap<String, CrateItems> crateItemList = new HashMap<String, CrateItems>();

    public CrateItems(String findName, ItemStack item, Integer weight){
        this.findName = findName;
        this.item = item;
        this.weight = weight;
        crateItemList.put(findName, this);
    }

    public HashMap<String, CrateItems> getAllItems(){
        return crateItemList;
    }

    public CrateItems getItem(String findName){
        return crateItemList.get(findName);
    }

    public static CrateItems newCrateItem(String findName, ItemStack item, Integer weight){
        return new CrateItems(findName,item,weight);
    }
}
quaint mantle
#

im vibin rn

tender shard
#

in my case I just used planet earth and not your school

earnest forum
sterile token
#
public void broadcast(Boolean component, Message message) {
component ? Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(message.getComponent())) : Bukkit.broadcastMessage(message.getText());
}```

its telling me that its not a statement
quaint mantle
#

ty

earnest forum
#

and getItem

shy finch
#

well I already knew java so I already understood it

#

but yeah

quaint mantle
#

ty

young knoll
#

But not every student is in the same school

earnest forum
shy finch
#

He was just referring to our school

tender shard
#

redempt is right that I only explained what a static CONSTANT is, but that doesn't make the argument invalid that I explained

quaint mantle
ancient jackal
quaint mantle
#

like i said im still kinda learning

tender shard
#

because a static constant is still a static property

quaint mantle
#

i dont know the definition

#

but i know how to use them

sterile token
earnest forum
# quaint mantle not 100%

say you have a private string name variable. you create a getter so that classes outside of that instance can access it

public class Items {

 private String name = "item";

 public String getName(){
   return name;
 }

}
earnest forum
#
public class OtherClass {
  public Items items = new Items();

  String name = items.getName();

}
quaint mantle
#

@earnest forum So if its ouside the class, its still accessible to use

#

THATS AMAZING

earnest forum
earnest forum
#

theres also setters,

ancient jackal
quaint mantle
#

correct?

shy finch
#

Repeating this question from earlier:

Hey, can somebody point me in the right direction for setting up publishing for this: https://github.com/WeaponMechanics/MechanicsMain

I've set up my settings.xml in my .m2 folder, but I am unsure what I need to put into my repo.

sterile token
earnest forum
#

public class Items {

 private String name = "item";

 public String getName(){
   return name;
 }

 public void setName(String name){
   this.name = name;
 }

}
earnest forum
earnest forum
#

only make these if you want the variables to change

ancient jackal
ancient jackal
sterile token
#

No please

#

I dont like if else

#

Loks really ugly the code

#

I changed to using if + return, for dont use if else

#

hahaha

tender shard
#

yay my memory leak is fixed

sterile token
#

In my case Intellij its leaking my memory

ancient jackal
sterile token
#

Idk what the fuck intellij is doing but with 64 gb of ram looks like an old car

#

Its really slowly idk what happening

#

Java its so amazing that it doesnt allow you to have 2 method with same name and same Argument, but using diff method from the argument

young knoll
#

How would you have 2 methods with the same name and arguments

ancient jackal
#

you dont

young knoll
#

I know

#

But like how would you expect that to work, even in theory

sterile token
#

If java allow that i wouldnt being having 4 methods for doing exactly the same but just cuz java its so annoying i have to have the 4 methods

shy finch
#

Repeating this question from earlier. I want to publish my code so people can access my api without manually downloading the jar file (Allow people to use maven). So I have this gradle project https://github.com/WeaponMechanics/MechanicsMain that I want to publish.

It's difficult because it is multiple modules, and it builds 2 separate jar files. I have already set up my local .md > settings.xml file, but I don't know what to do for my next step. I've tried looking at other spigot plugins on github but I haven't had any success in finding help.

vocal cloud
#

I made my own maven repo. You can always do the same if you have a webserver

river oracle
vocal cloud
#

Jitpack works as well for anything at java version 17 or 8

sterile token
vocal cloud
#

🤷‍♂️

young knoll
#

Jitpack is notoriously shitty

sterile token
#

Because i set a express POST listener, and didnt receive anything from the maven or gradle plugin

vocal cloud
#

Did you configure your repo properly?

sterile token
#

Im using an Express webserver, that has a POST request listener (I done it to debug). And them on the maven config i tell to do the request to the post listener

#

And i didnt receive anything

#

Understand?

#

Oh lmao i will use translator again

vocal cloud
#

Yes. I don't use express so idk