#help-development

1 messages · Page 874 of 1

river oracle
#

damn wtf that's wild

topaz cape
#

i guess i could hack into the hypixel database?

young knoll
#

I bet gitlab uses less ram

#

:p

river oracle
#

for some reason I actually doubt that

sullen marlin
#

ye gitlab probably way more

young knoll
#

Shhhhh

river oracle
#

imho the only real issue with bitbukkit is its a bit annoying you can't see PRs if you haven't signed CLA, otherwise its fine unless you want to integrate CL/CI

#

I wonder whose genius idea it was to group view and create together lol

young knoll
#

¯_(ツ)_/¯

sullen marlin
#

tbh I dunno what gitlab's permissions are

young knoll
#

I checked the other day, it has separate create and view perms for pull requests

#

Sorry, “merge requests”

river oracle
#

who tf trademarked pull requests

#

or are they just trying to be quirky

sullen marlin
#

ideally you'd also not want comments on PRs except for people that can create them either

remote swallow
#

maybe comments are seperate too

young knoll
#

I don’t see a perm mentioning comments

#

But apparently you can lock a merge request to limit comments

#

“You can prevent public comments in an issue or merge request. When you do, only project members can add and edit comments.”

river oracle
#

only thing I see is this, but not sure it does tbh

young knoll
#

Ah that might be it

river oracle
#

I wouldn't be to sure

#

since its under "Projcets:" and not "Merge Requests"

sullen marlin
#

I think thats for projects

young knoll
#

Yeah but the comment page doesn’t say you can add comments to projects

river oracle
#

that's kinda weird

#

you'd probably have to just spin up an instance and check it out yourself

young knoll
#

someone set it up and test kek ¯_(ツ)_/¯

remote swallow
#

you can

young knoll
#

Technically it’s also OS so you could make your own perms in theory

river oracle
#

yeah but that is +1 thing to maintain lol

remote swallow
#

just dont update /shrug

sullen marlin
#

the gitlab reference architectures are insane lol

#

8 servers? why not

remote swallow
#

you have that

#

its fine

young knoll
#

Lol

#

Wtf is gitaly

remote swallow
#

isnt git ea opensource

#

infact

#

md make ur own in java

young knoll
#

Ah yes

remote swallow
#

git md

river oracle
#

@remote swallow I am slaving away in documentation land

remote swallow
#

sounds like ur having fun

young knoll
#

Ah yes gitlab uses the best language

remote swallow
#

php

young knoll
#

Ruby on Rails

remote swallow
#

ruby off rails

river oracle
#

@remote swallow 1 step closer to tearing PineappleChat out of Pineapple

remote swallow
#

ill do the versioning when u finish it

young knoll
#

I still don’t understand why the ruby is on rails

molten hearth
#

it makes it faster

young knoll
#

I hope they are powered rails then

remote swallow
#

josh

#

coll

#

jish

#

nerd

#

helper man

#

jira staff

#

wake up

sullen marlin
#

wat

#

imma install gitlab on my laptop

remote swallow
#

i wanna rob josh on an mc server but hes ran away

young knoll
#

Mf it’s midnight

#

It’s 5am there why are you awake

remote swallow
#

because i fell asleep at 5 pm bc you didnt respond in dms

molten hearth
#

me waiting at 5 am because someone didnt respond in dms:

#

polar opposites fr

river oracle
remote swallow
#

what time even is it for the md

remote swallow
sullen marlin
#

3:45pm

molten hearth
#

sleep is temporary, the glory of leveling up your class is also temporary but more satisfying

remote swallow
river oracle
#

australian time gap is wild wtf

remote swallow
#

its only like 11 hours for me to md

river oracle
#

its 17 hours for me 💀 you can imagine that makes it hard to play games with my australian friends

#

wait if I did my math right

#

lol

#

one sec

#

this is so much more annoying with 12 hour time

#

yeah 17 hours

young knoll
#

16 here

molten hearth
#

ive worked with australians before but it was a bit weird

#

they'd be like

river oracle
molten hearth
#

"yo man can you do this ill be back in 12 hours for 5 minutes bye"

final monolith
#

Anyone here that knows about the WorldEdit/FAWE API?

#

Want to know how to retrieve the changed blocks by an operation

river oracle
#

@remote swallow how do you make a drop down in mark down

remote swallow
#

uhhhhhhhhhhhhhhhhhhhhhhhhhhh

sullen marlin
#

so turns out gitlab is the same

remote swallow
#

like code?

sullen marlin
#

there's no view-only merge request permission

river oracle
sullen marlin
#

doesn't seem like it

young knoll
#

Do you also have the view merge request list set

sullen marlin
#

I'm only tinkering with Settings-> General and Manage->Members

young knoll
#

Ah, idk then

#

Time for a strongly worded email

river oracle
#

@eternal night 😨 your gitlab dream might not come true unless you can find that permission

sullen marlin
#

also custom permissions at all are gitlab ultimate tier

#

they've really kneecapped the open source version

river oracle
#

lame

river oracle
#

wow that is ancient

#

we don't take PR for Bukkit afaik

#

if it is still an issue remake the issue on SPIGOT

#

they're private for a reason BUKKIT is nolonger maintained idk how many years you've been away, but

#

spigot maintains bukkit thus all reports should be made to the Spigot bug tracker

#

under the SPIGOT project

#

best you could do is email support, but I doubt they'll be unprivated

#

?support

undone axleBOT
orchid brook
#

Hi im trying to learn listener, so im actualy reading an opensource plugin But I have a question that I can't find an answer to.

They have a Event call "FishEatEvent"


    private static final FishEatEvent eatEvent = new FishEatEvent();
    
    public static FishEatEvent getInstance() {
        return eatEvent;
    }```

And they register the event like this: ```registerEvents(FishEatEvent.getInstance(), this);```

I don't understand why they use an instance ? I have always register my events like this ```registerEvents(new FishEatEvent(), this);```

Is there a reason why he uses the instance to register the event ?
river oracle
#

that's kinda a werid practice for events though

#

There really is no difference or benefit to that method even though an event is "technically" a singleton it's a bad practice for events imho just register your events as you have been doing

orchid brook
#

Alright thank u for the answer 🙂 !

sullen marlin
#

It's a reference to the bukkit bug tracker which is way dead

#

We never had anything to do with it

river oracle
sullen marlin
#

^

river oracle
#

bukkit is a dead project so you'll be hard pressed to find anything

#

best of luck :P

charred blaze
#

why didnt it fully load?

#

trying to load old project from eclipse

shadow night
charred blaze
#

wow it actually worked

#

thanks

quaint mantle
eternal night
#

Or, yknow, a CLA bot

shadow night
#

oh no, 9minecraft

#

well, doesn't look like it matters here

sullen marlin
shadow night
blazing ocean
#

how would I only show a player the silhouettes of other people?

#

like, invisibility but you can see player silhouettes

#

do they all need to be on one team? since that would break some of my current logic

sullen marlin
#

Pretty sure that's the only way to get that functionality

hushed spindle
#

thoughts?

echo basalt
#

mm that sounds like a pain to keep track of

hushed spindle
#

how so?

lilac dagger
echo basalt
#

Like

lilac dagger
#

a hashmap should do it

echo basalt
#

Well maybe

#

because you need to keep track of the lifecycle thing

#

shouldn't be too hard to do

#

Just annoying

lilac dagger
#

i think so, but you can just tick a linked hashmap

echo basalt
#

if you're using some BlockPos or Vector variable you need to keep track of worlds

hushed spindle
#

im just using Block

#

is there a reason not to use that

echo basalt
#

memo leak prone

#

actually lemme look at CraftBlock

hushed spindle
#

how does that work

echo basalt
#

if it only has a location internally should be fine

#

if it has a world tho it's leak prone

#

okay yeah

#

basically if for whatever reason you don't manage to remove a block from the map

#

let's say because of an exception or concurrency issue

#

and the world ends up unloading

#

(let's say someone's running mythicdungeons or something)

hushed spindle
#

ahhh i see

echo basalt
#

the world will still be in memory because there's a reference to your block

#

Location is safe after 1.13.2

hushed spindle
#

then using Location would be better?

#

ah cool cool

#

will convert them then

echo basalt
#

If your plugin supports ancient versions I'd recommend making a BlockLocation wrapper class that just stores the world id and xyz

hushed spindle
#

nah its 1.19+ so im good

#

ty, i didnt know that about block

echo basalt
#

same thing happens if you have a hard reference to any Entity

#

which is why we blow up at ppl and tell em to store UUID instead

hushed spindle
#

i just use UUID for entities yeah

echo basalt
#

same for any tile entity etc

hushed spindle
#

i know they get invalidated pretty easily but in my mind Block was always safe to use for that

echo basalt
#

anything world related is prone to world related leaks

#

a fun one I've seen was having a Player reference in a task

#

For example let's say I do something like this

lilac dagger
#

and just removing blocks if the world is this

echo basalt
#

that'd be good practice

hushed spindle
#

ive accidentally done that too lol, ended up with identical exceptions to when you send a player packets async so it sent me on a completely irrelevant search. ended up being due to a mistake i had made 3 years prior

echo basalt
#
@EventHandler
public void onQuit(PlayerQuitEvent event) {
  Player player = event.getPlayer();
  Bukkit.getScheduler().runTaskLater(plugin, () -> {
    if(player.isOnline()) {
      return;
    }

    myPlayerManager.unloadData(player.getUniqueId());
  }, TimeParser.parse("5 minutes").asTicks()); // my own utility stuff
}
#

This isn't exactly a leak but it keeps the player instance alive for longer than its scope intended

hushed spindle
#

yup

obsidian tiger
#

when enchanting an item, the enchantments are generated server side and not client side right?

hushed spindle
#

yeah

echo basalt
#

But we can fix that code by refactoring it a bit

obsidian tiger
#

so if I modify spigot source I could disable a specific enchantment?

echo basalt
#
@EventHandler
public void onQuit(PlayerQuitEvent event) {
  Player player = event.getPlayer();
  UUID playerId = player.getUniqueId();
  Bukkit.getScheduler().runTaskLater(plugin, () -> {
    if(Bukkit.getPlayer(playerId) != null) {
      return;
    }

    myPlayerManager.unloadData(playerId);
  }, TimeParser.parse("5 minutes").asTicks()); // my own utility stuff
}
hushed spindle
#

you could also just remove the enchantment during the event

obsidian tiger
#

i know java but I never wrote a plugin and havent looked at docs, wanted to ask here first before I open anything

echo basalt
#

And now this is "safe"

obsidian tiger
#

Ill check it out now

#

thanks alot athaleos

hushed spindle
#

you can listen to PlayerItemEnchantEvent (i think its called that) and remove the enchantment from that event

#

might also want to do the same to PrepareItemEnchantEvent in case the enchantment is in the enchantment offers

echo basalt
obsidian tiger
#

nice

#

looks like what I need so 🫡

echo basalt
obsidian tiger
echo basalt
#

my time parser lets me pass complex strings

#

:)

#

Like 5 minutes 30 seconds

#

or 5m 30s

obsidian tiger
#

mhh fair

peak depot
#

is there a way to only allow certain players to build, Interact etc in a chunk or like do I need to go through all block and then do a list

sullen marlin
#

Wdym

#

Theres events for interact and place if thats what you want

quaint mantle
#

merci becoup

#

im not the most advanced java developer

sullen marlin
#

More code needed

#

Post entire file

eternal oxide
#

?paste

undone axleBOT
quaint mantle
#

as you can see from the code above, i have been a developer in java for years

sullen marlin
#

Player player = (Player) sender;

#

Its called a cast and needs to go after the instanceof to prevent an error

eternal oxide
#

I'd also advise using teh LuckPerms API over sending console commands

shadow night
quaint mantle
quaint mantle
eternal oxide
#

no

sullen marlin
#

Please post full code

shadow night
#

I have quite a few questions

eternal oxide
#

is there a player variable?

shadow night
#

More active supporters, can anybody tell me wtf is going on

quaint mantle
eternal oxide
#

ah, its fine

#

oh no it's not

sullen marlin
#

No cast needs to be between line 30 and 31

eternal oxide
#

you cast before you check its a player

quaint mantle
#

ah i see

#

perfect

#

ty

eternal oxide
#

you didn;t need to make a variable at all

#

just saveInventory((Player) sender));

quaint mantle
#

im getting red squigly line with that

eternal oxide
#

hover over and see what it says

quaint mantle
eternal oxide
#

ah thats because your saveInventory method could throw an exception you are not dealing with

#

you will get that warning even using a player variable

#

You need to handle your exceptions with a try/catch block

eternal oxide
#

Your IDE probably offered you to either add a throws or a try/catch. You chose add a throws

quaint mantle
#

wait no i think thats what i did

#

idk

peak depot
quaint mantle
#

bro i wish minecraft was fucking python

ashen quest
#

Mo

#

No

quaint mantle
#

easiest shit going

ashen quest
#

It would be hella slower

shadow night
pliant topaz
#

yea

ashen quest
#

Already quite slow

quaint mantle
#

😆 im joking guys

shadow night
#

Tps'd be limited at 10

ashen quest
#

Fuck python actually

quaint mantle
#

WOAH

ashen quest
quaint mantle
#

thats a bit codist dont you think?

eternal oxide
pliant topaz
shadow night
ashen quest
#

Yea

#

U could use bash or sh

shadow night
#

Python is good for scripts for which sh is not enough and a proper programming language is too much

pliant topaz
#

idk, I only learned python like 1 year ago and only now we're starting with it in school xd

quaint mantle
#

ive been on discord longer than md5.

ashen quest
#

Damn

eternal oxide
#

md5 and a lot of others came from IRC 😉

ashen quest
#

Mojo seems a better alternative to python but it isn't released

quaint mantle
eternal oxide
#

probably, we've been at it a while

shadow night
ashen quest
ashen quest
#

I mean on discord

#

U need to be 13 on discord right

sand spire
#

In my country yeah

#

in most actually

quaint mantle
#

my fucking shitty code and my shitty error handler wont explain fuck all

#

any suggestions

eternal oxide
#

teh stack trace will tell you the actual error

sand spire
# quaint mantle any suggestions

Make it deOP when you go offline and add a password to make the command work so if your account gets hacked they cant mess up your server

quaint mantle
quaint mantle
eternal oxide
#

it will print in the console

quaint mantle
#

ok

#

perfefct

#

! [Sat 11:31:34 WARN ] java.lang.NullPointerException: Cannot invoke "org.bukkit.plugin.Plugin.getDataFolder()" because "this.plugin" is null

#

ok i believe this is my fault

#

llmfaoooo

#

now where is the this.plugin

#

    Plugin plugin;

    public void saveInventory(Player p) throws IOException {
        File f = new File(plugin.getDataFolder().getAbsolutePath(), p.getName() + ".yml");
        if (!f.exists() && !f.createNewFile()) {
            throw new IOException("Failed to create inventory file for player: " + p.getName());
        }
        FileConfiguration c = YamlConfiguration.loadConfiguration(f);
        c.set("inventory.armor", p.getInventory().getArmorContents());
        c.set("inventory.content", p.getInventory().getContents());
        c.save(f);
    }
#

plugin plugin im guessing

#

is what i need to change

echo basalt
#

?di

undone axleBOT
echo basalt
#

But I'd say

#

?learnjava

undone axleBOT
echo basalt
#

would help you

quaint mantle
#

with all due respect, i aint readin all that

echo basalt
#

With all due respect, I an't helping you further

quaint mantle
#

ok :)

#

i shall gpt

wraith dragon
#

☠️

#

dude

#

use gpt as an assistant and not a replacement bruh

quaint mantle
#

okay chat gpt fixed my issue in a matter of 2 messages

remote swallow
#

and do you know what the issue was

quaint mantle
#

thank you all for NOTHING (other than ElgarL, and md_5)

quaint mantle
#

Understood, let's resolve the NullPointerException issue by ensuring that the plugin instance is properly passed to your AdminToggleCommand class. Since you have no experience in Java, I will provide the complete revised code for both the AdminToggleCommand class and the way you should initialize it in your main plugin class.

Here is the revised AdminToggleCommand class

#

buddy. (period)

remote swallow
#

yeah that can be explained way better

quaint mantle
#

In 2014 during a schizophrenic BPD episode, I spent $492.63 on Candy Crush

quaint mantle
hazy parrot
lilac dagger
#

that's a lot

quaint mantle
#

In the domain of software engineering, particularly within the confines of object-oriented programming and design patterns, the modifications introduced to the AdminToggleCommand class encompass the instantiation of a constructor that mandates an instance of the Plugin interface as an argument. This constructor invocation is an embodiment of the Dependency Injection (DI) design pattern, which is a subset of the broader Inversion of Control (IoC) principle. By employing this pattern, we facilitate a decoupling of the command class from the instantiation logic of its dependencies, thereby promoting a more testable and maintainable codebase.

This DI pattern is implemented to inject the requisite Plugin instance, which is essential for accessing the filesystem path associated with the plugin's data storage directory via the getDataFolder() method. By ensuring that the Plugin instance is non-null at the time of the AdminToggleCommand object's creation, the design precludes the occurrence of a NullPointerException. This is achieved by the strategic placement of the command registration logic within the onEnable lifecycle method of the main plugin class, which is derived from the JavaPlugin abstract class provided by the Bukkit library.

#

Furthermore, adherence to the Command design pattern is observed, wherein the onCommand method encapsulates the execution logic pertinent to the administrative role toggling functionality. This encapsulation is pivotal, ensuring a singular responsibility principle (SRP) is upheld, thereby aligning with the SOLID principles of object-oriented design and contributing to a robust and scalable software architecture.

To instantiate the AdminToggleCommand with the correct state, the client code—the JavaPlugin subclass—must pass its this reference (which in Java signifies the current object instance) to the AdminToggleCommand constructor, effectively passing its own instance to the command handler. This operation is intrinsically linked to the polymorphic nature of the JavaPlugin class, ensuring that the specific plugin instance is bound to the command at the point of registration within the plugin's command map. This process is crucial for the Bukkit framework to correctly route command invocations to the associated executor with the appropriate context and state.

#

Good enough for you, @remote swallow ?

#

(This message was AI Generated.) by the way(). HES LITERALLY ON MY PAYROLE - DO NOT DISRESPECT! ( im paying him $60 a month. Team edition.)

shadow night
#

I have a feeling this is getting off-topic and unnecessary

quaint mantle
#

sorry.

#

well to be fair it is compleltely on topic, unnecessary, yes. on topic? yes.

shadow night
#

Just fix your issues if you are able to and if you aren't just ask here

smoky anchor
#

Heyo
InteractEvent gets called when player drops an item.
This is easily solved by storing the uuid of a player in a list on PlayerDropItemEvent and then checking if the uuid exists in PlayerInteractEvent
BUT
When a player drops an item from inventory, the events are called in reverse order, so this hack doesn't work.
Any way to solve this stupid problem ?

quaint mantle
tawny pine
#

hey guys, is there any way to fully disable a player from using a command? even if this command would usually activate code in another plugin. supposing a plugin has a /etc command, could i fully disable players from using this even though it is stated in another plugin?

eternal oxide
#

if they have no permission, they don;t see the command

sand spire
quaint mantle
tawny pine
lilac dagger
#

is it released to the public yet?

#

nope

quaint mantle
#

no. i would like to warn you about the rate limited issues.

eternal oxide
quaint mantle
#

anyways, this is off topic. MOVE TO #verified !

tawny pine
eternal oxide
#

most plugins already configure a permission per command, IF they are written properly

tawny pine
sand spire
#

Hey, I finished my code for a custom item with an ability, but I assign the Player player; in my PlayerInteractEvent with " player = event.getPlayer(); " and keep doing stuff with that specific player the entire code with " player. "

The problem is that if 2 players use it at the same time, the 2nd player will replace the 1st player. I think I have to use UUID's but i'm having trouble using/understanding it

Can anyone please explain what to add to my code so it knows to use the specific player that completed the PlayerInteractEvent at the start, and if a second player uses it at the same time it will also work

eternal oxide
#

what specifically does your item do?

sand spire
# eternal oxide what specifically does your item do?

Its an arrow, when I rightclick it turns into a ghast tear and an arrow starts hovering infront of me, when i click on entities the arrow flies towards them in the order I clicked on them, and then flies back to me and turns into an arrow again

eternal oxide
#

use a Set<UUID>

wet breach
eternal oxide
#

when a player activates you add their UUID to the Set.

#

then when using you check if their UUID is in the set and run your use code for them

sand spire
sand spire
topaz kestrel
#

why no work???

eternal oxide
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

echo basalt
#

there's no point in extending itemstack

#

it's incredibly bad practice

topaz kestrel
#

well, the statement is not working event.getCurrentItem() instanceof WixiCustomMenuItem wixiCustomMenuItem

echo basalt
#

You should instead track things with proper data structures

topaz kestrel
#

like?

echo basalt
#

Map<Integer, Whatever> on your menu class

topaz kestrel
#

this is outside of the inventory

#

not in the menu, it's in the player's inventory

#

while the menu is open

tawny pine
#

how can i execute a command from a non-op player as if they were op?

echo basalt
#

Then associate an nbt tag

topaz kestrel
echo basalt
#

?pdc

tender shard
fluid river
topaz kestrel
wet breach
eternal oxide
echo basalt
#

well

topaz kestrel
echo basalt
#

here's a super easy way to trip antimalware

tender shard
echo basalt
#

oldOpStatus = isOp
setOp(true)
runCommand
setOp(oldOpStatus)

wet breach
tender shard
# topaz kestrel what's PDC?

or: Why you should NEVER use NBT tags again! Spigot 1.14.1 added the biggest improvement that (in my opinion) ever made it into the Bukkit API: The Persistent Data Container (PDC). It can be used to store custom data on Entities, TileEntities, and ItemStacks. Using a bit of math, it can also be used to...

eternal oxide
wet breach
#

generally, in most cases you don't need to arbitrarily run commands from a plugin for a player rather you can just do the action from the plugin

wet breach
tender shard
#

btw @topaz kestrel you are not supposed to extend ItemStack in the first place

echo basalt
#

we should make it sealed

tender shard
#

spigot-api is java 8

eternal night
sand spire
# eternal oxide use a Set<UUID>

Like this?

private Set<UUID> playerUUIDs = null;```

```java
@EventHandler
    public void onInteract(PlayerInteractEvent event) {
        if (event.getHand() != EquipmentSlot.HAND) {
            return;
        }
        player = event.getPlayer();
        playerUUIDs.add(player.getUniqueId());
        if (!playerUUIDs.contains(player.getUniqueId())) {
            return;
        }```

And add the ifstatement to check if the player has the UUID to every event?
tender shard
#

Why is the field null?

eternal oxide
#

private Set<UUID> playerUUIDs = new HashSet();

sand spire
#

oh thank you

echo basalt
#

Sets.newConcurrentHashSet uwu

eternal oxide
#

remove them from the Set when you disable your feature

echo basalt
#

Well that's not super scalable

#

What if we did something like

sand spire
#

If 2 players use it at the same time will it work cause now the code will run if the UUID is anywhere in the set. Shouldn't I check if the player has the exact UUID?

eternal oxide
#

you run it for teh player who is activating it

#

if they set multiple targets, you have to track targets for them

#

each would have their own set of targets

tender shard
sand spire
#

good question

eternal oxide
#

iejava Map<UUID, Set<UUID>>

#

first UUID being the Players Id, teh second Set of UUID's being target UUIDs

echo basalt
#
public interface Setting<T> {

  T getDefaultValue();

}
public class BooleanSetting implements Setting<Boolean> {

  private final boolean defaultValue;

  public static Setting<Boolean> create(boolean defaultValue) {
    return new BooleanSetting(defaultValue);
  }

  private BooleanSetting(boolean defaultValue) {
    this.defaultValue = defaultValue;
  }

  @Override
  public Boolean getDefaultValue() {
    return this.defaultValue;
  }
}
public class PlayerSettingData {

  private final Map<Setting<?>, Object> values = new ConcurrentHashMap<>();

  public <T> T getValue(Setting<T> setting) {
    return values.getOrDefault(setting, setting.getDefaultValue());
  }

  public <T> void setValue(Setting<T> setting, T value) {
    values.put(setting, value);
  }
}
public final class Settings {

  private Settings() {}

  public static final Setting<Boolean> WHATEVER_SETTING = BooleanSetting.create(false); // false by default

}
#

hm

wet breach
#

I mean map can give you a set from the map

eternal oxide
#

he is setting multiple targets per player

echo basalt
#

lol then yeah this is completely unrelated

#

lmfao

wet breach
#

oh right

echo basalt
#
public class PlayerTargetData {

  private final UUID playerId;
  private final Collection<UUID> targets = Sets.newConcurrentHashSet<>();

  public Collection<UUID> getTargets() {
    return Sets.copyOf(this.targets);
  }

  public void addTarget(UUID targetId) {
    Preconditions.checkArgument(targetId);
    this.targets.add(targetId);
  }

  public void removeTarget(UUID targetId) {
    Preconditions.checkArgument(targetId);
    this.targets.remove(targetId);
  }
}
#

hm

sand spire
# eternal oxide he is setting multiple targets per player

This is how I add & cycle through targets if it helps

On leftclick

targets.add(rayTraceResult.getHitEntity());```
```java
LivingEntity target = (LivingEntity) targets.get(0);```
On projectile hit
```java
if (!targets.contains(player)) {
                pastTargets.add(event.getHitEntity());
                targets.remove(event.getHitEntity());
                if (targets.isEmpty()) {
                    homingArrows.cancel();
                    targets.add(player);```
eternal oxide
#

so using the Map```java
Map<UUID, Set<UUID>> targets = new HashSet();

// onInteract first time...
targets.put(player.getUniqueId(), new HashSet());

// adding a target...
targets.get(player.getUniqueId()).add(entity.getUniqueId()));```

echo basalt
#

elgar your 3rd line is error prone

eternal oxide
#

probably get an add or put wrong there, btu you get the idea

echo basalt
#

computeIfAbsent

young knoll
#

We love computeIfAbsent

eternal oxide
#

he only wants it to happen if the player is active using the arrow

sand spire
#

Should I change my current targets arraylist to a set?

private final ArrayList<Entity> targets = new ArrayList<>();```
tender shard
#

i never understood why computeIfAbsent uses a Function instead of a Supplier

eternal oxide
#

mine is just an example, so add if the entry is nt null

echo basalt
inner mulch
echo basalt
#

they should just have a second method

eternal oxide
#

You needs a target List/Set for each players using it

echo basalt
#

think of it like

inner mulch
eternal oxide
#

Set just prevents duplicates

echo basalt
#

If you have a constructor that takes your key as an argument

#

You can just do MyObject::new

sand spire
echo basalt
#

That's what the map is for

#

Now, holding hard references to Entities is leak prone

tender shard
#

ah yeah probably useufl in case you reuse the function you throw into computeIfAbsent

inner mulch
sand spire
#

Should I try elgarL solution or imIllusion solution or combine them

sand spire
eternal oxide
#

Mine, its for multiple players

#

well

#

his is too

echo basalt
#

Mine works for multiple players but needs an extra class for managing the map

#

Yours is super simple and beginner friendly while mine is foolproof and follows perfect etiquette

#

Well I should be making hashcode functions if that were the case

eternal oxide
#

yep

sand spire
eternal oxide
#

yes, all entities have a UUID

sand spire
tender shard
#

and you also cannot "add" to a map, you can only "put" to a map

eternal oxide
#

You have too much jank code in there to really tell what you are doing.

#

Start a new class

#

as each player needs their own target Set and arrow

sand spire
sand spire
eternal oxide
#

As your players each need their own arrow, targets and task you should create a data holder class

zealous osprey
echo basalt
#

safety

young knoll
#

Illusion is a concurrent hashmap simp

echo basalt
#

It's the impl I use by default

tardy mist
sand spire
echo basalt
#

It's not a static method ??

#

Well

#

The static constructor is on the creator class and just returns an instance of itself

#

I return it as the interface because there are no impl details that need to be exposed

#

It's a concept displayed in the Effective Java book

lilac dagger
eternal oxide
#
public class DataHolder {
    UUID id;
    Set<UUID> targets = new HashSet();

    public DataHolder(UUID playerId) {
        this.id = playerId;
    }
}```
#

this class shoudl also have fields for your arrow

rotund pond
#

I don't think "DataHolder" is a good name through

eternal oxide
#

in your Listener class you have ajava Map<UUID, DataHolder>

#

its not

echo basalt
#

why do we have a set of maps of sets

eternal oxide
#

but it will do for now, he can refactor

young knoll
#

We must go deeper

#

Nest all the collections

echo basalt
#

reminds me of that kotlin tuple thing

young knoll
#

Thanks I hate it

late sonnet
#

Tuple... i only use that thing for Discord4J and every time confuse my.. but only use Tuple3 xd

opal juniper
#

love tuples

tawny pine
#

is there any way of checking if a command was actually sent by a player, or the command was executed through the player using player.performcommand()?

sand spire
eternal oxide
#

You are getting confused

#

each DataHolder is for a specific player

#

you will create one for each Player

#

it only tracks data specific to the owning Player

#

so, their Id, Their Set of target Entity UUIDs and their arrow

lost matrix
# echo basalt

Pair and any derivation of it is programmatical garbage

eternal night
echo basalt
#

Yessir

eternal oxide
#

the arrow will only be known to/exist inside this data object

sand spire
eternal oxide
#

no need for arrows Set as each player will only have one

lost matrix
eternal oxide
#

then add a public method so you can add a target UUID

#
public void addTarget(UUID entityId) {
    this.targets.add(entityId);
}```
sand spire
eternal oxide
#

no need to pass in an arrow Id, you can do all this inside this class

#

each arrow will be specific to the Player so it's all inside here

tawny pine
chrome beacon
#

and why do you need to check it was called via code?

sand spire
lost matrix
echo basalt
#

Command events don't fire when forcefully ran

chrome beacon
tender shard
#

check the stacktrace

#

but why would one need that info

lost matrix
#

Myeah that works as well

lost matrix
young knoll
echo basalt
#

Source: I've had to inject a custom command map to debug forcefully ran commands

#

using Unsafe or something

young knoll
eternal oxide
lost matrix
#

DataHolderManager where? 🙂

eternal oxide
#

You can add error checking later

echo basalt
#

getHolderIfPresent where

#

or Optional<DataHolder> where

eternal oxide
#

lets not confuse him more 🙂

echo basalt
#

getHolder(player).ifPresent(holder -> holder.addTarget)

#

hm

echo basalt
#

meh

lost matrix
# echo basalt meh
public DataHolder getHolder(UUID playerId) {
  return holderMap.computeIfAbsent(playerId, DataHolder::new);
}
echo basalt
#

hm

sand spire
#

uh

eternal oxide
#

currently his Listner IS his holder instance

#

ignore them

echo basalt
#

The problem is

eternal oxide
#

They are just getting too far ahead 🙂

echo basalt
#

what if we check that on a task after the player logs off

sand spire
echo basalt
#

so we have to do some checks or scope everythin

eternal oxide
#

Currently the aim is to get a working set of code, nbot to be perfect

eternal oxide
sand spire
#

Should I put this in a set or just add it at the topMap<UUID, DataHolder> players = new HashSet();

eternal oxide
#

start a fresh clean class

sand spire
#

oh its wrong link

eternal oxide
#

Keep that one to copyu code from later, just start fresh

sand spire
eternal oxide
#

move players up to be a field

#

class level not a local variable

sand spire
#

It says Required type: Map Provided: HashSet for Map<UUID, DataHolder> players = new HashSet();

lost matrix
eternal oxide
#

ok, next job is to ensure you only add a new Map Entry if they don;t already have one

sand spire
#

Do I change it to this Set <Map<UUID, DataHolder>> players = new HashSet();

eternal oxide
#

HashMap, not HashSet

sand spire
#

oh

eternal oxide
#

ok, next job is to ensure you only add a new Map Entry if they don;t already have one...

sand spire
#

Do I want
Map <Map<UUID, DataHolder>> players = new HashMap();
or
Set <Map<UUID, DataHolder>> players = new HashSet();

eternal oxide
#

now instead of players.put( change to players.computeIfAbsent(

#

Map

sand spire
#

got it Map <UUID, DataHolder> players = new HashMap();

eternal oxide
#

Now you do whatever code you want to detect the player needing to add a new target

#

ignore arrows and all that for now

eternal oxide
#

no, computeIfAbsent

lost matrix
eternal oxide
#

lol, you need putting down 🙂

echo basalt
sand spire
#

Do I even need to put this in an ifstatement

            players.put(player.getUniqueId(), new DataHolder(player.getUniqueId());
        }```
eternal oxide
#

no

#

no .put

#

look at the link I just sent

#

you are simply replacing the word put with computeIfAbsent`

lost matrix
echo basalt
#

hm

#

I don't use optionals often

lilac dagger
#

pretty sure

echo basalt
#

funny

eternal oxide
# sand spire ah

the reason to use computeIfAbsent over put, is that using put will replace the Object every time. computeIfAbsent will only add it if it doesn;t already exist

sand spire
#

ah thanks

eternal oxide
#

calling put would erase any targets you have already set

eternal night
#

ifPresent is kinda ugly, you fall straight into callback hell with it

sand spire
#

I wanna make the dataholder method public right

lilac dagger
#

yeah, it's a cool way to do it quicker rather that recalulating the hash and position twice to achieve the same without

eternal oxide
#

database method?

sand spire
#

this public DataHolder(UUID playerID, UUID arrowID) {
this.id = playerID;
}

eternal oxide
#

no

#

its a constructor

#

remove the arrow field

echo basalt
#

luka's just throwing stuff at the wall and seeing what sticks

#

what if we took a step back to learn the basics

sand spire
#

do i wanna make a getter?

eternal oxide
#

no

sand spire
#

DataHolder(java.util.UUID, java.util.UUID)' is not public in 'me.luka.customitems.DataHolder'. Cannot be accessed from outside package

echo basalt
#

the constructor needs to be public

eternal oxide
#

you are passing an arrow UUID

#

do not pass an arrow UUID

#

JUST the player UUID

sand spire
#

I removed it, i still need to make it public i think

eternal oxide
#

no

echo basalt
#

.

#

Make your constructor public

eternal oxide
#

you shoudl not be passing an arrow UUID into teh class and it shoudl not be asking for one

#

it shoudl have already been public

#

yeah my bad, I didn;t make it public in my example

sand spire
#

you're good

echo basalt
#

Instead of going in circles for 2 hours let's learn java basics!

eternal oxide
#

he is learning 😉

#

slowly

sand spire
#

I learned a lot I just never used Set before and the UUID stuff is not java

eternal oxide
#

Have you added your code to add targets?

#

also, how do your players deactivate their arrow?

echo basalt
#

Every time you call new you're creating an object and calling the object's constructor

sand spire
#

not yet just reading through what you made so i understand it

eternal oxide
#

ok

echo basalt
#

An object can have multiple constructors, the one you call matches the parameters you pass

#

Think of a constructor as a mandatory method that's called every time you create an object

#
public class MyObject {

  public MyObject(int argument) {
    // This is a public constructor
  }
}
eternal oxide
#

if there is no constructor you can just call new YourObject(). With a constructor it forces you to provide whatever it asks for.

echo basalt
#

Declaring a constructor is like declaring a method with no name, where the return type is the class itself

#

So if I try to call new MyObject() this will error out because there's only one constructor, and it requires passing a paremeter

#

Everything is clear so far, right?

eternal oxide
#

I actually like this pastes.dev site

#

syntax highlighting, and so easy to edit live.

sand spire
echo basalt
#

Alright, now let's get to some data structures

sand spire
#

but now i'm reading your stuff and trying to add it to targets at the same time i should probably just do one

echo basalt
#

You know List, right?

sand spire
#

yeah

echo basalt
#

Alright

#

You know what a Set is, right?

sand spire
#

idk the difference between that and ArrayList but i know that I can store stuff in it and use loops to go through them

echo basalt
#

Alright

#

So a List has some order to it

#

You can add duplicate elements

#

get by index

sand spire
echo basalt
#

A Set is basically a list, but has no obligation to know order, and won't take duplicates

#

So if I have a List<Integer> and I add(1) and then add(1) and print the list, it prints [1, 1]

sand spire
echo basalt
#

If I have a Set<Integer> and I add(1) and then add(1) and print the set, it prints [1]

echo basalt
#

The same way HashSet is an implementation of Set

#

So the difference between a list and a set is clear?

sand spire
#

Yeah, but not between a list and an arraylist or a set and a hashset but idk if its relevant to know the difference

echo basalt
#

Alright so we have to get on the topic of interfaces

sand spire
#

for me it looks like it does the same

echo basalt
#

An Interface, in java, is basically a "contract" that defines expected behavior of a class

eternal oxide
#

Think API and implementation

echo basalt
#

That's really easy to understand as someone proficient and really vague as a beginner

eternal oxide
#

yeah true, but so is contract 😉

echo basalt
#

You can't directly initialize an interface (i.e you can't new MyInterface() as it isn't a class)

eternal oxide
#

^ you can;t new List()

sand spire
#

I probably know what an interface is I just don't know what I need to couple the name "interface" with but when I see it i probably get it

echo basalt
#

List, Set and Map are all interfaces

#

ArrayList is a class that implements the List interface

#

We call that "an implementation"

#

So ArrayList is an implementation of List

sand spire
#

Oh yeah my friend said I cant do new with those things as they're already made by java, I also can't do new for something like Player as its already made by spigot

echo basalt
#

Well

#

Not necessarily

#

You can't new Player because Player is an interface and not a class

eternal oxide
#

kinda. But really they are all Interfaces

echo basalt
#

So when implementing an Interface you're expected to actually implement the logic it demands

lilac dagger
#

watch someone actually implement all the logic just to use fake Players

sand spire
echo basalt
#

Yep

#

So the difference is also clear now?

sand spire
#

Yeah, I will try to not initialize interfaces in the future

echo basalt
#

Alright

eternal oxide
#

Doesn;t go well 🙂

echo basalt
#

Moving on, we have Maps

#

In other languages they're reffered to as dictionaries

#

Where you have a Map<K, V> where K is the Key type and V is the Value type

#

So on a Map<UUID, PlayerData>, UUID is your Key type and PlayerData is your Value type

sand spire
#

Oh thats why I can do "private Map<UUID, DataHolder> players = new HashMap<>();" but not "private Map<UUID, DataHolder> players = new Map<>();" as map is an interface and hashmap is a class that implements interface

eternal oxide
#

correct

echo basalt
#

Yep

sand spire
eternal oxide
#
List<?> example1 = new ArrayList<>();
List<?> example2 = new LinkedList<>();
List<?> example3 = new SortedList<>();```All lists, but different implementations
echo basalt
#

The Map interface defines a few methods, the more important ones are

boolean success = map.put(key, value)
V value = map.get(key)
V oldValue = map.remove(key)

#

There are some other ones like computeIfAbsent but most of those are just wrappers for these 3 basic ones

#

So let's do a basic impl

echo basalt
#

any type

eternal oxide
#

^ accepts any Object

sand spire
#

oh

#

why would you ever do that, or is that just fore xample

eternal oxide
#

Not good to use unless you are really experienced

sand spire
#

alr

echo basalt
#
Map<UUID, Integer> count = new HashMap<>();
UUID playerId = UUID.randomUUID();

count.put(playerId, 1);
count.put(playerId, 2);

int result = count.get(playerId);
#

What's result?

eternal oxide
#

it was just for example, less to type 🙂

sand spire
#

2?

echo basalt
#

Correct

#

Now

#
Map<UUID, Integer> count = new HashMap<>();
UUID playerId = UUID.randomUUID();

int result = count.get(playerId);
#

What happens in this case?

sand spire
#

null

eternal oxide
#

nasty

echo basalt
#

Correct

eternal oxide
#

it will actually throw an NPE as int can't be null

echo basalt
#

defaults to 0

eternal night
#

that does not default to 0, ElgarL is correct it'll explode

echo basalt
#

ouch

#

I remember something does

eternal oxide
#

You can;t assign null to a primitive

subtle folio
echo basalt
#

:(

sand spire
#

does it matter, what matters is that it wont work

eternal oxide
#

correct

echo basalt
# sand spire null

Well not exactly as int is a primitive and primitives can never be null

#

there we go

eternal oxide
#

yep

sand spire
#

alright

echo basalt
#

But yeah for any object it'd be Null

sand spire
#

so then 0, but yall said thats also not the case so it will just not work and give error

echo basalt
#

Yeah there's some autocasting trickery going on

#

You can worry about it at a later date

#

Regardless, keep in mind the following things:

#

Objects are kept in memory while they're stored in ANY collection (with the exception of weak collections, or when wrapped in a WeakReference - Advanced stuff)

#

And all the data they hold

#

So if you store for example a List<Player> and a player quits, that object will still be in the list

#

(which is a memory leak)

#

Make sure to invalidate your objects from whatever collections they're being held at if they're not meant to be valid

sand spire
#

Can I just remove event.getPlayer from the list onQuitEvent

echo basalt
#

Yes

sand spire
#

cool cause thats what I do for like everything that needs to stop workiung when u go offline

echo basalt
#

Never the less, good practice is to store UUIDs that represent these objects instead of the objects themselves

#

So for example instead of storing a list of Players, you store a list of all the UUIDs that represent the players

#

And you can get the player back from the UUID when needed

#

That just makes it so that IF you have a leak, that leak happens with as little data as possible

sand spire
#

yeah this arrow was my first real plugin and I just focussed on getting it to work and learned a lot while doing it now I wanted it to work for multiple players and kinda hit a wall cause I never learned about Set or UUID and stuff

eternal oxide
#

You are close now

echo basalt
#

Now, to tie it all together

eternal oxide
#

its really just a case of moving code into your DataHolder and adding methods to start/stop the arrow

echo basalt
#

When designing your structure you need to know what relationships there are between your data

#

So in your example, you have multiple players, and each player can track multiple targets

#

So you segment it a little bit

#

Making a "player data" class that represents what a player tracks

#

And making a "data tracker" class that represents all the player data for all the players

sand spire
#

Yeah and I only have 1 arrow per player so I don't need to store that in the same way as the players & targets, and the multiple targets are per multiple player so it should be below it or something

echo basalt
#

Basically wrapping a Map<UUID, Set<UUID>> in 2 classes

#

In that case it'd be a Map<UUID, UUID>

#

I'd still avoid being niche about your second argument and making a class for further expandability

eternal oxide
#

in your case you have all the structure now

#

currently your Listener IS your "data tracker"

echo basalt
#

Even if it looks something like

public class PlayerTrackingData {

  private final UUID playerId;
  private UUID targetId = null;

  public PlayerTrackingData(UUID playerId) {
    this.playerId = playerId;
  }

  public UUID getTargetId() {
    return this.targetId;
  }

  public void setTargetId(UUID targetId) {
    this.targetId = targetId;
  }
}
#

Your data tracker should be the one responsible for creating the data objects

sand spire
#

I have this rn

public class DataHolder {
    UUID id;
    Set<UUID> targets = new HashSet();

    public DataHolder(UUID playerID) {
        this.id = playerID;
    }
    public void addTarget(UUID entityId) {
        this.targets.add(entityId);
    }
}```
eternal oxide
#

thats your Player Data

echo basalt
#

Although in certain cases other classes can be the ones asking it to init the object

#

Your tracker class is basically just a Map<UUID, PlayerTrackingData> wrapper

eternal oxide
#

What he is talking about is the function your Listener is currently doing, which can easily be moved later

echo basalt
#

With friendly methods to get a player's tracking data, set the target etc

sand spire
eternal oxide
#

how do your players stop their arrow?

echo basalt
#
public class MyDataTracker {
  
  private final Map<UUID, PlayerTrackingData> dataMap = new HashMap<>();

  public PlayerTrackingData getData(UUID playerId) {
    return this.dataMap.computeIfAbsent(playerId, PlayerTrackingData::new); // get or run the function, insert and return its value
  }

  public void invalidateData(UUID playerId) {
    this.dataMap.remove(playerId);
  }
}
#

Is an example

#

It could be further improved by checking arguments and making sure the player is online type before creating objects

sand spire
eternal oxide
#

ok

#

in that case in your DataHolder create two methods. startArrow and stopArrow

#

for now, just empty methods with no arguments

sand spire
#

    }
    public static void stopArrow() {
        
    }```
eternal oxide
#

yep

echo basalt
#

Not static though

eternal oxide
#

you will call those from yoru listener when you need

echo basalt
#

Do you know what static does?

eternal oxide
#

yeah, no static

#

brb loo

sand spire
#

so it works everywhere, I made all my methods static but thats prob cause they methods I need to use over multiple projects in my Utils class

echo basalt
#

That's.. not the purpose of static

#

Static abuse

sand spire
#

All i know is that if 1 thing is static everything needs to be static or it wont work

civic sluice
#

nope

echo basalt
#

here's jan's take

#

It's a rewrite of my take

sand spire
#

I'll read one later idk which one

#

let me guess, if I abuse static everything will be super easy at the beginning but after I made tons of projects and I have a lot of code I will regret it

eternal oxide
#

static will break most things

echo basalt
#

Basically static and objects are like water and oil

#

They don't mix

#

Static basically means "this doesn't belong to any object but rather the type itself"

eternal oxide
#

It has it's uses, but they are very specific

echo basalt
#

its* ^

eternal oxide
#

yep

sand spire
#

alr

eternal oxide
#

too lazy to edit 🙂

echo basalt
#

mf

eternal oxide
#

going to leave it there to annoy 😛

echo basalt
#

ok boomer

sand spire
#

btw do I need to make multiple start & stop arrow methods, and when I rightclick i first have an ability for an arrow to hover infront of me, then I cancel it (so it falls down) when I leftclick and find a target and calculate the velocity towards the target and the next and the next then back to me and then I cancel it again and also delete the arrow

#

or can I put everything that needs to be stopped in the same method

eternal oxide
#

no

#

you can add a createArrow or activateArrow method

#

start/stop will be used to... (self explanatory)

sand spire
#

yeah rn i have

    private BukkitTask homingArrows;
    private BukkitTask hoveringArrows;```

the flyingArrow is the entity that spawns, the homingArrows is the calculation to the next target, and the hoveringArrows is the arrow hovering infront of me which needs to be stopped before I use homingarrows
#

I should add simular things in the start and stop right

eternal oxide
#

no

sand spire
#

or I mean the entity being created in the createArrow, and the other 2 in activateHovering and activateHoming

eternal oxide
#

what is activateHoming?

#

and hovering

sand spire
# eternal oxide what is activateHoming?

i don't have it yet, but I the bukkittask hoveringarrows (which is activated after summoning the arrow entity) makes the arrow hover infront of me (which is cancelled before I activate homingarrows) and when I activate homingarrows the calculation is made towards the targets & back to me

eternal oxide
#

ah ok

#

I was going to do the homing part in start

#

basically in start you begin your Homing

#

in create you start your hovering

#

so you do need two tasks as Fields

#

no s on the end, as these are single arrows

#

homingArrow hoveringArrow

#

There are many optimizations you can do later, but for now a task for each is fine

#

Later is when you start thinking about animation sequences

sand spire
#
//start hovering
        //start homing after hovering stopped
    }

    public void stopArrow() {
//stop hovering
        //stop homing later
    }
}```
eternal oxide
#

createArrow should start hovering. No tasks shoudl be running when you call create

sand spire
#

Do I wanna put the code of the arrow hovering in that method?

eternal oxide
#

not yet

#

well, you could I guess

#

create the task there

#

and start it

sand spire
#
//start hovering
    }
public void stopArrow() {
        //stop hovering
}
    public void startArrow() {
//start homing
        //no need to stop homing as it automatically stops when targets arraylist is empty
    }
}```
sand spire
#

I also want to make a method to spawn the arrow in the air right, cause when I cancel the hovering I don't wanna completely delete the arrow with it

eternal oxide
#

Not sure what you mean

#

when you call createArrow you shoudl spawn the Arrow entity where it needs to be and start a hover task

sand spire
#

half the code is red now tho so I should probably figure out how to link all objects

eternal oxide
#

ok

#

Bukkit.getPlayer(UUID) and Bukkit.getEntity(UUID) will fix most

sand spire
#

SHouldn't I just do this again but in the dataholder class

    private Arrow flyingYakaArrow;
    private BukkitTask homingArrows;
    private BukkitTask hoveringArrows;
    private double angle = 0.0;
    private boolean movingLeft = true;
    private Player player;``` cause it doesn't fix it
eternal oxide
#

yes

#

don;t store the Player though

#

use Bukkit.getPlayer(UUID) when you need it

ashen quest
#

Why shall one not store a player. What changes

eternal oxide
#

The Player object does not persist through logins

sand spire
#

public void createArrow() {
Player player = Bukkit.getPlayer(UUID);

eternal oxide
#

Best practice to reference by UUID

ashen quest
eternal oxide
#

yes

sand spire
#

Can I send screenshots when I'm verified or nah

eternal oxide
#

yes

sand spire
#

ok imam create an account rq cause its annoying i can't send ss

rotund ravine
echo basalt
#

bro hijacked my index to post bing

halcyon hemlock
rotund ravine
echo basalt
#

jan says bing more than crazy frog does

#

change my mind

sand spire
#

ok i verified

#

@eternal oxide can you friend me to prevent clogging the cht?

eternal oxide
#

create a thread

thin wind
#

Hello is it possible to make a glowing entity not visible through blocks ?

ocean hollow
#

how to find out the name of the plugin in order to add it to depend?

agile hollow
#

how can i get the hitted player with the ProjectileHitEvent?

orchid gazelle
remote swallow
orchid gazelle
#

And then cast to Player(but first check if it is a Player!!!)

tender shard
#

i love it

#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

dry hazel
tender shard
agile hollow
river oracle
#

also finally gonna start on the storage module today after I finish switching PineappleChat to gradle.kts

eternal night
#

otherwise it gets relocated

tender shard
#

because I'm relocating the shaded adventure and minimessage

#

I'll later create a separate module that's excluded from shadowJar but the issue is obv that I cannot pass an instance of the relocated Component into the actual paper event

#

so I have to serialize it w/ shaded minimessage and deserialize it with paper minimessage

river oracle
#

why wouldn't you want it to be relocated? oh for paper minimessage

tender shard
#

yeah because PlayerQuitEvent.quitMessage doesn't take a com.github.spigotbasics...Component 😄

eternal night
#

why choose MM as the intermediate format tho 😅

#

wouldn't json be nicer ?

tender shard
#

idk I'm using minimessage for all messages anyway

eternal night
#

Yea true I guess

#

saves you from shading gson serialiser

tender shard
#

i didnt even think about using sth else

#

guess it doesn't really matter

river oracle
#

once BungeeChat gets merged we can probably just do MM -> Json -> Bungee

#

everyone knows the real chads do PineappleChat -> Bungee though

young knoll
#

Isn't gson serializer part of spigot

eternal night
#

adventures bungee platform already does adv to bungee no ?

tender shard
#

fancy! it almost works lmao

#

why can't I access sth that's public 🥲

worldly ingot
#

Are you passing the instance?

#

You can access fields and methods, but you have to pass the instance from which you want to get the member

#

Otherwise it just assumes static

dry hazel
#

the class is package-private

young knoll
#

wtf I thought adventure dropped the bungee serializer

river oracle
#

+1 ^

tender shard
#

maybe the instance is null, let's check

young knoll
#

Apparently they didn't

river oracle
#

wack

tender shard
#

sure

young knoll
#

I mean it hasn't had a commit in 2 years

#

But it should still work

agile hollow
#

why my Bukkit.getScheduler not working?
i want after 10 seconds from the damage of the EGG on the victim the victim will get removed from the list nobw (List of UUIDs)

    public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
        if (event.getDamager() instanceof org.bukkit.entity.Egg) {
            org.bukkit.entity.Egg egg = (org.bukkit.entity.Egg) event.getDamager();
            ProjectileSource shooter = egg.getShooter();

            if (shooter instanceof Player && event.getEntity() instanceof Player) {
                Player attacker = (Player) shooter;
                Player victim = (Player) event.getEntity();

                // Add the victim to the list of hit players
                im.setnobw(victim);
                Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {

                    @Override
                    public void run() {

                        if(im.NoBowBoost.contains(victim.getUniqueId())) {
                            victim.sendMessage("E' gia' sotto effetto di un uovo!");
                            return;
                        }
                        im.removenobw(victim);

                    }
                }, 10 * 20);



                Bukkit.broadcastMessage(attacker.getName() + " hit " + victim.getName() + " with an egg! They are now on the hit list.");
            }
        }
    }```
glossy venture
#

does anyone know how to test on a different java version

#

in gradle

#

im writing my library at java 8 but i want string blocks for testing so ive tried doing

tasks.getByName("compileTestJava") {
    sourceCompatibility = JavaVersion.VERSION_16
    targetCompatibility = JavaVersion.VERSION_16
}
remote swallow
#

change tool chains

glossy venture
#

yk how?

remote swallow
#


java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(17)
    }
}


glossy venture
#

ah

#

cool thanksl

remote swallow
#

np

tender shard
remote swallow
#

do paper relocate it

tender shard
#

well it doesnt throw errors for getting the instance or class

remote swallow
#

it does have a varags on it

#

so it might be that

glossy venture
#

prob

remote swallow
glossy venture
#

why do u have reversed class names

remote swallow
#

im guessing to avoid relocation

glossy venture
#

oh ic

#

back to working on the language but now in java 8

tender shard
#

yeah that might be

glossy venture
#

yh

slender elbow
#

technically there is a deserialize(String), but that's going to be in the implementation, as it's a generic <R> deserialize(R)

#

and it'll be a String

astral scroll
#

ItemStack adapter anywhere?

#

im using a config serializable that i got somewhere but doesnt seem to work well

#

im in 1.20.1 and it started to need logger and atomic reference adapter???

river oracle
proud badge
river oracle
#

@eternal night you were right about groovy 😨 I switched PineappleChat over to kotlin holy fuck

eternal night
#

Yes xD

#

like, different worlds

river oracle
# eternal night Yes xD

side by side be like random magic with shitty syntax highlighting and clear as day what's going on

#

How do I include my transistive dependencies in my final published jar? or should just publishing the java component work

#

^ nvm

eternal night
river oracle
eternal night
#

Good decision NODDERS

proud badge
rough drift
#

I have a Vector direction and I want to make a block display have that rotation, however since I need interpolation I need to use quaternions, does anyone know how I could go Vector -> Quaternionf

obsidian drift
#

Is there a way to make the screen shake

proud badge
#

as in frozen?

obsidian drift
#

No I remember there is a function or something to make the camera tilt left or right as if the player is getting hurt

#

I found it player.sendHurtAnimation

hushed spindle
#

i do that myself too to check if a block was placed or not

proud badge
#

ok nice

hushed spindle
#

its fast enough to not appear on any timings

proud badge
hushed spindle
#

yeah

proud badge
#

because an issue is that if a build was to get rolled back the blockdata wouldnt stay

hushed spindle
#

probably not

proud badge
#

so ill have to modify the coreprotect code

#

to add it back

proud badge
#

also does it keep items when the block is broken, or do I have to remove the value myself?

rough drift
#

remove yourself afaik

proud badge
#

put the .jar file in your plugins folder

river oracle