#help-development

1 messages · Page 1902 of 1

fervent gate
#

It may not be the cause of the error, but having the pc run at 95+% RAM is actually pain though

dusk flicker
#

Get the keys of kits, so kit1, kit2, etc, then use the returned string to get kits.x.items and store it in a map

#

?jd

sleek turret
#

lmao, i see why that wasnt working for me earlier

fervent gate
#

Are there actually more packets to send to the player to spawn an NPC?

ServerGamePacketListenerImpl ps = craftPlayer.getHandle().connection;
        ps.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.ADD_PLAYER, npc));
        //Spawn Player packet
        ps.send(new ClientboundAddPlayerPacket(npc));
#

Because I am sending these 2 packets but I can't see them in-game

maiden thicket
maiden thicket
fervent gate
#

but I thought these spawned on the player

maiden thicket
#

nah it just lets the player know ur adding a player entity into the world

fervent gate
#

damn

fervent gate
#

It shows up in tab, just can't see it

#

npc.setPos(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ());

#

this is the right way right?

fervent gate
#

well, it isn't working

maiden thicket
#

show ur npc code

fervent gate
#

wait, lemme try smth

fervent gate
maiden thicket
fervent gate
#

mk

woeful crescent
#

After shading some stuff with maven, it is now including everything except for my project compile output.

#

can anyone help?

vocal cloud
#

project compile output? You mean the project itself

woeful crescent
#

i mean yeah

#

it's just not including my project's class files

#

in the jar

fervent gate
#

all of these little things...

keen basin
#

how can i get location from hashmap ?

#

Location location1 = new Location(player.getWorld(),warp.get(player.getName()));

woeful crescent
#

nvm

fervent gate
#

Is there a way I can allow the player to attack an npc?

#

A ServerPlayer that is

sly trout
#

I'm trying to use NBTAPI

#

but I can't compile it

#

gives me that error

iron tundra
#

Issue: On the issue line it says after onWeatherEvent it is asking for a ; but doing that would obviously break the code and wouldn't push forward with what I want
Use of code: I am trying to make when a lightning bolt strikes either near or on a iron ingot in this case it replaces it with a item called Lightning ingot

public class LightningBoltListener implements Listener {
    @EventHandler
    public void onPlayerEvent(PlayerDropItemEvent event1) {
        if (event1.getItemDrop().getName().equals("Iron Ingot")) {
            public void onWeatherEvent(LightningStrikeEvent event) { //Issue line
                if (event1.getItemDrop().getLocation().getX() >= 1 event.getLightning().getLocation.getX() || event1.getItemDrop().getLocation().getZ() >= 1 event.getLightning().getLocation.getZ()) {
                    event1.getItemDrop().setMetadata(1);
                    event1.getItemDrop().setCustomName("Lightning Ingots");
                }
            }
        }
    }
}
sly trout
#

bruh what

#

why do you have a method inside of your method

#

tf

iron tundra
#

I have zero idea what I am doing

sly trout
#

I can see that

iron tundra
#

I am just using api and hoping

sly trout
#

bruh

#

ayt

iron tundra
#

copium all the way here

sly trout
#

so

#

don't put a method inside of a method

#

u can't do that

iron tundra
#

alright, thank you

sly trout
#

okay so

#

let me explain how to do it

#

so on lightning event

#

you loop thru all the entities that are items

#

around where it landed

#

and then check if it iron ingot

#

and then change it

#

something like that

#

should work

sly trout
#

any1 knows?

lost matrix
lost matrix
sly trout
#

PDCs ?...

paper viper
#

?pdc

proven river
#

How to do I check if a players Max Health Attribute is bellow a certain value?

sly trout
#

player.getMaxHealth() < number

lost matrix
proven river
#

Alright thanks

sly trout
#

my bad

#

g

#

forgot the method

#

should be sum like dat

lost matrix
#

Player#getAttribute(Attribute)

#

should be GENERIC_MAX_HEALTH

proven river
#

Yea I was just trying to figure out the last part since it wouldnt accept like
< 20

lost matrix
#

Because this returns an AttributeInstance

proven river
#

Would that mean I have to convert it? or?

lost matrix
lost matrix
#

^

proven river
#

thanks :D

spare marsh
#

Is creating my method for checking and notifying a player if he is inside a region every 1/2 second better than using PlayerMoveEvent?

sly trout
#

you want to notify a player every 1/2 seconds

#

that is a lot of chat messages

spare marsh
#

No no don’t worry about that there will be a condition to check that

#

Not worried about the chat it won’t always notify just on enter and leave. I have my way of doing that but I’m just asking if making a timer that will check a player’s location to be able to see if he is inside a region better than checking it with playerMoveEvent?

ivory sleet
#

Both are fine

#

Tho I’d say the event might be more friendly

sleek turret
#

Method:

@SneakyThrows
    public void loadKits() {
        kits = new HashMap<>();
        File file = new File(getDataFolder(), "kits.yml");
        if (!file.exists()) {
            file.getParentFile().mkdirs();
            saveResource("kits.yml", false);
        }
        FileConfiguration fileConfig = new YamlConfiguration();
        fileConfig.load(file);

        ConfigurationSection kitConfig = fileConfig.getConfigurationSection("kits");
        if (kitConfig == null) return;
        if (!kitConfig.getKeys(false).isEmpty()) {
            Set<String> names = kitConfig.getKeys(false);
            names.forEach(name -> {
                List<ItemStack> items = (List<ItemStack>) kitConfig.getList("kits." + name);
                kits.put(name, items);
            });
        }```
YML:
```yml
kits:
  test:
  - ==: org.bukkit.inventory.ItemStack
    v: 2865
    type: NETHERITE_HELMET
  - ==: org.bukkit.inventory.ItemStack
    v: 2865
    type: NETHERITE_CHESTPLATE
  - ==: org.bukkit.inventory.ItemStack
    v: 2865
    type: NETHERITE_LEGGINGS
  - ==: org.bukkit.inventory.ItemStack
    v: 2865
    type: NETHERITE_BOOTS
  - ==: org.bukkit.inventory.ItemStack
    v: 2865
    type: NETHERITE_SWORD
  - ==: org.bukkit.inventory.ItemStack
    v: 2865
    type: ELYTRA```
Does anyone know why items would be null?
iron stream
#

What is the most convenient way to store user data for a server that may only ever have 10 unique players? idk whether to go with csv file or database or what

buoyant viper
#

maybe yaml files? @iron stream

iron stream
quasi patrol
#

It was working before.

delicate lynx
#

don't build in a onedrive folder

quasi patrol
quasi patrol
delicate lynx
#

because sync programs suck and lock files or just do weird things

hasty prawn
#

I've never had issues with OneDrive

blazing rune
#

How do I like get player chat logs and send them to and operator

#

Like CommandSpy

#

But only for commands

hasty prawn
#

PlayerCommandPreprocessEvent

sly trout
#

can we not add potion effects to a player when we are inside a scheduler task?

hasty prawn
#

You can

#

Not sure if you can do it async though

#

I'd assume yes but 🤷‍♂️

blazing rune
#

Ok

sly trout
#

the error is asynchronous effect add

#

but doesnt synchronous stop your code?

#

that would be unfortunate

#

because im trying to make it so every second the player has a certain helmet

hasty prawn
#

Adding a potion effect is not going to be a big deal synchronous

sly trout
#

it gives him night vis

#

yeah no but its a loop that runs in the background

#

loops thru players

#

and sees if a player has the helmet

hasty prawn
#

Yeah you don't need async for that, async is for extremely heavy operations like read/write from IO

sly trout
#

sync

#

it does it in the background?

#

does it not stop the whole code?

hasty prawn
#

Well, no, it does it on the main thread but that will take basically no time at all

#

Unless you have a hundred million players, then it might

sly trout
#

its a runtasktimer

#

loops thru players

#

and checks that

hasty prawn
#

Yep, just use that. No need for async.

sly trout
#

alright thank you very much 😄

ivory sleet
#

I mean you can access players asynchronously from ::getOnlinePlayers if you need to

hasty prawn
#

You can't add potion effects asynchronously apparently

ivory sleet
#

Yeah probably not

sly trout
#

why not tho?

ivory sleet
#

Because a potion effect is only lasting for a specific amount of ticks right

sleek turret
#

@ivory sleet, do u know much about yaml?

ivory sleet
#

That countdown has to be done somewhere, and if it’d be done asynchronously then you’d run into other concurrency update problems

#

@sleek turret yes

#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

sleek turret
#

i did, no one answered

ivory sleet
#

Bump it?

hasty prawn
#

Reply to your message

delicate lynx
#

output each variable and see what is null

sleek turret
#

the whole list is

#

the getList is jsut returning null

delicate lynx
#

oh

#

use getConfigurationSection("kit." + name)

ivory sleet
#

Probably wanna use "kits.test" as Path

hasty prawn
#

He is

ivory sleet
#

And then get it as a MapList

hasty prawn
#

"kits." + name

sleek turret
#

yeah, im getting the keys, then going kits.test

delicate lynx
#

try to use getConfigurationSection

#

I am dumb

#

you are using it

sleek turret
#

yeah

ivory sleet
#

Yeah well Idk if spigot supports a yaml sequence of configuration serializable

#

Like as api

#

Also why sneaky throw? Just try catch possible throwables

sleek turret
#

Just lazy

ivory sleet
#

You thwart the very reason Java invented checked exceptions

sleek turret
#

lmao

ivory sleet
#

But btw you can print out a YamlConfiguration instance I believe

#

and it should yield a string representation

#

(Or use some sort of break point if ur ide supports that) conversely to just print it

sleek turret
#

yeah im just gonna print it

quasi patrol
snow crow
#

hello\

#

i need help with change the api from 1.17.1 to 1.18.1 the jdk it was build around was 17

dusk flicker
#

what

#

What is your problem?

snow crow
#

i made it 1.17.1 in the past

#

spigot api

buoyant viper
#

just change it in ur build.gradle or pom.xml

#

from 1.17.1-R0.1-SNAPSHOT to 1.18.1-R0.1-SNAPSHOT

#

@snow crow

woeful moon
#

I have a class that queries a database and returns a boolean whether or not a player is already in the database. I need to surround it with a try/catch loop in case there's an error, but I'm unsure what to return in case there is an error (since it's neither true nor false). I've considered doing throws SQLException and then throw new SQLException();. Should I stick with that or do something else?

woeful crescent
#

hey guys, maven is packaging everything except for my project files

#

I'm using maven shade plugin to shade mongodb classes

sly trout
#

I really need y'alls help rn

#

how do you make a boat float on lava

woeful crescent
#

well, the issue isn't that the boat doesn't float on lava

#

it does

#

it just breaks if the player tries to ride on it

sly trout
#

I just cancel the damage event

#

the boat doesnt break

#

the issue is that it doesnt float

woeful crescent
#

wdym "doesn't float"

#

does it sink?

#

does it break?

sly trout
#

it sinks

#

to the bottom

#

i wanna ride it like a boat on water

dusty herald
proud forum
#

hello! i was wondering if there was an easy and more optimized way of doing this?

package me.mrhonbon.opmobs;

import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.inventory.ItemStack;

public class MobSpawns implements Listener {
    @EventHandler
    public void onMobSpawnEvent(CreatureSpawnEvent e) {
        if (e.getEntityType() == EntityType.CREEPER) {
            Creeper creeper = (Creeper) e.getEntity();
            creeper.setPowered(true);
        }
        ItemStack helmet1 = new ItemStack(Material.NETHERITE_HELMET);
            helmet1.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
        ItemStack chestplate1 = new ItemStack(Material.NETHERITE_CHESTPLATE);
            chestplate1.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
        ItemStack leggings1 = new ItemStack(Material.NETHERITE_LEGGINGS);
            leggings1.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
        ItemStack boots1 = new ItemStack(Material.NETHERITE_BOOTS);
            boots1.addEnchantment(Enchantment.PROTECTION_ENVIRONMENTAL, 3);
        ItemStack sword1 = new ItemStack(Material.NETHERITE_SWORD);
            sword1.addEnchantment(Enchantment.DAMAGE_ALL, 1);

        if (e.getEntityType() == EntityType.ZOMBIE) {
            Zombie zombie = (Zombie) e.getEntity();
            zombie.getEquipment().setHelmet(helmet1);
            zombie.getEquipment().setChestplate(chestplate1);
            zombie.getEquipment().setLeggings(leggings1);
            zombie.getEquipment().setBoots(boots1);
            zombie.getEquipment().setItemInMainHand(sword1);

        }
    }
}

i am a beginner so i apologize if this isnt the most optimized, but this code does work and does what it does, i just want to know if i can save some lines of typing with better code 😁

sly trout
dusty herald
#

oh ok

#

why do you want boats on lava

#

you can ride striders, they're a lot better than boats

woeful crescent
#

or u could teleport the boat to the strider

#

make the strider invisible

dusty herald
#

yes

woeful crescent
#

i dont think there's really just a straightforward way to make boats float on lava in spigot

#

cuz y'know

dusty herald
#

a boat that can walk on land

woeful crescent
#

it's hardcoded for boats to sink, i think

sly trout
#

ye

dusty herald
#

a texture pack that turns striders into boats that you can put a saddle on

#

and boats into striders

sly trout
#

mhm

craggy cosmosBOT
#

:dynoError: The AFK module is disabled in this server.

woeful crescent
#

it also might work if you cancelled the VehicleMoveEvent that gets called when the boat sinks down into lava

quaint mantle
#

MysticCat did this with only commands block

#

So with the power of coding, why can’t we improve his concept

woeful crescent
#

ok tbf

woeful crescent
#

;-;

vocal cloud
woeful crescent
#

whoops

#

wrong pom lmao

#

@vocal cloud

vocal cloud
#

Huh idk. Have you run mvn clean and everything to make sure it's not something gummed up in there?

#
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>16</source>
                    <target>16</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
``` this is the build I use and it works
#

Tho watch the java version

quasi patrol
muted quiver
#

Anyone know what i am doing wrong? I'm trying to set a player head to a custom skin

        ItemStack playerHead = new ItemStack(Material.PLAYER_HEAD); // Amount is 1 by default
        SkullMeta playerHeadMeta = (SkullMeta) playerHead.getItemMeta();
        playerHeadMeta.setOwningPlayer(Bukkit.getOfflinePlayer(UUID.fromString("a68f0b64-8d14-4000-a95f-4b9ba14f8df9")));
        playerHeadMeta.setDisplayName(Color("&c&lGo Back."));

        playerHead.setItemMeta(playerHeadMeta);
muted quiver
#

No errors, head is just not showing up

#

like w/ the texture

opal sluice
muted quiver
#

oh

#

im an idiot

#

nv,

#

nvm

#

ty

blazing rune
#

How do I add cooldowns to item abilities

#

Helo?

quasi patrol
blazing rune
proud forum
#

what i am trying to do is make a variable change from off and on to make events happen.

the easiest way i can describe this is something like this: if (toggle) is on: do stuff) and: if (toggle) is off: do stuff

so could someone assist me in making a command (/opmobs on|off) that defines whether a variable is off or on? (sorry if this is hard to understand i am just beginning with java and spigot development)

pine island
#

so if (cmd.getname.ignoresCase("opmobs"){ --- }

waxen plinth
#

As I would tell everyone

#

There are plenty of tutorials on how to use the spigot command library out there

#

But it's kinda terrible

#

You should familiarize yourself with it, then abandon it in favor of a command framework

feral yoke
#

Hello, I have a problem I would like to create a plugin in 1.18.1 but I have this error

Searched in the following locations:
    https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/spigot-api-1.18.1-R0.1-20220108.231739-38.jar```
blazing rune
#

How do I add my custom items to mob drops?

pine island
#

how do i spawn mobs on playyer's location?

#

well lightning to be exact

blazing rune
blazing rune
pine island
#

yeah

#

i think i found smth

blazing rune
buoyant viper
pine island
#

nope this is what i use

buoyant viper
#

i think ur spawnCreature method has no logic in it

pine island
#

i know

#

this should work right?

#

i updated it to camelCase btw

feral yoke
#

there is a problem with spigot because it is impossible to create a plugin in 1.18.1 🤔 end it tells me that it can't find the link for spigot

pine island
#

maybe try downloading build tools and building it natively?

feral yoke
#
apply plugin: 'idea'

group 'fr.aldraziel'
version '1.0.0'

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

task javadocJar(type: Jar) {
    classifier 'javadoc'
    from javadoc
}

task sourcesJar(type: Jar) {
    classifier 'sources'
    from sourceSets.main.allSource
}

compileJava {
    targetCompatibility = sourceCompatibility = JavaVersion.VERSION_17
    options.encoding = 'UTF-8'
}

repositories {
    mavenCentral()

    maven {
        url "https://hub.spigotmc.org/nexus/content/repositories/snapshots"
    }
    maven {
        url "https://hub.spigotmc.org/nexus/content/repositories/public"
    }
}

dependencies {
    api 'org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT'
    api 'org.jetbrains:annotations:22.0.0'
}```  the link redirect to a 404 error
😒
hasty prawn
#

Working for me

feral yoke
#

👀

#
Could not find spigot-api-1.18.1-R0.1-SNAPSHOT.jar (org.spigotmc:spigot-api:1.18.1-R0.1-SNAPSHOT:20220108.231739-38).
Searched in the following locations:
    https://hub.spigotmc.org/nexus/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/spigot-api-1.18.1-R0.1-20220108.231739-38.jar
``` hummmm
feral yoke
#

yes

pine island
#

maven > gradle

feral yoke
#

--'

pine island
#

try maven

#

it could be gradle

feral yoke
#

🤔 is possbility

pine island
#

maven forked for me

#

worked*

#

i just created a project

#

u can always migrate ur code

feral yoke
#

I'm going to test with maven I'm not ready 😛

hasty prawn
#

It seemed to work for me

feral yoke
#

it's just that the pom.xml that's what :x

hasty prawn
#

Might need to invalidate your caches.

feral yoke
#

I hadn't thought

pine island
#

i never came across this error

#

so i had no idea invalidating caches would work

feral yoke
#

then I use intelliJ <.<

pine island
#

wait u use eclipse?

feral yoke
#

no IntelliJ

pine island
#

yeah intelliJ is better

feral yoke
#

Yes google translate xd

#

-_-"

#

i'am french xd

pine island
#

dw

feral yoke
#

:x

#

ok it works with maven xd

pine island
#

well

#
@EventHandler
    public void onDeath(PlayerDeathEvent E)   {
        Player player = E.getEntity();
        Entity killer = E.getEntity().getKiller();
        player.setGameMode(GameMode.SPECTATOR);
        getServer().broadcastMessage(ChatColor.DARK_RED + "! "+ player.getName().toUpperCase() + " Has Died!!");
        Location killerLoc = killer.getLocation();

        if (killer instanceof Player){
            Player killerPlyr = (Player)killer;
            killerPlyr.setNoDamageTicks(20);
            player.addPotionEffect(PotionEffectType.HARM.createEffect(15, 2));
            player.addPotionEffect(PotionEffectType.SPEED.createEffect(60, 5));
        }
        spawnCreature(killerLoc, EntityType.LIGHTNING);

    }

    private void spawnCreature(Location killerLoc, EntityType lightning) {
        killerLoc.getWorld().spawnEntity(killerLoc, EntityType.LIGHTNING);
    }``` this works right?
#

also i cant register this event

#

oh wait nvm

quaint mantle
#

E

tall nova
#

E

tall nova
woeful moon
#

I have an sql time object (https://docs.oracle.com/javase/7/docs/api/java/sql/Time.html) and I want check how many minutes have passed between then and now. Everything I could find online relies on Time#getTime(), which is supposed to return the time passed since 1970 in milliseconds but gives something completely different. any ideas?

pine island
#

what does it give

woeful moon
#

the time is about 2 hours ago

#

it's supposed to return something very close to this (which is current)

young knoll
#

Time zones perhaps

quaint mantle
#

Probably. Use timetamp instead

wet breach
#

I am pretty sure your issue has to do with conversion

#

SQL stores time as hh:mm:ss and not in milliseconds

#

however SQL time understands various formats for time too, so it all depends on your code

#

also depends on the system as well

lunar python
#

How can I compile a jar with both the Spigot API and NMS in 1.18.1 for my plugin? (I'm using the latest BuildTools version)

hardy swan
#

if you mean purely just api and nms and do not require a remapped version of the nms packages, then the normal command is sufficient

#

java -jar BuildTools.jar --rev 1.18.1

lunar python
#

ok

#

but where does it get compiled?

#

i've only found the API

hardy swan
#

it should be in your local maven repo

lunar python
#

oh

hardy swan
#

under a different artifactId

lunar python
#

oh ok

#

thanks

wet breach
#

?bootstrap

undone axleBOT
#

Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.

Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163

summer scroll
#

How can you disable mouse movement completely like in Origin Realms?

wet breach
#

technically can't o.O

summer scroll
#

And also the wasd movement

summer scroll
#

That affect the mouse movement?

quaint mantle
#

ah

#

Missed the mouse word

summer scroll
#

So amazing that they can do that

quaint mantle
#

Maybe force player to spectate some entity? Iirc you cant move nouse in that case

mental jungle
#

how can I put a block to somewhere with plugin

mighty pier
#

how do i send a title to a player?

gentle oriole
#

quick question. do player.setHealth(0.0D); bypass the 3 second invulnerability that minecraft gives when the player just respawned/joined the server?

#

what makes a player isInvulnerable() ??

tacit drift
spiral light
#

sethealth bypass everything

tacit drift
hardy lynx
#

hi what do I do here?

mental jungle
hardy lynx
#

I did

mental jungle
#

it worked for me

hardy lynx
hardy lynx
#

k

#

and delete the other one?

mental jungle
#

not necessarily

hardy lynx
#

oh okay ty

gentle oriole
# tacit drift

does minecraft set players as invulenrable when they joined/just respawned/in creative?

#

🙃

spiral light
#

nvmd

#

that was some junky website there lol

gentle oriole
# spiral light nvmd

well im too lazy to try and see so im just gonna make a list that will contain players after respawning for 5 seconds

#

so I just tried and and see and it turns out it only returns true when player is in death screen. returns false after join/respawn and on creative

#

isnt there a grace period after respawning?

#

well on my game there isnt..

spiral light
#

maybe its some other stuff that blocks damage and not invulenrable

#

any extreme cool rich command-lib/api ?

manic furnace
#

?paste

undone axleBOT
manic furnace
#

I want to make a Class that implements Player, so i can get some other informations, which I write in the Class ,from the player but also can get infos like getUniquId. But When i cast it, I become a ClasCastException. How can I do that?
My code (My CommandClass):

public class TestCommand implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        Player p = (Player) sender;
        CostumPlayer cp =  p;

        Bukkit.broadcastMessage(String.valueOf(p.getUniqueId()));
        return false;
    }
}

My Class which implementes Player:
https://paste.md-5.net/alasenuwad.java

young knoll
#

Don’t implement player

#

Make a wrapper class that contains a player inside it

manic furnace
#

How?

snow crow
#

Help After Changeing the api version in pom.xml

spiral light
#

dont make it interface/abstract and create an constructor that contains the player obj

snow crow
#

log in thread

wet breach
# manic furnace How?
public class Otherthing {
private Player player;

public something(Player player) {
this.player = player;
}

}

basic premise of a wrapper

manic furnace
#

ok

wet breach
#

@spiral light sure, but its basic stuff so I have no problems with that 😛

young knoll
#

Also make sure to dispose of that class from any maps when the player logs off

wet breach
#

discord is going to eventually teach us we can efficiently speak with images and emojis without using words 😄

snow crow
#

🆗

grave fox
#

I don't know if this is a bug or a error, because when i try to reload the config of my plugin doesn't work
pd: i'm using reloadConfig();

young knoll
#

What doesn’t work

grave fox
#

when I try to reload the config of the plugin, the "config.yml" file

young knoll
#

Right

#

But what about it isn’t working

grave fox
#

doesn't reload the config

young knoll
#

Share code

#

Because I assure you that method does reload the config

grave fox
#
if (command.getName().equals("authentication")) {
            
            if (arguments[0].equals("reload")) {
                if (entity instanceof Player) {
                        main.reloadConfig();
                        Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', (String) this.main.getConfig().getString("message.reload")));
                } else {
                    if (entity.isOp()) {
                        Bukkit.getConsoleSender().sendMessage(ChatColor.translateAlternateColorCodes('&', (String) this.main.getConfig().getString("message.reload")));
                        this.main.saveConfig();}
                }
            }
        }
#

i tried with two forms but doesn't work any of it

spiral light
#

did your register the cmd ?

grave fox
#

yep

spiral light
#

does it send you the msg after reloadConfig ?

grave fox
#

yes

spiral light
#

and no error in console ?

grave fox
#

no error

#

and i don't have any try except

fervent gate
#

Is there a way to set a serverPlayer attackable and allow it to attack another player. The serverplayer is an npc added by me.

acoustic pendant
#

if (player.getWorld().getBiome(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()).equals(Biome.DESERT)) {

Can i add here a list from config so it detects what biomes have the person wrote in the config, or how could i do that?

young knoll
#

I would make use of the namespaced key

#

Via biome.getKey

spiral light
young knoll
#

And then you can check if a list .contains said key

fervent gate
spiral light
acoustic pendant
spiral light
#

adding npcs that are attackable and attack by them self are a bit tricky ^^

fervent gate
spiral light
#

listen to many packets and recreate how the player would move from A to B and how it attacks and how other player interact with it

#

what is waaaaay to diffucluty

#

or: create an real entity and modify the spawn packets to spawn your player instead .... it will look like an npc and attack/move how you want and the server handels everything for you

fervent gate
spiral light
#

if you want those npcs to be a normal peacefull mob you can use an Villager and modify some stuff to make it usefull

snow crow
#

so

#

ye again xD

#

Error occurred while enabling EnderRider v1.0-SNAPSHOT (Is it up to date?)
java.lang.IllegalArgumentException: The embedded resource 'config.yml' cannot be found in plugins\EnderRider.jar

quaint mantle
#

much reilable and prevents for a lot of asspain

#

you can even interact with your npc through bukkit api

spiral light
#

if they should attack players like zombies use zombies .... if you want them to shoot you need to use skeleton/pillager

fervent gate
quaint mantle
spiral light
spiral light
quaint mantle
#

just wait a little bit for hangar

fervent gate
spiral light
acoustic pendant
#
    private ArrayList<Biome> biome = new ArrayList<>();
    biome = (ArrayList<Biome>) getConfig().getList("biome");
                            if (player.getWorld().getBiome(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()).equals(biome)) {

Something like this would work to get a biome list from the config?

fervent gate
quaint mantle
spiral light
#

of course you will not get an explanation of what what does ...

quaint mantle
#

this is not going to break spigot rules 😉

spiral light
#

the names are self-explanatory too

spiral light
fervent gate
spiral light
#

is also a thing

spiral light
snow crow
#

or it the plugin first time starting

fervent gate
spiral light
spiral light
#

also if you dont know much about api / packets stuff you shouldnt do some npc stuff^^

snow crow
spiral light
snow crow
#

okkie

spiral light
#

also possible that your pom is not configured to include those resources

snow crow
#

This the paths with . pom.xml

fervent gate
spiral light
#

i guess

spiral light
#

packets nms everything isnt quick at all

#

you rly have to know how you would do that stuff

fervent gate
spiral light
#

you would need to listen for outgoing packets and make sure the packet for your real entity will not reach the client ... instead you need to spawn an npc with the same entityid of that real entity
also you may need to resend the equip + metadata stuff again for the player to make sure he can see it

snow crow
spiral light
snow crow
#

ok googling

spiral light
#

? just put it in "resources" and not "resources/META-INF"

snow crow
#

ok

fervent gate
#

I'm going to use libsdisguises to disguise some entities. It doesn't want to import, do I need to actually download the .jar file to my pc?

spiral light
#

you should check out their spigot-page/github if they support maven directly

fervent gate
spiral light
#

did you add the repository ?

fervent gate
#

Yes, but isn't that the spigot one?

spiral light
#

i dont think so

#

also your version is wrong ... i see 10.0.21 and not 10.0.27

fervent gate
#

wtaf

#

It didn't work as I did it 3 times, now I do it again, and poof

#

works straight away

snow crow
#

im back again 🙂 xD

#

[16:30:59] [Server thread/ERROR]: Could not load 'plugins\EnderRider.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml

young knoll
#

Show the full error

#

?paste

undone axleBOT
snow crow
young knoll
#

Your jar does not contain a plugin.yml

#

Do you have it in the right spot

snow crow
snow crow
young knoll
#

src/main/resources

#

Your folder structure is all messed up

snow crow
young knoll
#

Does just renaming ja.jaai.enderrider to src work?

sacred mountain
#

hey does anyone know how to fix client side visual glitches?

snow crow
sacred mountain
#

i have a setcancelled thing for water, but on the players screen it shows the water is gone

#

before and after

#

the anticheat went crazy

#

because people can jump in those holes

spiral light
#

client bug

#

you need to update that position for the player after that

sacred mountain
#

hm well someone just got banned for jumping ontop on ghost air

sacred mountain
#

just set the block?

spiral light
#

block.update maybe

tardy delta
quaint mantle
#

you should also relocate

tardy delta
#

hmm that didnt work previous time i tried

quaint mantle
snow crow
#

[16:52:38 ERROR]: Could not load 'plugins\EnderRider.jar' in folder 'plugins'
org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:170) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:144) ~[spigot-api-1.18.1-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.v1_18_R1.CraftServer.loadPlugins(CraftServer.java:415) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3408-Spigot-f4ff00f-74a5cc8]
at net.minecraft.server.dedicated.DedicatedServer.e(DedicatedServer.java:231) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3408-Spigot-f4ff00f-74a5cc8]
at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:994) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3408-Spigot-f4ff00f-74a5cc8]
at net.minecraft.server.MinecraftServer.lambda$0(MinecraftServer.java:304) ~[spigot-1.18.1-R0.1-SNAPSHOT.jar:3408-Spigot-f4ff00f-74a5cc8]
at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
... 7 more

#

im back again

#

lol

acoustic pendant
#
 if (player.getWorld().getBiome(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()).equals(loadBiomes("biomes"))) {
                                if (!(getPlayerHeat(player) >= 100)) {
                                    setPlayerHeat(player, 1);
                                }
                            } else if (!player.getWorld().getBiome(player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()).equals(loadBiomes("biomes"))) {
                                if (getPlayerHeat(player) >= 1) {
                                    setPlayerHeat(player, -1);
                                }
                            }```

why does it says that the if are always false?
acoustic pendant
young knoll
#

They have one

snow crow
#

yes

young knoll
#

Their folder structure is just messed up

acoustic pendant
snow crow
#

i just dont know where to place itt

young knoll
#

src/main/resources

acoustic pendant
#

why don't you use intelijj plugins?

young knoll
#

Just like your code should be in src/main/java

acoustic pendant
#

coll

young knoll
#

What

snow crow
acoustic pendant
#

plugin.yml has to be there

snow crow
#

wait if i dont have config file

acoustic pendant
#

that doesn't matter

#

is a file i created for my plugin

young knoll
#

The heck does loadbiomes do

tardy delta
#

what does clean package do?

acoustic pendant
spiral light
#

nope

#

just no

#

dont run loadBiomes everytime you need it ?

#

maybe save it somewhere.

snow crow
tardy delta
#

if biome equals a list of biomes???

spiral light
# snow crow

create a new project for plugins and compare those projects ...

tardy delta
#

that doesnt make sense

young knoll
#

A biome will never equal a list of biomes

#

So it's always false

acoustic pendant
#

oh

tardy delta
#

does anyone knows what clean package goal does?

#

cleans stuff or something and packages it?

tardy delta
wet breach
#

you shouldn't use clean unless necessary

#

otherwise it prevents using maven builds which utilizes caching so that it doesn't need to re-compile everything

#

just only what changed

tardy delta
#

i had like 3 jar files when i used the shade plugin

wet breach
#

however, if you utilize shading every so often you will probably need to use clean especially if dependencies being shaded were updated in the pom

tardy delta
spiral light
#

does just mvn package replace existing jars forced ?

quiet ice
#

mvn package just creates the jar

wet breach
#

original, contains your project class files nothing else before shading, shaded is all the stuff/dependencies placed into the jar, and the top one is both combined

tardy delta
#

wdym combined?

quiet ice
#

Both jar files merged

wet breach
#

shaded doesn't contain your project classes, it contains the stuff that you wanted shaded

#

original is your project classes

tardy delta
#

oh

wet breach
#

the top one is both those jars combined

snow crow
#

im back again

#

lol

quiet ice
#

So?

snow crow
#

jdk.internal.icu.impl.NormalizerImpl any alternates for this or dependency

tardy delta
#

cant ti just change that it only outputs the combined jar and nothing else?

wet breach
quiet ice
#

And why are you looking at JDK internals? Most IDEs hide them from you

wet breach
#

however, most of the time it isn't necessary even when you push builds to a maven repo

#

because maven only uses the end result jar

#

unless you specify you want all the jars pushed then it would do that as well lol

tardy delta
#

and what does this do? (plugins configuration)

wet breach
#

it is for transitive dependencies and the META-INF file that maven creates

quiet ice
#

It's literally the same library so it would be a drop-in solution

snow crow
#

ok 🙂

wet breach
# tardy delta and what does this do? (plugins configuration)

there is a pom file in META-INF that maven uses when your jar is used as a dependency and this is how it knows there is more dependencies, however when you shade this gets kind of screwed up because some of the dependencies are technically not dependencies no more as you just put them in your jar, so dependency reduced pom means, that it will remove dependencies from the pom in your compiled jar if they were shaded into your jar

#

setting it to false prevents maven from doing that

#

generally you should create it so that transitive dependencies can be picked up properly

#

but most of the time, it doesn't really matter as long as you document your project appropriately as well

#

if you are making an API that shades in some libs to be part of your API, you should generally set that false for the setting

#

for everything else, it should be true

tardy delta
#

so i can set it to true?

wet breach
#

if you want. It isn't going to do anything terrible to your compiled jar or project regardless of the setting

tardy delta
#

hmm i'll just leave it away

agile sinew
#

Does anyone know about NoteBlockAPI here?

spiral light
#

what is the problem maybe we can help you anyway

agile sinew
#

I want to stop RadioSongPlayer

#

but if I do, it cant play again

#

I want to reset

spiral light
#

you should look for help on their page ^^

agile sinew
#

I think it is radioSongPlayer.setLoop(true) but it is deprecated

tardy delta
#

does it say what to use instead?

agile sinew
#

perhaps

ivory sleet
#

Yeah

#

Repeat mode

#

setRepeatMode

tardy delta
#

🍞 🦆

tardy delta
#

why do both HikariDataSource and HikariConfig have the ::setDataSourceClassName method?

wheat flame
#

how can I use the spigot mappings for NMS on 1.18.1?

quiet ice
#

I do not think that they exist for 1.18.1

young knoll
#

Spigot mappings are dead

wheat flame
#

bruh

#

why

#

will they come back?

young knoll
#

No?

#

Us mojmap

wheat flame
#

ugh

wheat flame
quiet ice
#

why that

spiral light
vernal minnow
#

if i want to connect a player to a server in a bungeecord plugin, but the server is not online, then the connect command simply says that no server was found in the chat, but how do i get a response in the code if the server is online or not?

lost matrix
vernal minnow
#

how do i check if the server is online?

lost matrix
#

idk... get the servers inet address and ping it

quiet ice
#

alternatively do a more proactive approach and do a requirement that the server needs to ping the bungee server every few minutes, if it didn't it might be because it is not alive

#

A bit harder to pull off though and does not have a real benefit, but I've posted it anyways just for the sake of showing that there are multiple ways of solving this problem

lost matrix
#
  1. Get the targets IP and port via plugin messaging channel
  2. Ping the address
boolean reachable = InetAddress.getByName(ip + ":" + port).isReachable(3000);
#

Hm this looks like it deserves a utility class...

tardy delta
#

does this looks good? only wrong port xd

lost matrix
quaint mantle
#

I woudllnt do code in constructor, but otherwise just pass data Source and provide a static factory method

#

Also consider using MessageFormat.format or string format() for jdbc url

acoustic pendant
#

do anyone know the 1.18 way of this packet: PacketPlayOutWorldBorder ?

lost matrix
#

Yeah its usually a better idea to have a pure configuration data class that you can (de)serialize. Instead of having a constructor handle that.

quaint mantle
vernal minnow
#
Runtime.getRuntime().exec("/home/minecraft/bungeeServer/survivalServer/start.sh");

Can you use this command to start a server?

acoustic pendant
#

hmm

lost matrix
#

So center and size should be enough

acoustic pendant
#

i want to send the player a warning

#

but can't really use distance

lost matrix
tardy delta
#

performance?

lost matrix
#

permissions for example. If the admin uses different owners for your application and the bungee server then you will probably run into permission problems

#

And the shellscript must be executable (chmod)

quaint mantle
tardy delta
#

so you dont have to worry about types?

mossy prairie
#

How would I detect when someone buys something on a villager? Is there any event or I need to use InventoryClickEvent?

quaint mantle
quiet ice
#

The Objects#toString or the Object#toString()?

#

Eh, the difference is probably irrelevant here

alpine urchin
#

its no longer one packet

#

search for keyword "Border"

acoustic pendant
#

k thanks

echo basalt
#

set the warning distance hella high

#

and the center hella far

alpine urchin
#

ok me tho

acoustic pendant
#

B)

manic furnace
#

What is the advantage to Check for the command name before run the command?

lost matrix
simple summit
#

Is there a tick time remaining counter anywhere I can grab?

lost matrix
lost matrix
simple summit
#

Really I just need to know if the tick has overrun or not at the time i check

#

to know if i should schedule a task for this tick or next

pine island
#
    public void onDeath(PlayerDeathEvent E)   {
        Player player = E.getEntity();
        Entity killer = E.getEntity().getKiller();
        Player killerPlyr = (Player)killer;
        player.setGameMode(GameMode.SPECTATOR);
        if (killer instanceof  Player){

            getServer().broadcastMessage(ChatColor.DARK_RED + "! "+ player.getName().toUpperCase() + " was killed by "+ killerPlyr.getDisplayName());

        }else{ getServer().broadcastMessage(ChatColor.DARK_RED + "! "+ player.getName().toUpperCase() + " has died!");}
        Location killerLoc = killer.getLocation();

        killerPlyr.setNoDamageTicks(20);
        killerPlyr.addPotionEffect(PotionEffectType.INCREASE_DAMAGE.createEffect(15, 2));
        killerPlyr.addPotionEffect(PotionEffectType.SPEED.createEffect(60, 5));
``` hey, this is a event listener  and in the last 2 lines there are  potion effects i get them but for what feels like a tick
lost matrix
#

Because the executor has no idea how long the current tick will last.

simple summit
#

I'd be fine if it was negative in such an overrun for example

#

just some way to know if i should let a tick tick or keep spamming the current one 😛

lost matrix
manic furnace
#

Is there a way to color Arguments when you enter the m? Because by Default they are blue

ivory sleet
#

Yeah

#

Tho unsupported by spigot

simple summit
#

brigadier - see CommandAPI plugin

simple summit
#

that was for me lumina

pine island
#

ohk alr

ivory sleet
manic furnace
#

OK

ivory sleet
#

Idk if ACF supports colors, but mini wrote sth for suggestions I believe

pine island
ivory sleet
#

Perhaps extend the duration a bit?

pine island
#

no i think that wont help

ivory sleet
#

Bruh

ivory sleet
#

The duration is in ticks

pine island
#

why

#

WHY IS IT IN TICKS

ivory sleet
#

Because Minecraft’s primary time unit is in ticks

#

The game engine’s update rate is in ticks (ideally)

#

why wouldn’t it be

pine island
#

faior

#

fair*

#
        killerPlyr.addPotionEffect(PotionEffectType.INCREASE_DAMAGE.createEffect(300, 2));
        killerPlyr.addPotionEffect(PotionEffectType.SPEED.createEffect(1200, 5));
``` good now?
lost matrix
pine island
#

nah i need to summon on killer's loc

#

summon lightning*

lost matrix
#

Then use both events

ivory sleet
#

Believe it you could simply invoke Player::getKiller

#

which returns the last player who killed the player you invoke it on

pine island
#

wont really matter

#

it works fine rn

ivory sleet
pine island
#

i just wanted to fix the strength and speed!

lost matrix
pine island
#

not the player

pine island
lost matrix
#

didnt really read your code tbh

lost matrix
pine island
#

yep i know that

#

i was fixing tht rn

lost matrix
#

E is both dirty AND violates the java standard. And e is just dirty

spiral light
#

is it possible somehow to rewrite public static final fields in the newer java versions ?

ivory sleet
#

to?

spiral light
#

a custom thing

ivory sleet
#

such as?

spiral light
#

should i mention i wanne use reflection ?

lost matrix
ivory sleet
#

oh you wanna change the value of a static final field?

spiral light
#

i am stuck with shooting pigs instead of arrows while /summon works correctly

ivory sleet
#

you might need to use unsafe****

#

but even then you can only change certain things

#

iirc setting value of static final fields is not possible anymore with reflection (regardless of type or anything else)

lost matrix
#

Is it a primitive field?

spiral light
#

no its EntityType

#

i saw unsafe and tryd to use but it does not work too

ivory sleet
#

it should

#

given that you use it correctly ofc

lost matrix
dusk flicker
#

What's that bundler command or whatever it is?

ivory sleet
#

enums get inlined also

lost matrix
#

f

ivory sleet
#

and yeah, then we have jigsaw which may also prevent reflective manipulation

spiral light
#

i dont want the enum entitytypes... i want the nms-EntityTypes ... i can overwrite the entitys that spawn with /summon but for example shooting arrows it wont work and it will somehow shoot pigs and not arrows

lost matrix
spiral light
#

not rly... i want to make some changes to the arrow nms class ... so i need a new entity

lost matrix
spiral light
#

isnt it cleaner to have the default stuff overwritten then replacing every time ?

hollow sand
#

How would I be able to center a text and have its color?

#

I tried with StringUtils.center but to no avail

mellow swallow
#

hey

lost matrix
hollow sand
#

but for like

#

the default font

#

default mc font

#

thats what I'm most concerned about

lost matrix
#

Its not monospaced so you would need to know the pixel width of each character in the String you want to center

hollow sand
#

I see

#

thank you

lost matrix
#

And StringUtils.center should work just fine

#

Show some code @hollow sand

#

Just a guess: You forgot that Strings are immutable

mellow swallow
#

how to fix this

#

worldguard

lost matrix
#

lul

mellow swallow
#

how to fix this citizen plugin

quaint mantle
#

stop

#

not here

#

look at the channel

#

look

mellow swallow
#

kk

lost matrix
#

"Serious"
doubt

quaint mantle
#

lol

#

general is just help dev but even more general

lost matrix
#

I dont look into that channel

#

is it any fun?

#

Or as depressing as this one

spiral light
#

hmmm 7smile7,
what about reflection of private final... is that possible ?

ivory sleet
#

Yes

spiral light
#

oh wait, let me rewrite it with other words....
is that still possible like you would do in older java versions with reflection ?

ivory sleet
#

I believe sometimes inlined if it’s like
private final primitive variable = primitiveValue

#

Hmm

#

Well

#

You can just use setAccessible

#

and then change it reflectively

#

Always been able to

quiet ice
#

Except if the private member is in another module, then it is not possible

#

There are a few catches with that statement if I am right, but let's not list them

ivory sleet
#

Yes well he pointed out older versions

#

So I assume he meant pre strong encapsulation jep

quiet ice
#

well, I assume that "like under old java" suggests that JPMS is used

ivory sleet
#

¯_(ツ)_/¯

rustic bloom
#

Hello, I was wondering if there is a way to specifically check if an ItemStack is a tool?

spiral light
#

thought this should work ? @ivory sleet

ivory sleet
#

what field is it?

spiral light
#

private final

ivory sleet
#

idk

spiral light
#

its the factory for the entity

ivory sleet
#

like can you send the full stacktrace

#

and yeah ima look at that myself then

spiral light
#

wont help 😄

ivory sleet
#

btw your ide has marked it yellow

spiral light
#

i catch the error and print it ... probably thats why

ivory sleet
#

wat

#

no I mean it has analyzed sth

spiral light
#

wut

ivory sleet
spiral light
#

you mean this ?
yeah its because the obfuscated name is bm ...

ivory sleet
#

oh right

lost matrix
#

Pretty sure that you can achieve what you want without tinkering with those fields. Minecraft is quite data driven already.

spiral light
#

i was pretty sure it will work too

ivory sleet
#

okay im trying it out myself free soccer

spiral light
#

but somehow player shooting arrows will directly use the Field in EntityType instead of catching it from Registry

proven river
#

How can I make it so then when I remove a players health from the maxheath attribute it will keep the data and not reset them to full 20 hp and keep them at for example 18hp ?

lost matrix
proven river
#

wdym?

lost matrix
#

If you change the GENERIC_MAX_HEALTH attribute then the players health should not be changed as a result.

proven river
#

Hmm okay weird I'll take a look again and see what might be causing it

lost matrix
#

Be aware that im only about 75% sure about that.

proven river
#

Yea, All my code currently does is get the value of their hp then remove - 2 but it resets to 20 every time

lost matrix
#

What spigot version are you using?

proven river
#

1.18.1

lost matrix
#

Hm show me your code then

#

If it resets the health just set it again after changing the attribute

proven river
#
        Player player = e.getPlayer();
        double PlayerHP =  player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
        if(!player.isDead()){
            player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(PlayerHP - 2); // TEST THIS !!!!!
        }
    }```
patent horizon
lost matrix
proven river
#

Where would I be able to change that?

lost matrix
#

spigot.yml i think

proven river
#

Alright I'll have a look

lost matrix
#

And you should not get the value after all modification but the base value

ivory sleet
#

@spiral light

patent horizon
#

this hurts my knees

ivory sleet
#

oh

#

yeah

#

lol

#

lets not look at that x)

tardy delta
#

._.

lost matrix
# proven river Alright I'll have a look
  public void decreaseMaxHealth(Player player, double amount) {
    AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
    assert attribute != null;
    double current = attribute.getBaseValue();
    attribute.setBaseValue(Math.max(1, current - amount));
  }
proven river
#

ahhh

lost matrix
patent horizon
#

🥶

tardy delta
#

discord is the real shit fuck messenger 🥵

quaint mantle
#

Move to irc 🤓

patent horizon
spiral light
lost matrix
patent horizon
#

im grabbing the file from a shared network drive

lost matrix
quaint mantle
#

Objects reqnonnull

lost matrix
#
  public void decreaseMaxHealth(Player player, double amount) {
    AttributeInstance attribute = Objects.requireNonNull(player.getAttribute(Attribute.GENERIC_MAX_HEALTH));
    double current = attribute.getBaseValue();
    attribute.setBaseValue(Math.max(1, current - amount));
  }
lost matrix
#

Also viable:

  public void decreaseMaxHealth(Player player, double amount) {
    AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
    Preconditions.checkNotNull(attribute);
    double current = attribute.getBaseValue();
    attribute.setBaseValue(Math.max(1, current - amount));
  }
tardy delta
#

meh

lunar forge
#

Anyone know why this isn't working as it should be?

    public void play() {
        for (int i = 0; i < noteList.size(); i++) {
            Optional<Note> map = noteList.keySet().stream().findFirst();
            Note note = map.get();
            int wait = noteList.get(note);

            int totalWait = wait + ticks;
            ticks = ticks + wait;
            noteList.remove(note);
            new BukkitRunnable() {
                @Override
                public void run() {
                    if (!shouldStop) {
                        Bukkit.getOnlinePlayers().forEach(player -> {
                            player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 1, note.getPitch());
                        });
                    }
                }
            }.runTaskLater(Main.getInstance(), totalWait);
        }
    }```

In the noteList are 4 keys/values, but it only plays 2 notes.
#

My noteList is: HashMap<Note, Integer> noteList. The Integer stands for the amount of ticks it needs to wait to be played after a note has been played

tardy delta
#

heh you're dutch too uwu

#

it's crazy sometimes

hollow sand
#

I tried this

#

didnt work

#

its just sent out

lunar forge
hollow sand
#

the text on how you would normally send it

#

unless

#

would it work if I used a space character code?

#

like

#

0x20?

tardy delta
#

and never use Optional::get without ifPresent because on the end, if you removed everything it will throw an exception

lunar forge
#

In my code

tardy delta
#

instead of your for loop

#

i think using a normal for loop prevents you having a concurrent modification exception so that goes brr too

lunar forge
boreal sparrow
#

hello how do i add all online players to a list, and then randlomly select one :3

restive tangle
#

Bukkit.getOnlinePlayers() returns a list

#

Just choose a random from that

lunar forge
boreal sparrow
#

thank :DDD

tardy delta
#
public void play() {
Iterator<Map.Entry<Note, Integer>> iterator = noteList.entrySet().iterator();
  iterator.forEachRemaining(entry -> {
  int wait = entry.getValue();
  int totalWait = wait + ticks;
  ticks += wait;
  iterator.remove();
  Bukkit.getScheduler().runTaskLater(() -> {
    Bukkit.getOnlinePlayers().forEach(player -> player.playSound /* bla bla bla */);
}, Main.getInstance(), totalwait); 
});
}``` I would do something liek this
#

removing isnt even neccessary if you use ::forEachRemaining

quiet ice
#

What the hell

buoyant viper
#

i agree

tardy delta
#

looks weird uhm

boreal sparrow
#

hmm ik this is VERY specific how do i get all the online players in a list, select one (randomly), create a variable that contians the random selected player, and remove that random player from the player list

tardy delta
#

cast online player to an array and get one using a random

quiet ice
#

Like seriously, just use for (Map.Entry<Note, Integer> x : noteList.entrySet().toArray(new Map.Entry<Note,Integer>[0]))
much nicer

#

Or just don't modify the underlying array at all

boreal sparrow
#

hmm how do i cast online players to a array (im new sorry)

tardy delta
#

idk why he wants to remove

quiet ice
#

Or you could also go the iterator route but use while (iter.hasNext())

tardy delta
#

why not using a linkedhashmap

quiet ice
#

and remove with iter.remove

tardy delta
#

too much lambdas

quiet ice
#

that wouldn't require any lambdas

boreal sparrow
#

players = [Bukkit.getOnlinePlayers()];
this is sad help hmm

opal juniper
#

so why tf is there a org.bukkit.util.Consumer

tardy delta
#

something like Player[] players = Bukkit.getOnlinePlayers().toArray(new Player[0])

quiet ice
#
   for (Iterator<Note,Integer> iter = noteList.entrySet().iterator(); iter.hasNext(); iter.remove()) {
            Note note = iter.next();
            int wait = noteList.get(note);

            int totalWait = wait + ticks;
            ticks = ticks + wait;
            noteList.remove(note);
            new BukkitRunnable() {
                @Override
                public void run() {
                    if (!shouldStop) {
                        Bukkit.getOnlinePlayers().forEach(player -> {
                            player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 1, note.getPitch());
                        });
                    }
                }
            }.runTaskLater(Main.getInstance(), totalWait);
   }

somethign like that

tardy delta
#

put the !shouldstop out of the runnable

quiet ice
#

Or java 6, idk, either way, it was written when java didn't have a consumer interface

opal juniper
#

do we not think that should just be yeeted now

tardy delta
#

oh bruh

quiet ice
opal juniper
#

oh wait yeah cause plugins use it

tardy delta
#

imagine using the bukkit consumer instead of the java one

quaint mantle
#

Some 10 year old plugins

tardy delta
#

which are probably dead now

quiet ice
quiet ice
#

Though in the end it depends on the IDE and how many JVMs you have set up

boreal sparrow
#

List<Player> p = new ArrayList<>(Bukkit.getOnlinePlayers());
player.sendMessage(p);

#

how send message

quaint mantle
#

?learnjava

undone axleBOT
boreal sparrow
#

thanks

tardy delta
#

uhm no pick a player first and then send a message

quiet ice
#
List<Player> playerList = new ArrayList<>(Bukkit.getOnlinePlayers());
Player player = playerList.remove(ThreadLocalRandom.current().nextInt(p.size()));
player.sendMessage("Message");
quaint mantle
#

For loop

tardy delta
#

array 👀

quiet ice
#

that being said, it's pesudocode, did not test it and I won't test it anytime either

quiet ice
quiet ice
tardy delta
#

no need to remove

#

its a local method

#

idk where he uses it

quiet ice
#

The previous messages state that the playerlist should have the randomly selected player removed, if they meant kicking then yeah, arrays might be better otherwise no

#

But context is important, this could very well be an xy problem

tardy delta
#

oh idk

boreal sparrow
#

java: reached end of file while parsing

what does this mean?

#

error :ccc

tardy delta
#

you forgot a closing } somewhere

boreal sparrow
#

oo ok il look :DDD

tardy delta
#

probably at the end of your file

#

@quiet ice xx

quiet ice
#

wha

tardy delta
#

😳

quiet ice
#

java.lang.UnsupportedOperationException: Affection not implemented
at self/de.geolykt.sentience.io.WorldInterationManager.showAffection (native Method)
at self/de.geolykt.sentience.io.WorldInterationManager.processInput(WorldInterationManager.java:548285)
at self/de.geolykt.sentience.io.WorldInterationManager.lambda$start$0(WorldInterationManager.java:5486)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)

ancient plank
#

L no affection

rancid snow
#

is there a library for creating armorstands only 1 player can see
but that I can still see when they interact with the armorstand

late sonnet
boreal sparrow
#

very dumb question. i want to get all online players in a list/array. select one of those randomly and store it in a variable and remove it from the list (basically it removes one random player from the list of online players and stores it in a value)

rancid snow
quiet ice
#

Like, the list of all online players that is backed with the actual list of connected players or something else?

boreal sparrow
#

i wanna select one of the online players to be a hunter randomly, do some stuff to him, and everyone else tped and stuff

late sonnet
rancid snow
#

that wasnt there before

quiet ice
tardy delta
#

is thhe plugin logger preferred over the java util logger?

late sonnet
quiet ice
#

Even if you find hundreds of people using Logger.getLogger("Minecraft") (Why even use that?)

hasty prawn
#

sout 5Head

quiet ice
#

Paper nags you for using sysout

hasty prawn
#

Yeah, do you know why? Thonk

quiet ice
#

A really good question

hasty prawn
#

LOL

tardy delta
#

i saw plugin using the java util logger so i was wondering if it was better or something

hasty prawn
#

I always use sout for testing purposes, and then I use Logger if I actually want my plugin to print debug information or something so Paper will stfu

quiet ice
#

Yeah same