#help-development

1 messages · Page 1442 of 1

paper viper
#

are you using the sun.awt classes?

#

🤡

solemn shoal
#

yes

paper viper
#

You know, you should avoid that

#

in all costs

#

lmao

tacit drift
#

what java ver

solemn shoal
#

why tho

#

java 8 @tacit drift

paper viper
#

its basically deprecated api, and subject to removal

#

in the future

tardy delta
#

how do i even get that container this doesnt seems to work

CustomItemTagContainer container = new CustomItemTagContainer()
#

@quaint mantle

tacit drift
#

kek

tardy delta
#

or i need to implement methods or something...

hollow canopy
#

@eternal oxide dude can I send something to you

#

nobody answered my question

cerulean harness
#

Can anyone help me with world population? Is it possible to modify an existing ChunkGenerator? Basically I want to add my stuff to a world and not mess up any other populators by other plugins.

river hearth
#

I am really struggling to toggle open trapdoors/doors/fencegates in 1.12.2:

    public static void toggleOpenable(Block b) {
        MaterialData data = b.getState().getData();
        if(!(data instanceof Openable))
            return;

        Openable o = (Openable) data;
        o.setOpen(!o.isOpen());
        b.getState().setData((MaterialData) o);
        b.getState().update();
    }```
Anyone see anything wrong there? (please ping)
mossy loom
#

Why
new org.bukkit.scheduler.BukkitRunnable ()
sometimes it returns NoClassDefFoundException error?

paper viper
#

uh that makes no sense at all

#

"sometimes"?

#

what are you doing inside

#

the bukkitrunnable

#

and also show the exception

ivory sleet
#

Do you use that class outside the server or what

tardy delta
#

help i want to store an users uuid in container pdc but it wont work 😢

quaint mantle
#

is there any way to detect a totem being used?

mossy loom
paper viper
#

Holly shit

#

Yeah, there is a ton of stuff that is so wrong going on here...

shy wolf
#

?help

paper viper
#

i will list them all, maybe they will solve it, but here let me ask this

mossy loom
#

I'm a beginner ... What's wrong?

paper viper
#

what server type are you using?

#

are you using spigot

#

or some weird ass fork

shy wolf
#

some one can send the libory for the spigot api 1.16

paper viper
#

Ok let me explain whats very wrong here...

#

I will make a list

#

maybe fixing them potentially could solve the issue

mossy loom
paper viper
#

oh, that's probably why

#

yeah we don't support that here :(

quaint mantle
mossy loom
quaint mantle
#

tuinity does have a discord server at /tuinity

paper viper
#

you are using spigot api and tunity, and they have changed some classes

#

you have to use the tunity api

#

and also, let me explain what the heck is wrong

paper viper
#
  1. Naming conventions. They are bad. For package names, make sure they are all lowercase. For example me.Adixe.SuperHeroWars.Game.Magics.Magic4 -> me.adixe.superherowars.game.magics.magic4. And also, do not name your main plugin class Main. Read this thread I made: https://www.spigotmc.org/threads/why-you-shouldnt-name-your-main-plugin-class-main.493289/

  2. Dependency Injection/Singleton. Currently, you have an instance of your plugin which is both static but you are also using DI (dependency injection) with it. Choose one only. Though dependency injection is better in terms of OOP. I am referring to this part:

    private static Main plugin;

    public ArrowAnimation(Main m) {
        plugin = m;
    }

change to

    private Main plugin;

    public ArrowAnimation(Main m) {
        plugin = m;
    }
``` (and obviously rename Main)

3) Your method is static. Learn about what static abuse and when to use `static` and when to not. In short, you only use `static` (for methods) that are utility methods. Your method here isn't a utility method. 

4) Be consistent with your class imports. Instead of using `new org.bukkit.scheduler.BukkitRunnable`, import the actual class.

5) For what's inside the run method, please please PLEASE store `Config.getSettingsFile()` as its own variable. All of us programmers have bleeding eyes from seeing this multiple times. 

6) There is no need for `this.cancel()` if you are already exiting out of the `BukkitRunnable`

7) You have to be consistent with your APIs and Server types. You can't use `Tunity` with the Spigot API because Tunity modifies many classes (that likely cause the NoClassDefError because it can't find certain classes that Tunity added). So either switch to Tunity API and get support at their discord, or switch to a Spigot server.
#

@mossy loom

ivory sleet
#

🥲🥲🥲🥲

paper viper
#

I had to do it

#

lmao

round finch
#

would it be possible to hide an armor stand except for one arm?

#

and can it be done with libdisguese api?

#

i wanna make a rig of armor stand parts

#

and combined them

ivory sleet
#

That’s not possible afaik

round finch
#

i saw it be done with player parts in libdisguised

mossy loom
tardy delta
#

how can i link the uuid of a player to the pdc of a container?

round finch
#

so would it not be any entity body parts?

#

fx armorstand parts?

tardy delta
#

why is this not working?

container.set(key, new UUIDDataType(), uuid);
#

it doesnt find UUIDDataType

quaint mantle
#
playerLocation:
  location1: 
      ==: org.bukkit.Location
      world: Mineville
      x: 60.80454229417847
      y: 76.04952297318391
      z: -6.534091548579546
      pitch: 5.3418207
      yaw: 89.94321
  location2: 
      ==: org.bukkit.Location
      world: Mineville
      x: 60.80454229417847
      y: 76.04952297318391
      z: -6.534091548579546
      pitch: 5.3418207
      yaw: 89.94321
``` How would I go on setting this up? The last thing I had only got the locations but deleted it all when the server reset so that's not the way to go
#

giving somone 20$ to find a small severs plugins or give me best plugins for a factions sever

glass sparrow
#

$20 please

coarse moon
#

hey guys, what scope should jetbrains annotations be in my pom? i know they are provided in the newer versions of spigot but i'm using 1.8. should i shade it in?

quaint mantle
#

no bruh i said plugins meaning not just 4

glass sparrow
quaint mantle
#

alr 3 is that eny better

#

?

turbid grove
quaint mantle
#

well idk how to

#

how do i

glass sparrow
#

u gotta make something to stand out

quaint mantle
#

what website dp i go to to make my own

turbid grove
#

well its a learning journey of a few years at least

paper viper
#

for 1.8

quaint mantle
#

ive done coding for 2 years

paper viper
#

you dont have to add a scope

#

by default its set to <scope>compile</scope>

#

and shading uses that

coarse moon
#

thank you!

paper viper
#

np

glass sparrow
quaint mantle
#

alr

turbid grove
#

i've learnt from this when i started

#

the key is knowing the bukkit api if you already know java

quaint mantle
#

mk

round finch
#

is it impossible to hide armorstand body?

turbid grove
#

only showing its content?

#

idk

round finch
#

i thought it could be cool to hide part of it

round finch
tardy delta
#

how do i use PersistentDataContainer#set?

#

i want to set a value for the type chest

quaint mantle
#

hey

#

im tryna make a simple plugin which cancel the event if the block breaked isnt dirt

#

heres my code

#

can someone help me?

#
package me.mlgrush.axfx;

import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin implements Listener {

    @EventHandler
    public void onBlockBreakEvent(BlockBreakEvent e)
    {
        Material x = e.getBlock().getType();
        if (x == Material.DIRT)
        {
            e.setCancelled(false);
            return;
        }
        e.setCancelled(true);
    }
}

quaint mantle
#

that's my issue ^

opal sluice
opal sluice
#

You don't know how to retrieve serialized locations from a yml ?

quaint mantle
#

that's not it

opal sluice
#

What it is then 😂

#

The file gets reset at each restart ?

quaint mantle
#

gimme a sec

#

well yeah that's it yeah

#

but I can't get it to do location1, location2, etc

solemn shoal
#

@paper viper i just properly tested it, it works

paper viper
#

which

solemn shoal
#

works on linux too

#

the interactive launch thing

opal sluice
solemn shoal
#

oh woops i messed up and didnt define windows shell

fierce salmon
#

So I would like to make a countdown from 5 to 1 seconds but I dont know how to add a delay.

quaint mantle
#

I used arraylist to create the list, I know the arraylist resets when the server restarts but didn't know it reset the config

solemn shoal
#

hm its using bash on windows

quaint mantle
# opal sluice Send some code
    public static List<String> locations = ArenaConfig.get().getStringList("playerLocation");
    public static void setSpawnLocation(Location location, Player player) {
        location.add(player.getLocation());
        ArenaConfig.get().set("playerLocation", locations);
        ArenaConfig.save();
    }```
#

yeah I don't know what I had hours ago, deleted it and can't get it back

unkempt peak
#

The config should not reset after you restart the server

#

Are you saving it properly?

quaint mantle
#

so when I add a new object after restart, all gets wiped

#

and starts again

unkempt peak
#

That doesn't matter if you are setting the array list in the config it will not reset. As long as you get the string list add the location and then set the string list and save the config

#

If its resetting that means you aren't getting the list properly

tardy delta
#

Hello everyone I was wondering about a part of my plugin thats locks chests based on people their UUID, I'm trying to store the UUID of the owner of that chest inside the persistent data holder
someone who has ideas how to fix this?

solemn shoal
#

wait @paper viper i think it tries to evaluate java paths

#

thats processbuilder

opal juniper
#

Can i increase the friction of a falling block?
I need it to not slide as much

unkempt peak
tardy delta
# unkempt peak What's the issue?

well i want to store the UUID of the owner of the chest inside the pdc of the chest and then inside my eventHandler i can lock it for other player

sage swift
#

so store it as a string

#

then use UUID.fromString

unkempt peak
opal juniper
#

so it slides around

unkempt peak
#

Ah ok so whe the event is called try zeroing or lowering the velocity

tardy delta
#

I have to figure out a way to do that

#

so when reloaded the server, the owner is still linked to the chest

eternal night
#

I think the java docs of persistent data type even show an example impl of a uuid type

opal juniper
tardy delta
#

wel yea I've been looking for it half the day and didnt realy find anyrhing

sage swift
#
chest.getPersistentDataContainer().set(ownerKey, player.getUniqueId())
chest.update()```
tardy delta
#

😮

sage swift
unkempt peak
tardy delta
#

and whats that ownerKey again?

sage swift
#

basically makes it so plugins cant interfere with each other

tardy delta
#

oh i think i implemented it before

opal juniper
unkempt peak
#

Try getVelocity().zero()

fierce salmon
#

how do you add a delay

unkempt peak
unkempt peak
tardy delta
# sage swift ```java chest.getPersistentDataContainer().set(ownerKey, player.getUniqueId()) c...

I have something like this: look for the thing you said earlier

@EventHandler
    public void onContainerClick(PlayerInteractEvent event) {
        ItemStack itemStack = new ItemStack(Material.CHEST);
        NamespacedKey key = new NamespacedKey(plugin, "MBN");
        ItemMeta itemMeta = itemStack.getItemMeta();

        Player p = event.getPlayer(),
        UUID uuid = event.getPlayer().getUniqueId();
        Block block = event.getClickedBlock();
        Location loc = block.getLocation();
        PersistentDataContainer container = itemMeta.getPersistentDataContainer();

        if (MagmaBuildNetwork.playersWantingLock.contains(event.getPlayer().getUniqueId())) {
            if (event.getAction() == Action.RIGHT_CLICK_BLOCK && block.getState() instanceof InventoryHolder && block.getState() instanceof Lockable) {
                event.setCancelled(true);
                //container.set(key, new UUIDDataType(), uuid);
                //locks the UUID together with the PDC

                MagmaBuildNetwork.playersWantingLock.put(loc, uuid);
                Chest c = (Chest) block;

                c.getPersistentDataContainer().set(key, p.getUniqueId())
                c.update();
...
fierce salmon
#

run task later?

unkempt peak
#

Yes

sage swift
#

why are you getting the item's persistent data container

#

you're not even using it

opal juniper
tardy delta
#

uhh that was something from before

sage swift
#

you're also casting the block to a chest

#

you have to cast the state

tardy delta
#

but look this eroor

#

oh

sage swift
#

and again, you can't store the uuid, you have to store the string

#

but you also have to specify the PersistentDataType

unkempt peak
tardy delta
sage swift
tardy delta
#

getState() ?

bitter mural
#

hello, all! Is it bad practice to have an @EventHandler in the same class as a CommandExecutor?

unkempt peak
#

Yes

sage swift
#

kinda, yeah

#

but it depends on the size of a plugin

unkempt peak
#

Put events in there own class

tardy delta
#

pff

#

I'm probably doing some things wrong

bitter mural
#

Any advice for how best to pass information from the command that initiates the listener to start listening? E.g. I want to listen for a crafting event, but only from the player who ran /craft

ivory sleet
ivory sleet
sage swift
#

store the resulting inventoryview

#

then check if the view is the same as the stored

tardy delta
ivory sleet
#

Probably wanna use a set in this instance

bitter mural
#

ok good that's what I'm doing, but i thought it seemed a little too complicated maybe.

tardy delta
#

i did this
public static List<UUID> frozenPlayerList = new ArrayList<UUID>();

ivory sleet
#

No no no

bitter mural
tardy delta
#

and now I'm working at that lock problem :///

ivory sleet
#

That list has no reason to be static

sage swift
#

nor a reason to be a list

bitter mural
#

oh not me haha

tardy delta
#

doesnt matter

ivory sleet
#

And a set can be used to make lookups more efficient

sage swift
#

you're not gonna store the player twice

tardy delta
#

it works

ivory sleet
#

Scalability is important tho

wooden warren
#

How make an on armour equip/ de equip event

tardy delta
#

well yea the second time i did this
public static final Set<UUID> playersWantingLock = new HashSet<>();

#

so i would change that first one to a hashset?

sage swift
#

hashset implements the set interface, so you can leave it as Set unless you need HashSet's features

ivory sleet
#

Liskov substitution principle ^

tardy delta
#

something like this?

public static final Set<UUID> playersWantingLock = new HashSet<>();
sage swift
#

yep, that works

ivory sleet
tardy delta
#

but for some reason i can leave this <> empty
public static final Set<UUID> playersWantingLock = new HashSet<>();

#

is that used to be like this?

sage swift
#

yeah you can leave the type empty

#

because it's inferred

tardy delta
#

ke

sage swift
#

when the plugin is compiled, it puts the type in the definition too

ivory sleet
#

Yeah idk gecko just took the first thing that came when searching for it

sage swift
tardy delta
#

would i use a hashmap or hashset to store UUIDs for later look if someone is inside?

sage swift
#

set

bitter mural
#

Is it also bad practice to have two @EventHandlers in the same Listener? For instance, I want to check if the player crafted the right item (CraftItemEvent) and only then check if the player exits the crafting interface (InventoryCloseEvent).

sage swift
#

you don't need to store duplicates

tardy delta
#

oke

sage swift
#

unless you have a lot of stuff going on within

ivory sleet
#

Again if would advocate to do this as long as you follow single responsibility principle

tardy delta
#

but i was also going to use a hashmap to store the uuid of a player and the location of chest but dont know how to export information from that

#

when i want to use it an eventhandler

sage swift
#

dont need to

bitter mural
#

thanks all!

subtle kite
#

did you figure this out?

sage swift
#

whenever someone tries to open the chest, just check whether the stored uuid matches the uuid of the clicker

tardy delta
#

oh

#

how would i do that the best way?

#

well storing that does not really work

#

thats the problem

subtle kite
#

I may have something that might help you , but prob not fourteenbrush
might be also useless for you

tardy delta
#

oh

#

I've been struggling for a while XD

unkempt peak
#

I always put events and commands in there own classes

ivory sleet
#

I have everything in one class md_5

unkempt peak
tardy delta
#

this is strange i never saw that my name changed to fourteenbrush xd

unkempt peak
#

It's such a mess in one class

opal juniper
ivory sleet
#

Minimalism it is

unkempt peak
#

Yeah lol besides laziness it has no advantages

opal juniper
#

I tend to write a plugin all in one class, then realise I should of split it out and do it afterwards

#

The one thing I instinctively make a new class for is packet adapters

#

Other than that, it’s a main class party

#

🥳

unkempt peak
#

When I make a plugin I always think through and make the packages and think of the classes I will need

#

Before I write any code

opal juniper
#

Yeah, I wish I did that

tardy delta
#

ow yea is there a way to make the plugin.yml usage output another color?

ivory sleet
#

You said SOLID? What’s that never heard of it

tardy delta
#

if you understand what i mean

opal juniper
#

Idk to be honest

unkempt peak
#

What do you meN

opal juniper
#

Can you put colour codes in the usage

unkempt peak
#

Mean*

tardy delta
#

i know §1 works but maybe there is a way to put it a class and automatically do it

opal juniper
#

If the colour codes work just use them

#

Right?

tardy delta
#

mmm

unkempt peak
#

Just use &1 with translate codes

opal juniper
#

I mean, I try and avoid returning false and instead print the help command or whatever

amber lake
#

What data structure do you guys use to store huge amount of data? But I want one that supports faster fetch and update(like add and remove), and if possible it should by thread-safe and concurrent

tardy delta
#

return false does print the command usage right? :/

opal juniper
#

But what I do is return true and print out one manually

amber lake
#

Sorry, instances of classes*

ivory sleet
#

Would be surprised if your data consisted of classes

amber lake
#

Didn't understand

ivory sleet
#

Anyways I usually use a ConcurrentHashMap with a loading function or a caffeine expiring cache (also thread safe) but ofc this very much depends on how you’re storing data

#

For instance maps aren’t suitable for permissions nodes

amber lake
#

I'm using concurrentmap to store "<UUID, ...>" informations, but I want something like an ArrayList, with fast random access and modification, the problem is that want a thread-safe option of it.

sage swift
#

CopyOnWriteArrayList

ivory sleet
#

Thread safe stuff will always be slower

#

They have to use some sort of lock mechanism assuming the data structure is mutable to avoid certain issues

amber lake
ivory sleet
#

Depends on what type of data

#

Also everything on stack overflow isn’t probably the best source for learning data modeling etc

tardy delta
#

how do i get that persistentDataType? tag ms pls

sage swift
#

could use an auto-incrementing Integer key as the index in a ConcurrentHashmap

amber lake
#

Let's suppose that my plugin will store 50k+ instances of a custom class, which data structure should I use?

sage swift
#

PersistentDataType.

ivory sleet
tardy delta
#

dont know how to make that

sage swift
#

you type PersistentDataType.

ivory sleet
#

how are you going to use the data

tardy delta
#

i want to store uuids inside a container

sage swift
#

PersistentDataType.STRING

#

really simple

ivory sleet
tardy delta
#

well this seems easy for you but not for me

sage swift
#

he wants to have chest locks with owners

#

whoever places it down probably becomes owner

ivory sleet
#

oh

tardy delta
#

no only the people who do /lock and they become inside a hashset or something

amber lake
# ivory sleet Still what type of data is this

I would take forever to explain the whole plugin. So, supposing that the class has just 3 fields and them doesn't hold that much of informations, is ArrayList good enough to store them?

tardy delta
#

i have to stop maybe tag me with an reponse :))))

ivory sleet
#

But as I said

#

Depends very much on WHAT data and HOW you’re going to use it

#

Is it permissions? Is it homes?

sage swift
#

at that point maybe sql

#

lmao

ivory sleet
#

Things like that matters

amber lake
ivory sleet
#

What is the maxValue and numbers doing

#

What are you doing with the data

#

Why do you need that

#

First and foremost we develop an idea then we create the model design which suits that idea

amber lake
#

The maxValue will be a final and I will update the numbers, adding and removing them as I need

sage swift
#

seems weird to store 50000 owners in memory

amber lake
#

😂

ivory sleet
#

I’m out you still haven’t told us what the numbers are for

#

Good bye

amber lake
#

I just did

#

I will add and remove them of the list 🤨

sage swift
#

that's not what they're for though

#

or are you adding and removing for fun

unkempt peak
#

lol

amber lake
#

😐

sage swift
#

:]

amber lake
#

Bro, it's just a study, which type would you guys use?

#

Sorry, class*

sage swift
#

always forget, does entity.Damageable#damage ignore armor? if so, how can i make it not?

#

yes it does ignore time for nms

tardy delta
#

hi

unkempt peak
#

Hello

wraith rapids
#

what we use depends on what it's for

#

arraylist is a good default implementation

#

usually it doesn't matter enough to give a shit about

grim sage
#

hey guys ! someone know how to drop an item ?

player.getWorld().dropItem(player.getLocation(), new ItemStack(Objects.requireNonNull(Material.getMaterial(reward[0])), Integer.parseInt(reward[1])));

It seems not working

wraith rapids
#

define not working

chrome beacon
#

Well that's the correct method but we can't really help with that info

grim sage
#

hum very strange because I saw on forums that this method don't work for some people

ivory sleet
#

That code isn’t the best

#

Objects::requireNonNull and Integer::parseInt may throw exceptions with the given inputs

wraith rapids
#

well what would you expect of the spigot forums

#

literally everyone who posts there is sub 70 iq

grim sage
ivory sleet
#

It works yeah

#

Well

unkempt peak
#

Working != good

grim sage
lilac dagger
#

simplify it

#

you'll see how easy it is

sage swift
#

Objects.requireNonNull high iq, that'll show em!

lilac dagger
#

i mean

#

in here it'll do nothing

ivory sleet
#

Assume the elements in the array is always satisfying parseInt and getMaterial then it works

lilac dagger
#

pretty sure itemstack has a validate check for null

grim sage
#

If I do it it don't work too

player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.GRASS, 1));
unkempt peak
#

That should work fine

#

Is there an error?

#

Also make sure that code is actually running

lilac dagger
#

maybe item spawning is disabled

unkempt peak
#

^

#

Yes

coral sparrow
#

What is the method for Executing when right clicked a block in ur inv

lilac dagger
#

you can also use dropItemNaturally

grim sage
lilac dagger
#

maybe you have a pre check

lilac dagger
#

that stops it from running

#

or the event is not registered

coral sparrow
#

event.getclickedblock?

unkempt peak
#

Sysout and make sure the code is running

lilac dagger
#

the best way is to provide the whole code

coral sparrow
#

PlayerInteractEvent

#

i meant this

lilac dagger
#

we won't need it, i promise :>

grim sage
#

hum lmao the drop line is never triggered

#

this is probably why it doesn't work xD

glass sparrow
#

even oxygen

wraith rapids
#

lol'

grim sage
#

But I don't know now why my "full inventory detector" is not working

#

xD

wraith rapids
#

the player's lungs interacted with oxygen

#

fire some events

glass sparrow
#

playerbreatheevvent

lilac dagger
#

ss it

coral sparrow
#
  public void onInteract(PlayerInteractEvent event) {
        Action action = event.getAction();
        Player player = event.getPlayer();
        Block block = event.getClickedBlock();
        
        if(action.equals(Action.RIGHT_CLICK_AIR)){
            if(block.getType().equals(Material.STONE)){
//Exectue a cmd
            }
        }
    }```
opal juniper
#

I think redempt has a good inventory checker waits for @wraith rapids to have a seizure

coral sparrow
#

Will this work as intended

sage swift
#

/stop

glass sparrow
#

no

glass sparrow
opal juniper
glass sparrow
#

it has to be click block

opal juniper
#

As well

glass sparrow
#

no air

coral sparrow
#

like

unkempt peak
#

Right_click_block

coral sparrow
#

I want to click the block

#

not on the block

opal juniper
#

Wtf is that texture

unkempt peak
#

Yeah lol

glass sparrow
#

change it to right click block to check for the right clicketh of a blocketh

coral sparrow
unkempt peak
#

lol

opal juniper
coral sparrow
opal juniper
#

Yeah

coral sparrow
#

Like click the object not ON it

glass sparrow
#

oh

#

just check for a click

#

then get item in main hand

unkempt peak
#

Lol check for right click block and get hand

opal juniper
#

Or right click air

#

Get the hand of the player

#

And check the item

coral sparrow
unkempt peak
#

?

glass sparrow
#

yeah block or air

coral sparrow
#

He must click the item

glass sparrow
#

yeah check if item in hand is the wanted item

#

or material

#

or name

#

or nbt tag

opal juniper
#

Yeah, so check the item in their hand is the correct item using a pdc off something

coral sparrow
opal juniper
#

Yeah, then, open a gui

unkempt peak
#

Lmao check if they right click the item and open the gui

coral sparrow
unkempt peak
#

Its not hard

coral sparrow
#

.

unkempt peak
#

Check the item data

opal juniper
#

Get the main hand and get the item

#

Check using the persistent data container

unkempt peak
#

Name lore material literally anything

opal juniper
#

No

#

Use pdc

#

Not more

#

Lore*

pulsar zenith
#

I am trying to get a list using a dependency injector, and I am having a NPE.

glass sparrow
#

personally i use an &0 tag in my lores

coral sparrow
#

ok ty for help

#

now how do i get fps

#

jk xd

glass sparrow
#

fps is always 30

#

anything else is a myth

coral sparrow
#

xd

ivory sleet
#

```java
code here

wraith rapids
#

make inv private

#

and final

pulsar zenith
#

Where I am storing the list:

private List<String> hunter = new ArrayList<String>();
    private List<String> speedrunner = new ArrayList<String>();

    private boolean hasGameStarted = false;

    public List<String> getTeam(Team team){
        if(team.equals(Team.HUNTER)){
            return hunter;
        }
        if(team.equals(Team.SPEEDRUNNER)){
            return speedrunner;
        }
        return null;

    }
    public boolean getGameStatus(){
        return hasGameStarted;
    }
    public void setGameStatus(Boolean b){
        hasGameStarted = b;
    }

Where I am trying to get the list

 private Main main;

    public ClearInv(Main main) {
        this.main = main;

    }

    List<String> hunter;
    boolean gameStatus;

    private final ManHuntInventory inv = new ManHuntInventory();

    private ManhuntGameManager manhuntGameManager;
    public ClearInv(ManhuntGameManager manhuntGameManager){
        this.manhuntGameManager = manhuntGameManager;
        hunter = manhuntGameManager.getTeam(Team.HUNTER);
        gameStatus = manhuntGameManager.getGameStatus();
    }
opal juniper
#

Make is static as well for the lols

You won’t piss off anyone

coral sparrow
#

if(action.equals(Action.RIGHT_CLICK_BLOCK)){ if (player.getItemInHand().equals(Material.SKULL_ITEM)){}

wraith rapids
#

don't use equals to compare enum constants

#

use ==

opal juniper
#

^^

coral sparrow
wraith rapids
#

and the item in main hand will never be equal to a Material

#

the item in the main hand is an ItemStack

#

which will never be equal or == to a Material

#

get the type of the itemstack and compare it instead

coral sparrow
#

it worked but ok xd

opal juniper
#

How lmao

glass sparrow
#

what

wraith rapids
#

literally not possible lmao

glass sparrow
#

he is the master of code

wraith rapids
#

in fact you should be getting a compiler warning about it

opal juniper
#

What ide u use?

#

Ms paint?

glass sparrow
#

dont diss paint ide

pulsar zenith
#

nah notepad is best

sage swift
#

you dont understand he made his own Material enum with itemstacks

coral sparrow
#

photoshop

#

fire

opal juniper
#

That’s not a thing, but ms paint ide actually is:

https://ms-paint-i.de

glass sparrow
#

its the best ide

coral sparrow
#

loool

opal juniper
#

I can see it

floral kindle
#

Does anyone know how to disable animation of the double chest?

opal juniper
#

Packets

sage swift
#

or something to do with Lidded

floral kindle
#

I can get the animations out of the chest

#

I just have a problem doing this with the double chest

paper viper
#

Does anyone know the proper way to run another task from a task that is being executed? For example, if the user runs ./gradlew build, I want it to also run the shadowJar task

opal juniper
#

Or, cancel the event and show the inv of the chest to the player

sage swift
#

at monitor priority of course

cinder thistle
opal juniper
cinder thistle
#

I don’t think I’ve seen an update i a while

ivory sleet
#

Or shadowJar.dependsOn build

wraith rapids
#

tell the bukkit scheduler to run shadowjar

opal juniper
paper viper
cinder thistle
amber lake
#

The fuck is this...

opal juniper
#

I don’t get it, what’s so funny

#

It’s ms paint ide

unkempt peak
#

Lmao

amber lake
opal juniper
#

Lmao

#

It’s converts pictures of code to@code

#

It’s an ocr

unkempt peak
#

Actually that's pretty cool

opal juniper
#

So you make the pictures of code in paint

amber lake
#

Ocr? I don't that that term

opal juniper
#

And then it compiles

wraith rapids
#

quite a bit of technology and software acually goes into making that happen

opal juniper
#

Optical Character Recognition

#

So picture -> text

unkempt peak
#

Yeah I've tried using an ocr before they take alot of work to be accurate

opal juniper
#

Yeah I can imagine

lilac dagger
#

i'm so stupid if guys create ides just for the memes

opal juniper
#

No a guy made it a while back

#

Idk him, but it is open src

amber lake
amber lake
lilac dagger
#

no need to imagine

#

😂

amber lake
#

😅

coral sparrow
#

nvm

torn oyster
#

https://paste.md-5.net/sezojowise.cpp
hey i have this scoreboard system (its pretty crap)
this method is ran in a runnable every second
how do i make it not flicker and be able to have teams

#

i've had this system for like 3 months

#

i kinda wanna change it

wraith rapids
#

consider using a plugin

torn oyster
#

nah i need it to show important stuff in my minigame plugin

#

and also im here to ask for help with my plugin

#

not to be told to use another plugin

wraith rapids
#

sometimes the best move is not to play

torn oyster
#

i need it to show stats in my minigame

wraith rapids
#

consider finding a library

torn oyster
#

oh thats what u mean

wraith rapids
#

no not really what I meant at first but using a library is the "i'm making a plugin" version of "consider using a plugin"

#

basically there is little need to reinvent the wheel and someone probably has already put the effort in

#

that said i'm not sure if any good scoreboard libraries exist

#

doesn't hurt to look though

ivory sleet
#

Yeah you could use a plugin which might provide an api which you would use then

torn oyster
#

featherboard api?

sage swift
#

the first step is to not use 1.8

#

lol

opal juniper
#

can i get the material type of the result when a specific block is broken?

eg

Grass -> Dirt

Stone -> Cobble

Dead Bush -> Stick

eternal oxide
#

getDrops()

lilac dagger
#

that works?

#

i tried it on my miniwalls minigame

wraith rapids
#

how does that work now? i remember there being butthurt about it being changed recently

opal juniper
#

Hmm

wraith rapids
#

something about the default overload and fortune

lilac dagger
#

it didn't worked

opal juniper
#

i feel like that could work

lilac dagger
#

at all

opal juniper
#

What if i say that if the first drop in the getDrops() is not equal to the type of the block?

#

then i would know something different is the result

sage swift
#

you can use BlockDropItemEvent maybe?

lilac dagger
#

do you guys know of any way to extract all the strings of a class?

sage swift
#

it really depends on the use case

eternal oxide
#

are you talking about strings for translation or just String fields?

sage swift
#

like, if you want to modify the drops of a broken block, use BlockDropItemEvent
if you want to get the theoretical drops before it's broken, you can use getDrops

lilac dagger
#

any string a class has

wraith rapids
#

or compile time string literals

lilac dagger
#

as fields, as variable, or even passed as a parameter

eternal oxide
#

then no, not without a crazy amount of reflection

lilac dagger
#

damn

wraith rapids
#

why

lilac dagger
#

i just had a cool idea

eternal oxide
#

it doesn;t sound cool so far

lilac dagger
#

are you afraid that i'll create viruses or something?

opal juniper
#

How is this always true?

eternal oxide
#

No, just some abomination that will become sentient and start WW3

wraith rapids
#

are you sure it's not saying always false

opal juniper
#

yeah

#

i can't read

#

why tho

wraith rapids
#

the collection is annotated as not null

lilac dagger
#

i think it can never be null

wraith rapids
#

or rather the method is

opal juniper
#

i thought that not every block drops though

wraith rapids
#

it may still be empty, but you will always get some sort of a collection

opal juniper
#

ahh

#

ok

#

huh

#
            if(exploded.getDrops().isEmpty()) continue;

            Collection<ItemStack> drops = exploded.getDrops();

            if(Iterables.get(drops,0).getType() != exploded.getType()){
                if(!Iterables.get(drops,0).getType().isBlock()) continue;
            }

Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0

wraith rapids
#

the collection is empty

#

index 0 does not exist

opal juniper
#

i thought the top line would weed that out

wraith rapids
#

why are you getting it again after the isEmpty check

opal juniper
#

point

#

actually i know

#

cause i was doing null

#

so i didn't want to get until i knew it wan't null

#

But still

wraith rapids
#
            Collection<ItemStack> drops = exploded.getDrops();
  
            if(drops == null || drops.isEmpty()) continue;

            if(Iterables.get(drops,0).getType() != exploded.getType()){
                if(!Iterables.get(drops,0).getType().isBlock()) continue;
            }

Caused by: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0

#

idk why it's doing that though

#

try it this way

#

maybe it returns a different collection the second time or some arcane shit

opal juniper
#

it didn't error

lilac dagger
#

there is an iterable? :O

opal juniper
#

yuhuh

lilac dagger
#

oh, it's from google

opal juniper
#

yeah

lilac dagger
#

i thought i didn't knew my jre

opal juniper
#

Is there a way to make falling blocks not slide all over the place

wraith rapids
#

you'd have to control their velocity manually

#

they never got any friction code associated with them since they normally turn into regular blocks when they touch the floor

opal juniper
#

Can i add friction 😈

sage swift
#

it also might be semi-clientside where the block will keep sliding even though it's not moving on the server side

wraith rapids
#

by manually slowing them down, sure

#

all physics are semi clientside

opal juniper
#

They are just going for a dip

wraith rapids
#

the client will try to simulate everything and will just yield to whatever the server says actually happened

#

that's happening because they're entirely clientside

opal juniper
#

I tried to zero their velocity on the block change but i think i need to send a packet?

wraith rapids
#

the server isn't applying the regular air resistance and friction to them

#

since they're entirely clientside you'll need to manage them manually with packets

opal juniper
#

Yeah oj

sage swift
#

why are you torturing yourself with this

opal juniper
#

With what

#

Granted those vectors ^^ need some work

hollow canopy
#

can you guys give some hint to me? I want to do this

#

Has this player already got a shulker inventory? If so: open that inventory by looking through a map for it If not: create a new shulker and add it to a map with the player uuid as a key

#

I have the shulker check I did it

wraith rapids
#

my SHOULDERS

opal juniper
#

Sheeeed
Caused by: com.comphenix.protocol.reflect.FieldAccessException: No field with type short exists in class PacketPlayOutEntityVelocity.

wraith rapids
#

check the source

opal juniper
#

cannot find it

#

<

#

bad day

wraith rapids
#

net.minecraft.server.PacketPlayOutEntityVelocity

opal juniper
#

danke

#

seems like they may be doubles

loud cloud
#

For Bungeecord, is there a way to detect when there are No default or fallback servers to send a player to? And then connect them to a different sever before they get kicked with that message

opal juniper
#

Nope, not that

loud cloud
#

huh

opal juniper
#

sorry not for you

loud cloud
#

oh

opal juniper
#

lemme read ur q

loud cloud
#

sorry

wispy fossil
#

they just schwimmin

opal juniper
#

<

wispy fossil
#

oh nice lol they can be a pain sometimes

opal juniper
#

yuhuh

#
        final PacketContainer veloctiyPacket = new PacketContainer(Server.ENTITY_VELOCITY);
        veloctiyPacket.getIntegers().write(0,id);
        veloctiyPacket.getDoubles()
                .write(0,(double) 0.0)
                .write(1,(double) 0.0)
                .write(2,(double) 0.0);
wispy fossil
#

thats why i used armor stands 🤣

#

still have their troubles though

opal juniper
#

Yeah

wispy fossil
#

cant get em to SIT

opal juniper
#

Huh, it didn't error if i used integers

#

but it didn't do nuttin

#
    @EventHandler
    public void onBlockChange(final EntityChangeBlockEvent event) {
        final int id = event.getEntity().getEntityId();
        if (this.blockIDs.remove(id)) {
            cancelVelocity(id);
            event.setCancelled(true);
        }
    }

    public void cancelVelocity(int id) {
        final PacketContainer veloctiyPacket = new PacketContainer(Server.ENTITY_VELOCITY);
        veloctiyPacket.getIntegers().write(0,id);
        veloctiyPacket.getIntegers()
                .write(0,0)
                .write(1,0)
                .write(2,0);
        Bukkit.getOnlinePlayers().forEach(player -> {
            try {
                RealPhysics.this.protocolManager.sendServerPacket(player, veloctiyPacket);
            } catch (final InvocationTargetException e) {
                e.printStackTrace();
            }
        });
    }
#

It must just be because they are technically gone or something

#

idk

#

wait

#

but im overwriting the id

wispy fossil
#

when I first tried using fallingblocks I peeked into the original block physics plugin's code
it was from 1.8, they imported an entire physics engine and applied that to falling blocks
to prevent them from disappearing, they just cancelled the event (I believe?)
that no longer works in 16.5 and I couldnt find a better solution to keeping them alive, and at the same time keeping their velocity
but packets might work

wraith rapids
#

they are clientside so the event should never fire

opal juniper
wraith rapids
#

oh so you went back to the cancelling destroy packets approach

opal juniper
#

Yeah

#

it works

#

Just i need to stop the sliding

#

Hmm i really dk what the problem is here

wraith rapids
#

dunno

opal juniper
#

i mean with that code above i am overwriting the id with the x

#

but the strange thing is that the wiki says they are doubles but it only accepts ints

turbid grove
#

guys, where do I find the logic responsible for thrown midair enderpearl collision detection?

wraith rapids
#

they're probably ints in 1/8000 of a block

opal juniper
#

Yeah they are

#

well

wraith rapids
#

it says they're shorts but idk

opal juniper
#

it errors saying there are no shorts

#

not if you use ints

wraith rapids
#

yeah the actual packet class uses ints

#
   public void b(PacketDataSerializer var0) throws IOException {
      var0.d(this.a);
      var0.writeShort(this.b);
      var0.writeShort(this.c);
      var0.writeShort(this.d);
   }
#

but it's sent as shorts over the protocol

opal juniper
#

oh i see that now

#

hadn't read the whole src

wraith rapids
#

did you try it without overwriting the id with the x

opal juniper
#

what, do 1,2,3 for the velo

wraith rapids
#

yeah

opal juniper
#

yeah i did

wraith rapids
#

id is 0

opal juniper
#

although

wraith rapids
#

nothing happens?

opal juniper
#

no

#

What does 0 velocity actually mean

#
    @EventHandler
    public void move(PlayerMoveEvent event){
        event.getPlayer().getVelocity().zero();
    }

as a test i wrote this ^^^^ and it doesn't do anything

wraith rapids
#

player velocity is entirely clientside

#

all player movement is entirely clientside

#

setting the player's velocity doesn't do anything

#

and you'd have to use player.setVelocity after modifying it anyway

#

get's generally clone the underlying value

torn oyster
#

how do i include a jar file located in here

#

in my maven package

chrome beacon
#

Stary by not using that

torn oyster
#

the maven repo for the jar file im using doesnt work

#

and hasn't worked for like 3 years

wraith rapids
#

build it locally

#

or install it to your local repo from the jar

chrome beacon
#

^^

wraith rapids
#

i don't remember how but that's a thing you can do

opal juniper
#
    @EventHandler
    public void move(PlayerMoveEvent event){
        Vector velo = event.getPlayer().getVelocity();
        velo.zero();
        event.getPlayer().setVelocity(velo);
    }

Ok yeah this works

#

Ok, so my packet doesn't work

#

as a test i set the y to 1

#

and i am running it like this:

    @EventHandler
    public void crouch(PlayerToggleSneakEvent event){
        Player player = event.getPlayer();
        Entity e = player.getWorld().spawnEntity(player.getLocation(), EntityType.BEE);
        cancelVelocity(e.getEntityId());
    }
#

This is good news though, because it could work

torn oyster
#
mvn install:install-file -Dfile=L:/Downloads/ScoreboardLib.jar -DgroupId=me.tigerhix.lib -DartifactId=scoreboard -Dversion=1.0.1-SNAPSHOT -Dpackaging=jar```
#

why isnt it working lmao

#

it says build success

#

but when i compile it

#

the thing still says the import doesnt exist

wraith rapids
#

did you add it to your pom

torn oyster
#

i cant

#

i am using a jar file

wraith rapids
#

you can

torn oyster
#

in the libraries

#

how do i

wraith rapids
#

that's the point of using the command you pasted

#

to install it to your local maven repo

#

so you can add it to your pom

#

and pull it from your local maven repo

#

-DgroupId=me.tigerhix.lib
-DartifactId=scoreboard
-Dversion=1.0.1-SNAPSHOT

torn oyster
#

ah

wraith rapids
#

this is the dependency information

torn oyster
#

i understand now

wraith rapids
#

the repository information is not required

#

as you just installed it to your local repo

#

which is used by default

torn oyster
#

there

#

works now

#

i thought installing it would add it to the list of dependencies

ivory sleet
#

Absolutely not sorry

quaint mantle
#

Why cant i use instanceof pattern matching in Intellij?

#

It says that "patterns in instanceof are not supported at language level 16"

wraith rapids
#

the java version you're building for doesn't support it i guess

#

it was added in java 14 or something iirc, not sure why it would complain about it

quaint mantle
#

I'm using AdoptOpenJDK 16

opal juniper
#

I seem to have got it to work somewhat @wraith rapids

#

There must be an error in my code

#

or just that the packets are unreliable, idk

#

Most freeze but you get a few that don't

wraith rapids
#

could be some weird interpolation happening on the client

opal juniper
#

Yeah, idk

wraith rapids
#

i suppose it's also possible that the server sends a velocity packet for the block just before it's destroyed by the event being cancelled

#

which would override the packet you send

#

try sending your velocity packets a tick or two later

#

also, über protip

#

instead of despawning them, make them fall into the ground

opal juniper
#

umm, is that possible

wraith rapids
#

teleport them downwards by .1 blocks and they will no longer collide with the top side of the block they're on

#

and they just fall through

opal juniper
#

ohh

#

ok

wraith rapids
#

can just send a relative teleport or movement packet for each of them

opal juniper
#

i could do that and then remove them

wraith rapids
#

yeah

opal juniper
#

delaying them like this:

            new BukkitRunnable() {
                @Override
                public void run() {
                    cancelVelocity(id);
                }
            }.runTaskLater(this,2L);
``` dont help ><
wraith rapids
#

try spamming the packet a shit ton and see if that helps

#

send it once every tick for each entity for like 20 ticks

opal juniper
#

lmao

pulsar zenith
#

I am trying to get a list using a dependency injector, and I am having a NPE.
Where I am storing the list:

private List<String> hunter = new ArrayList<String>();
   private List<String> speedrunner = new ArrayList<String>();

   private boolean hasGameStarted = false;

   public List<String> getTeam(Team team){
       if(team.equals(Team.HUNTER)){
           return hunter;
       }
       if(team.equals(Team.SPEEDRUNNER)){
           return speedrunner;
       }
       return null;

   }
   public boolean getGameStatus(){
       return hasGameStarted;
   }
   public void setGameStatus(Boolean b){
       hasGameStarted = b;
   }

Where I am trying to get the list

 private Main main;

    public ClearInv(Main main) {
        this.main = main;

    }

    List<String> hunter;
    boolean gameStatus;

    private final ManHuntInventory inv = new ManHuntInventory();

    private ManhuntGameManager manhuntGameManager;
    public ClearInv(ManhuntGameManager manhuntGameManager){
        this.manhuntGameManager = manhuntGameManager;
        hunter = manhuntGameManager.getTeam(Team.HUNTER);
        gameStatus = manhuntGameManager.getGameStatus();
    }
wraith rapids
#

post actual code and post the actual error

opal juniper
#

is there an easy way to delay code without the whole 5 line runnable thing

wraith rapids
#

yes with the 2 line bukkit runtasklater thing

#

bukkit.getscheduler().runtasklater(plugin, () -> {// code here}, delay);

opal juniper
#

oh i always forget about lambda

#

i find the arrows kinda goofy

#
            for(int i = 0; i < 20; i++){
                Bukkit.getScheduler().runTaskLater(this, () -> {
                    cancelVelocity(id);
                }, 1L);

            }

Ok, so this doesn't do anything
Idk what will

wraith rapids
#

that just schedules 20 tasks to happen on the same tick

opal juniper
#

<

#

yeah

wraith rapids
#

use i instead of 1L

#

make the velocity shoot them up instead of stop them

#

maybe some of the blocks get dropped out of the eid set or something

opal juniper
#

its that

#

some just don't move

#

but i don't know why or how

#

like

#
        public void create() {
            final FallingBlock fallingBlock = this.location.getWorld().spawnFallingBlock(this.location, this.blockData);

            this.id = fallingBlock.getEntityId();

            fallingBlock.setHurtEntities(false);
            fallingBlock.setDropItem(false);
            fallingBlock.setVelocity(this.vector);

            packetInterceptor.setBlockedOnce(fallingBlock.getEntityId());
            blockIDs.add(this.id);
        }

This is the method i use to make them

#

But if i change it so that no matter what, if the EntityChangeBlockEvent gets called they get their velocity packet they still don't work

wraith rapids
#

yeah it kind of just looks like some of them aren't receiving any velocity packets at all

opal juniper
#

Yeha

#

Idrk why they wouldn't get them though

wraith rapids
#

dunno

spice juniper
#

when do you need to add api version to your plugin.yml

opal juniper
#

wdym by when

wraith rapids
#

when you use materials that were added after 1.12

opal juniper
#

oh ok

wraith rapids
#

ideally always

spice juniper
#

okay

opal juniper
#

Hmmm

wraith rapids
#

as not specifying an api version has your entire plugin going through the batshit crazy compat layer

opal juniper
#

Im pretty stumped tbh with this. It seems like some entities just kinda don't exist at all even to the client

#

Or like their EID shifts or sommin

wraith rapids
#

they clearly do though as they do respond to the destroy packets you resend

#

just not the velocity packets

opal juniper
#

Actually thats a point

#

hmm

wraith rapids
#

try sending some other kinds of packets for them

#

maybe the teleport down by .1 block packet

#

see if the stragglers ignore that too

opal juniper
#

this?

wraith rapids
#

proobably

#

use the relative teleport packet

#

or movement packet

#

idr which it's called

#

there's one that lets you "move this by this many blocks to this direction from its current position"

#

so you can just tell it to go .1 blocks down rather than calculating the absolute location of where that'd be

opal juniper
#

im not seeing it

#

REL_ENTITY_MOVE

#

?

wraith rapids
#

sounds like it

opal juniper
#

this looks like a pain

#

i don't have time now

#

i gtg

#

thanks tho

wraith rapids
#

i remember there is some sort of a limit to how far it can go, like 8 blocks or something

opal juniper
#

yeah i saw something like that

#

more than that it is a tp

wraith rapids
#

myeah

opal juniper
#

idk

#

ok see ya + thanks

wraith rapids
#

👌🏿

pulsar flint
#

Does anyone know how to check an area for a certain block type and summon a mob at every one of their positions?I don’t even know where to start with it.

sage swift
#

for (int x = -radius; x <= radius; x++) {
if (world.getBlockAt(x, y, z).getType() == yourMaterial) {
doThing

pulsar flint
#

Am I able to do this with the worldguard API using regions? If so, how? And how would I spawn mobs at every block of that type in that area? Say for example I wanted to summon slimes to all the slime blocks

sage swift
#

worldguard/edit api, good luck

#

horribly overcomplicated api, very unfriendly developers
they laugh at every question

#

they do have their own discord though

quaint mantle
#

Which is better for adding players to a list (if in list has particle trail) HashMap or Arraylist?

sage swift
#
  1. don't store the player object, store the uuid
  2. are you storing extra information for each player? (like the type of trail)
quaint mantle
#
  1. ok
  2. no, cause theres only the 1 type, so it would only be the username/UUID
sage swift
#

you're storing the trail that the player has selected, no?

#

there's only one type

#

so then use a set

#

hashset

#

Set<UUID> enabledTrails = new HashSet<>();

quaint mantle
#

Oh word, never though to use HashSet

sage swift
#

list is for when you can have duplicate objects

#

you won't be storing uuids twice, so there's no need

#

and Set has better performance in some aspects than List

drowsy helm
#

and set is unordered

ivory sleet
#

LinkedHashSet

#

TreeSet

pulsar flint
wraith rapids
#

get the min and max bounds of the region

#

iterate over all of the blocks contained between those points

#

spawn a slime for each slime block

#

or whatever

cold pawn
#

How can I make a command that changes a specific string in a players data.yml I already got the data part working but for some reason I cant seem to get the string changing part right?

eternal oxide
#

You should never directly edit a player dat file

cold pawn
#

hmm ok then how would I go about making that then without doing it directly?

eternal oxide
#

Seeing as all you've said is editing a string, no one can tell you

cold pawn
#

What more can I say the whole plugin works when a player joins a a default string is saved in a data.yml with there uuid then when a command is ran that string is suppose to change to something else

eternal oxide
#

You are giving us literally nothing to work with

cold pawn
#

What do you want me to give u the code I have so far?

eternal oxide
#

A String, a UUID, something is supposed to change

#

No, just tell us exacly what you are trying to achieve

cold pawn
subtle vector
#

my thing isnt working. the goal is when i hit something it replaces the current attribute with a differnt attribute. eg i have 20 attack damage the ability replaces the 20 with 21 or x, instead whats its doing it adds a new one it shows on the sword +20 attack damage and + 21 attack damage and idk why

eternal oxide
#

So nothign to do with the player dat file then

cold pawn
#

Its suppose to change that default string that's set in the data.yml to a new string that is then displayed when they run a command

#

nope

subtle vector
#

i am currently using method remove attribute modifier and then do add attribute modifier method

eternal oxide
#

Currently your code checks the config entry exists. If it does it changes that entry to "FireElement"

cold pawn
#

Yes bit it returns null when I run the command

dusk flicker
#

that data manager is def null

eternal oxide
#

So your real problem is you have an NPE error...

#

It helps a lot if you tell us all the info

#

?paste the FULL error

queen dragonBOT
cold pawn
eternal oxide
#

FireCommand.java:32

#

which line is that ?

dusk flicker
#

i wanna make a bet its the if statement

eternal oxide
#

yep, betting data is null

cold pawn
#

if (this.data.getConfig().contains("players." + player.getUniqueId().toString() + ".element"))

dusk flicker
#

Called it

#

LOL

cold pawn
#

correct

dusk flicker
#

I can see the NPE from 10 miles away

#

you never set the data var to anything

eternal oxide
#

you never set a value to data

dusk flicker
#

also what the fuck is that perm msg

cold pawn
#

wym data is just extending the datamanger thats already created in another class?

dusk flicker
#

thats not how that works

eternal oxide
#

data is never set. its just a definition

dusk flicker
#

this is literally basic java

pulsar zenith
#

I am trying to get a list using a dependency injector, and I am having a NPE (Null Pointer Exception) .

Where I am storing the list:
https://paste.md-5.net/uketaqigag.cs

Where I am trying to get the list
https://paste.md-5.net/recuricika.java

Stacktrace

Could not pass event PlayerJoinEvent to ManhuntAbilites v0.9
java.lang.NullPointerException: null
       at me.PACKAGENAME.manhunt.PlayerChecks.HunterChecks.ClearInv.PlayerJoin(ClearInv.java:44) ~[?:?]

line 44 is where I attempt to check if a name is in the speedrunner list.

queen dragonBOT
pulsar zenith
#

ah

sage swift
#

what do you pass into the ClearInv constructor?

pulsar zenith
#
 public ClearInv(ManhuntGameManager manhuntGameManager) {
        this.manhuntGameManager = manhuntGameManager;
        this.speedrunner = manhuntGameManager.getTeam(Team.SPEEDRUNNER);
    }
sage swift
#

when you actually create it

#

what do you pass in

pulsar zenith
#

Sorry what do you mean? Do you mean in my gamemanager class where i do

ClearInv clearInv = new ClearInv(this);
sage swift
#

ok

#

show the Team class

pulsar zenith
#

Its Enums

#
public enum Team {
        HUNTER,
        SPEEDRUNNER,
        NONE
}
sage swift
#

you dont actually show line 44, do you?

pulsar zenith
#

oops sorry forgot to include

sage swift
#
    public List<String> getTeam(Team team){
        if(team.equals(Team.HUNTER)){
            return hunter;
        }
        if(team.equals(Team.SPEEDRUNNER)){
            return speedrunner;
        }
        return null;

    }``` you can use `==` for enums
pulsar zenith
#

will do

#

Line 39 is

if (speedrunner.contains(event.getPlayer().getName())) {
sage swift
#

oh that's 39?

pulsar zenith
#

Yes sorry, I had to update the stacktrace

#

Line 39 is where it attempts to check if a speedrunner is in the list.

sage swift
#

see if returning a new ArrayList in the getTeam method works

#

which is odd because it should be returning the list

#

try making hunter and speedrunner final, see if they're ever set to null afterwards

pulsar zenith
#

Ill try final first

sage swift
#

^ that should bring up errors in the ide

#

if they are changed

pulsar zenith
#

yes it does

sage swift
#

you set em to null at some point?

pulsar zenith
#

The list? No, I do not touch them until I have to add them to the list with a command

sage swift
#

well you said it brought up errors

lofty mulch
#

maybe getTeam returns null

pulsar zenith
#

Ill try returning a list that has something in it

#

Alright, so in my getTeam method, I cannot attempt to add anything to my test list, and if I try to get that testlist from my ClearInv class, it gives a NPE

lofty mulch
#

add somethings to the team

pulsar zenith
#

ok

lofty mulch
#

can

#

i see your manhuntGameManager class

pulsar zenith
#

Adding anything to the list also causes a NPE

sage swift
#

so it's null

lofty mulch
#

lmao

pulsar zenith
#

Ok, so before I return the team, should I add something to the list?

sage swift
#

no, you should make the list exist

#

they should be final anyways

lofty mulch
#

new ArrayList();

sage swift
#

at some point youre doing hunter = null

#

or whateverElse = null

#

which is why i suggested setting the lists to final

#
  1. more clarity and 2. helps you find where you set them to null
pulsar zenith
#

ok got it

pulsar zenith
lofty mulch
#

yes

#

this is the basic java problem

#

you should read gecko's answer/explanation again

pulsar zenith
#

Ok