#help-development

1 messages · Page 2171 of 1

glass mauve
#

yea, but he created a SPIDER field

worthy yarrow
#

That was what I have been using, entityType and it didnt work when I tested it

#

not sure if that was the problem or not, but I have tested with entityType

earnest forum
#

just use EntityType.SPIDER

glass mauve
#

idk

earnest forum
#

good to have clarity

glass mauve
earnest forum
#

in ur code

glass mauve
#

just use EntityType.SPIDER

worthy yarrow
#

So as you said, entitytype is an enum, do i have to define spider within an enum?

earnest forum
#

its part of spigot

worthy yarrow
#

thats what I figured

glass mauve
#

no just do this: e.getDamager().getType().equals(EntityType.SPIDER)

earnest forum
#

dont use .equals

#

use ==

#

because its an enum

#

e.getDamager().getType() == EntityType.SPIDER

glass mauve
#

yea, but try to use equals for most stuff in Java

earnest forum
#

== for primitives and enums

worthy yarrow
#

alright

earnest forum
#

dont use .equals() for primitives and enums

worthy yarrow
#

    @EventHandler
    public void MobHitEvent(EntityDamageByEntityEvent e) {
        if (e.getEntity() instanceof Player) {
            Player player = (Player) e.getEntity();
                if (e.getDamager().getType() == EntityType.SPIDER) {
                    player.sendMessage(ChatColor.DARK_RED + "You have been given poison from the spider bite!");
                    player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 8, 1));```
earnest forum
#

can cause issues for some enums im pretty sure

worthy yarrow
#

Look good?

glass mauve
#

yea

earnest forum
#

yes that should work

glass mauve
#

you can change this:

if (e.getEntity() instanceof Player) {
   Player player = (Player) e.getEntity();
}
```to:
```java
if (e.getEntity() instanceof Player player) {
}
#

if you are on a newer Java version

worthy yarrow
#

I just have one more issue, cant load the plugin to test server getting error: "Caused by: java.lang.UnsupportedClassVersionError: me/nuclearkat/custommobeffects/CustomMobEffects has been compiled by a more recent version of the Java Runtime (class file version 60.0), this version of the Java Runtime only recognizes class file versions up to 52.0"

worthy yarrow
earnest forum
#

how do i

#

not know that

glass mauve
#

xD

worthy yarrow
#

So the class file version error... I'm ont sure how to fix that, is it something in intellij?

glass mauve
earnest forum
worthy yarrow
#

Java should be latest, minecraft is paper 1.8

glass mauve
#

maybe you need to change your Java version

earnest forum
#

ye

glass mauve
#

1.8 server?

worthy yarrow
#

I prefer 1.8 over others, just havent bothered to change it to 1.18

glass mauve
#

your Java is too new for 1.8

earnest forum
#

u need java 1.8

#

not java 17

glass mauve
#

you can easily change that in intellij

#

change it in your gradle or maven file

#

and in the project settings

worthy yarrow
#

Should I keep using java 17 and just change server version to 1.18.2?

#

or would that even do anything

glass mauve
#

so I recommend to always use the newest version

worthy yarrow
#

That's probably what I would want anyways

earnest forum
#

as long as u dont use nms nothing should change

#

actually no

#

some of the enum names change

glass mauve
#

Java 17 is 10000x better than 1.8

worthy yarrow
#

yada0 why would they change? I'm developing for 1.18.2 already

earnest forum
#

stuff changed in 1.13

#

the game is a lot different in that version

glass mauve
#

yea

earnest forum
#

a bunch of stuff changed in the api as well

glass mauve
#

its way harder to change version for mods than for plugins

earnest forum
#

yea

#

because everything in mods is NMS

glass mauve
#

I think they also removed 1.8.* documentation for Forge

#

and old versions generally

earnest forum
#

atleast in plugins we have spigot to handle most of the backend nms stuff

glass mauve
#

im using protocollib :D

worthy yarrow
#

I guess I just don't understand why I wouldn't want to just change server version to 1.18

#

Since I'm already using spigot 1.18.2 api

glass mauve
#

lol

worthy yarrow
#

Is that not correct?

#

The api doesnt change in relation to mc version?

earnest forum
#

some of it does

#

some stuff gets deprecated

glass mauve
#

it makes no sense to use spigot 1.18.2 api for 1.8

earnest forum
#

yeah lol

#

are they backward compatible?

#

are u using like viaversion or something

worthy yarrow
#

I have via installed yes

glass mauve
#

if one spigot api version works for every mc version why releasing more than one api version lol

earnest forum
#

more features

#

less need to go into nms

worthy yarrow
#

Why not just add features to the existing api

#

tested the custom mob effects and the spider still doesnt give poison when it hits me

#

Do I have to add a conditional that checks for the entitytype whenever a player gets hit?

glass mauve
#

can you show your current code

worthy yarrow
#

    @EventHandler
    public void MobHitEvent(EntityDamageByEntityEvent e) {
        if (e.getEntity() instanceof Player player) {
                if (e.getDamager().getType() == EntityType.SPIDER) {
                    player.sendMessage(ChatColor.DARK_RED + "You have been given poison from the spider bite!");
                    player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 8, 1));```
vocal cloud
#

Some features from the 1.18 API don't work on 1.8 and vice versa

glass mauve
#

you get the message in chat?

worthy yarrow
#

Neither

#

the potion effect or the message

#

What if I change, player.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 8, 1)); to ((Player) e.getEntity()).getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.POISON, 8, 1));

#

I tested that and it does not work

glass mauve
#

what if you hit a Spider instead of you getting hit

worthy yarrow
#

I suppose that could work, if I did that I'd like to add an additional condition that checks if they hit the spider with their fist

#

That way if you have a tool or weapon you won't get the poison effect

#

Another plugin I wanted to make was one where if you take fall damage it will give you slowness to sort of simulate hurting your feet

iron glade
#
if(target.getHealth() > 1) {

 target.setHealth(target.getHealth() - 1);
 target.playEffect(EntityEffect.HURT);

 }
   else if(target.getHealth() == 1) {

 target.setHealth(0);
//do some other stuff
 }```
#

why does that not kill the player -.-

#

It's in a repeating scheduler btw

maiden vapor
#

If the player’s health is 1.1, it won’t deal enough damage, leaving them with 0.1

earnest forum
#

make sure to floor the target.setHealth(target.getHealth() - 1);

tall dragon
#

if the players health is 1.1 it wont do damage at all

iron glade
#

didn't know player's could have something in between

#

regarding health

earnest forum
#

yes thats why its a double

tall dragon
#

well yea., its just not displayed

earnest forum
#

if you print the player's health it should say 20.0

#

if they're full

iron glade
#

yes

maiden vapor
#

Think you can just change > 1 to > 0. I think you need to avoid setting the hp to negative, can’t remember if that causes problems

iron glade
earnest forum
#

not the place

worthy yarrow
#

If I use EntityDamageByBlockEvent that returns the block that damaged the entity correct? And if so, does that apply to fall damage?

earnest forum
#

try it and see

#

it probably won't

#

since the block itself isn't causing the damage

maiden vapor
#

Maybe says something for dripstone since that increases fall damage, but not sure.

worthy yarrow
#

I looked it up in javadocs, it "Returns the block that damaged the player."

#

Might just have to play around with it a bit

earnest forum
#

the player landing on the block is causing the damage

#

the block isnt causing the damage

#

like how say, a cactus causes the damage

worthy yarrow
#

right

earnest forum
#

if you want to find fall damage

#

you can use entity damage event

#

check if the cause is DamageCause.FALL

#

and then u can get the block under the player

worthy yarrow
#

Ahhhhh that is exactly what I need

earnest forum
#

make sure to check if the entity is a player

#

theres no player damage event

#

for some reason

worthy yarrow
#

I know that's what I was stuck on

#

I kept trying to look for/create a fall damage instance

earnest forum
#

you can just ask here

#

tell us what you're trying to achieve

tall dragon
worthy yarrow
#

It's more about the experience, I'm pretty new to spigot api so instead of someone writing the code I need I'd like to write it myself so I can learn

earnest forum
#

yes we're not gonna spoonfeed u

#

rarely anyone does here

#

just gonna give some pointers on how to get it done

tall dragon
#

telling u which event you need isnt really doing it for you

earnest forum
#

what to look at, etc

worthy yarrow
#

if (e.getEntity().getLastDamageCause().equals(EntityDamageEvent.DamageCause.FALL))

earnest forum
#

use .getCause()

#

from LastDamageCause

worthy yarrow
#

ok

earnest forum
#

because that gives u an EntityDamageEvent

worthy yarrow
#

So essentially just being more specific?

tall dragon
#

pretty sure EntityDamageEvent has an getCause, right now ur using the last damage cause instead of the one that comes with the event. those might not match im not sure

earnest forum
#

yes it does

#

getLastDamageCause().getCause()

#

is what i meant

tall dragon
earnest forum
#

yes

#

getLastDamageCause gives you an EntityDamageEvent

#

its weird

#

wait

#

nvm

#

you are using the EntityDamageEvent lol

#

just use e.getCause()

#

sorry

tall dragon
#

yah

#

😄

worthy yarrow
#
            if (e.getEntity().getLastDamageCause().getCause().equals(EntityDamageEvent.DamageCause.FALL)){
                ((Player) e.getEntity()).getPlayer().addPotionEffect(PotionEffectType.SLOW.createEffect(5, 1));
                ((Player) e.getEntity()).getPlayer().sendMessage(ChatColor.DARK_RED + "You have injured your ankles and been given slowness for 5 seconds!");
                    ```
#

When I did e.getCause it just gave me @NotNull error

earnest forum
#

just use e.getCause()

#

thats not an error

worthy yarrow
#

Oops sorry

#

read it wrong

earnest forum
#

also

#
if (e.getEntity()instanceof Player player){

}
#

do this

#

so you can just use player instead of casting again

#

every time

#

this automatically casts the entity into player variable

#

if ur in latest java

worthy yarrow
#

"Patters in instanceof are not supported at language level 8"

earnest forum
#

ok then dont do that

#
if (e.getEntity()instanceof Player){
   Player player = (Player) e.getEntity();
}
thorny dawn
#
class HandleWorlds: Runnable {
    override fun run() {
        Bukkit.getScheduler().scheduleSyncRepeatingTask(Main().plugin, Runnable() {
            send("Test message.")
        },0,20)
    }
}

i am currently fucking around with runnables but why isnt this doing anything?

earnest forum
#

the way you cast it like 3 times is annoying me

worthy yarrow
#

intellij did that automatically when i did e.getEntity().getPlayer

tall dragon
tall dragon
#

exactly how you are starting the one inside it. but i dont think u really want them nested?

thorny dawn
#

does implementing Runnable not require me to use the run fun?

tall dragon
#

yes it does

#

but the thing ur running

#

ur just scheduling antoher runnable

thorny dawn
#

ooh

#

i see where ur going

#

how would i fix that

tall dragon
#

u could also send test message inside run

thorny dawn
#

so if i remove the scheduling method how do i set delays etc?

tall dragon
#

you need to actually start it somewhere

#

for example your onenable

#

but instead of using Runnable, use the class name

bright jasper
thorny dawn
#

like reference it in the main class?

tall dragon
#

no

#

like call the Bukkit.scheduleSyncRepeatingTask somewhere

#

for example in onEnable

thorny dawn
#

ooh

#

and instead of a new runnable put the class name?

#

got it

tall dragon
#

ye

thorny dawn
#

thanks a lot mate

tall dragon
#

since ur class extends runnable

#

👍

mighty pier
#

whats the difference between Bukkit.getScheduler() and BukkitRunnable?

earnest forum
#

you use the scheduler to start the bukkit runnable

mighty pier
#

e

thorny dawn
#
    fun createWorld(): String {
        val worldname = "testworld"
        val worldcreator = WorldCreator(worldname)
        worldcreator.type(WorldType.LARGE_BIOMES)
        worldcreator.generateStructures(false)
        val world: World? = worldcreator.createWorld()!!
        world?.worldBorder?.setCenter(0.0, 0.0)
        world?.worldBorder?.size = 100.0
        world?.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false)
        File(world?.worldFolder, "gamedata.yml")
        return worldname
    }

is file in line 11 not being created because the world may have not fully been created yet?

tall dragon
#

im not really that familiar with kotlin but possibly

thorny dawn
#

tried replacing world?.worldFolder with Bukkit.getWorld(worldname).worldFolder but it still did nothing

quaint mantle
#

I want the player to stop flying even I am doing this its not stopping to fly:

        if (!fly) {
            Player p = (Player) sender;
            p.setFlying(true);
            fly = true;
            p.sendMessage(ChatColor.GOLD+"Flying Enabled");
        }else if (fly == true){
            Player p = (Player) sender;
            p.setFlying(false);
            fly = false;
            p.sendMessage(ChatColor.GOLD+"Flying Disabled");
        }```
thorny dawn
quaint mantle
#

me?

thorny dawn
#

yes

quaint mantle
#

oh ok

thorny dawn
#

oh wait

#

yeah

#

do that

quaint mantle
#

ok

worthy yarrow
#

You would want to do something like p.setAllowFlight(true/false)

thorny dawn
#

^

worthy yarrow
#

Are you trying to make a /fly command?

quaint mantle
quaint mantle
#

IT WORKED

#

THANK YOU

worthy yarrow
#

No problem

heady spruce
#

hi, im trying to do a kit sorting. i have the general concept running. but im trying to add the items into a map, but the map is always empty, does anyone now why?

Map<Integer, ItemStack> newSort = new HashMap<Integer, ItemStack>();

    @Override
    public boolean onCommand(CommandSender s, Command c, String l, String[] args) {
        Player player = (Player) s;
        player.getInventory().clear();

        KitManager.givePlayerKit(player, KitManager.getKit("tank"));
        player.sendMessage("Sort test");

        for (int i = 0; i < player.getInventory().getSize(); i++) {
            ItemStack item = player.getInventory().getItem(i);
            if (item == null || item.getType() == Material.AIR) {
                continue;
            }
            newSort.put(i, player.getInventory().getItem(i));
        }
        
        return false;
    }

    @EventHandler
    void onChat(PlayerChatEvent e) throws IOException {
        for(int slot : newSort.keySet())
        {
            ItemStack item = newSort.get(slot);
            Bukkit.getLogger().info("test");
        }
        //e.getPlayer().getInventory().clear();
        KitManager.givePlayerKitWithCustomSort(e.getPlayer(), KitManager.getKit("tank"));
        Main.yamlConfiguration.set(e.getPlayer().getName() + "tankkit", newSort);
        Main.yamlConfiguration.save(Main.file);

    }
tall dragon
#

you know i have a theory

#

how do you register your command

#

@heady spruce

eternal night
#

Your theory is most likely right XD

heady spruce
tall dragon
#

my theory is that you register your command and listener both with a new class

#

meaning its well a different instance

#

so the filled map is in another instance

eternal night
#

Instance but yea ^

eternal oxide
#

you also never return true from your onCommand so the command will always display an error

sullen marlin
heady spruce
tall dragon
#

no i mean instance

#

for example you register your command with new YourClass() and you do the same for listener

#

those are now different instances of the same class

heady spruce
#

oh ok i read that wrong xd

eternal oxide
#

Either use teh same instance or make teh Map static

glass mauve
#

teh

tall dragon
#

can someone turn elgarl's pirate mode off?

eternal oxide
#

not editing it 🙂

tall dragon
#

haha

heady spruce
chrome beacon
#

Create a new file

thorny dawn
eternal oxide
#

Yes. File is only a pointer. Nothing needs to exist at that location

#

Not until you create it.

thorny dawn
#

gotcha

vivid flower
#

anyone knows what is inventory context 0x77 on 1.12.2???

crude cobalt
#

How can I make a local variable for each player that would work with threads?

eternal oxide
#

too vague a question

tardy delta
#

ah

heady spruce
#

does anyone know how to get a item of a map from a config?
example of the config: Koasyytank: 3: ==: org.bukkit.inventory.ItemStack type: POTION damage: 16389 amount: 3 so i tried to get the list, and then get the item from the list / map. but it wont work, does anyone have an idea?

eternal oxide
#

That is not a valid serialization of an ItemStack

#

Why not just serialize it properly and you can read it easily

crude cobalt
# eternal oxide too vague a question

I don't even know how to put it differently. I'll try this: I have a variable that should count the number of squats a player has made over a period of time. It must be a local variable, because it must be different for each player. After I want to create a new thread using Bukkit.getScheduler.scheduleSyncDelayedTask(). But I can't use local variable in thread. What to do?

buoyant viper
#

Why, Google, why.

#

just because you can doesnt mean you should

vocal cloud
#

Wack I didn't realize that was serverside too

buoyant viper
#

who do u think tells u the statistics

heady spruce
vocal cloud
buoyant viper
#

not if its persistent across (re)installs 😎

tardy delta
#

🤤

vocal cloud
#

I've never really looked at that data. Same with advancements

tardy delta
#

is there even a way to create advancements with the api?

#

i thought it included creating json files too

crude cobalt
vocal cloud
#

Use a database then

eternal oxide
#

put it in the players PDC, then subtract that value from the statistic

crude cobalt
thorny dawn
#

can someone help me with writing yml files using yamlconfiguration? (non config file) the docs are really confusing for me and couldnt find anything online

short raptor
#

Can anyone here help me with the LuckPerms api?

eternal oxide
#

LP have their own help Discord

short raptor
#

Ohh ok

#

Thx

#

I will wait for there

tardy delta
#
heady spruce
#

does anyone know to get a map from a config?

tardy delta
#

#getSection?

eternal oxide
#

ConfigurationSection#getValues(true)

tardy delta
#

nearly :(

heady spruce
#

xd

heady spruce
short raptor
#

I already looked there

tardy delta
#

what are you trying to do?

short raptor
#

Check if a user's in a group

#

Both the methods on the wiki don't seem to work properly

tardy delta
#

thats just Player#hasPermission

short raptor
#

Deopping the players is not an option so instead I tried this

#

But it seems to return true 100% of the time

#

Or at least for any existing group, idk what happens if pass a group name that doesn't even exist

tardy delta
short raptor
#

Oh

#

I think I know what I did

#

Yeah it's my bad I'm braindead

#

Should have been g -> g.getName()

crimson scarab
#

how can i simulate my own chorus fruit effect

tall dragon
eternal needle
#

hi i have a problem with that i have a plugin that a have made but i crash the server after som hours

i think it's this code https://paste.md-5.net/apuceporuy.java

pls help me i don't get any error or somthing it just crash

dark arrow
#
public static void catcher(Zombie zombie , Location location){
        zombie.setCustomName(ChatColor.RED+"Catcher");
        for(Entity entity:zombie.getNearbyEntities(3,3,3)){
            if(entity instanceof Player){
                Player player = (Player) entity;
                entity.addPassenger(player);

            }
        }

    }```This is suppose to put player as a passenger on zombie but it does not do that
tall dragon
#

huh

#

you look for entities arround the zombie

#

then try to add the player as passenger of another player

#

so himself probably.

eternal oxide
dark arrow
eternal oxide
#

ok, then this runnable is not crashing your server

dark arrow
#

its working

eternal needle
#

what kida things can crash the server?

tall dragon
dark arrow
eternal oxide
dark arrow
#

wierd loops

eternal oxide
#

that loop will never exit

eternal needle
eternal needle
crimson scarab
tall dragon
#

problem is ur while loop is doing bassically nothing

#

it generates a random number and does nothing with it

eternal needle
tall dragon
# crimson scarab yes

ah well get the player location, add some random offset. check if its safe, teleport

lost matrix
tall dragon
#

second of all: don't create a new Random instance every time

lost matrix
#

Same goes for NPEs

dark arrow
#

does the levitation effect does not work if mob has a passenger?

lost matrix
eternal needle
chilly spire
#

hi, ive recently created 2 different currencies using gemseconomy, and now im using moneyhunters for the players being able to get those currencies but i can only earn the defaul one, how can i set it to players to gain different currencies depending on the mob they ar killing/ore they mining? Thanks

lost matrix
tall dragon
eternal needle
chilly spire
#

umm, wym

#

oh

#

sorry

tall dragon
#

like, with code

chilly spire
#

this the development channel

tall dragon
chilly spire
#

k ty

lost matrix
eternal needle
#

ok

prime kraken
#

Hello, hope everybody are good, i've one question, I would like to give every 5 min an item to all the players of the server, what should I use ?

lost matrix
#

?scheduling

undone axleBOT
lost matrix
#

You can also use a Timer and start a bukkit runnable every 5mins

prime kraken
#

Nice thank you, the bukkit runnable will affect the performance of my server ?

lost matrix
#

Everything can impact the performance if you use it wrong

desert tinsel
#

why i have that error: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure when my connection method is: ```java
public Connection getConnection() throws SQLException{

    if (connection != null){
        return connection;
    }

    String url = "jdbc:mysql://localhost:3306/stat_tracker";
    String user = "root";
    String password = "";


    this.connection = DriverManager.getConnection(url, user, password);

    System.out.println("Connected to Stat Tracker Database");

    return this.connection;

}```
prime kraken
lost matrix
#

Use a connection pool like HikariCP

thorny dawn
#

ive noticed that creating an entire world with the server running is very resource heavy causing my server to fall behind. is there a way to avoid this?

tall dragon
#

hmm lets see here. dont?

dark arrow
#

i have made a zombie which forces player to sit on it but how can i make it so that it can fly

thorny dawn
dark arrow
#

levitation effect does not work on enitties with passrenger

chrome beacon
thorny dawn
#

its basically freezing the server for like 4-5 seconds and then created a thread dump

tall dragon
#

why would you create a whole world im confused

eternal oxide
#

Creating a single world should not lock up your server, unless your server is trash

tall dragon
#

that too

thorny dawn
#

im hosting it locally as im testing my things in there

#

so it should be fine

tall dragon
#

can we see the dump?

thorny dawn
#

maybe theres not enough ram allocated to it?

#

kk wait

#

uh its too large to paste here ill make a pastebin

tall dragon
#

?paste

undone axleBOT
dark arrow
#

i have made a zombie which forces player to sit on it but how can i make it so that it can fly

chrome beacon
#

Do you want the player to control the flying?

#

Otherwise just launch the zombie

thorny dawn
dark arrow
#

i just want to fly vertically (no control )

chrome beacon
dark arrow
eternal oxide
#

Entity#setVelocity(new Vector(0,1,0))

tall dragon
terse raven
#

this way you have a smooth transition and the player has (nearly) no control

dark arrow
terse raven
#

oh then just give the velocity to the zombie

#

and give him no ai

rough drift
#

I need to get crafted amount from a craftitemevent, how can I do that (reply when you can)

terse raven
#

then he wont move

dark arrow
#

i am trying to make it so that there are custo zombie around which can catch the player and fly , then leave them at a height

terse raven
#

good luck

rough drift
rough drift
chrome beacon
rough drift
#

yes but I need what has been crafted

#

so like if you shift click bread and make 1 stack

#

i want 64

#

not 1

terse raven
#

this event fires when a crafting recipe has been completed

#

in a crafting table

#

not when it has been crafted

eternal oxide
#

you check the output slot for the result

tall dragon
#

ye only it will only show 1 bread

#

if you shift click

#

u get more

eternal oxide
#

yep

#

Math

terse raven
#

ye

#

math

tall dragon
#

mathfs

rough drift
#

what math even is required

chrome beacon
#

So just check if player is shift clicking and calculate

terse raven
#

as i think that is called when it is crafted

#

not when it is laid out in a crafting table

chrome beacon
#

It's the otherway around

eternal oxide
#

If shift clicking, check smallest stack size in Matrix

rough drift
#

o smort

terse raven
chrome beacon
#

No 🙃

#

But it would make sense for it to be the other way around

#

Try it and see I guess

lost matrix
terse raven
#

PrepareItemCraftEvent is the correct one

dark arrow
#

the velocity launches at once

terse raven
#

and after he crafted

#

and calculate the difference

#

then you have the amount

lost matrix
#

Thats exploitable

terse raven
#

how

lost matrix
#

One tick diff means you can in theory drop items in the tick you are crafting

terse raven
#

if you calculate the amount of items could be crafted

#

with stuff in the crafting table

#

and the stuff that could be crafted after

#

you cant drop into a crafting table

lost matrix
#

You can always drop items on the ground

terse raven
#

yea but it wouldnt go into the crafting grid

terse raven
#

yea but it wouldnt go into the crafting grid??

#

if you calculate how much you could craft with the items in the crafting grid before and how much you could craft after

tall dragon
pastel juniper
#

I created a custom item, which is a paper. The problem is that players can make books with it, how can I disable the use of the specific paper???

opal juniper
#

can you change a particles color?

tall dragon
lost matrix
lost matrix
tardy delta
#

why not just checking the custommodel data?

tender shard
#

they didnt mention that their item has custom modeldata

tardy delta
#

dunno why you would create custom items without a custom texture ;p

tender shard
#

idk maybe its configurable or sth 😄

#

but yeah IF it has custom modeldata, that should be good enough

#

to prohibit crafting

tardy delta
#

ye i dont remember

iron glade
#

Is there a way to convert a project to a maven project in intellij?

prime kraken
#

Hello team, i'm trying to do a Schuduler and i get a java.lang.IllegalArgumentException: Plugin cannot be null I don't know what to do, my class where the scheduler is : ```public class Salaire {

public static Valdara plugin;
public Salaire(Valdara plugin) {
    this.plugin = plugin;
}

public static void salaireJoueur() {

    for (Player p : Bukkit.getOnlinePlayers()) {

        Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
            @Override
            public void run() {
                p.sendMessage("Execute 1sc");
            }
        }, 0, 20);

    }
heady spruce
#

hey, does anyone know how to fix an error. i have in my config a hashmap, everything works. but when the itemstack in the hashmap has a itemmeta, it wont work, does anybody why?
the config:

Koasyyassasin:
  '0':
    type: POTION
    damage: 16389
    amount: 3
  '1':
    type: DIAMOND_SWORD
    meta:
      ==: ItemMeta
      meta-type: UNSPECIFIC
      enchants:
        DAMAGE_ALL: 1```

my code: 
```java
try {
            
            @SuppressWarnings("unchecked")
            Map<Integer, Object> map = (Map<Integer, Object>) Main.yamlConfiguration.getValues(true).get("Koasyytank");
            System.out.println(map);
            for (int i = 0; i < kit.getKitSize(); i++) {
                if(map.get(i) != Material.AIR)
                p.getInventory().setItem(i, ItemStack.deserialize((Map<String, Object>) map.get(i)));
            }
        } catch (NullPointerException ex) {

        }```
prime kraken
tardy delta
#

^

iron glade
#

make plugin private

prime kraken
iron glade
#

I hope you know what static does and are not just abusing it

eternal oxide
tardy delta
#

static abuse hmm

eternal oxide
#

lots

prime kraken
eternal oxide
#

?scheduling

undone axleBOT
prime kraken
#

I've read like they said earlier

iron glade
eternal oxide
#

You are close, but your understanding of static is bad

#

don;t make things static simply because your IDE told you to do so

prime kraken
#

Thank you for the encouragement it's nice, it's help me, i will get more information about the static

#

Nice to know too for the static

iron glade
#

Don't worry, we all started somewhere

prime kraken
#

Thanks you a lot

eternal oxide
#

remove the static off everything

prime kraken
#

Good, i will do that

humble tulip
#

Add framework support i beleive

eternal oxide
#

then access it as an instanced object

Salaire task = new Salaire(this);
task.salaireJoueur();```
prime kraken
#

Nice that what I needed i think, i will save that i have to do that next time in my little head with little brain x)

heady spruce
#

hey, does anyone know how to fix an error. i have in my config a hashmap, everything works. but when the itemstack in the hashmap has a itemmeta, it wont work, does anybody why?
the config:

Koasyyassasin:
  '0':
    type: POTION
    damage: 16389
    amount: 3
  '1':
    type: DIAMOND_SWORD
    meta:
      ==: ItemMeta
      meta-type: UNSPECIFIC
      enchants:
        DAMAGE_ALL: 1```

my code: 
```java
try {
            
            @SuppressWarnings("unchecked")
            Map<Integer, Object> map = (Map<Integer, Object>) Main.yamlConfiguration.getValues(true).get("Koasyytank");
            System.out.println(map);
            for (int i = 0; i < kit.getKitSize(); i++) {
                if(map.get(i) != Material.AIR)
                p.getInventory().setItem(i, ItemStack.deserialize((Map<String, Object>) map.get(i)));
            }
        } catch (NullPointerException ex) {

        }```
tardy delta
#

dont think that you should cast it to a map

#

why not just iterating over koadsyyassasin

heady spruce
#

because i just changed to make sure its not because of the map

#

then i noticed its because of the itemmeta

tardy delta
#

and then doing yaml.getItemstack(koadyasssasin + str)

prime kraken
#

@iron glade @eternal oxide thank you for your help

#

I put, the Salaire task = new Salaire(this); in my main classe and the task.salaireJoueur(); on my enable, but doesn't work, no error in my log, but i had to search why to the schedule don't work

eternal oxide
#

No players = no scheduled tasks

maiden vapor
eternal oxide
#

if you create a single task for all players, instead of yoru current setup where you are creating a task per player

prime kraken
#

If i do that, it work for all player already in the server

tardy delta
#

where is that player coming from?

prime kraken
#

But no for the new player wo join

eternal oxide
#
    public static void salaireJoueur() {

            Bukkit.getScheduler().runTaskTimer(plugin, new Runnable() {
            @Override
            public void run() {
                 for (Player p : Bukkit.getOnlinePlayers()) {
                    p.sendMessage("Execute 1sc");
                 }
            }, 0, 20);

        }```
prime kraken
#

Ok i just had to switch

#

I will made like this

iron glade
#

Where am I supposed to find this "Add Framework Support" button??

#

Those explanations I found online are from like 2012

iron glade
#

Is there an easy fix for this?

#

Every § is some weird box with a ? inside now

earnest forum
#

dont use that character

heady spruce
#

just change the encoding to something else

earnest forum
#

use the ChatColors

heady spruce
# iron glade

use chatcolors, or just change the encoding to Cp1252 something else

eternal oxide
#

No

#

always use UTF-8

hybrid spoke
iron glade
eternal oxide
#

If you didn't save as UTF-8 you will get corrupt characters when you load it up as UTF-8

heady spruce
#

i never had problems with other encodings idk

earnest forum
#

yea change it to UTF-8 but that characters a lot more annoying to use

#

because u gotta copy paste it every time

iron glade
#

It was an old eclipse project which I just loaded in intellij

eternal oxide
#

You will when you start trying to use kanji or other Asian languages

heady spruce
tender shard
#

ALWAYS USE UTF8

heady spruce
#

ok

#

i understand

vocal cloud
#

Alcohol rant inc?

tardy delta
#

when is UTF16 becoming a thing

tender shard
eternal oxide
#

wait till we get so many emoji we are upto UTF128

vocal cloud
# tardy delta when is UTF16 becoming a thing

UTF-32 (32-bit Unicode Transformation Format) is a fixed-length encoding used to encode Unicode code points that uses exactly 32 bits (four bytes) per code point (but a number of leading bits must be zero as there are far fewer than 232 Unicode code points, needing actually only 21 bits). UTF-32 is a fixed-length encoding, in contrast to all oth...

tender shard
#

wtf

#

no

tardy delta
#

🥳

tender shard
#

FIXED LENGTH?!

#

why fixed length

#

the big advantage of utf8 is that it's NOT fixed length

vocal cloud
#

Nothing quite like wasting hard drive space

#

The main disadvantage of UTF-32 is that it is space-inefficient, using four bytes per code point, including 11 bits that are always zero.

tender shard
#

well it's not about hard drive but it's a problem for stuff like embedded devices that only have like 4kb or sth

eternal oxide
#

Remember when we worked with Bits and Nibbles as most computers had 8k of memory. Those were the days.

tender shard
#

thank god I wasn't born back then lol

#

my first PC already had like 128 mb of ram

eternal oxide
#

The first computer I actually owned myself was in 1982. a Singlair ZX Spectrum.

heady spruce
#

Caused by: java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class org.bukkit.inventory.ItemStack (java.util.LinkedHashMap is in module java.base of loader 'bootstrap'; org.bukkit.inventory.ItemStack is in unnamed module of loader 'app')
Does anyone know why im getting this error?
What im trying to do is get an map from a Config that has ItemStacks, what i noticed it it works, but when the Item has a Meta, it wont work? Does anyone know why?

Here is some code:

public static void givePlayerKitWithCustomSort(Player p, Kit kit) {
        try {
            

            Map<Integer, Object> map = (Map<Integer, Object>) Main.yamlConfiguration.getValues(true).get("Koasyyassasin");
            System.out.println(map);
            for (int i = 0; i < kit.getKitSize(); i++) {
                if(map.get(i) == Material.AIR) {
                    continue;
                }
                p.getInventory().setItem(i, (ItemStack) map.get(i));
            }
        } catch (NullPointerException ex) {

        }

    }```
if there is something wrong just let me know.
tardy delta
#

bruh why dont you iterate over the itemstacks?

tender shard
eternal oxide
#

(ItemStack) map.get(i) will always fail

tender shard
#

instead of doing get, use getItemStack

eternal oxide
#

deserialize it, or use config.getItemStack

heady spruce
eternal oxide
#

try it and see?

heady spruce
#

still only works with the items that doesnt have an itemmeta.

eternal oxide
#

reading a properly serialized inventory```java
List<Map<String, Object>> inventory = (List<Map<String, Object>>) map.get("inventory");

for (Map<String, Object> item : inventory) {
ItemStack stack = ItemStack.deserialize(item);
this.items.add(stack);
}```

prime kraken
#

Does an API or something exist to do custom inventory size and not have a multiplier of 9 ?

eternal oxide
#

This is if you don;t use getItemStack

tender shard
#

that's not possible

#

the client doesn't understand it

tardy delta
#

hmm looks kinda clean now

prime kraken
#

Nice thanks !

iron glade
tardy delta
heady spruce
#

wait nvm

#

i figured it out

tardy delta
#

dont abuse static or the uwu cat will die

iron glade
#

what's wrong here Caused by: org.yaml.snakeyaml.scanner.ScannerException: while scanning for the next token found character '\t(TAB)' that cannot start any token. (Do not use \t(TAB) for indentation)

#

Didn't use tab a single time

tardy delta
#

yaml uses spaces instead of tabs

eternal oxide
#

used Tab to indent instead of spaces

tardy delta
#

use a yaml validator to check

iron glade
#

I just wrote it completely new

heady spruce
iron glade
#

Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml

#

now it's getting funny

crimson terrace
#

(/ω\)

heady spruce
crimson terrace
#

(*/ω\*)

#

there we go

iron glade
#

In my src folder

#

as always

tender shard
heady spruce
tender shard
crimson terrace
#

°w°

tender shard
#

it should normally be in /src/main/resources/

heady spruce
#

if you are using maven u have to put it in resources ig

tardy delta
#

-<

iron glade
tardy delta
#

°w°

#

nah

heady spruce
tender shard
#

plugin.yml belongs to /src/main/resources/

tardy delta
#

fix your errors smh

iron glade
#

ah hell it got this project all messed when importing it from eclipse

tender shard
#

eclipse's maven integration is so shitty

heady spruce
iron glade
#

the resources folder isnt even there lmao

heady spruce
tender shard
trail pilot
#

hello

heady spruce
tender shard
trail pilot
heady spruce
trail pilot
tender shard
#

lol

heady spruce
tender shard
#

noone asked me how I am :<

tardy delta
#

how are yu alex

heady spruce
tender shard
trail pilot
#

i can use java 8 with newest versions?

tender shard
#

1.18 requires java 17+

#

or are you talking about plugins?

vocal cloud
#

Yeah, thankfully

trail pilot
heady spruce
tender shard
#

you can compile a plugin against EVERY java version

vocal cloud
#

You shouldn't though

tender shard
#

I always compile and code my plugins for java 8

trail pilot
#

yay

tardy delta
#

i just switched to java16 for the patterns

trail pilot
#

most of cool things are in newest java versions

tender shard
#

yeah true but also tbh there's no real reason to use newer versions code-wise imho

trail pilot
#

like new switch system are cool

tender shard
#

after java 8, nothing was added that's really like "required" or sth

trail pilot
#

yea

tender shard
#

I mean sure there's some nice features but it's really not worth it if you still wanna support 1.16

vocal cloud
#

Records are nice. Also instance of casts are nice.

trail pilot
#

yes

tender shard
#

true, but both can be replaced with very similar things using java 8

#

just create another local var for instanceof

#

and just create your own data class for the records

trail pilot
#

obv they are just optimized version

iron glade
#

whats going on here

trail pilot
#

lol

#

packages are fked

iron glade
#

indeed

trail pilot
#

you can only place classes on src/main/java

iron glade
#

yeah but idk why it's only src

trail pilot
#

then your group id - artifacts

trail pilot
tender shard
#

not a backslash \

iron glade
#

it did a \ automatically

trail pilot
#

new > directory > main - java

tender shard
#

weird

#

it doesn't do that for me

#

but anyway, you have to create a FOLDER, not a PACKAGE

trail pilot
tender shard
# iron glade

if you upload your whole stuff on github I'll fix it quickly

vocal cloud
#

Incoming PR

tender shard
#

nah I want write perms lol

vocal cloud
tender shard
#

including their github password

#

credit card details

#

etc

vocal cloud
trail pilot
iron glade
#

I think I got it

trail pilot
#

👍

iron glade
#

but this sheet just deleted the plugin.yml

#

lmao

trail pilot
#

anyway just use

#

its the best thing

vocal cloud
#

Until it crashes and throws a huge tantrum

iron glade
#

now it says it doesnt find main class

tender shard
#

it's basically 100% useless for spigot

#

it's good for forge and stuff

iron glade
tender shard
#

and it crashes my intelliJ like every day twice

tender shard
#

rightclick on the "java" folder, then do "mark as sources root"

trail pilot
tender shard
#

obviously click on "sources root" and not "Test sources root"

iron glade
tender shard
#

did you right click the java folder?

iron glade
#

yes

trail pilot
tender shard
#

right click your pom.xml. is there an option (at the bottom) like "Load as Maven project" or sth?

trail pilot
#

just use minecraft dev ij plugin

#

even its worst

tender shard
#

it has nothing to do with this

trail pilot
sharp flare
#

how does one instantiate a sql db when a plugin starts, do u open a connection and close it every query or make a connection and close it on plugin disable

tender shard
#

HikariCP

iron glade
#

Not that

#

now?

tender shard
sharp flare
tender shard
iron glade
#

I reloaded the project then it gave me the option to select as sources root

tender shard
#

do you also have a resources folder now?

sharp flare
trail pilot
#

oh wow i dont really remember how to setup an plugin lmao

tender shard
sharp flare
#

oh aight

tender shard
trail pilot
iron glade
#

it's still saying it doesn't find main class wth

tender shard
#

but imho maven is WAAAY easier to use

trail pilot
tender shard
#

english seems to be hard too lol

trail pilot
tardy delta
#

¯_(ツ)_/¯

trail pilot
#

:'

vocal cloud
#

I have to use Gradle with forge and it's a gunSelf moment

trail pilot
#

yea lmao

tender shard
#

I really dislike gradle because it uses a weird syntax, has a ton of integrated "lifecycles" that noone needs, always needs to download a huge 150 mb wrapper script that needs to constantly run in the background, etc etc

#

It's however also very powerful, sure

#

TL;DR: Both maven and gradle are fine and whoever prefers X will always dislike Y

#

but yeah both are totally fine to use

trail pilot
#

yea

tender shard
#

I learnt maven first so maven is my boooi

trail pilot
#

me gradle

tender shard
#

in fact I really hated maven at first lol

#

I had some discussion with someone about it on github

trail pilot
#

lol

tender shard
heady spruce
#

and i just ruined everything lol

tender shard
#

this dude spent like 5 hours explaining maven to me

#

I am so glad he did that

trail pilot
#

oh lol

#

im too lazy for read that

tender shard
#

understandable lol

trail pilot
#

anyway lombok is cool!

tender shard
#

I like it too

#

but don't say it too loud here

vocal cloud
#

No

tender shard
#

most people here hate it for no obvious reason

eternal needle
heady spruce
trail pilot
trail pilot
#

oh

#

lmfao

#

i use lombok for forge dev

tender shard
#

how to trigger people:

public class Test {
    
    public static final Test INSTANCE;
    
    private static Test getInstance() {
        return null;
    }
}
heady spruce
#

im officialy the most stupid person on the earth, im wondering why the map is empty but i clear the inventory before i add them

trail pilot
#

oh nooo i said it!!!

heady spruce
tender shard
#

the joke is that the field is public but the getter is private and that the instance is always null anyway

trail pilot
vocal cloud
#

The only reason I don't like Lombok is cause it's Lombok

#

If it was Lombawk I'd be pretty ok with it

trail pilot
#

damnnn

tender shard
iron glade
#

you gotta be shittin me, this thing set the package in the main class to main.java.me.minesuchtiiii.autoequip;

#

and exported without errors

trail pilot
#

oh wtf

echo basalt
tender shard
echo basalt
#

spigot code can be pretty triggering sometime

#

mfs do unsafe casts everywhere

tender shard
trail pilot
#
(long)int test = 1;```
echo basalt
#

this block only made the server crash 45 times when I tried to wrap CraftServer

trail pilot
#

;))

tender shard
vocal cloud
#

Waiting for the person who has yet to learn about for loops to post code

iron glade
tender shard
#

had those problems myself way too often

#

it's always when people use eclipse, then switch to maven, and now you try to import in intellij

iron glade
#

please tell me that's not always the case when importing from eclipse

heady spruce
#

wait i just fixed my error without even trying to fix it

tender shard
#

it happens when you do "normal eclipse project -> maven eclipse project -> intellij"

trail pilot
#

which is better

for loop or forEach

tender shard
#

depends

#

do you need the index?

#

no -> foreach
yes -> for

#

techincally both are the same

trail pilot
#

yea

tender shard
#

javac internally still creates an index but you can't access it

#

the bytecode end up being the same

trail pilot
#

Iterator?

tardy delta
#

Collection::forEach kekw

tender shard
#

an iterator is only useful if you need it

#

lol

tender shard
trail pilot
#

who gonna use it?

tender shard
eternal oxide
#

iterator when you want to modify the Collection as you process it

trail pilot
#

yes

tender shard
#

well for example if you iterate over collection and want to remove stuff

vocal cloud
#

I didn't know how much of 8 I didn't know untill I watched an old video from the release of 8 on what was new

tender shard
#

for example this won't work:

for(String string : myStringList) myStringList.remove(string);
#

you need an iterator for this ^

vocal cloud
#

removeif which takes in a consumer or w/e it's called

trail pilot
#

yea i know that, but like when you code a plugin

tender shard
trail pilot
#
switch(type) {
case 1 -> {
// code
 }
}```
#

i dunno but i like that syntax

tender shard
tardy delta
#

wait do you still need a case label in the new switch?

tardy delta
#

im probably confusing it with rust rn

tardy delta
#

ah im java17

trail pilot
#

im java8

tender shard
#

the enhanced switch was added in java 12

trail pilot
#

wait i dont remember lol

vocal cloud
#

Yeah the new switch is pretty slick.

trail pilot
#

i just read it somewhere

tender shard
#

it's nice but you can do the same thing since like forever

#

at least for the syntax thing

#

it does offer some new things though that cannot be done in java 8

trail pilot
#

syntax is more sexy

tardy delta
#

well you need a case

tender shard
#

but I dont remember which exactly

tardy delta
#

this wont work

trail pilot
#

that

tender shard
#

just the syntax is different

trail pilot
#

not in java 8

#

:'

sacred mountain
#

then upgrade

tender shard
#

of course

sacred mountain
#

java 16

trail pilot
#

still

case 1: {
}```

```java
case 1: //code
tender shard
#
public static void main(String[] args) {
        int myInt = 1;
        switch(myInt) {
            case 1:
                System.out.println("one");
                break;
            case 2:
                System.out.println("two");
                break;
        }
sacred mountain
#

can run on 1.8

tender shard
#

it's exactly the same thing

robust zenith
#

Hi guys, can I run plugins i created with Java 17/18 running a Server Version buildt in 1.8 for example creating a plugin in java 17 and using paper 1.12?

tender shard
#

you should do your plugins in the oldest java version you wanna support

#

if you want to do a plugin that should run on java 8 (spigot 1.12) you must compile your plugin for java 8

trail pilot
#

make plugin in the newest version then make an wrapper for it

tender shard
#

I ALWAYS code for java 8 unless I know this plugin is for 1.17 or 1.18+ anyway

tender shard
trail pilot
robust zenith
#

Yeah i am trying to do stuff with NMS but on what i can see something is not working in older minecraft version... for example i have problems with npc textures

vocal cloud
#

Just use that new Minecraft server rewrite that doesn't use any Mojang code

trail pilot
#

or make an thing that i dont remember cuz i dont have a good memory

tardy delta
#

well uh im trying to load an user from the database, and that user has alot of data like a list of homes, cooldowns, a kingdom. So should i load all of these within a new preparedstatement or what? im confused

trail pilot
#

how to implement it on my brain?

tardy delta
#

what is that site even doing

tender shard
trail pilot
#

nothing

tardy delta
#

fun

trail pilot
#

yea really funny

tender shard
trail pilot
#

xdd

tardy delta
#

anyways give me an answer for my question lol

tender shard
trail pilot
tender shard
trail pilot
kindred valley
#

?paste

undone axleBOT
tender shard
tardy delta
#

the databases hates you too 🙉

tender shard
#

I'd definitely load their data on join at once

trail pilot
tardy delta
rapid rock
#

is there any way i can change intensity of rain maybe making it drop more water or smth

#

or am i delusional

tender shard
tardy delta
#

im just wondering how to implement the queries as i need multiple queries from different tables

tender shard
#

the rain animation is 100% client side

trail pilot
#

where are java base code docs for be a good dev?

tender shard
#

all the server does is to tell the client "it rains now"

rapid rock
#

is that what i am limited to

trail pilot
#

yes

tender shard
tender shard
rapid rock
#

alr

trail pilot
#

javadoc rules

#

to respect

#

like myMethod()

#

ect i dont really remember some rules xd

kindred valley
#

Is there any tutorial to make the custom items with texture packs

vocal cloud
#

Java conventions 🤤

tender shard
trail pilot
#

anyway why ppl here hate static methods or fields?

tender shard
tender shard
trail pilot
#

:notreally:

tender shard
trail pilot
tender shard
#

static is for stuff that regards the class itself

#

static is for stuff that doesn't change between instances of this class

#

example:

trail pilot
#

yes

tender shard
#
public class Person {
  private final static int MAX_AGE = 150;
  private final String name;
  private int age;
  public Person(String name, int age) {
    this.name = name;
    if (age <= MAX_AGE) {
      this.age = age;
    } else {
      throw new IllegalArgumentException("No one can be older than 150 years!");
    }
  }
  public void setAge(int age) {
    if (age <= MAX_AGE) {
      this.age = age;
    } else {
      throw new IllegalArgumentException("No one can be older than 150 years!");
    }
  }
}
trail pilot
#

Person.MAX_AGE lol

tender shard
#

MAX_AGE is common between all persons in this case

#

so it's static

#

bad example of course but you get what I mean lol

#

also singletons

trail pilot
#

yes xd

tender shard
#

e.g. Bukkit.getOnlinePlayers()

trail pilot
#

yes its static

tender shard
#

obviously you never have more than one server running

#

so yeah the server is a singleton

#

same for every plugin

trail pilot
#

yea

tender shard
#

all plugins are singletons by design

trail pilot
#

gtg

tender shard
#

so in theory, EVERY field in the main class could be static

tender shard
trail pilot
#

yes

iron glade
#

is there a way to compare armor by its strength?

tender shard
#

what exactly do you mean with "strength"?

robust zenith
#

i have problems taking signature of player (SKIN nms)

iron glade
tender shard
#

but tbh there's only IRON, LEATHER, DIAMOND, etc

#

it's only 5 or 6 types anyway

iron glade
#

I want to make a player automatically equip armor from ground if it's better than his current armor

tender shard
#

okay but now imagine this

#

someone could have a leather chestplate that's insanely enchanted

#

so it's way better than iron armor

iron glade
#

yeah true I guess I have to take that into consideration

quaint mantle
tender shard
quaint mantle
#

ah okay

tender shard
#

I just wanted to show people that "static" isn't automatically bad

#

because MAX_AGE will always be 150 for every person

#

I know the example is stupid

quaint mantle
#

yup

hasty prawn
#

sTaTic AbUse