#help-development

1 messages · Page 1452 of 1

keen kelp
#

can I make something listen to ByEntity and another to any damage that's NOT enetity

wraith rapids
#

an event won't be both entity and block damage at the same time

keen kelp
#

yeah I just thought it would be a common problem

wraith rapids
#

you can listen to them both

keen kelp
#

but fall damage isn't either?

wraith rapids
#

probably not no

keen kelp
#

but I want to handle all damages

wraith rapids
#

then listen to entity damage event

#

and spin the appropriate type of logic based on the actual event you get

quaint mantle
#

hey spigot anyone? 😄 its spigot api

dense goblet
#

anyone know if entity.damage respects armour etc?

wraith rapids
#

do you have a question

dusk flicker
#

Didn't know this was a thing ;p

keen kelp
#

since it doesn't provide me with the attacker

wraith rapids
#

you would

keen kelp
#

wait wat

wraith rapids
#

and handle it appropriately

#

fuck

#

wrong button

#

you'd test whether it is a entity damage by block/entity event

#

and handle it appropriately

quaint mantle
dense goblet
#

ty toto 🙂

quaint mantle
#

np

keen kelp
wraith rapids
#

by getting the damager

keen kelp
#

EntityDamageEvent doesn't include the attacker right

wraith rapids
#

it doesn't but EntityDamageEvent might be an EntityDamageByEntityEvent

#

which does

wraith rapids
#

EntityDamageByEntityEvent is an EntityDamageEvent

#

EntityDamageEvent could be a EntityDamageByEntityEvent

keen kelp
#

I confuse

wraith rapids
#

OOP

#

EntityDamageByEntityEvent extends EntityDamageEvent

keen kelp
#

imma go figure it out

#

somehow

dense goblet
#

my bad I gave the wrong link

wet breach
#

lol

#

eventually

#

anyways I gave the premise in how it works 😉

#

up to them to figure out how to apply it

wraith rapids
#

what is he even trying to do

wet breach
#

so, they want to apply their own damage but keep the knockback effect

#

so this involves cancelling the first damage event to apply custom damage

wraith rapids
#

doesn't the damage event have like a setDamage or setFinalDamage method or something

wet breach
#

it might, but I remember the event needing to be cancelled if you were going to change the damage values

keen kelp
#

only setDamage

#

but not setfinaldamage

#

which isn't helpful

wet breach
#

in either case, they are worried about the knockback effect so I gave the snippet in how you would re-apply knockback yourself

keen kelp
#

I read the sauce

#

but I still dont understand

#

how to get damager myself

wet breach
keen kelp
#

it just super(damager) and it somehow does it

wet breach
#

probably a better link is to use the javadocs

#

which i gave above

keen kelp
#

public Entity getDamager() {
return damager;
}

wet breach
#

yes it returns the entity that damaged the other entity

keen kelp
#
private final Entity damager;
    public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
        super(damagee, cause, damage);
        this.damager = damager;
    }
#

it just supered it and somehow it works

#

I dont know how to do this for myself

wraith rapids
#

what

keen kelp
#

that's the thing

wraith rapids
#

i was away for like 2 minutes

#

what is he doing now

wet breach
#

idk, they are freaking out over a super call

keen kelp
#

same thing wdym

#

I just dont understand am I that slow

wet breach
#

No, just worrying about something that you don't need to worry about is all

keen kelp
#

how did it get the damager

wraith rapids
#

this.damager = damager;

#

it got the damager in the constructor

#

it then assigned the damager to the field

#

now it has the damager

wet breach
#

because you are only looking at the class, and not how it is actually implemented in the server, which is ok because you don't really need to worry about how it is specifically implemented. There is a reason I gave link to the API Javadocs. This way you don't get confused over implementation details.

#

I think I should just explain how my snippet works >>

keen kelp
#

so how do I do it in my listener

wraith rapids
#

i think the issue here is that he doesn't understand the is-a relationship between the entitydamagebyentity and entitydamage events

keen kelp
#

ok there's a relationship, then?

wraith rapids
#

yes, like i said

#

entitydamagebyentityevent is a entitydamageevent

#

Car is a Vehicle

keen kelp
#

ok I understand

#

so I use EntityDamageByEntityEvent

#

in my listener

wraith rapids
#

no

#

you listen to entity damage event

#

and check whether it is a entitydamagebyentity event

keen kelp
#

and get the damager the same way as EntityDamageByEntityEvent right?

wraith rapids
#

any Vehicle might be a Car

#

but not every Vehicle is a Car

#

the entitydamageevent (Vehicle) you get could be an entitydamagebyentity event (Car)

#

or it could be an entitydamagebyblockevent (Bicycle)

keen kelp
#

ok

#

but how do I tell

wraith rapids
#

you want to check whether it is a Car and then treat it as a Car

#

instanceof

#

if (vehicle instanceof Car)

keen kelp
#

getcause?

wraith rapids
#

no, instanceof

keen kelp
#

yes but like..

wraith rapids
#

the event could be an instance of EntityDamageByEntityEvent

wet breach
#

seems like you have this handled so I will leave you to it 😉

keen kelp
#

X instanceof car

wraith rapids
#

event instanceof EntityDamageByEntityEvent

keen kelp
#

but how do I get X

wraith rapids
#

X is the event

keen kelp
#

so if(event instanceof EntityDamageByEntityEvent)?

wraith rapids
#

yes

#

if this returns true, the event is an EntityDamageByEntityEvent

#

and you can cast it to EntityDamageByEntityEvent

keen kelp
#

yeah I understand

#

I was just stuck on this

wraith rapids
#

and then call the methods specific to EntityDamageByEntityEvent on it

#

if (event instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent event2 = (EntityDamageByEntityEvent) event;
event2.getDamager()

#

or
if (event instanceof EntityDamageByEntityEvent) {
((EntityDamageByEntityEvent) event).getDamager()

keen kelp
#

I see...

#

hmm

#

it's working

#

but the velocity is off

wraith rapids
#

well yes

#

the implementation given to you was very trivial

#

it's calculated differently by the game

keen kelp
#

hmm

wraith rapids
#

in order to reproduce it properly you'd have to figure out what the server does to calculate it

keen kelp
#

can I make it calculate using the original function or smth?

opal juniper
wraith rapids
#

the jerk looks like you're setting its velocity to 0 for some reason

#

you'd need to either invoke or copy nms shit in order to reproduce vanilla behaviour

#

basically glhf

keen kelp
#

frick

wraith rapids
#

ig you could just tweak the numbers until it looks more or less right

keen kelp
#

I need it to be the same .-.

wraith rapids
#

try something easier as your first project

#

see if the jerk still happens if you remove the velocity packet

#

and by remove i mean comment out the code that sends it

opal juniper
#

i have commented out the call to the method that sends the cancel velocity packet tho, so i am kinda confused

#

sorry, forgot to send that^^^

wraith rapids
#

then it's probably just vanilla being weird

opal juniper
#

what like the falling blocks + tnt

wraith rapids
#

seems kind of annoying to set up

opal juniper
#

I can try, cant remember how to summon a falling block tho

#

lemme look

wraith rapids
#

my only other guess is that cancelling the destroy packet somehow fucks with the velocity

keen kelp
#

wait...

#

what am I doing smhhh

#

I can just get the original damage to 0

#

then the KB would still apply

wraith rapids
#

iirc that stops the damage sound and knockback

keen kelp
#

and I can just damage the player myself

#

really?

wraith rapids
#

i know for certain it stops the sound

keen kelp
#

let's see

wraith rapids
#

not sure about knockback

keen kelp
#

since it's double

#

I can just make it 0.0000001 right

wraith rapids
#

well

#

i guess

#

not exactly an ideal solution and will probably fuck with plugin compatibility somewhere down the road

#

but ig bukkit doesn't really leave much of a choice

keen kelp
#

screw it Im gonna bodge hard until it's a problem

opal juniper
#

Why does the EntityChangeBlockEvent get called when sand goes from block -> fallingBlock

keen kelp
#

how do I like log something when starting the server

#

just like Plugin Loaded

opal juniper
#

getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "[Plugin] Plugin Is Enabled");

#

in the onEnable()

wraith rapids
#

how about no

#

don't send messages to the console sender

#

use your plugin's logger for logging

#

getLogger().info("plugin enabled")

keen kelp
#

well not for logging

#

just

wraith rapids
#

gets automatically prefixed with your plugin name

opal juniper
#

Yeah, but it is nicer cause it sends colours

keen kelp
#

ohhh

#

I see

wraith rapids
#

and respects the end user's logger configuration for your logger

keen kelp
#

but can I color it

wraith rapids
#

and does work with colors contrary to popular belief

keen kelp
#

just use the magical color thing?

#

§

wraith rapids
#

you need § instead of & yeah

#

or use ansi colors

opal juniper
#

idk tbh, thats a point. Can you distinguish between them?

keen kelp
#

holy sh*t

#

setDamage 0 works

#

for knockback

wraith rapids
#

now, there's something to keep in mind

keen kelp
#

idk about sound effect and it doesn't matter since I do my own damage after it anyway

wraith rapids
#

using .damage on an entity fires a new entity damaged event

#

so make sure you don't process those

keen kelp
#

if(event.getEntity() instanceof Player)

wraith rapids
#

if a player gets damaged, you catch that event

#

then you set the damage to 0

#

and then you damage the player, yes?

keen kelp
#

yes

wraith rapids
#

that will fire a new event

keen kelp
#

@EventHandler
public void OnPlayerDamaged(EntityDamageEvent event)
{
if(event.getEntity() instanceof Player)
{

wraith rapids
#

which then is caught by your listener again

keen kelp
#

it's the first condition

wraith rapids
#

you set the damage to 0

#

and you damage the player

#

which fires a new event

#

and eventually either the server or the entity dies

keen kelp
#

but it doesn't do that?

#

idk why

#

oh right

wraith rapids
#

well i'm not sure what you're doing but it should be doing that

keen kelp
#

I dont do damage

#

I do setHealth

wraith rapids
#

yeah, that'd be why

#

i'm not totally sure which is better

keen kelp
#

since I have a variable that tracks health instead

wraith rapids
#

on one hand you'd want the event to be fired, as that'd let other plugins customize the result

#

but on the other hand that could also cause incompatibility with plugins that make assumptions

keen kelp
#

true

#

but Im prolly just gonna make the entire combat system myself :P

wraith rapids
#

inter-plugin compatibility when dealing with combat and damage is cancer and you never get it right

#

something always blows up somewhere

quaint mantle
#

what is wrong?

keen kelp
#

if not Imma get custom plugs

quaint mantle
#

errors on 37 and 38 lines

wraith rapids
#

read the warning

opal juniper
wraith rapids
#

it'll tell you what's wrong

quaint mantle
opal juniper
#

omg

wraith rapids
#

what is the error

opal juniper
#

whats the full error

quaint mantle
#

k, wait

wraith rapids
#

or, actually

#

read what the warning says first

#

i have a strange tingling sensation that it might somehow be relevant

opal juniper
#

lmao

quaint mantle
wraith rapids
#

have you read the warning yet?

#

see that yellow underline on line 37?

#

place your mouse on it

quaint mantle
#

yes

wraith rapids
#

and then use your eyeballs to read

opal juniper
#

ok thanks

quaint mantle
#

i'm added suggestion assert rage != null;

#

and nothing

wraith rapids
#

that won't help

#

read what it says

opal juniper
#

<

wraith rapids
#

NullPointerException is thrown when you try to call a method or otherwise deference a variable or a field that has no value

#

a variable without a value is null

#

it points at no object

#

it is a null-pointer

quaint mantle
#

yup

wraith rapids
#

trying to interact with it throws a null-pointer exception

#

now read the warning

#

and apply this understanding to the error

#

getTeam is annotated as Nullable

#

it's return value could be null

#

therefore calling any methods on the returned value before checking whether it is null will blow up if it is null

#

check yourself before you shrek yourself

#

nullcheck nullable variables

cold field
#

'shrek yourself'? lol

quaint mantle
#

very big amount of null

wraith rapids
#

some sort of desynchronization between clientside and serverside physics presumably

royal hawk
#

Guys hello i spawn Particle.REDSTONE, i want change color

and i have this code:
player.spawnParticle(builder.particle(), location.getX(), location.getY(), location.getZ(), 0, 0.001, 1, 1, 1);
how change color to 224, 224, 224 rgb?

opal juniper
#

This is quite a pain

quaint mantle
wraith rapids
#

ideally you'd getTeam and if it's null, then registerNewTeam

#

not sure what registerNewTeam does when there is already an existing team

quaint mantle
royal hawk
quaint mantle
silk hamlet
#

Seeesh

royal hawk
dusk flicker
#

Nothing should just throw an Exception

quaint mantle
wraith rapids
#

throw a throwable

dusk flicker
#

It would be more specific, if it's not the developer is a dumbass that set it to throw it

royal hawk
dusk flicker
#

??

keen kelp
#

why does running a command echo that command back to me

wraith rapids
#

you are probably returning false

keen kelp
#

bruh

#

I is dummy

#

ok so how do I send a message to the console/command block or whatever so I can tell them this command can only be run as a player

#
if(commandSender instanceof Player)
{
//thing
}else
{
//tell console

}
#

oh k

#
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        if(commandSender instanceof Player)
        {
            Player p = (Player) commandSender;
            int ping = p.getPing();
            p.sendMessage("Your Ping is: " + Integer.toString(ping));
        }else
        {
            commandSender.sendMessage("You can only use this command as player!");
        }
        return true;
    }
maiden briar
#

How can I place the thing after the if statement automatically on the next line? Can't find the right setting in IntelliJ

if(condition) callMethod();
else if(condition)
  callMethod2();

What I want:

if(condition)
  callMethod();
else if(condition)
  callMethod2();
summer scroll
maiden briar
#

Yes, but IntelliJ has no setting for that?

#

I really tried, but it can't get fixed

#

The last thing is what I want

summer scroll
#

what do you mean setting for that?

maiden briar
#

That they auto format it

wraith rapids
#

press enter

#

you don't need a setting

maiden briar
#

Yes I know, but if I return back, they auto formatted it back

wraith rapids
#

yeah the auto formatting is trash

maiden briar
wraith rapids
#

i've disabled it because it keeps fucking up everything

maiden briar
#

Anyways it is good, but I can't get this fixed

keen kelp
#

what method converts strings to int and what errors does i catch if it can't be converted

#

Im trying to make a command with argument here

wraith rapids
#

Integer.parseInt

summer scroll
#

and NumberFormatException

keen kelp
#

Integer.parseInt(strings[1])

#

this is right right? why am I getting red underlined>

wraith rapids
#

assuming strings is a String[] and the array has at least 2 elements yes

#

we don't know why you're getting red underlined

#

the red underlined says why it's red underlined

keen kelp
#
@Override
    public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
        try(Integer.parseInt(strings[1]))
        {

        }
        return false;
    }
#

that's all I have

wraith rapids
#

that's not how you do a try catch block

keen kelp
#

wait what

young knoll
#

You are doing try-with-resources

wraith rapids
#

you're confusing try catch with try with resources

#

resources should be autocloseable

#

int is not autocloseable

keen kelp
#

oh

maiden briar
#

Ah the setting was "Control statement in one line" to false

keen kelp
#

what do I do

wraith rapids
#

you google "how to try catch java"

royal hawk
#

Guys hello i spawn Particle.REDSTONE, i want change color

and i have this code:
player.spawnParticle(builder.particle(), location.getX(), location.getY(), location.getZ(), 0, 0.001, 1, 1, 1);
how change color to 224, 224, 224 rgb?

keen kelp
#

so what's the correct why to parse a command with a number argument

wraith rapids
#

the way you were doing it

#

but right

keen kelp
#

bruh

wraith rapids
#

you google "how to try catch java"

#

and see how to do it properly

royal hawk
maiden briar
#
try
{
  int i = Integer.parseInt("0");
  //number
}
catch(NumberFormatException e)
{
  //no number
}
keen kelp
#

yep as I expected

young knoll
#

🥄

keen kelp
#

spooon

maiden briar
#

PLS learn JAVA

keen kelp
#

I just forgot ok me sadge ;-;

maiden briar
#

Ok

royal hawk
#

Its redstone particle?

#

Version 1.12.2 hm

quaint mantle
#

registerNewTeam from getNewScoreboard doesn't works

#

Absolutely

wraith rapids
#

don't use a shit outdated version if you don't want a shit outdated api

quaint mantle
maiden briar
#

I created my own ChatComponent class, I want to do ChatComponentinstance + anotherChatComponentInstance

wraith rapids
#

you can't

#

not without being super gay

royal hawk
#

I want 1.12.2 without 1.16.5

maiden briar
#

Ok so it is pretty difficult? Then we'll need to create an append method

wraith rapids
#

you'd have to prefix them with "" to kick in the string concatenation

#

and the resulting object would be a string

#

you'd then have to convert it back into a chatcomponent

maiden briar
#

Ok, I will create an append method

wraith rapids
#

why not just use one of the half a dozen viable component libraries out there

maiden briar
#

Let me do it my own way 😄

keen kelp
#

how do I add a file to be included by git

royal hawk
#

player.spawnParticle(Particle.REDSTONE, location.getX(), location.getY(), location.getZ(), 0, 0.001, 1, 0, 1); i have this code

#

its only green

quaint mantle
#

I can not, but i have this:

Team rage = Bukkit.getScoreboardManager().getNewScoreboard().registerNewTeam("rpg_rage");
quaint mantle
#

try this

#

i dont have my ide open but i think it is something like this

royal hawk
#

its red and dark red

keen kelp
#

I need to add if() to all command classes right

#

since or else it would run all commands?

royal hawk
#

i want only light blue

wraith rapids
#

a command executor will only be called for the commands it has been set as the executor of

#

cmd.setExecutor(commandExecutor)

keen kelp
#

wait then why is it doing it

quaint mantle
keen kelp
#

confused unga bunga

wraith rapids
#

by default all of your plugin's commands will have the main class instance set as their executor

keen kelp
#

oh

#

bruh

#

Im so bad

#

I forgot to change the executer when copying

#

brehh

quaint mantle
#

I want to add player in team for custom glowing color

opal juniper
#

Ok, i think that there may be a new Velocity Packet Sent on that jerk in middair however idrk how to cancel only that one...

quaint mantle
#

Something like this:

rage.addEntry(player.getName());
keen kelp
#

so I currently have this
}catch(Exception NumberFormatException)
{
commandSender.sendMessage("health has to be a number");
}

#

but it also throws this error when I dont give any argument

#

how do I differentiate

quaint mantle
keen kelp
#

oh right

quaint mantle
keen kelp
#

oh ok

#

what's the difference

quaint mantle
#

exception checks for every error and numberformatexception checks for only when you put string into int

keen kelp
#

oh so like the order

quaint mantle
#

Thanks for spoonfeed, but i have all of this in my code already without last line. I won't set scoreboard for player, team must simply creates

kind coral
#

hi guys i am trying to save data into my config
i should have something like this:

count:
playeruuid: uuid
location: serialised location

tho I've reached what i wanted it does duplicate things. like it does repeat the same things twice but with a different counter.

pulsar path
#

I set the velocity of an boat for Y to 1f but my boat does nothing... why

Vector playerVelocity = ent1.getLocation().getDirection();
velo.setX(playerVelocity.getX() / 100.0 );
Float veloY = getPlayerSlot(ent1);
System.out.println("Velo gets "+veloY);
velo.setY(1f);
e.setVelocity(velo);
quaint mantle
#

and btw i think you should learn atleast basics of java

#

wdym?

keen kelp
#

nvm

quaint mantle
#

okey

#

hi spigot! I made a skinChanger but it doesn't work :(```public static void changeSkin(Player player, String skinPlayer) {
GameProfile profile = ((CraftPlayer) player).getHandle().getProfile();
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;

    connection.sendPacket(new PacketPlayOutPlayerInfo(
            PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, ((CraftPlayer) player).getHandle()));

    profile.getProperties().removeAll("textures");
    profile.getProperties().put("textures", getSkin(skinPlayer));
    Bukkit.broadcastMessage(getSkin(skinPlayer).toString());

    connection.sendPacket(new PacketPlayOutPlayerInfo(
            PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, ((CraftPlayer) player).getHandle()));
}```
private static Property getSkin(String skinPlayer) {
        try {
            URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + skinPlayer);
            InputStreamReader reader = new InputStreamReader(url.openStream());
            String uuid = new JsonParser().parse(reader).getAsJsonObject().get("id").getAsString();

            URL url2 = new URL("https://sessionserver.mojang.com/session/minecraft/profile/" + uuid
                    + "?unsigned=false");
            InputStreamReader reader2 = new InputStreamReader(url2.openStream());
            JsonObject property = new JsonParser().parse(reader2).getAsJsonObject().get("properties")
                    .getAsJsonArray().get(0).getAsJsonObject();
            String texture = property.get("value").getAsString();
            String signature = property.get("signature").getAsString();
            Bukkit.broadcastMessage(texture);
            return new Property(texture, signature);
        } catch (IOException exception) {
            exception.printStackTrace();
            return null;
        }
    }
``` and no erros when I run it.
#

:(

#

I have this method which produces a strange issue

#
    public void start() {
        arena.setOccupied(true);
        int pos = 0;
        for (UUID uuid : players) {
            IPlayer iPlayer = core.getPlayerManager().getPlayer(uuid);
            iPlayer.setMatch(this);
            Player p = playerReference.get(uuid);
            if (!p.isOnline()) {
                arena.setOccupied(false);
                return;
            }
            
            alivePlayers.add(uuid);
            
            p.getInventory().setArmorContents(null);
            p.getInventory().forEach(itemStack -> p.getInventory().remove(itemStack));
            p.getInventory().addItem(new ItemStack(Material.DIAMOND_AXE, 1));
            p.setFoodLevel(20);
            p.setHealth(20);
            p.getActivePotionEffects().forEach(potionEffect -> p.removePotionEffect(potionEffect.getType()));
            p.teleport(arena.getSpawns().get(pos));
            p.setAllowFlight(false);
            p.setFlying(false);
            pos++;
            if (pos == arena.getSpawns().size()) {
                pos = 0;
            }
        }
        startCooldown();
    }```
#

But for some players the an item that was previously in their inventory is actually still there when they click the slot

#

As seen at the end of this clip

#

This only happens on one of the accs

keen kelp
#

How do I get player from the command

quaint mantle
#

p.getInventory().clear()?

keen kelp
#

no I mean like

quaint mantle
#

Issue still exists with clear

keen kelp
#

/kill <player>

#

convert string player name to Player

quaint mantle
#

Bukkit.getPlayer(args[0]);

keen kelp
#

k thax

kind coral
quaint mantle
#

wait this might have fixed it

upper vale
#

What's the best way to get and also cancel the raw-est player chat input possible? I'm having issues with plugins such as DeluxeChat or CMI either providing me with some reformatted message or not letting me cancel properly with PlayerChatEvent.

quaint mantle
#

So ``` p.getInventory().clear();
p.getInventory().forEach(itemStack -> p.getInventory().remove(itemStack));

upper vale
#

highest and lowest all cause issues

#

especially with DiscordSRV

#

nothing gets cancelled lol

#

1.16

#

dont think that has anything to do with the issue

keen kelp
#

if player has health boost(more than 20 health), how do I set their health to that

eternal night
ivory sleet
#

PlayerChatEvent iirc is more of a monitor event right now consider AsyncPlayerChatEvent is a thing

keen kelp
#

that's gold hearts right

eternal night
#

yea

upper vale
#

isnt the playerchatevent fired before asyncplayerchatevent or am i missing something here

quaint mantle
#

it is

eternal night
#

the others you can just set by modifying max health

keen kelp
#

^

maiden briar
#

Does somebody know how many pixels the itemname from any item (in the meta) max may have?

keen kelp
#

the extra red heards

quaint mantle
#

Can I set someone's mode to spectator but have the client assume it's survival? so they can't interact with shit but can't fly through blocks and have that vague menu spectator has

keen kelp
#

no

ivory sleet
#

Then another question would be why do you use a deprecated event Demeng? The scheduler would be the way if you wanna do stuff on the main thread with APCE.

keen kelp
#

movement is partially client side so if the client thinks theyre in survival they wont go through walls

upper vale
#

fixing up an old plugin, ig i changed it because schedulers weren't on my mind or something 🤔

maiden briar
#

Oh oof

cyan oyster
#

how to download java 7

#

or 8

eternal night
#

provides openjdk8 with hotspot jvm

quaint mantle
#

I'll just use my own spectator mode then, would cancelling interaction and pickupevents be sufficient?

pulsar path
#

Why wont the boat (entity e) not start to fly?

Vector playerVelocity = ent1.getLocation().getDirection();
velo.setX(playerVelocity.getX() / 100.0 );
Float veloY = getPlayerSlot(ent1);
System.out.println("Velo gets "+veloY);
velo.setY(1f);
e.setVelocity(velo);
opal juniper
#

Can you get all of the entities effected by an explosion, not just the blocks?

opal juniper
#

Its just, i need to get all the falling blocks affected by an explosion

#

But then i remembered that they don't even trigger the EntityDamageByEntityEvent

#

hmm, thats a point

#

thanks

#

does the getNearbyEntities() base it off a radius from the entity?

#

Or do i do it like this:

List<Entity> entities = event.getEntity().getNearbyEntities(5.2,5.2,5.2);

quaint mantle
#

I was about to pop a hemorrhoid over this, turns out I just fucked shit up myself. I was trying to figure out why my players weren't being hidden but I had this method at the end of my match finish method ```java
for (UUID uuid : dead) {
Player dead = playerReference.get(uuid);
for (UUID alivePlayer : alivePlayers) {
Player alive = playerReference.get(alivePlayer);
alive.showPlayer(dead);
}
}

opal juniper
#

ok, iirc it is 5.2 blocks

#

nah it works, ish

#

maybe tho

maiden briar
#
public void setField(String field, Object object)
    {
        try
        {
            Field reflectedField = this.object.getClass().getDeclaredField(field);
            reflectedField.setAccessible(true);
            reflectedField.set(this.object, object);
        }
        catch(NoSuchFieldException | IllegalAccessException e)
        {
            e.printStackTrace();
        }
    }

    public Reflection getFromField(String field)
    {
        try
        {
            Field reflectedField = this.object.getClass().getDeclaredField(field);
            reflectedField.setAccessible(true);
            return new Reflection(reflectedField.get(this.object));
        }
        catch(NoSuchFieldException | SecurityException | IllegalAccessException e)
        {
            e.printStackTrace();
            return null;
        }
    }

getFromField works, but setField gives java.lang.NoSuchFieldException

quaint mantle
#

Do you need to register schedulers in your main class?

#

No right?

radiant aspen
#

I mean you dont need to, but depending on what your coding you can

quaint mantle
#

I'm just trying to send a message every 30 seconds.

radiant aspen
#

ye so just add a scheduler on your main onenable

#

thats fine

quaint mantle
#

alright cool.

cold field
#

Guys, quick question. I would like to know how to write a patch for a java application. I looked how spigot patch nms package, i think they use something like a diff tool but idk the name...

eternal night
#

spigot uses git to create patches

cold field
#

I would like to apply a patch to a maven dependency. Is there some plugin that allows me to do that?

eternal night
#

to one of the servers maven dependencies ?

#

or to your program

#

maven dependencies are distributed as jars afaik

cold field
#

a 3th party dependency

eternal night
#

you'll have a hard time patching these

cold field
#

What does it means 'afaik'?

eternal night
#

as far as I know

cold field
#

Ok, thanks.

royal hawk
#

Guys how create circle particles behind of player?

smoky elbow
#

gives me an error, I have to make sure that when he enters for the first time he opens that inventory. If it is in the list it opens the inventory

#

that is?

#

I understand this but I don't know the pk ahahaha

quaint mantle
#

pk?

maiden briar
#

How can I split any message at the & character and get the second character behind it? ("message&a&bm&c"), I want then String[]{"&a", "&b", "&c"}

eternal night
#

regex is probably the way to go

maiden briar
#

Ok

smoky elbow
#

so what should I do? I do not understand

quaint mantle
#

show the join.regole class

smoky elbow
#

ok

maiden briar
#

Because I want to test messages on not working color codes like &z is nothing

final fog
#
if (player.isOnGround) {
``` is deprecated, is there anything else I should be using?
eternal night
#

I don't think so. Deprecated because the client gets to set it

#

there was some effort on #5515 on paper, but I don't think that ever made it anywhere near upstream

keen kelp
#

is there an event for player death?

#

can't find it

pulsar path
#

cant you add an velocity to an boat with an player inside? I set an velocity but boat ignores it

pulsar path
final fog
#

PlayerDeathEvent

eternal night
#

lol

keen kelp
#

thanks

smoky elbow
#

how do I call the first join of the player? putting hasPlayedBefore() opens it to me in every join

quaint mantle
#
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(player.getName());

if (offlinePlayer.hasPlayedBefore())
{
    Bukkit.broadcastMessage(player.getName() + " plays for the first time!");
}
tardy delta
#

how can i get how many blocks a player mined with the Statistic class?

#

Statistic.MINE_BLOCK ?

cyan oyster
#

i wanna use java 15

#

any download links

eternal night
#

adopt openjdk has java 16

cyan oyster
#

I mean 15

#

not 16

eternal night
cyan oyster
#

1.16.4 doesnt support 16

eternal night
#

what

#

really ?

#

1.16.5 definitely does

cyan oyster
eternal night
#

but with 1.16.4 ?

cyan oyster
#

yes

eternal night
#

like what prevents you from just 1.1.6.5 it and run java 16

cyan oyster
#

anyways what is JVM

eternal night
#

you wanna usually go with hotspot

#

which is the one you would find in an oracle java distribution

#

openj9 is a JVM developed by IBM/Eclipse Foundation and focuses more on low resource usage

quaint mantle
smoky elbow
cyan oyster
#

i download JDK or JRE

quaint mantle
#

jdk

eternal night
#

^^

smoky elbow
quaint mantle
#

wait what?

#

i dont understand what u wrote

cyan oyster
smoky elbow
#

I need that only the first join adds the player to the list and opens the inventory

eternal night
#

depends very very much on operation system

#

and installation method of java 16

#

like, I really don't know

smoky elbow
quaint mantle
#

yeah sure

smoky elbow
cyan oyster
eternal night
#

then even more questions as to how you installed java 16

cyan oyster
#

idk

eternal night
#

Yea then gl xD

cyan oyster
#

i will search on google

eternal night
#

👍

quaint mantle
#

Hi guys so I'm trying to delete a world (with its folders and files inside) it works but the region folder is not deleted. I asked to some people and even to a multiverse core's devs and told me that it was happening because there were some player data in that world, the problem is that actually before deleting the whole world, I teleport all players in that world to a different one. So can someone help me with this please?

bitter nymph
#

Hi. I use the Clans-API and i get the error java.lang.ClassNotFoundException: Clans.ClanConfiguration if i deploy my jar on the server. Have anyone any idea?

quaint mantle
quaint mantle
#

removes the deprication error 🙂

cyan oyster
quaint mantle
maiden briar
#

I will try, thanks!

cyan oyster
#

@eternal night thanks it help a lot

eternal night
#

concerning how minor the changes are, I don't see much of a reason to keep 1.16.4

quaint mantle
#

yeah and that

maiden briar
#

@quaint mantle Isn't Matcher also an option?

#

Like check if the colors are in the pattern

#

Ok....

wide dune
#

How do I "individualise" an inventory?
I am trying to make a system where you place a furnace, and if you left click you bring an upgrade menu up and if you click the diamond it gets upgrade, but I'm not sure how to link the furnace to the inventory since the inventory will be the exact same for every furnace
It might be a stupid question but idrk how to do it haha

maiden briar
#

I wanted to check the codes, and throw exceptions

#

Oh sorry then

#

Yes, I want every color as that, and then can I check if valid

opal juniper
wide dune
#

Not necessarily, so basically how do I make it so when they click the diamond in the inventoryclickevent it finds the furnace which that links to

#

since you cant link the inventory to the furnace as theyre all the same

tardy delta
#

so when you leftclick it brings up an furnace gui?

wide dune
#

Yeah

#

I have it so that happens

#

but inside the inventoryclickevent

#

how do I find the furnace from the inventory

opal juniper
#

Wait, when you left click what? The diamond?

wide dune
#

so when they click the diamond

#

yeah

opal juniper
#

ahh ok

#

so i would use a pdc

tardy delta
#

and what is that diamond?

wide dune
#

whats a pdc?

tardy delta
#

persistent data contaiiner

#

it stores primitive values inside the container

wide dune
#

Ah okay

tardy delta
#

xd

wide dune
#

how will the pdc enable me to link this generic diamond clicked to the furnace?

tardy delta
#

but explain what's that diamond?

opal juniper
#

u could store the id of the furnace

wide dune
#

the thing you click to upgrade the furnace

tardy delta
#

and where's that?

wide dune
#

in the inventory that you pull up when you left click the furnace

tardy delta
#

ooh

wide dune
#
@EventHandler
    public void onLeftClickBlock(PlayerInteractEvent e) {
        if (Objects.requireNonNull(e.getClickedBlock()).getType() == Material.FURNACE) {
            if (instance.getFurnace(e.getClickedBlock()) != null) {
                FurnaceObject furnace = instance.getFurnace(e.getClickedBlock());
                FurnaceGUI.openUpgradeGUI(e.getPlayer(), furnace);
            }
        }
    }```
tardy delta
#

just make an eventHandler that checks if you left click a furnace and then bring up a gui

#

o

wide dune
#

I already did that

#

my issue is that

#

I'm inside my inventoryclickevent

#

i register that they clicked a diamond

#

now how do i link this inventory to the specific furnace

opal juniper
#

I am really confused tbh

#

So there is a furnace

opal juniper
#

That when u left click it opens a custom inv?

wide dune
#

Yeah it opens a generic inventory

#

which is the same for every furnace

tardy delta
#

and ther's a diamond tp upgrade

opal juniper
#

Ok, so do the furnaces get stored?

wide dune
#

for now json

#

temporary

opal juniper
#

ok

wide dune
#

but then how do I get the specific furnace when I click the diamond in an inventory which is the same for every furnace

opal juniper
#

Well, i mean if you store the loc of the furnace then you could just compare the loc and increment level by one

tardy delta
#

maybe store the player's UUID inside a hashlist when they upgraded their furnace?and every time you rightclick a furnace it checks if that player's uuid is inside it
yes -> it shows up custom inv gui i assume
no -> just normal furnace

wide dune
#

how do I link the UUID to the inv?

tardy delta
#

wait

opal juniper
#

no

tardy delta
#

idk i would do it that way

quaint mantle
#

I'd use a hashmap, but objects work better 🙂

tardy delta
#

but I'm figuring out how to access the pdc of a container that've been placed down

quaint mantle
#

make an object for every furnace

wide dune
#

thats what I've done

quaint mantle
#

detailing information like, owner, current upgrade state

#

all that

wide dune
#
public class FurnaceObject {

    @Getter
    Block b;

    @Setter
    @Getter
    int level;

    @Getter
    private static FurnaceObject instance;


    public FurnaceObject(Block b, int level) {
        instance = this;

        this.b = b;
        this.level = level;
        FizzyFurnaces.instance.addFurnace(this);
    }

}```
quaint mantle
#

you can do @getter instead of write a getter? 😮

wide dune
#

if you use lombok

tardy delta
#

:/

ivory sleet
#

pretty sure u could annotate the class with @Getter instead

#

@wide dune

wide dune
#

What does that do?

ivory sleet
#
@Getter
class POJO {
  Object o1;
  Object o2;
}

effectively same as

class POJO {
  @Getter
  Object o1;
  @Getter 
  Object o2;
}
sharp bough
#

this is fine right?
return new ItemStack(Material.AIR);
it will return a new itemstack generated in the return with material AIR

drowsy helm
#

yurp

tardy delta
#

can i get the state of a block (.getState()) that've been placed down (event.getClickedBlock() inside eventHandler) ?

ivory sleet
#

yes

maiden briar
#

Ok the solution @quaint mantle :

Pattern colorCodesPattern = Pattern.compile("(?<!\\\\)(" + code + "[a-zA-Z0-9])");
Pattern validColorPattern = Pattern.compile("(?<!\\\\)(" + code + "[a-fA-F0-9])");

And match them

tardy delta
#

okay then it would be possible to get the pdc of a block that is already placed down

ivory sleet
#

also I believe \d can be instead of 0-9

sharp bough
#

does anyone have an exmaple of some class that adds default commented lines?

ivory sleet
#

commented lines?

sharp bough
#

like

ivory sleet
#

are we talking configs?

sharp bough
#
/command
#this command does that```
#

yea

#

config.yml file

#

i saw a few examples online but they are quite rare

ivory sleet
#

I believe the spigot config api doesnt allow you to put commented headers on nodes

#

needless to say their version of snakeyaml isnt capable of it iirc

sharp bough
#

one solution i found for this is creating a doc.text and copy paste the stuff and document it there, but i want a better solution

ivory sleet
#

I mean one way would be to use something else instead of the spigot config api like a 3rd party lib

#

I believe Configurate has a way of dealing with commenting nodes

hushed spindle
#

im trying to hook into vault but it seems that when i do the economy's registeredserviceprovider is null, even though i have vault installed hooked into essentials economy and have vault in my plugin.yml's depends

    public static boolean setupEconomy() {
        if (Main.getPlugin().getServer().getPluginManager().getPlugin("Vault") == null) {
            return false;
        }

        RegisteredServiceProvider<Economy> rsp = Main.getPlugin().getServer().getServicesManager().getRegistration(Economy.class);
        // rsp is null
        if (rsp == null) {
            return false;
        }
        econ = rsp.getProvider();
        return true;
    }
ivory sleet
#

do you depend on vault?

hushed spindle
#

yes

ivory sleet
#

and you can ensure essentials is loading before your plugin

#

?

hushed spindle
#

i tried adding essentials to the depends as well which also didnt change anything, and judging from the server console essentials does load before my plugin and after vault

#

also checked if i was using the right import of economy and checked if essentials is properly hooking into vault and stuff

ivory sleet
#

In principle it should work then

hushed spindle
#

right but rsp is still null lol

#

so im at a loss

ivory sleet
#

where do u call setupEconomy

hushed spindle
#

in my main's onenable

ivory sleet
#

idk probably some weird pebkac issue

hushed spindle
#

im not even sure if its a plugin issue but i wouldnt know what on the server could cause the plugin to break

#

i had another plugin that uses similar hooking like that which worked previously and stopped working as well for the same reason

ivory sleet
#

can u send ur Main class?

#

?paste

queen dragonBOT
hushed spindle
#

know code quality aint the best with the whole public static enabled shit but this is just a tiny private plugin i had to make

ivory sleet
#

idc

#

as long as its readable

#

yeah this feels like a strange issue

#

did u check if Main.getPlugin().getServer().getPluginManager().getPlugin("Vault") returns null or if
rsp is null

hushed spindle
#

i did, it can find vault

#

just rsp is null

ivory sleet
#

what version of essentials

hushed spindle
#

also wouldnt see how any of these plugins could cause issues

#

latest

ivory sleet
#

which is?

hushed spindle
#

i literally just downloaded it lol, 2.18.2

ivory sleet
#

oh well

#

idk maybe try an older version or smtng

hushed spindle
#

will try that out

#

maybe its vault or smtn

chrome beacon
#

Is Vault in softdepend or depend?

ivory sleet
#

ye could likewise be that

hushed spindle
#

depend

#

dont think older versions will fix it either because updates arent released that frequently for vault or essentials

#

the newest versions just made it compatible for 1.13.x and stuff

chrome beacon
#

EssentialsX does get fequent updates

ivory sleet
#

^

chrome beacon
#

And you better not be using the original one

#

I also would go grab the latest dev build of EssentialsX

hushed spindle
#

i mean there hasnt been an update since nov 2020

ivory sleet
#

cap

hushed spindle
#

an official one anyway

ivory sleet
#

oh yeah not a release

chrome beacon
#

Dev builds get released ever other day or so

hushed spindle
#

will do the dev builds tho

chrome beacon
#

Yeah you need the dev builds

#

There's already a fix for Vault in the commits

quaint mantle
#

How can I prevent players from picking up EXP

hushed spindle
#

still didnt do it

#

man

ivory sleet
#

do u use spigot?

quaint mantle
#

does that also stop the orbs from dissapearing

#

i dont thhink so

chrome beacon
hushed spindle
#

always restarting the server dw

#

i got 2.19.0-dev+126-887772a

chrome beacon
#

That's not Vault

hushed spindle
#

no essentials

#

vault 1.7.3

quaint mantle
#

so xp orbs have targets?

ivory sleet
#

try this Athlaeos in onEnable

Bukkit.getScheduler().runTask(JavaPlugin.getProvidingPlugin(this.getClass()), () -> {
  Collection<Class<?>> a = Bukkit.getServicesManager().getKnownServices();
  for (Class<?> b : a) {
    Collection<RegisteredServiceProvider<?>> c = Bukkit.getServicesManager().getRegistrations(b);
    for (RegisteredServiceProvider<?> d : c) {
      System.out.printf(
        "Service from %d class %d instance %d\n",
        d.getPlugin().getName(),
        d.getService(),
        d.getProvider());
    }
  }
});```
royal hawk
#

Guys how link to pitch particles i have this code:

for (int ig = 0; ig <= 5; ig++) {
float radius = 1.5f;
double x = Math.sin(YinYangAngle);
double z = Math.cos(YinYangAngle);
YinYangAngle -= 0.1;

        player.spawnParticle(Particle.REDSTONE, location.getX() + x, location.getY() + z + 1, location.getZ(), 0, 0, 1, 0);
    }

he work only one side, example:
player.spawnParticle(Particle.REDSTONE, location.getX() + x, location.getY() + z + 1, location.getZ(), 0, 0, 1, 0); // for x

player.spawnParticle(Particle.REDSTONE, location.getX(), location.getY() + z + 1, location.getZ() + x, 0, 0, 1, 0); // for z

how link to player?

ornate heart
#

I have a class called PlayerDataManager and all it does is it holds a map of player data, and has methods that deal with stuff in this map.

If I know that I will only have 1 instance of this class, is it suitable to make the stuff inside of it (The map and methods) static? Why or why not? I'm asking for a friend. I normally would not make stuff static but he brought up this argument.

muted idol
#

hey there so im trying to run functions over servers with this code but at line 50 i get this error in my console java.lang.ClassCastException: java.util.Collections$UnmodifiableRandomAccessList cannot be cast to org.bukkit.entity.Player
my class: https://pastebin.com/08j6M5WB

hushed spindle
#

you're trying to cast all online players to a single player

ivory sleet
#

Athlaeos hmm then the instance exists

#

do u have ur plugin on github or smtng?

hushed spindle
#

no not really, i suspect it to be a server/other plugin issue though although i really wouldnt know why

sharp bough
#

if i do

    public Inventory build(){
        Inventory inv = new CreateLocationsGUI().buildLocations(pageId,"Select the location to add the loot in");
        return inv;
    }
    
    public void sum(){
        pageId++;
    }```
and run build it will open inv pageID 1
but if i then run sum 
and run build again, it wil open the pageID 2 right?
hushed spindle
#

another plugin i had there, fancyitems, used to work just fine and now it just doesnt

ivory sleet
#

yeah its odd

sharp bough
ivory sleet
#

I mean after all it seems like vault and essentials work like they should

#

according to the prints

onyx shale
#

What is he trying to do?

hushed spindle
#

trying to hook into vault but the registered service provider for economy is returning null

ivory sleet
#

get essentials Economy implementation through servicesmanager

onyx shale
#

Idk never had any problem from any essential version

flint elk
#

How can I create a server by code in Java / Spigot and add it to a BungeeCord server?

#

Without bungee restart

onyx shale
#

private boolean setupEconomy() { RegisteredServiceProvider<Economy> economyProvider = pl.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class); if (economyProvider != null) { economy = economyProvider.getProvider(); hasEco=true; } return (economy != null); }

#

Worked everytime for me

flint elk
#

im stupid

tardy delta
#

how can i let my scoreboard show placeholderapi campatible values?

flint elk
#

u need the placeholder api in your plugin

tardy delta
#

oh

hushed spindle
#

which import for economy are you using @onyx shale

flint elk
# tardy delta how can i let my scoreboard show placeholderapi campatible values?

Love the video or need more help...or maybe both?
💬Join us on Discord: http://discord.gg/invite/fw5cKM3
Thank you for tuning in to this episode of TheSourceCode! ❤️

If you enjoyed this video make sure to show your support by liking , commenting your thoughts, and sharing for all your friends to see and learn!

All code is available on Github:
...

▶ Play video
hushed spindle
#

rather you have 2 diff ones it seems

onyx shale
#

net.milkbowl.vault.economy.Economy

#

Only 1

#

The snippet had the namespace and was lazy to ever remove it

royal hawk
#

Guys i have this code how link animation to pitch?
I view static lines rotation

#

i want

sharp bough
#

what does ..createInventory(null,..) mean? what does null represent?

cyan oyster
#

what is this spigot download error?
Resetting Spigot-Server to CraftBukkit...
error: No such remote: 'upstream'
HEAD is now at c744c872 CraftBukkit $ Sat May 22 22:56:24 ICT 2021
Applying patches to Spigot-Server...
fatal: Resolve operation not in progress, we are not resuming.

ivory sleet
#

InventoryHolder

quaint mantle
#

how can I keep snowman from dying in the desert

hushed spindle
#

cancel EntityDamageEvent

cyan oyster
quaint mantle
#

but which damagecause is it

hushed spindle
#

idk you can test it

quaint mantle
#

oh it's melting

#

ofcourse

chrome beacon
#

Yeah was about to say

cyan oyster
#

wait it is doing something again

quaint mantle
#

what about when a snowman leaves a snow trail, what event would have that

#

oh yep that's it.

#

I was looking at the wrong event

muted idol
#

hey there is there any way to generate a world without any lag. so using my code once two players join a server it starts generating a world, thing is that then the server becomes very laggy and unstable while the world is generating and some times the players get kicked out. that's why i thought it would maybe be easier if i would have a server which the players wait in while on the other server the world is generating and then the players would get teleported once the world is finished generating.
is there any way to make this any smoother?

#

im making a manhunt plugin, so 3 vanilla worlds

#

that could maybe work but how would i then go about doing that if a player wants to play it again. do i just reload the server?

#

yea no im thinking more that everytime a game of manhunt finishes it reloads the server and then it deletes the old world and generates a new one

#

yea but if the player get kicked out to the lobby server and then the server reloads?

#

but yea that does sound kinda stupid

#

how would i go about unloading a world then?

ornate ledge
#

How can a plugin be affected by changing from jdk 8 to JDK 16?

muted idol
#

alright, but then when a world of manhunt finishes how would i go about creating a new world?

#

since that would cause lag

ornate ledge
#

ahh alright

#

so the best jdk is 8 so far right?

muted idol
#

and then i never have to reload it?

#

awesome

#

amazing ill look more into loading and unloading worlds!

vital jacinth
#

Adding to this, consider using a Java's FileVisitor to delete the world files and directories.

muted idol
#

thanks i've been trying to solve this now for weeks!

opal juniper
#

If i include the config.yml in the jar what is the best way to load it into the plugin dir

cyan oyster
#

why is this error?

package me.yourname.projectname;

public class Main ~~JavaPlugin~~ {

}
#

Javaplugin is error

#

ingore ~~

maiden briar
#
public void setField(String field, Object object)
    {
        try
        {
            System.out.println(getObjectClass());

            for(Field field1 : getObjectClass().getDeclaredFields())
            {
                System.out.println(field1.getType());
                System.out.println(field1.getName());
            }

            Field reflectedField = getObjectClass().getDeclaredField(field);

            reflectedField.setAccessible(true);
            reflectedField.set(this.object, object);
        }
        catch(NoSuchFieldException | IllegalAccessException e)
        {
            e.printStackTrace();
        }
    }

This won't work if I try to get a field from the extended class, how to fix? (Like if I for example extend JavaPlugin and want to get the field "description" (JUST AN EXAMPLE!!!)

vital jacinth
cyan oyster
#
package me.yourname.projectname;

public class Main extends JavaPlugin {

}

still

maiden briar
#

PLEASE learn JAVA BEFORE coding

#

Have you added Bukkit's dependency?

drowsy helm
#

you have no imports

cyan oyster
#

i downloaded buildtools

maiden briar
#

No wrong, get it from Maven

vital jacinth
cyan oyster
#

how

maiden briar
#

By LEARNING JAVA

#

Search as first on google what Maven is

cyan oyster
vital jacinth
opal juniper
onyx shale
#

most actually do

#

gives them a feeling of superiority

maiden briar
#

I also started without learning java, failed, and failed, made stupid mistakes. Then I looked forward and in a month I mastered Java. That was the end of stupid mistakes!

#

*Month of 2

vital jacinth
maiden briar
#

I did an paid course, but whatever, you have to learn Java

vital jacinth
maiden briar
#

Nah it was a good one

#

I know Java better than before

#

And rest of the tings I search on the web

royal hawk
worn tundra
#

Went through it already knowing Java to familiarize myself with the theory

#

works really well

ivory sleet
#

Mastering java in 2 months lol

opal juniper
muted idol
#

hey there how would i go about checking for something while the server is starting?

muted idol
#

like running a function like right after the plugin is loaded

opal juniper
#

Im a bit confused by what you mean...
What does the function do

muted idol
#

it check if a world is there if it's not there it starts generating the world

opal juniper
#

you can either just add code to the onEnable

#

or write a method that gets called onEnable

muted idol
#

oh yea right lol

opal juniper
#

but if you are doing world stuff, your plugin should probably load preworld

paper viper
#

tvhee i remember when you used to ask here before knowing java

#

im glad you learned now

muted idol
paper viper
#

no

#

tvhee

muted idol
#

oh thought so

opal juniper
#

lmao

#

yeah, if you are doing world shit probably put this:
load: STARTUP
in ur plugin.yml

#

cause this makes the plugin load b4 the world

vital jacinth
#

Pretty sure you can't load a new world in your plugin before the server has finished starting, so be careful with that.

quiet ice
#

wdym? I assume not

paper viper
#

are you using netbeans

ivory sleet
#

It’s some what ambiguous actually

paper viper
#

o

quiet ice
#

I assume that the method takes in Object...
The issue is that int[] could also be seen as a single value of Object or an array of Objects

ivory sleet
#

R u actually wanting to pass an array or just a the int

#

Ye

quiet ice
#

Then it is interesting to why the IDE thinks that it is varargs

#

If newInstance(255) does not compile, then it is a bug

ivory sleet
#

Cast it to object to explicate it

#

Hm

#

Would new Object[]{new int[]{255}} stop the complaints?

sage swift
#

ew

quiet ice
#

uhm, I think we are getting in the realms of accidentally creating things that may compile, but not run

ivory sleet
#

Yeah it’s verbose

#

Hmm interesting

quiet ice
#

what are the arguments that the constructor takes (i. e. the actual constructor)?

#

If having it on multiple lines does not bother you, you might want to try

Object o = new int[] {255};
c.newInstance(o);
muted idol
#

hey there so i have just generated a couple of worlds but for some reason if i try for example to go to from world1 to world1_nether with a nether portal it dosen't work same thing with the end portal how would i go about fixing this?

quiet ice
#

But idk, eclipse takes in

Constructor<?> c = this.getClass().getConstructor(getClass());
c.newInstance(new int[] {255});

nicely, so it might be an IntelliJ issue after all

sage swift
#

haha intellij

ivory sleet
#

🥲

echo ether
#

Does Spigot wait "onDisable" in plugins?

ivory sleet
#

Pog

sage swift
onyx shale
#

The server will not shutdown till all the calls are done

sage swift
#

"no, it'll shut down before it lets plugins finish doing what they need"

quiet ice
#

varargs can be evil at times

onyx shale
#

Woth exceptions i guess..

echo ether
#

As I remember, it was 15 or 30 seconds max?

#

After that, Spigot forces the plugin to finish its tasks

onyx shale
#

There is indeed some form of timeout

ivory sleet
#

Does a max even exists

#

thought it was like 1 min

onyx shale
#

You will receive like "the plugin failed to..."

quiet ice
#

ProccesBuilders exist if you need to do really long calculations

ivory sleet
#

Oo

echo ether
#

I was sure that it waits but why the people in Spigot forum keep saying "no, you have 1 tick to finish your task"

#

maybe it has changed

#

I'm not sure...

ivory sleet
#

1 tick lol

onyx shale
#

Some plugins do heavy stuff on disable i doubt 1 tick is a limit

quiet ice
#

1 tick is the limit on disable

#

There is no further tick after that

echo ether
quiet ice
#

So don't use the Bukkit Scheduler on disable

echo ether
#

Oh, you mean scheduler

ivory sleet
#

Oh the disable tick can be pretty long then

muted idol
#

alright

sharp bough
chrome beacon
#

Current item can be null

#

That too

sharp bough
#

lol didnt see that

#

let me change it

#

still when i click outside the gui

#

it reurns the eror r

#

yea but thats what i have

#

like

#

so just

#

if (event.getCurrentItem() == null || clickedItem.getType() == Material.AIR) return;

dense goblet
#

is there a way of making a sound audible from further away than normal?

sharp bough
#

and if you click an empty slot?

#

thats air

#

but if you click outside the gui then its null

#

oh you are right, thank you

dense goblet
#

ah its only for my custom-sent sounds so it should be easier

wraith rapids
#

an empty slot can return either null or an air itemstack

#

depending on context

tardy delta
#

imagine using a decompiler :/

dense goblet
#

so ig I'd have to send out a sound to each player with the distance clamped to some max value

wraith rapids
#

generally speaking, always check for both null and air

paper viper
#

^ thats what i do

wraith rapids
#

will save you quite a bit of headache with bukkit's inconsistent usage of null and air in return values

tranquil viper
#

Im getting a weird issue when working with arraylists

#

the ArrayList says that the value is in it but then doesnt recognize it

#
if (bypassChatList.contains(main.targetName)) {
                            inv.removeItem(chatBypass);
                            inv.setItem(13, removeChatBypass);
                            player.updateInventory();
                            System.out.println("test");
                        } else if (!(bypassChatList.contains(main.targetName))) {
                            inv.removeItem(removeChatBypass);
                            inv.setItem(13, chatBypass);
                            System.out.println("test1");
                            player.updateInventory();
                        }

wraith rapids
#

what is that supposed to mean

tranquil viper
#

yea thats confusing

#

so here

#

thats my code yea

#

it never prints test

#

it only ever prints test1

#

but

#

my arraylist contains the targetName

wraith rapids
#

that second if condition is redundant

#

if bypassChatList.contains(main.targetName) returns false, !bypassChatList.contains(main.targetName) will by definition return true

tranquil viper
#

why would it return false though

wraith rapids
#

it's not related to the issue you're having

#

but it's redundant

tranquil viper
#

oh

#

yea ik that

#

but I was just messing around to see if i could get it to work

#

idk

wraith rapids
#

print out the target name and print out the list to stout

tranquil viper
#

lol

wraith rapids
#

what type is the list

tranquil viper
#

array

wraith rapids
#

what type or arraylist

tranquil viper
#

string

wraith rapids
#

add the target name to the list and then print the list

tranquil viper
#

i am already doing that

wraith rapids
#

add it before checking contains

tranquil viper
#

k

#

works

#

but i cant keep it there

#

also another weird issue

opal juniper
#
    @EventHandler
    public void test(PlayerToggleSneakEvent event) {
        Entity e = event.getPlayer().getWorld().spawnEntity(event.getPlayer().getLocation(), EntityType.BEE);
        velocityPacket(e.getEntityId(), 0, 10, 0);
    }

    public void velocityPacket(int id, double x, double y, double z) {
        final PacketContainer veloctiyPacket = new PacketContainer(Server.ENTITY_VELOCITY);
        veloctiyPacket.getIntegers()
                .write(0, id)
                .write(1, (int) (x * 8000.0D))
                .write(2, (int) (y * 8000.0D))
                .write(3, (int) (z * 8000.0D));
        veloctiyPacket.setMeta("CUSTOM", 1);
        Bukkit.getOnlinePlayers().forEach(player -> {
            try {
                this.protocolManager.sendServerPacket(player, veloctiyPacket);
            } catch (final InvocationTargetException e) {
                e.printStackTrace();
            }
        });
    }

why no worky

wraith rapids
#

get the hashcode of the string in the list and compare it to the hashcode of target name

#

and by compare i mean print them both and look at them

tranquil viper
wraith rapids
#

not the list

#

the thing in the list

#

bypassChatList.get(0).hashCode()

tranquil viper
#

theyre the same

wraith rapids
#

now try calling Objects.equals on them and see what it returns

tranquil viper
#

how do I do that lol

wraith rapids
#

get the thing from the list

#

get the target name

#

then Objects.equals(a, b)

tranquil viper
#

im still confused on how to do that

#

ngl

tardy delta
#

how do i fix that when i typ a command, all the available options come onto the screen? like this:

ivory sleet
#

a solution is commodore

wraith rapids
#

Objects.equals(bypassChatList.get(0), main.targetName)

tranquil viper
#

oh LOL i put object

#

whoops

#

tru

#

true

dense goblet
wraith rapids
#

remove the line where you add the name to the list before checking

tardy delta
#

okay

tranquil viper
#

java.lang.IndexOutOfBoundsException

tardy delta
#

but for some reason my cmd isnt working

dense goblet
#

in what way?

wraith rapids
#

your list is empty

tranquil viper
#

yea

wraith rapids
#

remove the thing I told you to add earlier

tranquil viper
#

i did

wraith rapids
#

then why is the list empty now

tranquil viper
#

cause i removed it