#help-development

1 messages · Page 536 of 1

pseudo hazel
#

how did you do that before

quaint mantle
#

or at least thats my idea

#
private JavaPlugin arenaAPI;

    public ConfigManager(JavaPlugin plugin) {
        this.arenaAPI = plugin;
    }
public void createConfig() {
        this.file = new File(arenaAPI.getDataFolder(), "arenas.yml");
        if(!this.file.exists()) {
            this.file.getParentFile().mkdirs();
            this.arenaAPI.saveResource("arenas.yml", false);
        }

        this.configuration = new YamlConfiguration();

        YamlConfiguration.loadConfiguration(this.file);

    }
#

I know I should rename the variable but I want first to make it work lol

zenith gate
#

well once you make it once itll be easy to manipulate into multiple sessions. use the world as a template, copy it, create the session, wants someone wins, teleport them out, and delete that world.

pseudo hazel
#

what doesnt work about that

quaint mantle
#

I get a NullPointerException, but I think I just saw where's the problem, let me try to fix this and I'll tell you

#

nah, can't fix it @pseudo hazel but I know where's coming from the error

tall furnace
#

Ok so I have a problem.
I've got a Listener, and am listening for the PlayerToggleSneakEvent. Other Listener classes are working perfectly fine. Here's my listener
`public class GameListener implements Listener {

@EventHandler
public void onSquat(PlayerToggleSneakEvent e) {
    e.getPlayer().sendMessage("Aha, you squatter you!");
}

}and here's where I register it (along with other listeners)@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(new BannerListener(this), this);
Bukkit.getPluginManager().registerEvents(new EditListener(), this);
Bukkit.getPluginManager().registerEvents(new GameListener(), this);
}`

Now the really unusual thing here is that the events in the BannerListener and the EditListener are working just fine. I've verified that I am exporting to the correct location, that I can modify code and have it work in the server, but anything in my GameListener class is simply not being called. I've registered the event, I've implemented the listener, and I've used the annotation. All my marks are checked. No compilation errors, no errors in console. Idk what's going on here.

quaint mantle
#

as you can see in my API main class I have this in the onEnable:
configManager = new ConfigManager(this);

and I was using in my main plugin the ArenaAPI.configManager.createConfig() so I was using the API instance instead of my main plugin instance

pseudo hazel
#

put your onEnable in your api constructor

severe folio
#

loadConfiguration returns the config

#
FileConfiguration myConfig = YamlConfiguration.loadConfiguration(myConfigFile);
raw prairie
#

Kot fuck

quaint mantle
severe folio
#

np, only read that far tho so i didnt read ur initial problem yet

raw prairie
#

Are there any tutorials for using the spigot API with kotlin?

#

Right now on youtube theres only a setup tutorial

quaint mantle
#

ok thanks it seems to be everything working correctly now

#

thanks again for helping me ^^

severe folio
zenith gate
#

would it be an eventhandler to do something based off of time? to make a mob attack someone no matter how far they are away.

compact haven
#

what

#

you mean a scheduler @grave kiln ?

#

omfg

#

I’m so sorry

raw prairie
compact haven
#

@zenith gate

zenith gate
compact haven
#

literally just search “spigot api kotlin” but, as a kotlin developer, spigot development with kotlin sucks ass

dense geyser
#

is there any known list of strings that can be sent into PacketPlayOutCustomPayload? wondering what's possible with it

tall furnace
compact haven
#

pretty sure anything can? It’s for server -> modded client communication I believe

severe folio
regal scaffold
#

Hey guys

#

Where the knowers at

remote swallow
#

the knowers of what

regal scaffold
#

Wanted to say a good bye for now, wanted to thank you all for helping so much learning MC dev

compact haven
#

@gray narwhal add another event in there that’s more common like a chat event and see if it’s the event itself that’s broken instead of the listener

regal scaffold
#

I was hired as a full time full stack dev so gonna be leaving mc development for now

compact haven
#

I fucking hate my life

#

how can discord tags be so ass

compact haven
#

@tall furnace I meant to tag you

severe folio
compact haven
#

yeah I really need to do that lmao

regal scaffold
#

@remote swallow @tender shard @young knoll @wet breach @tardy delta @echo basalt

Sorry if I’m missing some, but thank you for always answering the weirdest of questions, got me to where I am now. Take care!

regal scaffold
remote swallow
#

damn

compact haven
#

W

severe folio
#

holy shit, congrats

tall furnace
tall furnace
#

Grats, have fun with it

regal scaffold
#

My first job as a web dev

#

Thank you

#

And thanks again spigot

compact haven
#

ew you’re doing frontend

regal scaffold
#

Nope

tall furnace
regal scaffold
#

Backend

tall furnace
#

oh

regal scaffold
#

I hate frontenis

#

Api

compact haven
#

oh thank god

tall furnace
#

Not PHP I hope

regal scaffold
#

Nah

tall furnace
#

nasty stuff

regal scaffold
#

Phthon django

severe folio
#

what language/framework?

compact haven
#

you said full stack so I thought u meant both

severe folio
#

ah

compact haven
#

okay that’s still detestable

regal scaffold
#

It’s not as bad

#

But so far it’s nice

tall furnace
#

It's 6 figures tho

severe folio
compact haven
#

you’re high

regal scaffold
#

Django is like the only decent alternative for python

tall furnace
#

It's so ugly

regal scaffold
#

Flask is too small

#

And they wanted python as language so not many choices

compact haven
#

PHP wasnt even meant to be a language in the first place

regal scaffold
#

Wasn’t really my choice either

severe folio
regal scaffold
compact haven
#

either they have existing tech or they read that python is good somewhere online

regal scaffold
#

Existing

tall furnace
hazy parrot
#

personal home page (╯°□°)╯︵ ┻━┻

regal scaffold
#

Now I gotta learn all these annoying new cloud stuff

#

Aws is so massive

quiet ice
# regal scaffold

What's up with Korea and Iran's name? Lao doesn't adhere to that scheme

regal scaffold
#

First is cognito

#

Not sure, it’s just dummy data

#

First google search

tall furnace
#

Is there a way to confirm that an event was called other than by listening for it?

compact haven
#

Perhaps add an EventListener LOWEST and ignoreCancelled parameter

#

Only way to know for sure is to inject a listener first in the static list pretty sure

tall furnace
tardy delta
#

what

remote swallow
#

I just thought of a great way to kill a server. Listen to every event on lowest priority and unregister all events

tall furnace
remote swallow
#

Wouldnt post it anywhere i just thought of it

compact haven
#

okay besides the section codes for colors and the illogical comment, and probably the weirdest tabs, it looks fine

severe folio
compact haven
#

uh actually yes

#

how did you not get an error in console for that

#

There’s definitely a message in console

#

(unless the event api changed since I used it as well)

tall furnace
tall furnace
tall furnace
#

Thanks for the tip; will return with a definitive result.

#

Ayyyyyy my squatter code worked XD
And yes, that did solve my problem. Thanks for the tip! Wonder why it's not automatically added in with the other unimplemented methods?

severe folio
#

Probably because it's static..?

quiet ice
#

Because there is no contract at the JLS level

#

Java (the language) does not know that it needs that method

tall furnace
high pewter
#

I'm wanting to use IntelliJ IDEA build artifacts to easily test, debug and hot-swap my plugin. However, I'm wanting to use aikar's commands library, so I need to shade that into the JAR. I am using Maven, and when I use mvn package, the JAR works fine. However, if I use the build artifact, even though I have checked Delegate IDE build/run actions to Maven, it doesn't seem to use Maven and the JAR produced is not shaded. How can I hot-swap a shaded JAR?

opal juniper
#

just use maven build and set the output location

#

also - dont

high pewter
#

wdym also - dont? Don't what?

opal juniper
#

hotswap

high pewter
#

How come?

opal juniper
#

close the server and restart. If you are using /reload or plug(man/woman) it can introduce issues

quiet ice
#

they are talking about JVM-level hotswapping

high pewter
#

I'm not using /reload or plugman, I'm using IntelliJ's own hot-swapping which lets you know if you make incompatible changes

opal juniper
#

oh okeee

quiet ice
#

If you can, use ACF as a standalone plugin

#

Otherwise you can add it on the runtime classpath, but for building public releases you can use outside your IDE you'd need to use maven or gradle.

high pewter
#

What do you mean by adding to the runtime classpath, sorry?

eternal oxide
#

use the libraries entry in plugin.yml

high pewter
#

I'm happy to use Maven for public releases, though

high pewter
quiet ice
high pewter
#

Ohh right ye, I know what you're on about now. I'll try that!

hard socket
#

what is better? making my Utils class all static or interface/abstract?

#

I have multiple Utils classes btw

eternal oxide
#

If it it truly a Utils class (stateless) then static

hard socket
#

stateless?

eternal oxide
#

doesn't require initializing ^

hard socket
#

its like this

eternal oxide
#

Not a utils class

hard socket
#

I will be using it in a lot of classes

eternal oxide
#

remove all teh statics and make it a singleton

hard socket
#

alr thanks I am trying to enhance my code

#

can you review my code in github and tell me what should I do?

remote swallow
hard socket
#

oh alr thanks anyways

quaint mantle
#

How can I import NMS classes using gradle? I've tried running java -jar BuildTools.jar --rev latest --remapped in my project directory and then compileOnly 'org.spigotmc:spigot:1.19.4-R0.1-SNAPSHOT' in my build.gradle dependencies, but I can't import any classes.. What should I do?

remote swallow
#

for remapped you need to use paperweight or another 3rd party special source plugin

rotund ravine
#

?nms

remote swallow
rotund ravine
#

Meh

shadow night
#

how do I load a resource pack from code?

#

I have one in my resources folder but idk how to load it

eternal oxide
#

The client has to have your resource pack not your plugin

opal juniper
#

if you have it in your resources folder you are gonna need to host a webserver on the server to deliver it to the client

shadow night
#

._. oh gosh

#

ig I can do that

opal juniper
#

or just, yaknow, use dropbox or sommin

rotund ravine
#

Something with a direct download is needed

#

So no dropbox

opal juniper
#

dropbox works for years

shadow night
#

I don't wanna rely on random file hosting services so Ig

opal juniper
#

i used it

shadow night
#

hmm, right, my bungee hosts a webserver so I should try

#

so, nothing happens

quaint mantle
eternal oxide
#

?nms

quaint mantle
#

Thanks

storm scaffold
#

Is there a generic way to tell if a PlayerInteractEvent causes something to happen? E.g. if it is a villager interaction, door, container or anything?

eternal oxide
#

no

storm scaffold
# eternal oxide no

just not at all? It just cannot be done? I'm trying to find out when a player is using a goat horn

eternal oxide
#

thats not generic, thats specific

remote swallow
#

oh just check if their main hand is holding a goat horn and they right click air or a block

storm scaffold
#

I mean trying to ignore everything else

storm scaffold
#

Or if you click a villager it doesnt, but a mooshroom it does

remote swallow
#

is there something that would break if the horn doesnt go off?

storm scaffold
#

I'm trying to make a custom effect that triggers when you use a goat horn

remote swallow
#

might need to listen to sound packets or whatever they're called, might be wrong

storm scaffold
#

is there no way to do it other than sound packets?

eternal oxide
#

You could try if the target is an entity or the Material#isInteractable() the horn won't sound

shadow night
quaint mantle
#

Which jar should I use for the nms? I am guessing the remapped obf one, but I just want to make sure:

original-Test-1.0.jar
Test-1.0.jar
Test-1.0-remapped-obf.jar
shadow night
#

what should I debug? I did everything I could do

upper vale
upper vale
#

Why? which part

#

setPlaceholders takes an offline player as an argument

#

Or if the plugin parses the player name separate you can just include that in the placeholder I guess

#

Not really

high pewter
#

Earlier I was asking about how to fix my attempt at hot-swapping Maven and I tried all your suggestions but I couldn't get it working. I feel like it would probably make more sense for me to just ask the best way to do it rather than why what I'm doing won't work, especially since there seems to be a variety of ways to do it. So how should I test/debug/hot-swap a shaded Maven plugin?

quaint mantle
#

can i need get playername.tostring ? for insert to database or only p.getname fine ?

remote swallow
#

uuid

quaint mantle
#

bro don't hate me but

remote swallow
#

getName should be fine then

hazy parrot
quaint mantle
#

😄

#

i have minecraft

#

rlyy

#

i liked this emoji

agile anvil
#

Probably head to #help-server . The current channel is reserved to spigot and bungee development

#

Then you should probably look at their wiki

high pewter
# quiet ice If you can, use ACF as a standalone plugin

Actually, I forgot to try this, but I'm trying it now. When you said "If you can", did you mean if a plugin version exists or if I am personally able to? Because I can't seem to find a plugin version and the JAR provided by Maven doesn't even have a plugin.yml

quiet ice
high pewter
#

Ah dang 😕

grim oak
#

Hi, I've made custom events in my plugin and was wondering how I handle those events from another one of my plugins? Do i just need to import it kinda like a library?

quiet ice
#

Do you even have the handler list and everything set up in the first place?

#

If so - yes. Though depending on your setup you may need to invoke ./gradlew publishToMavenLocal or mvn install beforehand

quaint mantle
#

why doesnt this work

#

no errors in consol

#

just simply doesnt work

#

whole class if yall wondering what this is

tardy delta
#

?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.

quiet ice
#

Superperms is always a bit iffy

#

But are you really sure that the permisison exists in the first place?

quaint mantle
#

what more do you want me to tell uou

quiet ice
#

Is the issue in the filter or in the teleportPlayer method?

quaint mantle
#

filer

#

filter

shell robin
#

Do you think a chat control plugin should have features other than profanity protection, clearing chat, locking chat?

tardy delta
#

so the players dont have that permission?

quaint mantle
#

they do

#

i tripple checked

tardy delta
#

and teleportPlayer gets called?

quaint mantle
#

no it doesnt because the filter doesnt work. No players survives the filter. No matter if they have the perm or not

severe folio
quaint mantle
#

or at least thats my interpretation

eternal oxide
quaint mantle
#

oh dont get me wrong teleport playerS gets called i checked with a consol out print

quiet ice
#

Also, does it work if you are in OP?

eternal oxide
#

when are you calling it?

quaint mantle
eternal oxide
#

how are you assigning the permission?

quaint mantle
#

i just assigned the permission through luckperm rn because im testing around

#

the web editor

eternal oxide
#

then you either typed teh permission wrong or there is code you are not showing which is relevant

severe folio
#

couldnt you just filter(...).collect().forEach(...) or does that not make any difference?

tardy delta
#

why would you collect

severe folio
#

idk eveywhere i see for this sorta thing collects before looping through

#

(i never really use this myself so i wouldnt know lol)

quaint mantle
#

nvm i figured it out. While it did trigger the teleport player it for some reason stoped while loading the config but also didnt trwo an consol error

#

ima try to figure out why that happens now

#

thx for the help tho

visual laurel
#

Why are these recipes not registering/working when using the items:

        NamespacedKey T1KeyTirFrostd = new NamespacedKey(this, "t0t1tirfrostd");
        NamespacedKey T2KeyTirFrostd = new NamespacedKey(this, "t1t2tirfrostd");
        NamespacedKey T3KeyTirFrostd = new NamespacedKey(this, "t2t3tirfrostd");
        NamespacedKey T1KeyTirFrostn = new NamespacedKey(this, "t0t1tirfrostn");
        NamespacedKey T2KeyTirFrostn = new NamespacedKey(this, "t1t2tirfrostn");
        NamespacedKey T3KeyTirFrostn = new NamespacedKey(this, "t2t3tirfrostn");
        RecipeChoice TirFrost0d = new RecipeChoice.ExactChoice(TirFrostItem(0, 1));
        RecipeChoice TirFrost1d = new RecipeChoice.ExactChoice(TirFrostItem(1, 1));
        RecipeChoice TirFrost2d = new RecipeChoice.ExactChoice(TirFrostItem(2, 1));
        RecipeChoice TirFrost0n = new RecipeChoice.ExactChoice(TirFrostItem(0, 2));
        RecipeChoice TirFrost1n = new RecipeChoice.ExactChoice(TirFrostItem(1, 2));
        RecipeChoice TirFrost2n = new RecipeChoice.ExactChoice(TirFrostItem(2, 2));
        Recipe upgradeT0T1TirFrostd = new SmithingRecipe(T1KeyTirFrostd, new ItemStack(TirFrostItem(1, 1)), TirFrost0d, T1Upgrade);
        Recipe upgradeT1T2TirFrostd = new SmithingRecipe(T2KeyTirFrostd, new ItemStack(TirFrostItem(2, 1)), TirFrost1d, T2Upgrade);
        Recipe upgradeT2T3TirFrostd = new SmithingRecipe(T3KeyTirFrostd, new ItemStack(TirFrostItem(3, 1)), TirFrost2d, T3Upgrade);
        Recipe upgradeT0T1TirFrostn = new SmithingRecipe(T1KeyTirFrostn, new ItemStack(TirFrostItem(1, 2)), TirFrost0n, T1Upgrade);
        Recipe upgradeT1T2TirFrostn = new SmithingRecipe(T2KeyTirFrostn, new ItemStack(TirFrostItem(2, 2)), TirFrost1n, T2Upgrade);
        Recipe upgradeT2T3TirFrostn = new SmithingRecipe(T3KeyTirFrostn, new ItemStack(TirFrostItem(3, 2)), TirFrost2n, T3Upgrade);
        getServer().addRecipe(upgradeT0T1TirFrostd);
        getServer().addRecipe(upgradeT1T2TirFrostd);
        getServer().addRecipe(upgradeT2T3TirFrostd);
        getServer().addRecipe(upgradeT0T1TirFrostn);
        getServer().addRecipe(upgradeT1T2TirFrostn);
        getServer().addRecipe(upgradeT2T3TirFrostn);```
floral drum
undone axleBOT
visual laurel
#

do you want me to paste my entire onEnable event?

visual laurel
visual laurel
kindred valley
#

Just filled my screen np

visual laurel
#

ah

tardy delta
#

time to buy a bigger screen

quaint mantle
#

what is this

#

i tilted

#

omg

#

spoon me for fix this

ocean marsh
#

Hey guys can some one help me drm rules...
My plugin was just took down and I don't know how to comply with the rules

#

I have been working on this plugin for over two year so I would be really glad that some one can help me

quaint mantle
#

omg db master writing

quiet ice
#

Just put it through proguard but there isn't much you can DRM/Obfuscate

echo basalt
#

drm is stupid anyways

ocean marsh
#

btw it's a premium plugin

quiet ice
#

even then not much can be done

quiet ice
echo basalt
#

damn I expected more of you

quiet ice
#

but what is the query? From what I know this looks like it's missing a few keywords

#

Hey, I would never have touched one if it wasn't because I am forced due to school

quaint mantle
#

wait i will show u

#

SELECT * FROM players.playerstats WHERE name ?

#

wait will send

#

code

dense geyser
#

name = ?

quaint mantle
#
        PreparedStatement statement = getConnection().prepareStatement("SELECT * FROM players.playerstats WHERE name ?");
        statement.setString(1, name);
        ResultSet result = statement.executeQuery();

        if (result.next()){
            int level = result.getInt("level");
            statement.close();
            return new Stats(name, level);
        }
        return null;
    }```
dense geyser
#

change it to WHERE name = ?

ocean marsh
#

they took down my plugin and I want to comply with the rules...
I have a way to remove access from the plugin is this the issue ?

quaint mantle
dense geyser
quiet ice
#

especially if it requires an internet connection

dense geyser
#

it should be SELECT * FROM players.playerstats WHERE name = ?

hazy parrot
#

getConnection().prepareStatement("SELECT * FROM players.playerstats WHERE name ?"); => getConnection().prepareStatement("SELECT * FROM players.playerstats WHERE name = ?");

quaint mantle
quiet ice
#

As I said, there is almost nada you can do in terms of DRM and obfuscation

hazy parrot
quaint mantle
#

i will try ur method 1m

quiet ice
#

Also, be very aware that tools such as Recaf exists to remove your DRM within minutes if people really wanted to

hazy parrot
dense geyser
quaint mantle
#

ah

#

mb sry

dense geyser
#

alrighty in the silence ill ask my quick question

#

whats the bungee equivalent of a configurationsection

quiet ice
#

The best way to prevent that is to make your plugin rather uninteresting/unappealing to reverse engineer. So ironically don't obfuscate or hide anything because people that try to do nefarious stuff get a kick from reverse engineering. If there isn't anything to RE they won't bother doing anything

dense geyser
#

you should put a comment in some of the obfuscated files saying "if you're trying to reverse engineer this, you need to re-evaluate your life choices"

quiet ice
#

But you probably did hide something

ocean marsh
#

I use intellij and compily the plugin that's all

#

I have multiple time opened the plugin from online web site to check some errors

quaint mantle
#

sry guys i was ask this question but im forgot
how to control world datapacks with plugin ?

#

i wan't to control minecraft biome colors with plugin

young knoll
#

No api for it

#

You need NMS and or packets

dawn hazel
#

so i know static abuse is bad and all, but does anyone know why static abuse is bad? what issues does it cause?

young knoll
#

It limits testability and tightly couples your code

dawn hazel
#

so basically is makes it harder to change code later on?

young knoll
#

Mhm

remote swallow
#

read this

#

@dawn hazel

dawn hazel
#

ohhhhh

#

okay thank you

echo basalt
#

oh yeah I wrote that

young knoll
#

Maybe I am a clown

#

What then huh?

remote swallow
#

ur a clown

remote swallow
#

@echo basalt they ruined ur perfect search

echo basalt
#

NOO MY SEARCH INDEX

#

@sullen marlin I'll give you 20 bucks if you can blacklist anyone else from typing those 3 specific words

young knoll
#

Discord needs personal pinned messages

#

Well maybe not needs but yeah

ivory sleet
#

I think static abuse is a bad term, it entirely depends on what you’re doing, but more often when someone refers to static abuse they mean you probably cluttered every variable in ur code with static or sth like that (I like to call it under engineered design choice or similar along those lines)

Edit:
It limits testability, reusability, often thread safety also (hermmmm SimpleDateFormat fuck you).

Choice of static implies you write a type poor system thus can’t take advantage of generics, which means clumsier usage if Optional, generic functional interfaces, Streams and so on.

It can also makes your code less defended since everything becomes more accessible since its global now. This makes it so that one part of the code that breaks easily when another part of the code is touched since depending on more classes becomes more susceptible and tangible. But also makes a shit ton of stuff break when changing small stuff just.

I could go on more about it but I think this should be convincing enough.

young knoll
#

If your code is displaying code symptoms please see a code doctor

ivory sleet
#

Sounds static

remote swallow
#

i remember when i didnt know what static was so would just see any static i saw static abus

eternal oxide
#

its generally a mistake by beginners who don't understand getters

ivory sleet
young knoll
#

I’m tempted to say it

#

But I shall resist

ivory sleet
#

No

#

Good coll

remote swallow
#

conclurusion search index

echo basalt
#

thanks conclure

#

I still want that term whitelisted though

ivory sleet
#

Hmm, I may be able to look into it through the bot

ivory sleet
remote swallow
#

i used my brain

#

once in a year occurance

young knoll
#

What about an illusion smearch smindex

remote swallow
#

smearch smindex

ivory sleet
#

Scoll scearch scindex?

echo basalt
#

epic crunch windex

remote swallow
#

ishmooshon smearch shmindex

zenith gate
#

How can I check if the current world's day ends in a 0?

ivory sleet
#

The last digit is 0?

zenith gate
#

yes

young knoll
#

day % 10 == 0

zenith gate
#

like 140 or 50

#
private static void currentTime() {
        long worldTime = Bukkit.getServer().getWorld("world").getFullTime();
        if (worldTime % 10 == 0) {
            System.out.println("The day has ended");
        }
    }

So this would work?

young knoll
#

Iirc the time is in ticks not days

#

So you need to divide by 24000

zenith gate
#

oh shit you right

#
if (worldTime / 24000 % 10 == 0) {
            System.out.println("The day has ended");
        }

That'll do it?

worldly ingot
#

I'd be careful with that lol

zenith gate
#

Why's that? lol

worldly ingot
#

Depends on order of operations. (worldTime / 24000) % 10 to be safe

young knoll
#

BEDMAS doesn’t cover modulo

zenith gate
#

PEMDAS! I thought i was rid of you

remote swallow
#

its bodmas coll

#

or bidmas

young knoll
#

And now we have 3 different ones

#

And now 4

remote swallow
#

Brackets
Powers/Indicies
Division
multiplication
addition
subtraction

worldly ingot
#

Regional terminology and order of operations aside, it's just more clear to read is all

#

At least your intentions are clear, that is

zenith gate
#

Well I am always eager to learn eligible code.

ivory sleet
#

I think its even an item in effective java

zenith gate
#

Im just trying to create an event that would happen every 10 minecraft days.

young knoll
#

But we still need the real answer

#

Where is modulo in the order of operations

worldly ingot
#

It's a division

#

Only instead of getting the product, you get the remainder

young knoll
#

BEDMMAS

worldly ingot
#

Sorry, "the quotient", not "the product". If you want to get technical

drowsy helm
young knoll
#

And none of them convey that multiplication/division and addition/subtraction are grouped

remote swallow
#

they are?

young knoll
#

See what happens when you don’t go to school

remote swallow
zenith gate
#

would setting an entity to be aware to true, make them globaly angry? meaning they will start to attack you no matter how far away you are?

young knoll
#

No

#

Mobs are all aware by default

small holly
#

anyone know why this

    @EventHandler
    public void updateHead(InventoryClickEvent event) {

        Inventory inv = event.getClickedInventory();
        if (event.getSlotType() == InventoryType.SlotType.OUTSIDE || event.getCursor() == null || event.getCursor().getType() == Material.AIR)
            return;
        ItemStack item = event.getCursor();
        NBTItem nbtItem = new NBTItem(item);
        if (!nbtItem.getBoolean(NBTConsts.GLITCH_ITEM))
            return;

        if (!nbtItem.getBoolean(Consts.playerHead))
            return;


        if (event.getSlotType() == InventoryType.SlotType.ARMOR) {
            event.getWhoClicked().getInventory().setHelmet(Heads.updateHeadWorth(item));
            return;
        }

        inv.setItem(event.getSlot(), Heads.updateHeadWorth(item));

    }

is now doing this (worked perfectly fine last night) https://cdn.discordapp.com/attachments/809570302572625990/1112893725887184986/2023-05-30_12-01-45.mp4

#

updateHeadWorth does this btw just incase you think it could bethat

    public static ItemStack updateHeadWorth(ItemStack item) {

        OfflinePlayer player = Bukkit.getServer().getOfflinePlayer(((SkullMeta) item.getItemMeta()).getOwner());

        double worth = HeadHunterMain.getEco().getBalance(player) * Config.get().Percent_Of_Player_Value;


        String[] loreLines = new String[get().Player_Lore.length];
        Map<String, String> placeholders = new TreeMap<String, String>() {{
            put("%headhunter_player_worth%", String.format("%,.2f", worth));
        }};
        for (int line = 0; line < loreLines.length; line++) {
            loreLines[line] = ContentUtils.color(Placeholders.placeholder(get().Player_Lore[line], placeholders));
        }

        ItemMeta meta = item.getItemMeta();

        meta.setLore(Arrays.asList(loreLines));

        item.setItemMeta(meta);
        NBTItem nbtItem = new NBTItem(item);
        nbtItem.setFloat(Consts.playerHeadWorth, (float) worth);
        item = nbtItem.getItem();
        return item;

    }
#

well now its just doing it visually

grand otter
#

is there a tutorial to add apis with gradle?

remote swallow
#

like maven, add the repo and the dep with compileOnly if its a plugin api or implementation if its a library

grand otter
#

What is the difference between libraries and plugins?

young knoll
#

Plugins run as plugins

#

Libraries need to be shaded into your plugin

remote swallow
#

libraries you would shade and include inside your plugin, plugin api would be a plugin that you access, either designed for that or just as a way to access stuff relating to a plugin

grand otter
#

Its just an actionbar thing

#

I assume its an api

remote swallow
#

send the link

grand otter
remote swallow
#

that would be a plugin api, in its current state you would need to mvn install it or use a file dep, ill see if i can find a better one

grand otter
#

which is easier?

remote swallow
#

file dep

grand otter
#

okie, so Im pretty sure I need to go to project settings -> libraries?

remote swallow
#

file dep can be done through gradle and is better to be done through gradle

grand otter
#

ok, so how do I do that?

remote swallow
#

iirc its compileOnly file("path")

remote swallow
grand otter
#

why cant I use my own one?

remote swallow
#

you can by all means

grand otter
#

ok

#

so I have the jar, how to I add it

remote swallow
grand otter
#

thats it, just add it to build.gradle?

remote swallow
weak meteor
#

ig its vbetter idk

grand otter
#

the plugin

remote swallow
#

add depend: [ActionBarAPI] to your plugin.yml, and then also add the plugin to the server

grand otter
#

I did the plugin.yml thing, but what else do I have to do?

remote swallow
#

just need to add the jar to the server plugins

grand otter
#

ok, but when I use the method, I get this error: error: package me.Senneistheboss.abapi does not exist
import me.Senneistheboss.abapi.ActionBarAPI;

#

I imported it too

#

So your saying I just need to add it to my pluin.yml, and then add it to my plugins folder? Thats it, nothing with build.gradle or my editor?

weak meteor
worldly ingot
#

Look at your getConfig method and your load method

#

What do you notice being different?

#

(you actually are trying to define two load methods, one of which is incomplete)

weak meteor
#

getConfig isnt void

grand otter
worldly ingot
weak meteor
#

damn

#

im

#

stupid

#

asf

worldly ingot
#

but yeah, that aside, you have two load methods lol

weak meteor
#

look

#

idk if im using abstract classes the way are supposed to, i only use it to create a certain of DataType for the proyect lol

worldly ingot
#

You're using them fine but I think in this case specifically you're likely better off using just a concrete class that accepts an argument via a constructor

#

The only variable thing in your subclass (Messages) is the string

restive thunder
#

Anyone know of I plugin that I could use that would allow me to enchant items that blast players into the air and other custom things?

worldly ingot
#

In the future, #help-server. But you're probably looking for something like EcoEnchants

#

There are free alternatives as well. A quick Google for "Spigot custom enchantment plugin" will bring up plenty

restive thunder
#

Thank you

worldly ingot
#

It does. It's just a little wasteful is all. Generally you would use an abstract class for a type that shares functionality with numerous subclasses, but the subclasses add more specific methods

#

(When I say wasteful, I don't mean wasting memory or resources or anything. Just wasteful design-wise)

weak meteor
#

lol

#

thanks, Choco

worldly ingot
#
public class Config {

    private FileConfiguration config;

    private final Plugin plugin;
    private final String name;
    private final File file;

    public Config(Plugin plugin, String name) {
        this.plugin = plugin;
        this.name = name;
        this.file = new File(plugin.getDataFolder(), name);
    }

    public String getName() {
        return name;
    }

    public File getFile() {
        return file;
    }

    public FileConfiguration getConfig() {
        if (!file.exists()) {
            Console.send(CC.translate("&c&l[Pantech] &f" + name + " didn't exist! Creating it..."));
            plugin.saveResource(getName(), true);
        }

        config = YamlConfiguration.loadConfiguration(file);
        return config;
    }

}```
#

You get the same sort of thing just out of a single class

#
public final class YourPlugin extends JavaPlugin {

    private final Config messagesConfig = new Config(this, "messages.yml");

}```
weak meteor
#

Im managing IPs like with strings bc i dont know at all what package to use i type IP in Intellij and there so many options, what do u recomend?

weak meteor
#

thats easier

#

maybe im modifying it

worldly ingot
weak meteor
#

Thanks

velvet cove
#

Is there someone here that got the Java SE17 certification?

worldly ingot
#

Like the education certificate?

velvet cove
#

Yeah, the one you get from oracle

worldly ingot
#

That's something I've honestly forgotten about but should probably do

grand otter
weak meteor
velvet cove
#

@worldly ingot Oh wait I asked it in the wrong group my bad, I'll ask it in general

wary mountain
#

for some reason this dosent work. (supposed to check if user has item in their main hand when the event triggers. does anyone know whats wrong here?)

worldly ingot
#

getItemInUse() probably isn't what you want

#

getKiller().getInventory().getItemInMainHand() perhaps

wary mountain
worldly ingot
#

Just as a note by the way... I'm assuming you're extending ItemStack given that you're doing an instanceof check. This won't ever work. You'll always get an internal ItemStack instance, even if you passed in a custom ItemStack type into setItem(), setItemInMainHand(), or some other method to set items

#

If you want to keep track of a special item, you'll have to do it either by name, lore, or preferably, its PersistentDataContainer

subtle folio
#

Can I asynchronously copy a world?

#

or does it have to be on main thread..?

grand otter
wary mountain
#

no wait

#

nevermind it is

young knoll
#

Thou shall not extend Bukkit classes

wary mountain
#

items is a hashmap

young knoll
#

(Mostly)

wary mountain
#

Item is my own interface

#

so im checking if that Item object is an instance of BulldozerItem @worldly ingot does that make sense?

grand otter
weak meteor
#

check on google "Add libs folder to gradle"

wary mountain
#

hm still dosent work

worldly ingot
#

I see the Map#get() call now

#

Uncertain how well ItemStacks will play as Map keys though

wary mountain
worldly ingot
#

PES_BlankieThumbsUp Then disregard

wary mountain
wary mountain
worldly ingot
#

Unconventional but if it works, it works. Just keep this in mind if things fail to work in the future. I'd still personally opt to look into the PersistentDataContainer for a more consistent means of tracking custom items

wary mountain
#

didnt know that existed when starting this lol

worldly ingot
#

Just custom NBT 🙂

wary mountain
#

odd since other items work completely fine with the same logic

#

maybe the event listener is wrong?

grand otter
high pewter
#

I can identify if an Entity is passive (for the most part) by checking if it is an instanceof Monster, but can I do something similar given an EntityType? I'm trying to spawn a random entity and want to control the chance of the entity being passive or not so need to identify which entity types are considered passive

echo basalt
#

uhm great question

#

you can call EntityType#getEntityClass and do a little reflection to see if it inherits Monster

pallid oxide
echo basalt
#

you can just like

#

save the world

#

make a file copy async

elder quartz
#

Hello guys, im going thru a lot of changes in my code trying to load some configuration from a file.

public Map<String, String> getRoleMappings() {
        Map<String, String> roleMappings = new HashMap<>();

        // Retrieve the "roles" section from the configuration
        ConfigurationSection rolesSection = DiscordRoles2.getInstance().getConfig().getConfigurationSection("discord.roles");

        System.out.println(rolesSection);

        if (rolesSection != null) {
            System.out.println("RoleSectionNoNulo");
            // Iterate over each role in the "roles" section
            for (String key : rolesSection.getKeys(false)) {
                ConfigurationSection roleSection = rolesSection.getConfigurationSection(key);
                if (roleSection != null) {

                    // Retrieve the role-id and group values for each role
                    String roleId = roleSection.getString("role-id");
                    String group = roleSection.getString("group");

                    // Add the role mapping to the map
                    roleMappings.put(roleId, group);
                }
            }
        }

        System.out.println("RoleSectionNulo");

        return roleMappings;
    }

This is my role mapping trying to get a section from my config.

discord:
  bot-token: BOT_TOKEN
  guild-id: 'GUILD_D'
  roles:
    - role-id: 'ROLE_ID'
    group: GROUP

For some reason the roleSection variable comes null when i try to load that section...

echo basalt
#

yeah so

#

Your formatting's wrong

#

Or well, your code doesn't match what the formatting's for

#

You want to get a map list in this case

elder quartz
#

But i dont get to formatting since roleSection does not even get close to populate

echo basalt
#

Well

#
one:
  two:
    three: "Hello!"

makes one and two sections

#

and three as a string inside the two section

#
one:
  two:
    - three: "Hello!"
      four: "there!"
    - three: "Hello again!"
      four: "whatever"

makes one a section and two a maplist

elder quartz
#

So i got to load the discord section and then make a maplist with the two, right?

echo basalt
#

Yeah so roles in your case is a maplist

#

So you call section#getMapList

#

loop through the list

#

and get the values from the map

elder quartz
#

Ooh, got you, let me try that out

#

I had hours trying to fix this.... made it work, thanks! ❤️

echo basalt
small holly
#

To whoever said "use Lua" for my mask effects thank you so much lol I have managed to do it

quaint mantle
#

Not sure if only applies to Minecraft display entities but for some reason I cannot manage to make a display entity to do a full rotation with interpolation

#

I am expecting it to do a 360 rotation around the Y axis but maximum angle is 180 per rotation. So I thought about splitting the rotation in two interpolations but then I figured out that in second interpolation it reverts back (lets say it first rotate clockwise on first interpolation but on second interpolation it rotates counterclockwise so it never completes the full rotation...)

echo basalt
#

what the fuck

#

something I just discovered

#

you can declare a class inside of a method

#
public void doWhatever() {
    class Entity {
        public int x;
        public int y;
        public EntityType type;

        public Entity(int x, int y, EntityType type) {
            this.x = x;
            this.y = y;
            this.type = type;
        }
    }

    new Entity(0, 0, EntityType.ARMOR_STAND);
}
#

this is valid syntax

glossy venture
#

yeah

smoky anchor
#

I know about this, never seen it aynwhere tho

echo basalt
#

saw it in minecademy source code

#

they did a little math evaluator and declared the parser class in the eval method

drowsy helm
#

virtually no usecases where you use that over a private class declaration

#

just makes the method more complicated imo

glossy venture
#

can other methods use the class as well?

#

or is it scope bound

drowsy helm
#

yeah bound to the method's scope

#

but if its your own code and you're declaring it private anyway who cares lol

buoyant viper
#

boy java is the The language ever

astral pilot
#

How do you create a customhead from a website

quaint mantle
astral pilot
#
 private void generateHeadFromURL(String url, SkullMeta headmeta) {
        GameProfile profile = new GameProfile(UUID.randomUUID(), null);
        byte[] encodedData = Base64.encodeBase64(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
        profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
        Field profileField = null;

        try {
            profileField = headmeta.getClass().getDeclaredField("profile");
        } catch (NoSuchFieldException | SecurityException e) {
            e.printStackTrace();
        }

        profileField.setAccessible(true);

        try { profileField.set(headmeta, profile); }
        catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); }
    }
#

This doesn't seem to work

agile anvil
#

What isn't working?

delicate lynx
#

you can only pass skin links from minecraft's cdn

quaint mantle
#

Paste stacktrace if possible, use md5 paste

astral pilot
delicate lynx
#

not namemc

quaint mantle
#

Why are you not returning the GameProfile?

agile anvil
astral pilot
#

I don't need to return it

quaint mantle
#

?

#

Method is misleading

#

generateHeadFromURL

astral pilot
#

nvm i found the problem

#

the url i provided was wrong

astral pilot
quaint mantle
#

Why are you using fields?

#

What????

agile anvil
#

Omg

astral pilot
#

u mean this? GameProfile profile = new GameProfile(UUID.randomUUID(), null);

agile anvil
#

No, why are you using reflection?

quaint mantle
#

Your method should return a GameProfile... Then with a new method, prolly with a new class, pass the URL and the SkullMeta and use the previous method.
I recommend failing fast in the method that fetches the GameProfile

chrome beacon
quaint mantle
#

In case it cannot find the player texture...

#

Now if you don't know any about it, there's an already working, great library regarding getting skulls

astral pilot
#

it automatically applies the changes

#

into headmeta

agile anvil
quaint mantle
quaint mantle
#

Yes!

#

Like this case

agile anvil
#

And look the lib's one

quaint mantle
#

You did need us to read your code in order to find an issue. It's a 100% possible that you are able to read your code, but not a 100% possible that average programmer can read your code.

#

Don't make it harder for us. Also, it will help you in the future whenever you need to read it again (trust me you'll improve)

#

I know from first hand writing that bad back in the day and then having to check what the heck I did and wasting a couple minutes figuring out what I did 🤷🏻

astral pilot
#

i dont get it how is creating

#

separate

#

methods

#

makes it cleaner

#

if i were to return GameProfile

#

that means

#

ill need to do the rest of the code

#

somewhere else

quaint mantle
#

I will explain it simple

astral pilot
#

and the method name generateHeadFromUrl() seems a pretty straightforward name

agile anvil
#

applyTextureToHead would make more sense

#

Because generate implies you would return a newly thing

quaint mantle
#

Lets say that you have a Drone class. Now you are in charge to create a method that makes it fly/move to a specific location.
Instead of writing all logic inside the specific method, you can split it in multiple methods so you can later reuse any of the methods.

#

Even better if you share many of these steps in a library.

astral pilot
#

but i don't see a point of splitting those methods if its just a

#

small code

quaint mantle
#

Paradigm

#

Thats why

astral pilot
#

yea but its pretty small

agile anvil
#

This is modularity. It allows many things:

  • your code is way more readable by you but also by others
  • you maybe won't need to comment your code
  • it is easily debuggable and fixable
  • if you want to change a feature it's quick and efficient, error free
astral pilot
#

why make another one and make your code bigger

quaint mantle
#

I mean, your way works

agile anvil
#

Nowadays, we don't seek for something to work only. We seek for something maintainable

astral pilot
agile anvil
#

What if the GameProfile class changes tomorrow? You'll have to rewrite the whole thing even though the "URL" stuff doesn't

quaint mantle
#

A perfect example is the Material enum

#

It's not going to be an enum anymore

astral pilot
#

well thanks anyways ill look forward into those

#

but i guess for now imma stay with my approach

agile anvil
#

You'll see that in most of the code you may find in GitHub etc

sour folio
#

How would i make is sp when you close a gui it gives the items in the gui to the player?

livid dove
#

So was mucking around with a way to find chunk coordinates faster than "are coordinates in chunk X".

int chunkX = (x < 0) ? (x - 15) >> 4 : x >> 4;
int chunkZ = (z < 0) ? (z - 15) >> 4 : z >> 4;

If you already have the chunk x and z's (some Api's give the coordinates rather than the chunks themselves for... reasons) if you right shift 4 bits you essentially divide by 16 right?

So if x is negative, - 15 (to account for x -1 , z-1 starting at -1,-1) , but either way, right shift 4 bits and boom, you've now got the current X and Z coords of the chunk.

As its an int calc, it always rounds down.

Boom, easy check of chunk coordinates based off location X and Z coordinates

agile anvil
agile anvil
livid dove
#

for chunks

agile anvil
#

0, 0 ?

#

Mmh

#

Got it ahah

livid dove
#

hehe

agile anvil
#

I didn't saw it that way, that's great thx for sharing

#

How does the Location#getChunk work?

eternal night
#

Returns you the loaded chunk the location is part of

agile anvil
#

Didn't know it was agregation of chunk

shadow night
native ruin
#

What would be the best way to add alot of different commands and command arguments?

agile anvil
shadow night
echo basalt
#

Make sure the listener is registered

#

After the logger is initialized

livid dove
# native ruin What would be the best way to add alot of different commands and command argumen...

Build a framework based around HashMap<String,Command> where "Command" is its own abstract class.

You can then write classes that extend that abstract, have a "perform" or "execute" method and then add all the commands to the map onEnable and, when a command is called, if the respective string is found in the arguements, boom, it performs that command via the onCommand function literally just having "commandHashMap.get(args[0]).perform()"

echo basalt
#

Ew no not a map

livid dove
#

Wtf do you mean ew no not a map? If boi is about to deadass straight face say switch case ur about to catch these hands

echo basalt
#

do you really think I write commands like that

#

hell no

#

Using a map like that is a very low-level approach and will like

#

become a pain if you want to do anything remotely complex

livid dove
#

define "complex"

echo basalt
#

for example /message <player>

native ruin
#

I don't actually I'm really bad with commands

livid dove
native ruin
#

Any recommendations?

echo basalt
#

Because with your hashmap example you'd need to input any player name etc

native ruin
#

Acf, got it

echo basalt
#

No I inject in the command map

#

for tab completion and all

livid dove
echo basalt
#

mans got the fancy uml

livid dove
#

Because its stinky

#

Check mate

echo basalt
#

I just repurposed my scripting parser to work on commands swagcircle

#

lol ok

native ruin
#

Chat listener for commands 💀

echo basalt
#

at work we just do this

#

and then it does its predictions based on whatever

#

I just did whatever came to mind

shadow night
echo basalt
#

show me where you register the listener

shadow night
#

the main class is in the paste too

agile anvil
#

Are you sure the plugin loads ?

shadow night
#

yes

#

all plugin functions work, all the other events

#

just these ones

eternal oxide
#

playerjoin and playerchangeworld fire just fine

shadow night
#

when I join nothing happens

#

nothing in console

eternal oxide
#

then post your actual code not bits and pieces you think are relevant.

shadow night
#

like everything?

eternal oxide
#

do you have it on git?

shadow night
#

no, but I can put it there

eternal oxide
#

would be easiest

shadow night
#

yeah, wait a minute

grave kayak
#

I'm trying to create a plugin that has a prompt for players to enter their desired name for a custom tool. I want the players to be able to use hex codes when making the name for their tool but I cannot seem to get it to work. does anyone know how I can achieve this ?

smoky anchor
#

Show us what you already have

#

And tell us what exactly is not working

grave kayak
#
                        if (hasEnchantedEmeraldBlock) {
                            ItemStack elytraCopy = new ItemStack(Material.ELYTRA);
                            if (elytraCopy != null) {
                                ItemMeta elytraMeta = elytraCopy.getItemMeta();
                                if (elytraMeta != null) {
                                    for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
                                        elytraMeta.addEnchant(entry.getKey(), entry.getValue(), true);
                                        elytraMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', toolName));
                                    }
                                    elytraCopy.setItemMeta(elytraMeta);
                                }
                            }``` 
when i enter the code in game "&#f4d508&lʜᴏᴇ &#ffad0f&lᴏꜰ ᴘ&#ff803b&lᴏᴛᴀ&#ff4e63&lᴛᴏ ᴘ&#ff198d&lʟᴏᴡ&#ea17b6&lɪɴɢ" it just comes up as is shown here. i know it is possible because of plugins like epicrename but i just dont know how to get it to work
#

toolName is what I want to use hex codes on

smoky anchor
#

I do not think the function tralslateAlternateColorCodes can take in hex, you'd have to parse that string yourself

eternal oxide
#

isn't it ChatColor.of for hex?

ivory sleet
#

It can

#

&x&F&F&F&F&F&F would be white

#

Very cursed

smoky anchor
#

Well yes, but not in the way he wants
&#rrggbb

ivory sleet
#

Yes but it can parse hex tho

#

Which is what you initially said, picking on ur words a bit now but yea

grave kayak
#

rip, im wondering how plugins like epicrename have the functionality to do that through their /rename command though

agile anvil
#

It's quite easy with a simple regex

blazing ocean
#

how do I do a delay/sleep in a BukkitRunnable? i'm trying to do a countdown and that countdown is in a bukkitrunnable

astral pilot
#

How do I do this with onTabComplete()

eternal oxide
eternal oxide
#

you have a Field set to getConfig() which causes it to load before saving the default

shadow night
#

oh, I see

#

I'm gonna change that

eternal oxide
#

set teh field after you call saveDefaultConfig()

agile anvil
shadow night
astral pilot
agile anvil
agile anvil
#

The Mojang command system

eternal oxide
shadow night
astral pilot
eternal oxide
shadow night
#

but why do they not work for me

eternal oxide
#

Although I can;t vouch for 1.8

shadow night
#

it's still weird

eternal oxide
#

clean install to your server

#

delete your jar and it's directory

shadow night
#

hmm

agile anvil
eternal oxide
#

if it really doesn't exist your build will fail

shadow night
#

I forgot to remove it lol

eternal oxide
#

ah you set it excluded when you pushed to git

#

an dcooldowns

shadow night
#

yeah, it shouldn't be used at all

#

it's some useless code I tried to make and then just removed it

#

but forgot to remove stuff

eternal oxide
#

Clean that up and I bet it works 🙂

shadow night
#

I should probably delete unnecessary stuff instead of just leaving it there

eternal oxide
#

yep

shadow night
#

I'm not spigot or something to deprecate everything instead of deleting

#

for some reason, it wouldn't prompt me, but when I set it to always download it downloaded?

eternal oxide
#

use a different set

#

one that rquires you to accept or you get kicked

#

you can;t force a player to accept, only kick if they don't

shadow night
#

but it doesn't even prompt

eternal oxide
#

if it doesn;t prompt it thinks you already have the pack

shadow night
#

I've seen some servers do when they open a book and you can choose but that will cost me extra time

#

I don't think this belongs here, but I think my player wants to shoot themselves

dusty herald
#

rip

lucid gazelle
#
else if (dmgCause == ENTITY_EXPLOSION) {
    Entity explosionEntity = getDamager(e);
    Entity exploder = getDamager(explosionEntity.getLastDamageCause());
    if (exploder instanceof Player)
        teamCheck(e, player, (Player) exploder);
    if (exploder instanceof Projectile) {
        ProjectileSource projectileShooter = ((Projectile) exploder).getShooter();
        if (projectileShooter instanceof Player) {
            teamCheck(e, player, (Player) projectileShooter);
        }
    }
}```

i'm trying to check if a player can indirectly harm team member
this works for end crystals, but not for TNT minecarts

what am i doing wrong?
#

the getDamager() casts the EntityDamageEvent to EntityDamageByEntityEvent and gets the damager

tardy delta
#

no java 17?

lucid gazelle
tardy delta
#

why not using instanceof Player x then

lucid gazelle
eternal oxide
#

why are you mixing explosions and projectiles?

lucid gazelle
# eternal oxide why are you mixing explosions and projectiles?

i already have a seperate check for projectiles alone

else if (dmgCause == PROJECTILE) {
    Entity projectile = getDamager(e);
    if (projectile instanceof Projectile) {
        ProjectileSource projectileShooter = ((Projectile) projectile).getShooter();
        if (projectileShooter instanceof Player) {
            teamCheck(e, player, (Player) projectileShooter);
        }
    }
}```

i'm trying to check if an explosion was caused by a projectile shot by a player
#

sort of like shooting snowballs on an end crystal to explode it and harm another player

peak depot
#

Maby then send your whole code

lucid gazelle
#

but weird this is, it works for end crystals but not for tnt minecarts

#

?paste

undone axleBOT
tardy delta
#

if (event.getDamager() instanceof Projectile projectile && projectile.getShooter() instanceof Player shooter)

lucid gazelle
lucid gazelle
eternal oxide
#

I'd start by cleaning up the code. Use a switch (dmgCause)

#

make it easier to read and debug

#
switch (dmgCause) {
case ENTITY_ATTACK:
case ENTITY_SWEEP_ATTACK:
  //code
  break;

case ENTITY_EXPLOSION:
  //code
  break;

case MAGIC:
  //code
  break;

case PROJECTILE:
  //code
  break;
}```
lucid gazelle
#

ahh ok

eternal oxide
#

you should also test the event is an instance of EntityDamageByEntityEvent before blind casting

lucid gazelle
#
private Entity getDamager(EntityDamageEvent e) {
        if (e instanceof EntityDamageByEntityEvent entityEvent) {
            return entityEvent.getDamager();
        }
        return null;
    }```
eternal oxide
#

much more readable

#

now you can easily add debug messages to see what fires when a tnt minecart is blown up

tardy delta
#

blowing up things that early in the morning?

lucid gazelle
#

the exploder returns null for some reason

#

when it should be Arrow

eternal oxide
#

probably because it will be a VehicleDamageEvent not an EntityDamageByEntityEvent

lucid gazelle
#

oh

eternal oxide
#

vehicles are a bitch

#

half finished API

lucid gazelle
#

lmaoo

#

i can just make a getVehicleDamager() method then

eternal oxide
#

just need another instanceof check in yoru method and return the damager of the vehicle event

#

in getDamager()

#

if (e instanceof VehicleDamageEvent)

lucid gazelle
eternal oxide
#

I actually like that getDamager wrapper. I may use it myself

lucid gazelle
#
cannot cast 'org.bukkit.event.entity.EntityDamageEvent' to 'org.bukkit.event.vehicle.VehicleDamageEvent'```
#

wait what

#

ide error

eternal oxide
#

yeah, the pain of the Vehicle API

#

you may have to specifically exclude tnt minecarts and also listen to the Vehicle damage event

lucid gazelle
#

i can just get it from then then no?

eternal oxide
#

you can try

#

However I think it will be lost.

#

it will be off into the vehicle api

#

test if it's a vehicle and try

#

I'm pretty sure you are into the issue I found long ago.

lucid gazelle
eternal oxide
#

yep, the issue is a Vehicle should override the getLastDamageCause() to return a VehicleDamageEvent

#

but it doesn;t, it returns an empty EntityDamageEvent

#

This is where teh Vehicle API breaks down

lucid gazelle
eternal oxide
#

The issue is getting the player who triggered the minecart. that data is lost

lucid gazelle
#

wait how?

eternal oxide
#

This is the "missing" part of the Vehicle API

lucid gazelle
sour folio
#
                        if (hs.getSpawnedType() == EntityType.PIG)```  why does the code after the of statement run even if the spawnertype is a different type?
tardy delta
#

are you using {}?

eternal oxide
sour folio
#

i didnt add it

#

to the message

lucid gazelle
#

i can test which events are fired, and listen to that

eternal oxide
#

You will get an EntityDamageEvent when it's shot (probably)

#

There should be a VehicleDamageByEntityEvent btu there isn;t

#

it was wrapped into the VehicleDamageEvent

#

but that never gets saved as lastDamager

lucid gazelle
eternal oxide
lucid gazelle
#

didn't knew this existed

sour folio
#
                        if (hs.getSpawnedType() == EntityType.PIG) {

why does the code after the of statement run even if the spawnertype is a different type? Its so annoying

eternal oxide
#

There is no of in the code you posted

sour folio
sour folio
#

Ther is an ‘if’

eternal oxide
#

ah

lucid gazelle
tardy delta
#

i know that the default spawn type is pig so idk if the server is aware of the actual type

#

probably or there wouldnt be a method for that 💀

sour folio
eternal oxide
sour folio
#

Arnt they?

tardy delta
#

are you even sure its a dif type

sour folio
tardy delta
#

why am i seeing pig then

sour folio
eternal oxide
#

I'd suggest in the ignite event add the attacking players UUID to the entites PDC

lucid gazelle
eternal oxide
#

That way in your damage event you can check for a PDC value and instantly know that Entity was attacked by a player

lucid gazelle
eternal oxide
#

in teh ignite event, check if a tnt minecart. if it is and it was shot with a flaming arrow, get teh shooters UUID.toString() and put on teh tnt entity PDC

lucid gazelle
#

ah got it

#

lemme test it rq

eternal oxide
#

then in teh damage event under explosion you just have to check to see if there is a PDC entry, grab it, get teh entity it belongs to and you have yoru damager

dusk apex
#

@brave sparrow usless

hazy parrot
smoky anchor
eternal oxide
#

well minorly

#

in your getDamager method you check for a PDC entry, grab it and return Bukkit.getEntity(UUID.fromString(pdcEntry)

#

then add a listener for the ignite event

#

in there if the entity is a TNT minecart you store the attackers uuid in its PDC

remote swallow
visual laurel
lucid gazelle
# eternal oxide in your getDamager method you check for a PDC entry, grab it and return Bukkit.g...
@EventHandler
public void onMinecartIgnite(EntityCombustByEntityEvent e) {
    if (e.getEntityType() != MINECART_TNT) return;
    if (e.getCombuster() instanceof Projectile projectile && projectile.getShooter() instanceof Player projectileShooter) {
        PersistentDataContainer cartData = e.getEntity().getPersistentDataContainer();
        cartData.set(new NamespacedKey(main, "shooter"), PersistentDataType.STRING, projectileShooter.getUniqueId().toString());
    }
}```

```java
if (explosionEntity.getType() == MINECART_TNT) {
PersistentDataContainer explosionEntityData = explosionEntity.getPersistentDataContainer();
String shooterUUID = null;
if (explosionEntityData.has(new NamespacedKey(main, "shooter"), PersistentDataType.STRING))
    shooterUUID = explosionEntityData.get(new NamespacedKey(main, "shooter"), PersistentDataType.STRING);
if (shooterUUID == null) return;
Player shooterPlayer = Bukkit.getPlayer(UUID.fromString(shooterUUID));
teamCheck(e, victim, shooterPlayer);```
#

i did this instead, not sure how i could implement the PDC getter in getDamager()

#

i could always add another parameter boolean isMinecart

eternal oxide
#

you have an entity in getDamager()

echo basalt
#

man pdc can get messy like that

#

?paste

undone axleBOT
eternal oxide
#

it's the rest of it thats rubbish

#

using the entity you get teh pdc

echo basalt
#

oh shoot my pdc wrapper only works on items

#

clean up the code a bit y'know

eternal oxide
#

also create your NamespacedKey as a Field in teh class. no need to create it every time

lucid gazelle
#

but the issue is this

#

how would it differentiate between those

eternal oxide
#

no need to change anything in there from teh original code

#

only modify the getDamager method

#

the explosionEntity.getLastDamageCause() does return an EntityDamageEvent.

#

its just not an instance of EntityDamageByEntityEvent

#

because Vehicle

#

so instead of returning null you do your PDC check on e.getEntity

#

returning yoru shooter

lucid gazelle
quaint tapir
#

event.setDroppedExp(0); event.getDrops().removeAll(event.getDrops());

#

the mob still drops it's natural drops

#

anyone know how to stop that?

flint coyote
#

Does it still drop xp?

quaint tapir
#

nope

flint coyote
#

try clear

#

event.getDrops().clear()

eternal oxide
#

one sec

lucid gazelle
#
private Entity getDamager(EntityDamageEvent e) {
    if (e instanceof EntityDamageByEntityEvent entityEvent) {
        return entityEvent.getDamager();
    }
    PersistentDataContainer explosionEntityData = e.getEntity().getPersistentDataContainer();
    String shooterUUID = null;
    if (explosionEntityData.has(shooterKey, PersistentDataType.STRING))
        shooterUUID = explosionEntityData.get(shooterKey, PersistentDataType.STRING);
    if (shooterUUID == null) return null;
    return Bukkit.getPlayer(UUID.fromString(shooterUUID));
}```
eternal oxide
#

or close

#

no need to null check. use getEntity() and it will be null if no match exists

sage patio
#

[PlaceholderAPI] Failed to load expansion .... Identifier is already in use.
any idea

lucid gazelle
eternal oxide
#

yes, but there is no way the string would be null if it's present

eternal oxide
#

thats just your IDE bitching at you 🙂 Because it's stupid

#

to silence yoru IDE you can wrap in a Objects.requireNonNull or some crap

tardy delta
#

getOrDefault to avoid two lookups :)

eternal oxide
#

you could, just have to provide a valid uuid

#

easier to just do two lookups 😉

#

I seriously hate the space bar on this new Ducky keyboard. It constantly bounces

tardy delta
#

my laptop spacebar isnt much better

flint coyote
#

I'm also thinking about a new keyboard but I'm really unsure which one

eternal oxide
#

I constantly get double spaces as I type with this one

flint coyote
#

Which one is that?

quaint mantle
eternal oxide
#

Ducky ONE

#

I can;t fault it but for teh space

tardy delta
tardy delta
#

looks fine but i never understood why they are still two windows buttons

#

like who even uses the right one

eternal oxide
#

I never use them except when doign tech support

#

telling the end user to press teh windows button makes support easier

#

many years ago when they were introduced we used to install programs to disable them as they kept tabbing you out of games.

tardy delta
#

brr

eternal oxide
#

I believe it was Microsofts way of getting their logo on a keyboard like Apple

smoky anchor
eternal oxide
#

age

#

teh and ; instead of '

#

As you get older your fingers move slower and don't bend as much.

#

so keys get switched teh yoru that;s

vast ledge
#

Do you type with 1 hand or 2?

eternal oxide
#

and notice those double spaces . this damn keyboard

#

2

vast ledge
#

Rly i type teh because its an easier keystroke for me

eternal oxide
#

mine is unintentional

nimble oxide
#

Its not sending anything in the minecraft chat either it does not send anything in the console .. I use Citizens API, but its not working, and no errors at startup. 🙂

tardy delta
#

naming conventions bruh

vast ledge
#

Are you registering the event?

#

whyd i ask xD

nimble oxide
#

xd

nimble oxide
eternal oxide
#

when are you registering the class?

vast ledge
nimble oxide
eternal oxide
#

when?

vast ledge
nimble oxide
#

in onEnable

eternal oxide
#

all we need now is a latest.log from yoru server then

vast ledge
#

Is it sending the Logger message?

eternal oxide
#

?paste

undone axleBOT
nimble oxide
vast ledge
#

Ok, then upload ur log like elgar said

nimble oxide
quaint mantle
#

can i control player vanilla level from database or configfile ?

eternal oxide
#

I'm betting a missing command in plugin.yml

nimble oxide
eternal oxide
#

a missing command would exit your onEnable early, thus no event registered

nimble oxide
#

What??

vast ledge
#

Spigot has an enabling process