#help-development

1 messages · Page 1760 of 1

quaint mantle
#

can someone help me please

rough jay
#

you did not understand what I want to do

#

I don't want to read/load group name from file

fallow merlin
#

Ok now how do I turn these into an NBTCompound?

lavish hemlock
#

I mean

#

you probably can't turn them into a compound

#

and actually that means you don't need to parse the values on the right, as NBTBoolean doesn't exist

#

so just use an NBT string

idle wren
#

is there a way to let mobs spawn outside of the world border?

lavish hemlock
#

no

fallow merlin
#

And I have an idea of how to do that

echo basalt
fallow merlin
#

Is there a way to convert a Map<String, String> into an NBTCompound?

quaint mantle
#

<<<>>>????!?@?!@?!

quaint mantle
fallow merlin
#

that makes sense

idle wren
#

so i will try to use that

echo basalt
#

Yeah that's what I meant

lavish wave
#

How can I get the TPS of the server?

quaint mantle
#

/tps

young knoll
#

Afaik it’s not exposed in the API

#

It’s in CraftServer

lavish wave
#

I mean in code 🤦

quaint mantle
#

literally just look at what they give you when you execute the /tps command

iron palm
young knoll
#

Hi

quaint mantle
#

Paper has getTPS btw 🙂

young knoll
#

MD is coming for you

lavish wave
quaint mantle
#

Well, another reason to move...

young knoll
#

For a private plugin, sure

#

For a public plugin, not worth it

lavish wave
#

How can I make it?

quaint mantle
#

what

lavish wave
#

get the TPS

tranquil viper
#

    public MongoClient mongoClient;
    public MongoDatabase db;
    public MongoCollection<Document> history;
    
    @Override
    public void onEnable() {
        getCommand("cmd").setExecutor(new Cmd(this));
        initMongo();
    }

    private void initMongo() {
        mongoClient = MongoClients.create();
        db = mongoClient.getDatabase("PunishmentHistory");
        history = db.getCollection("StaffHistory");
    }

}```

https://hastebin.de/huyivukaqi.properties - anyone know why I am getting this error?
#

I have never had this issue when working with discord bots, all the sudden I try using mongo with spigot and I get that

tardy delta
#

how do i prevent this message?

lavish wave
#

How can I get the TPS with code? I have for one entire class space.

young knoll
#

CraftServer.recentTps or something

lavish wave
young knoll
#

Probably obfuscated in newer versions

#

So have fun with that

west oxide
#

hey , i am wondering if there's devs that are willing to work on my server with me, am looking for someone that would help me build the network and keep working together in the long run and benefit together

||i cant afford paying that much right now but am willing to once the server is working well||

young knoll
#

?seevices

#

?services

undone axleBOT
fallow merlin
#

How do I convert chunk relative coords to global coords?

quaint mantle
#

wdym

fallow merlin
#

I have some coords in a chunk (15,67,12 for example) and I need them to be global coords (243,67,402)

#

Because chunks have their own coords

eternal night
#

multiple the chunk cords by 16 and add relative cords

fallow merlin
#

Oml tysm

tardy delta
#

this is global to chunk

chunk.getBlock(Integer.parseInt(data[0]) & 0b1111,
                    Integer.parseInt(data[1]), Integer.parseInt(data[2]) & 0b1111))
fallow merlin
tardy delta
#

uh data[0] is x

#

1 is y and 2 is z

tender shard
tardy delta
#

i know

#

not mine

tender shard
#

looks it comes from a decompiler 😄

#

normally people just use /16 or << 4

tardy delta
#

its just
relative -> chunk

x & 0b1111
y 
z & 0b1111```
#

oh

#

im not normal

#

bitwise is not my stuff

hasty prawn
#

<< 4 is for nERdS

tender shard
#

yeah x & 0b1111 and x << 4 is basically the same, isn't it?

tardy delta
#

i dunno 🥺

tender shard
#

I also don't know, I just assumed it 😄

#

because if it's not the same, it wouldn't make sense that it works 😄

lavish wave
#
[19:05:16 INFO]: [LcraftAPI] Enabling LcraftAPI v1.0.0
[19:05:17 INFO]: [LcraftAPI] The Spigot Module Lcraft Languages API will be loaded.
[19:05:17 INFO]: [LcraftAPI] The Spigot Module Lcraft Languages API is loaded.
[19:05:17 INFO]: [LcraftAPI] The Spigot Module Lcraft Permissions API will be loaded.
[19:05:17 ERROR]: Error occurred while enabling LcraftAPI v1.0.0 (Is it up to date?)
java.lang.NoClassDefFoundError: de/lcraft/apis/languages/utils/spigot/ModuleCommand
        at de.lcraft.apis.permissions.main.spigot.ModuleMain.onLoad(ModuleMain.java:15) ~[?:?]
        at de.lcraft.api.plugin.modules.minecraft.spigot.ModuleLoader.loadModule(ModuleLoader.java:15) ~[LcraftAPI.API-1.0.0.jar:?]
        at de.lcraft.api.plugin.modules.minecraft.spigot.ModuleManager.loadModule(ModuleManager.java:76) ~[LcraftAPI.API-1.0.0.jar:?]
        at de.lcraft.api.plugin.modules.minecraft.spigot.ModuleManager.loadModules(ModuleManager.java:27) ~[LcraftAPI.API-1.0.0.jar:?]
        at de.lcraft.api.plugin.main.spigot.APIPluginMain.onEnable(APIPluginMain.java:24) ~[LcraftAPI.API-1.0.0.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Purpur-1393]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Purpur-1393]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Purpur-1393]```
lavish wave
# lavish wave ``` [19:05:16 INFO]: [LcraftAPI] Enabling LcraftAPI v1.0.0 [19:05:17 INFO]: [Lcr...
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:449) ~[patched_1.17.1.jar:git-Purpur-1393]
        at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:727) ~[patched_1.17.1.jar:git-Purpur-1393]
        at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:318) ~[patched_1.17.1.jar:git-Purpur-1393]
        at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1216) ~[patched_1.17.1.jar:git-Purpur-1393]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:321) ~[patched_1.17.1.jar:git-Purpur-1393]
        at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.ClassNotFoundException: de.lcraft.apis.languages.utils.spigot.ModuleCommand
        at java.net.URLClassLoader.findClass(URLClassLoader.java:433) ~[?:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:586) ~[?:?]
        at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:852) ~[?:?]
        at java.lang.ClassLoader.loadClass(ClassLoader.java:519) ~[?:?]
        ... 15 more
[19:05:17 INFO]: [LcraftAPI] Disabling LcraftAPI v1.0.0
lavish wave
tardy delta
#

java.lang.ClassNotFoundException:

lavish wave
#

the class exists

quaint mantle
#

In jar?

lavish wave
#

I made 3 APIs

  • Lcraft API
  • Lcraft Permissions API
  • Lcraft Languages API

But when I use in my Test Module the Permissions and Languages API the main api says, he dont know these...
I dont want to implement the Permissions API and Languages API to the Main API, because in future it will be
more apis.

lavish wave
#

Its saved localy

quaint mantle
#

Does the jar contains ModuleCommand class?

idle wren
#

how can i use worldborder with packets? so that i can make individual borders for players

lavish wave
#

But its not public maven reposetorys

quaint mantle
#

thats it

rough jay
quaint mantle
iron palm
#

uhh
https://pastebin.com/Lxm4rUKy
Why it isnt working when i go to the cords that were set in main-lobby.safezones?(im sure the Doubles are fine cause i got an output with a sendmessage and the values were true.)

rough jay
#

Bruh use pastebin for all that code

#

it takes the whole screen you just hide previous messages

eternal oxide
quaint mantle
#

Why are you using Double and not double

iron palm
#

oops

eternal oxide
#

a double is a primittive and will nto accept null.

#

it will better show if your config is working

iron palm
#

hm i'll edit that

quaint mantle
#

double is a primitive type, while Double is a class wrapper for double.

iron palm
#

btw what should i do for fixing my problem :

quaint mantle
#

Since double is primitive, its default value will be 0. On the other hand, Double variables are objects, so their default value will be null

eternal oxide
#

use a BoundingBox to check locations like you want

#

new BoundingBox(x,y,z,x1,y1,z1)

iron palm
#

i need to use it too

quaint mantle
#

This also applies to other primitives and their respective class wrappers:

int and Integer
long and Long
float and Float
boolean and Boolean

young knoll
#

Don’t forget Short and short and Character and char

quaint mantle
#

Ya

iron palm
#

chars are totally useless for me atleast.
i never used them

lavish wave
#

How can I upload a maven repository?

quaint mantle
iron palm
quaint mantle
#

char is useful when you work with string.toCharArray

young knoll
#

Don’t exclude data types

#

That’s mean

tardy delta
#

is looping through all players and checking if they have a permission a heavy operation?

quaint mantle
#

no

eternal oxide
#

depends how many players

tardy delta
#

like 20 so probably no

eternal oxide
#

then no

quaint mantle
#

pretty sure you wouldnt get more than 200 players on a single server

young knoll
#

Even then it’s probably not that significant

eternal oxide
#

probably not, so long as its not repeatedly. Its just a lookup

eternal oxide
#

errors?

iron palm
#

but no output

#

also*

eternal oxide
#

are you now using doubles?

iron palm
#

yes

eternal oxide
#

then switch to using a BoundingBox

#

your math is probably wrong

iron palm
#

oh

eternal oxide
#

then it should be working, if you checked it 🙂

iron palm
#

can it be because of <= , >=?

#

i mean should i change them to < , >?

eternal oxide
#

no, you shoudl change to a BoundingBox so you don;t need to know whether its > or <

#

you just call if (box.contains(location.toVector()))

eternal oxide
#

Nope random guess. I thought it looked pretty

quaint mantle
#

how do i get the player who throws the xp bottle in expbottleevent

rough jay
#

How do I transform a String like this [Kiwi, Banana, Strawberry] into a list of String like this ?

Fruits:
  - Kiwi
  - Banana
  - Strawberry
eternal oxide
#

expBottle is a projectile, you getShooter()

quaint mantle
eternal oxide
#

Projectile#getShooter()

quaint mantle
#

there is no .getShooter in the event

iron palm
young knoll
#

Did they say Event#getShooter?

rough jay
#

bruh .getShooter isn't a method from your event

quaint mantle
#

so how do i get the person throwing it

young knoll
rough jay
#

Projectile#getShooter()

quaint mantle
eternal oxide
quaint mantle
#

whts #

rough jay
#

!learnjava

quaint mantle
#

um

young knoll
#

You tried

#

?learnjava

undone axleBOT
rough jay
# quaint mantle whts #

Method#class
So when someone writes Projectile#getShooter() it means the method getShooter() comes from the class Projectile

iron palm
eternal oxide
eternal oxide
iron palm
#

Cannot resolve method 'contains(org.bukkit.util.Vector)'

#

nice

rough jay
eternal oxide
#

You used the wrong BoundingBox, or you are not using a recent version of Spigot

quaint mantle
#

would this work?

young knoll
#

Split the string on ","

#

And then Arrays.asList the array

eternal oxide
#

wrong BoundingBox import most likely

young knoll
iron palm
quaint mantle
young knoll
#

Sure

quaint mantle
#

great

iron palm
#

IT WORKED

#

Thanks Elgar

eternal oxide
#

np

iron palm
#

and f
i have to do the same thing for 4 more arenas like this

#

lol

eternal oxide
#

before you do

#

it would be better if you stopped storing each x,y,z,x1,y1,y2 and just store the locations of each two Vector positions

iron palm
#

hm

eternal oxide
#

config.set("path", location.toVector())

#

that will save a Vector to yoru config

#

you can load it as a complete Vector

iron palm
eternal oxide
#

actually you could just save teh BoundingBox

#

its serializable

#

just save the BoundingBox

iron palm
#

ok

tardy delta
main dew
#

hello i am trying to connect to this page in java and read the structure but i have an error Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: https://pl.namemc.com/search?q=Proscreeam1337
https://pl.namemc.com/search?q=ProScreeam1337 but in chrome every think work perfect

eternal oxide
#

you are probably ignoring a redirect in the header

main dew
#

wdym?

eternal oxide
#

Many websites auto redirect. If you do not process that redirect you will get a 403

rough jay
#

So I made this

if (yaml.getString("team_one") != null) {
    for (String str : yaml.getString("team_one").split("\\s*,\\s*")) {
        if (Bukkit.getPlayer(str) != null) {
            manager.setTeamGroup(Bukkit.getPlayer(str), Group.TEAM_ONE);
        }
    }
}

But yaml.getString("team_one").split("\\s*,\\s*")) gives me the player's name surrounded by [ and ]... Any idea how to remove them?

main dew
#

what do you mean about redirect? url doesn't change

eternal oxide
#
URL url = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);

URLConnection conn = url.openConnection();
conn.setReadTimeout(5000);
conn.addRequestProperty("User-Agent", "Mozilla/4.0");
conn.setDoOutput(false);

// Handle redirects.
String redirect = conn.getHeaderField("Location");
if (redirect != null){
    conn = new URL(redirect).openConnection();
}

try    (JsonReader reader = new JsonReader(new InputStreamReader(conn.getInputStream()))) {```
livid tundra
#

what's the event for something being thrown?(e.g. snowballs, potions, ect.)

rough jay
young knoll
#

replace or substring

eternal oxide
#

There shoudl not be any [] Are you sure its not from auto formatting in teh toString?

young knoll
#

Ah right, arrays have [] when run through toString

spare prism
#
if(BotController.getSessions().containsKey(player)) if(BotController.getSessions().get(player).equals(playerIp)) return;

Why the BotController.getSessions().containsKey(player) returns false if there is that key? (CraftPlayer{name=EstrangedFury}:127.0.0.1)

young knoll
#

Use UUID

#

Player references change upon reconnecting

spare prism
young knoll
#

UUID will be based on the name then, but you can still use it

young knoll
#

Do you have any other plugins

eternal oxide
# main dew https://paste.md-5.net/duyajunuwu.java https://paste.md-5.net/giyejimaga.rb and ...

Try using an HttpURLConnection instead ```java
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(5000);
conn.addRequestProperty("User-Agent", "Mozilla/4.0");
conn.setDoOutput(false);

// Handle redirects.
String redirect = conn.getHeaderField("Location");
if (redirect != null){
conn = (HttpURLConnection) new URL(redirect).openConnection();
}```

paper viper
#

raymando just wondering

#

what java version you using

#

it isnt related, but theres a new cool http api built into the jdk for later versions

eternal night
#

java 11 http client is pretty fun ^

paper viper
#

Yep

main dew
paper viper
#

what about this current thing

#

you are working on

main dew
#

now I change java 8 to 16 (only for test)

#

but nothing change

eternal oxide
#

I'd guess its looking for a cookie

quaint mantle
#

@eternal oxide hi, when i get the nbt tag compound of an item, even though i added my custom nbt called bottleType:grand, it returns null

#

what do i do

#

i've already told you

runic mesa
#

With EntityDamageEvent how do i get the player who damaged

#

or

#

wait

#

can i use getcause

#

yeah

quaint mantle
#

Why

runic mesa
#

Thank you! Ill use the event u said

rough jay
runic mesa
#

Im dumb, ive realized i need to use the same event

#

wait

#

No

#

Im lost in my own stuff rn

#

I understand

#

I just thought i couldnt use it but realized i can just move my code into this

#

tyvm

stone sinew
#

In NBTTags why is Unbreakable a byte?

unkempt peak
#

I think because there is no boolean type

#

Yeah

#

It just uses 1 or 0 as true or false

stone sinew
#

Yeah but instead of an int... its a byte...

unkempt peak
#

Byte is smaller

#

It's to save space

stone sinew
#

Not by much though. 1 is smaller than 1b in other forms xD

unkempt peak
#

An int is 4 bytes

dire marsh
#

anyone know some kind of thing where I can put annotations on fields then make all those fields editable in a gui without me having to write so much code for every damn field I want people to be able to edit

tranquil viper
#

    public MongoClient mongoClient;
    public MongoDatabase db;
    public MongoCollection<Document> history;
    
    @Override
    public void onEnable() {
        getCommand("cmd").setExecutor(new Cmd(this));
        initMongo();
    }

    private void initMongo() {
        mongoClient = MongoClients.create();
        db = mongoClient.getDatabase("PunishmentHistory");
        history = db.getCollection("StaffHistory");
    }

}```

https://hastebin.de/huyivukaqi.properties - anyone know why I am getting this error?
quaint mantle
#

How can i make minion-skeletons that kill everyone but you?

unkempt peak
tranquil viper
#

I copied the same pom from a working project and added spigot

#

It only seems to give me that error when trying to do it in the onEnable()

#

psvm works fine no errors

unkempt peak
#

Sorry I don't have experience with mongo

grand flint
#

How can I check if an item has a certain word in it's lore?

tranquil viper
#

Get the meta and then check the lore

unkempt peak
#

lol

grand flint
#

How to check the lore??

unkempt peak
#

Get the ItemMeta and use getLore()

tranquil viper
#

I also recommend stripping the lore of any chat colors when checking

grand flint
#

Yep

#

I got the itemmeta but how do I check the lore?

unkempt peak
grand flint
#

I got thelore

unkempt peak
#

So what's the issue?

grand flint
#

I am wondering how do I check if a word is in the lore?

unkempt peak
#

String.contains(anotherString)

hybrid spoke
#

check each line for that word

grand flint
#

Thank you

grand flint
hybrid spoke
unkempt peak
#

Yes

hybrid spoke
#

so you would have to iterate through that list

grand flint
#

Can I check only the first line

unkempt peak
#

Loop foreach string in getLore

grand flint
#

Because the custom item I have only has it in the first line

hybrid spoke
#

i mean, sure you could but once you change it your server will throw exceptions in your face

unkempt peak
#

Don't use lore to detect custom items

#

Use a pdc

grand flint
#

What is that?

#

I just have this thing where a player dies and they drop a potion

unkempt peak
#

PersistentDataContainer

grand flint
#

And I want to check if the potion is a player dropped potion by the plugin

hybrid spoke
#

in higher versions items has a place in the data file of bukkit to store namespacedkeys with values

grand flint
#

That's very useful

#

Do you have docs for that?

hybrid spoke
grand flint
#

Thank you

eternal oxide
raw coral
#

Im trying to use launch projectile to spawn a fireball out the player but how do i make it go slightly to the left

tepid talon
#

you could get the player location

#

then offset it

raw coral
#

but i want the angle to be slightly to the left

#

not where it spawns

#

like this

grand flint
#
public void onDamage(EntityDamageEvent event) {
        if (event.getEntity() instanceof Player) {
            Player player = (Player) event.getEntity();
            if ((player.getHealth() - event.getDamage()) <= 0) {
                event.setCancelled(true);

                PlayerCorpseEntity.execute(player);

                event.getEntity().getWorld().dropItemNaturally(event.getEntity().getLocation(), getRespawnItem(player));

                player.setHealth(20.0);
                player.getInventory().clear();
                player.setGameMode(GameMode.SPECTATOR);

            }
        }
    }
#

Why does this not drop the player's dead items?

#

What does .clear(); do

#

So it won't delete them right?

#

So it does delete them??

#

Why

#

It doesn't even drop them

#

Why would I want them to delete them lol

quasi flint
#

Is it possible to calculate the knockback a player should be affected with when he gets hit?

grand flint
#

I asked why it didn't drop them

quasi flint
#

Now, better question how?

grand flint
#

Well?

#

Why does it not drop the player's items

#

Actually the player keeps the items some how

#

i dont want to drop them

#

Why doesn't it just drop naturally

#

??

#

But he goes in spectator

#

Ye

#

and

#

after i put him into survival

#

tthe items are still in his inventory

#

Ye I guess

left swift
#

how can i make an entityarmorstand that has something similar to noclip? I would like to give it velocity, but when it's in a block it gets stuck

hybrid spoke
#

maths

grand flint
#

thats an event??

lavish wave
hybrid spoke
grand flint
#

nvm

left swift
#

What is the best idea to give armorstand a natural movement mob (e.g. like a pig)?

hybrid spoke
#
lavish wave
quasi flint
#

What would the method be exactly?

acoustic pendant
#

what is it used to move armorstands in a circle?

#

i mean

#

what type of code

quasi flint
#

Just setting the loc I guess

acoustic pendant
#
public boolean runCircle(Location loc, float radius, float speed) {
        double amount = 7;
        for (double t = 0; t < amount; t += 0.1){
            float x = radius * (float) Math.sin(t);
            float z = radius * (float) Math.cos(t);
            ArmorStand circle = (ArmorStand) Bukkit.getWorld("world").spawnEntity(new Location(loc.getWorld(), (float) loc.getX() + x, (float) loc.getY(), loc.getZ() + z), EntityType.ARMOR_STAND);
            circle.setVisible(false);
            circle.setGravity(false);
            circle.setMarker(true);
            circle.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
            Bukkit.getScheduler().runTaskTimer(CircleMarker.getInstance(), () -> {
                circle.getLocation().toVector().multiply(speed);
            }, 0, 1);
        }
        return false;
    }```
#

i have done something like this

#

but doesn't look to move

#

is this what you mean?=

quasi flint
#

Alrighty. Time to dig through nms code

raw coral
#

How can i shoot fireballs out of a dragons mouth, LivingEntity#launchProjectile isn't working for me

visual tide
#

when a player clicks in their own inventory when having a custom inventory open, will inventoryClickEvent.getClickedInventory().getHolder() return the custom inventory or the player's?

acoustic pendant
#

isn't that with arms movement?

crimson terrace
late sonnet
raw coral
#

what would the vector be

visual tide
crimson terrace
acoustic pendant
#

?

crimson terrace
#

then put that xyz into a vector and boom you have the thing youre trying to make

raw coral
#

just drag.location.toVector?

crimson terrace
#

come to think about it, there is probably a method for it

#

Ive always done it with math

acoustic pendant
#

ok, ty

raw coral
crimson terrace
#

velocity

#

I think

#

never seen the direction

visual tide
#

NMSophobia go brr

crimson terrace
#

if you set velocity it would probably go faster the further away the dragon is

raw coral
#

im spawning it at the drags loaction

#

and its just

#

still

crimson terrace
#

are you setting the velocity at least?

raw coral
#
val fireball = dragon.world.spawnEntity(dragon.location,EntityType.FIREBALL) as Fireball
                    fireball.velocity = dragon.location.toVector()
visual tide
#

nms isnt needed here, im just asking wether querying the holder of an inventoryclickevents inventory will return the player inventoryholder or the custom inventoryholder when the click in their own inventory

crimson terrace
#

setVelocity or so

raw coral
#

it is, thats just how kotlin works

crimson terrace
#

oh nvm me then

raw coral
#

fireball.velocity = fireball.setVelocity in java

crimson terrace
#

you probably wanna delay the velocity set by a few ticks

visual tide
#

oh lol

crimson terrace
#

for some reason it usually doesnt work when you set the velocity directly after spawning the entity

raw coral
#

Can you elaborate

#

Yea

#

Anyway can you elaborate on the using nms

#

The fireballs are just like this

#
val fireball = dragon.world.spawnEntity(dragon.location,EntityType.FIREBALL) as Fireball
                    object: BukkitRunnable(){
                        override fun run() {
                            fireball.velocity = dragon.location.toVector()
                        }
                    }.runTaskLater(SandboxCore.instance,2)
eternal oxide
#

The majority of the time you are spawning that fireball inside the dragon

#

dragon.getLocation().add(dragon.getLocation().getDirection())

#

or use the Entity#launchProjectile

subtle folio
#

Whenever I force respawn a player from a pvp battle, the still take knockback whilst respawning, is there a way I can prevent this? https://imgur.com/a/u71ESx7

young knoll
#

set their velocity to 0, 0, 0 after you respawn them

#

Might need to delay a tick

subtle folio
#

already tried setting velocity, ill try waiting a tick,

buoyant viper
acoustic pendant
#

Hello, i have this code:

    public boolean runCircle(Location loc, float radius, float speed) {
        double amount = 7;
        for (double t = 0; t < amount; t += 0.1){
            float x = radius * (float) Math.sin(t);
            float z = radius * (float) Math.cos(t);
            ArmorStand circle = (ArmorStand) Bukkit.getWorld("world").spawnEntity(new Location(loc.getWorld(), (float) loc.getX() + x, (float) loc.getY(), loc.getZ() + z), EntityType.ARMOR_STAND);
            circle.setVisible(false);
            circle.setGravity(false);
            circle.setMarker(true);
            circle.getEquipment().setHelmet(new ItemStack(Material.PUMPKIN));
            Bukkit.getScheduler().runTaskTimer(CircleMarker.getInstance(), () -> {
                circle.getLocation().toVector().multiply(speed);
            }, 0, 1);
        }
        return false;
    }
}```
 i'm trying to move the stands in circles, but it doesn't seem to do it... could anyone help me?
chrome beacon
rough jay
chrome beacon
#

I hope I didn't ping

rough jay
#

yes but how do I replace/substring?

#

Like this?

String playerName = str.substring(1, (str.length() - 1));
chrome beacon
#

Yeah like that

raw coral
#

Anyone know why these fireballs arent going to the point i set (-669,9,-275)

fireball.velocity = Location(dragon.world,-669.0,9.0,-275.0).subtract(fireball.location).toVector().normalize()

left swift
#

how can i add default movement to nms entity?

patent horizon
#

how would i check if a listener is already registered to the plugin

#

just loop through the list or is there an easier way?

visual tide
#

is there an easier way to get a HumanEntity's inventory's InventoryHolder than humanEntity.getOpenInventory().getBottomInventory().getHolder()?

granite burrow
#

Is there an event that fires when a player types a command?

patent horizon
#

isnt that what the implements CommandExecutor for....?

young knoll
#

There is still an event for it

raw coral
#

how can i give a player knockback

runic mesa
#

Im spawning primed tnt how would i make it not explode

jade igloo
#

so im using spigot/java to code plugin and i was looking at examples. they put super(Type.PLAYER_EGG_THROW, player); they wante me to replace Type with something but idk what that means. i have low iq sorry if this sounds dumb

young knoll
#

No idea what that code refers to, I don't recall anything like that in the API

jade igloo
#

public PlayerEggThrowEvent(Player player, Egg egg, boolean hatching, byte numHatches, Boat hatchType) {
super(Type.PLAYER_EGG_THROW, player);
this.egg = egg;
this.hatching = hatching;
this.numHatches = numHatches;
this.hatchType = hatchType;
this is the stuff before and after if u need

#

thats not all just a little of it

sullen marlin
#

seriously

#

events haven't worked like that for at least 10 years

young knoll
#

Explains why I didn't recognize it

sullen marlin
#

its for the old event system which was removed on 31 Jan 2012

#

so not quite 10 years, but almost

jade igloo
#

yea but can u help me?

waxen plinth
sullen marlin
#

find a better example

waxen plinth
sullen marlin
#

& what do you want to do

jade igloo
#

i want to make an egg spawn 100 boats when it breaks

waxen plinth
#

md which mob did you vote for

waxen plinth
#

And spawn 100 boats if it's an egg

#

Not sure why that's what you want to do but who am I to judge

sullen marlin
#

I didnt vote, & lol

#

what even won again

waxen plinth
#

allay

jade igloo
#

so theres no possible way to use the code i already have in there

sullen marlin
#

the code you posted so far makes 0 sense

#

its code from inside spigot not a plugin

#

suggest you find a newer tutorial

#

anything in the last 8 years should do

raw coral
#

I would just read the wiki lol

subtle kite
#

anything in the last 8 years should do
XD

torn shuttle
#

running sonarlint on my project for the first time... let's see how many issues it finds

#

hahaha 3202 issues

#

one issue every 12 lines of code, fantastic

young knoll
#

Nice

torn shuttle
#

man this is going to weigh on my conscience until it's down to 0

young knoll
#

Good luck with that

livid tundra
#

what's the difference between the getX function of a Location and the getBlockX?

candid galleon
#

getX returns the precise location, blockX returns the location rounded

worldly ingot
#

Floored*

#

Important distinction there

young knoll
#

floored I belie~ dangit

livid tundra
#

that's it?

young knoll
#

Yes

livid tundra
#

what's the best way(least amount of text) to teleport an entity 10 blocks into the air?

sullen marlin
#

e.teleport(e.getLocation().add(0,10,0))

livid tundra
#

so e.getlocation returns a copy?

sullen marlin
#

yes

livid tundra
#

thanks!

runic mesa
#

how would i make my mob not drop any of its armor

unkempt peak
runic mesa
#

Will that work for its armor ive given it too?

unkempt peak
#

Yes anything that is in its inventory will not be dropped

#

If you only want to remove armor you can remove each item from getDrops

runic mesa
#

Thank you

young knoll
#

LivingEntity#getEquipment#setXDropChance

unkempt peak
#

Huh I haven't used that but ig that might be easier

runic mesa
#

Oh

#

but then it wouldnt be able to drop custom items after right?

unkempt peak
#

Yeah you should be able to set all the drop chances to 0

runic mesa
#

yeah but i would like to add a custom item to drop after

unkempt peak
#

Well if your doing that it would be easier on death

#

You can just add it to the drops

runic mesa
#

oh

#

Wait

#

I could also just spawn the item at a specific location right?

unkempt peak
#

You could but that would be the best way of doing it

#

Wouldn't*

#

It's easier and better to just add it to the drops

runic mesa
#

got it!

restive mango
#

So, I have a class that is a command which destroys a block and adds it to a list. I want to set it so that when the server is shutting down, the onDisable logic runs through this list and replaces all these blocks. How do I create a list variable that lasts through multiple uses of the command, and can also be called from the onDisable logic?

livid tundra
#

maybe you should save the variable to a file every time you use it?

restive mango
#

i'd rather not constantly save and load it from a file if possible

#

if that's the only option i can do that

#

i just want to use a hashmap 😦

livid tundra
#

I don't know any other options, but I'm terrible at spigot, I started like 6 months ago, so there probably are other options

young knoll
#

Just make a list instance variable somewhere

#

And provide a way to access it

restive mango
#

what is a 'list instance variable'?

worldly ingot
#

A field of type List

young knoll
#

^

restive mango
#

i wish i knew words better

worldly ingot
#

I generally advise against fields inside of classes that implement CommandExecutor or Listener if those fields are to be accessed outside of those classes, so you're probably best to make a List in your plugin's main class, have a method to add to it and call that method in your command class

restive mango
#

oooh

#

i think i am starting to understand

worldly ingot
#

Suppose if you're restoring those blocks, you'd want to use a Map<Block, BlockData> or Map<Block, BlockState>, but it's up to you how you want to handle that

restive mango
#

yeah that was just a lie to more easily explain my problem

#

it's actually a map of Chunk keys and then an integer which is just the number of active bukkitrunnables using that chunk

#

basically while these chunks are 'in use' i have to prevent things like paintings or such from dying

#

and also prevent them from unloading

glossy venture
#

is there a way to create an entity which doesnt tick?

#

could be useful for armor stands

#

to make custom entities

#

so it uses a small amount of server resources

quaint mantle
#

maybe see paper source code for how they have an option for no tick armor stand?

worldly ingot
#

Doesn't 1.17 introduce the server-sided non-ticking entity that just holds data?

#

Or was that 1.18?

glossy venture
#

idk

#

would be nice

worldly ingot
#

Yeah. 1.17. Marker entity

#

It's an invisible entity with no hitbox that doesn't tick

restive mango
#

blarg

quaint mantle
#

@worldly ingot are you winning

#

i dont mean to intrude into your personal life

glossy venture
restive mango
#

im doing something stupid arent i

glossy venture
#

like heads?

restive mango
#

wait

#

i cant post images

#

god DANGIT

glossy venture
#

verify

worldly ingot
#

No, it's an invisible data entity ;p

glossy venture
#

sad

#

i may have to make my own entity class

#

nms

#

entity

restive mango
#

any idea what the actual proper syntax for this is

#

if (activechunks.putIfAbsent(CL, 1) != null) {}

glossy venture
#

seems good to me

restive mango
#

it says '!= cannot be applied to 'null', 'int''

glossy venture
#

no idea what ur trying to accomplish tho

restive mango
#

im just tryna make my code efficient

glossy venture
#

i think it returns the value

restive mango
#

yeah

hasty prawn
#

an int primitive can't be null

restive mango
#

it returns either the value, or null if no value was there

#

i mean that's sort of the point though

glossy venture
#

isnt it supposed to return Integer?

restive mango
#

@hasty prawn

glossy venture
#

instead of primitive int

#

as its generics

#

wtf

restive mango
#

nevermind

#

im an idiot

#

i dont know why my map can't use a primitive as the thing it's storing

#

but

#

OH WELL

#

works now

glossy venture
#

yeah

#

generics dont accept primitives

#

use Integer instead of int

#

and Float instead of float

#

etc.

restive mango
#

this is me tbh

#

but it

#

is working

#

so

#

LETS GO

glossy venture
#

nice

marble rivet
#

how do i make the worldborder instantly kill a player

glossy venture
#

check if they are out bounds

quaint mantle
glossy venture
#

or get border size and check

#

every 5 ticks or so

#

maybe idk

marble rivet
#

i only want to kill them once they are far enough that the border would start damaging them in vanilla

glossy venture
#

then search the values

#

and add them

quaint mantle
#

meh

#

maybe search it on

#

?google

undone axleBOT
marble rivet
#

couldn't i just kill them if the damage cause was whatever the world border's damage type is?

glossy venture
#

sure

#

if there a cause for that

quaint mantle
marble rivet
#

i think it may be suffocation

#

since there's no other way to take suffocation damage in this gamemode i guess i could use it

quaint mantle
#

then add that to your border size to get the block then just kill them

glossy venture
#
// schedule
Bukkit.getScheduler().scheduleSyncRepeatingTask(() -> {
  for (Player player : Bukkit.getOnlinePlayers()) {
    // get position and world
    Location loc = player.getLocation();
    World world = loc.getWorld();

    // get size and center of border
    int s = (int)Math.floor(world.getWorldBorder().getSize());
    Location c = world.getWorldBorder().getCenter();
    
    // check position
    if (Math.abs(loc.getX()) > c.getX() + s || Math.abs(loc.getZ()) > c.getZ() + s) player.setHealth(0);
  }
}, 1, 5);
#

this might work

#

havent tested it

#

wrote it in discord

#

might not even compile

marble rivet
#

i realized that you could set the damage buffer and damage amount of the worldborder which does exactly what i need

glossy venture
#

really

#

nicee

glossy venture
#

so it doesnt matter if ur negative or positive on the axis

#

but i have a better way

#
// schedule
Bukkit.getScheduler().scheduleSyncRepeatingTask(() -> {
  for (Player player : Bukkit.getOnlinePlayers()) {
    // get position and world
    Location loc = player.getLocation();
    World world = loc.getWorld();

    // get size and center of border
    int s = (int)Math.floor(world.getWorldBorder().getSize());
    Location c = world.getWorldBorder().getCenter();
    
    // check position
    if (Math.abs(loc.getX() - c.getX()) > s || Math.abs(loc.getZ() - c.getZ()) > s) player.setHealth(0);
  }
}, 1, 5);
#

that should work

buoyant viper
#

making a plugin to make lightning possibly strike players if theyre holding a metallic sword, will using LightningStrikeEvent suffice?

#

and also, is there a /good/ way to test if where they are standing, they have direct sky view?

#

like no blocks obstructing the path between lightning and player

#

right now im just doing this which feels like it should work but could be better

raw coral
#

how do i make a block like purple stained glass

#

using set type

#

setData is deprecated

unkempt peak
#

Material.PURPLE_STAINED_GLASS

undone axleBOT
buoyant viper
#

?di

#

^^ did for myself

tranquil viper
#
Player target = Bukkit.getPlayer(targetName.trim());```

Anyone know why target is returning to null? The targetName is a valid player
hasty prawn
#

Are they online

tranquil viper
#

yea

unkempt peak
#

Why are you using a string for players?

#

You should use UUID if possible

tranquil viper
#

I can't

#

because I can't even get the player

hasty prawn
#

Does it happened to be colored? I see you're getting this from a title

tranquil viper
#

In the first place

#

I use UUID after

hasty prawn
#

If it's colored you need to strip the color from it

tranquil viper
#

thanks

unkempt peak
tranquil viper
#

in a title

#

of a gui

hasty prawn
#

Yeah just strip the color then. ChatColor.stripColor I think

tranquil viper
#

yup works

#

thanks

#

:)

vast junco
#

How can I get the overworld when creating a new Location()?

tranquil viper
#

I am using the litebans api and when it gives me the startdate of a ban, it gives me a long string like: 1636258711477. Anyone have any ideas on how to convert it to an actual date lol

drowsy helm
#

Pretty sure thats just time in millis

#

Any date lib should have a method to convert it

tranquil viper
#

It’s a pretty bare api tbh, docs are horrible and don’t give much help at all

drowsy helm
#

Definitely millis time

tranquil viper
#

thanks

glossy venture
#
String string = "hello world sus"; // initial string
String[] words = string.split(" "); // split into words

// replace words
words[0] = "among"
words[1] = "us"

// concatenate
StringBuilder b = new StringBuilder();
for (String word : words) b.append(word);
#

a bit messy

#

but yea

#

oh wait u removed msg

tranquil viper
#

I forgot that I can just put it in an array xd

#

I remembered right before u sent

glossy venture
#

oh lmao

tranquil viper
#

thanks g

glossy venture
#

nice

quaint mantle
#

hello
i can connect to my mysql monitor using sudo mysql -u root

#

but my plugin cant

#

i run the server with sudo btw

#

no password

tranquil viper
#

idrk bout mysql but do you have to whitelist ips or smth

#

I know for mongo you have to manually whitelist ips that can access it

#

even localhost

restive tangle
#

How would I add nbt tags to an entity.

quaint mantle
#

Welp maybe im wrong meh

restive tangle
#

It's fine, I made a janky way of getting my entity through custom name.

latent dove
#

join gen 1

dry forum
#

how would i go about detecting when a player is 30 blocks away from an entity to do stuff? im trying to make a plugin that deletes entities when a player is 30+ blocks away from an entity then when a place is under 30 blocks away from it, it apppears. i just dont know what id use for it, a constant bukkit runnable to check the players locations and the entities or is there another way?

restive tangle
#

How do I compare entity.getCustomName() to a string, I've debugged and know that the string is exactly the name of the entity yet it returns false.

#
    public boolean mobExists(){
        for(Entity entity : world.getEntities()){
            if(entity.getCustomName() == null) continue;
            if(entity.getType() != this.entity) continue;
            if(entity.getCustomName() != this.name) continue;

            return true;
        }
        return false;
    }
summer scroll
dry forum
last ledge
#

        if(event.getMessage().contains(bannedWords)){```

umm how do i get CharacterList from config.yml
#

i meann and check if the chat has that words

young knoll
restive tangle
#

That does not work.

#

But I'll try once more.

glass tangle
quasi flint
#

event.setcancelled(true);

#

player.sendMessage("blablabla");

wicked inlet
#

hi
i have this custom recipe
problem is if i put 1 item per slot, crafting table shows the result and there is no need to put 32 item per slot
how do i make it neccessary to have at least 32 item per slot

quaint mantle
#

thats not supported in minecraft by default

#

you'd have to listen for craft event

idle wren
#

how can i make individual world borders for players using packets?

hollow sand
#

Anyone know why I get this error?

#

here is the code:

quaint mantle
#

you literally passed the plugin in constructor

#

if BrewingRecipe is your plugin

hollow sand
#

I was trying smth new and was following a guide

hollow sand
quaint mantle
#

you do runTaskTimer(recipe, 0L, 1L)

hollow sand
#

o

#

Thanks

quaint mantle
#

however imo you shouldnt run code in constructor, construct the object first, and only then schedule

topaz cape
ivory sleet
#

Yes, for the subcommands, use a map for the subcommand tokens rather than switching on the first argument

#

No

#

No worries, I’d also suggest taking a look at Java naming conventions again.

ivory sleet
#

?tempban @quaint mantle 7d false advertisement

undone axleBOT
#

Done. Enough chaos for now.

hollow sand
#

How would I be able to get a brewing ingredient by their meta?

#

nvm figured it out

delicate cargo
#

what version of buildtools should i use for a 1.16.5 server?

ivory sleet
#

latest

delicate cargo
#

ty

#

there isnt an org.bukkit

#

what did i do wrong?

ivory sleet
#

?

delicate cargo
#

after i built the path with buildtools there is no org.bukkit

ivory sleet
#

no because this is spigot?

delicate cargo
#

what?

#

there is supposed to be an org.bukkit part

ivory sleet
#

wat

#

no

#

the server jar contains a package with the name org.bukkit

#

but that's not a folder name

#

it might have been a group id back in the days

delicate cargo
#

i have found the buildtools file i used ages ago

slim kernel
#

is there a better way than doing 3 for loops to check if there is a block in a specific radius around a location?

ivory sleet
#

probably not

opal juniper
#

uh you can use location#distance

#

oh wait

ivory sleet
#

you to a certain extent need to iterate through three dimensions so three loops seems reasonable

opal juniper
#

i misread

delicate cargo
#

it was the spigot file, not the buildtools file!

#

im a fool

ivory sleet
opal juniper
#

🤷‍♂️ > 🤷

ivory sleet
#

🌞

quaint mantle
#

¯_(ツ)_/¯

#

better than everything.

quaint mantle
mortal hare
#

is there any fancy way to listen to bukkit events, or having Listener or Handler named class with Listener implementation is enough?

ivory sleet
#

🥲

quaint mantle
opal juniper
ivory sleet
#

idk if it's classified as fancy though

mortal hare
#

because i'm having two repeating blocks of code doing the same thing in both events and having one function interface to both of the events would be great.

#

ik there's registerEvent() method, but I really don't know where to get EventExecutor argument

#

I managed to dig up my NMS needs faster than this class lol

rough jay
#

Hey so I'm trying to write to yml to setup groups and all...

#

I made a method that adds a player to a group (the group being a String)

private void addPlayerToGroup(Player player, String group) {
    YamlConfiguration yaml = new YamlConfiguration();
    List<String> values = new ArrayList<String>();
    values.add(player.getName());
    yaml.set(group, values);

    try {
        yaml.save("plugins/MaxiCity/teams.yml");
    } catch (IOException e) {
        e.printStackTrace();
    }
}
#

but I don't know how to remove the player from the group now

#

there's no YamlConfiguration#remove or #delete...

quaint mantle
mortal hare
#

god damnit

#

i was going to write this 😄

rough jay
#

what about existing players on the category?

#

they will be removed

#

I don't want that

mortal hare
#

afaik YAML implementation of bukkit doesn't allow to add or remove entries from lists

#

you need to remove it from list and then set the list without the player

rough jay
#

yeah ok

mortal hare
#

i could be wrong tho, but I had this problem before, couple years ago 😄

rough jay
#

so I get the list, remove the player, and set the entry to new list without player

mortal hare
#

getStringList(java.lang.String) Returns a defensive copy. You have to re-set the value in the path. yes I was right

rough jay
#

Also I modified my first code tho

rough jay
tardy delta
#

how should i handle vanished players on my server? Right now when they vanish they are added to a Set<UUID> and when they leave the server vanished, they are removed from that set and written to a config file. Should i consider keeping them into memory until the server restarts or not?

mortal hare
#

depends what kind of vanish do you want to have

#

if you want to have persistent vanish, i suggest saving it to a file instead.

#

since you will be vulnerable to a memory leak

ivory sleet
#
class EventExecutorListener<E extends Event> implements Listener, EventExecutor {
  final Consumer<? super E> c;

  EventExecutorListener(Consumer<? super E> c) {this.c=c;}

  @Override public void execute(Listener l,Event e) {
    c.accept((E)e);
  }

  static<E extends Event> void register(Plugin plugin, Class<E> clazz, Consumer<? super E> blah) {
    EventExecutorListener<E> e = new EventExecutorListener<>(blah);
    plugin.getServer().getPluginManager().registerEvent(clazz,e,NORMAL,e,plugin,false);
  }
}```
dovidas sry for the wait but yeah
mortal hare
#

what does eventexecutor do

#

in bukkit

ivory sleet
#

it's a functional interface handling an event call from a listener

#

along with the event instance

mortal hare
#

shouldnt an eventExecutor pass the value back somehow to another listener

ivory sleet
#

the value?

mortal hare
#

i mean the event object

ivory sleet
#

well

#

bukkit has it like this

#

there exists an event executor for every Method

mortal hare
ivory sleet
#

pog, but yeah you might wanna take a closer look at the event system impl yourself

mortal hare
#

yea im looking into JavaPluginLoader class rn

ivory sleet
#

I forgot most details by now but there's a good reason why its a (Listener,Event) -> void

paper viper
#

thats sexy

#

let me copy and paste

ivory sleet
#

lol yeah

paper viper
#

so i look like pro coder

#

but its not my code

#

😎

ivory sleet
#

arent u alr pro coder

paper viper
#

Nah

ivory sleet
#

DeluxeMediaLibFunctionProviderAbstractFactory?

paper viper
#

lol

mortal hare
#

by utilising this trick i could encapsulate my handler class more

#

nice

ivory sleet
#

the biggest reason I see why you might wanna avoid the reflective system is because of speed but even then JIT does a fairly significant job in minimizing reflective invocation overhead

tardy delta
#

?paste

undone axleBOT
tardy delta
rough jay
tardy delta
#

uhh i'm using Set<UUID>

#

if you dont need to store a whole player object

mortal hare
#

which would be problem if there's big amount of players

#

prefer using Set or Map for this

tardy delta
#

and the one from set is?

#

O(1)?

mortal hare
#

well if its hashset its o(1)

#

amortized

opal juniper
paper viper
#

and also turn types like ArrayList -> List, HashSet -> Set

opal juniper
#

the issue is the player objects

#

they can go stale

paper viper
#

Finally, use private

#

cause encapsulation good

tardy delta
#

🙏

opal juniper
#

just make everything static cause if there are no instances there is less memory usage

paper viper
#

Yes

ivory sleet
#

😏

paper viper
#

the secret way

mortal hare
#

don't confuse him

#

static is bad in java OOP

ivory sleet
#

depends

opal juniper
#

it’s not bad

paper viper
#

its not bad yeah

opal juniper
#

just has its uses

tardy delta
#

any comments to my code?

paper viper
#

singleton like GSON or something lol

tardy delta
#

🎃

opal juniper
paper viper
#

show code

ivory sleet
#

I mean I have seen some pretty awful work arounds because "static bad" like a singleton for sneaky throws which could have been a simple utility

tardy delta
paper viper
#

private static final Set<UUID> vanishedPlayers = new HashSet<>();

#

😮

ivory sleet
#

you must die

opal juniper
#

private static

tardy delta
#

o:

paper viper
#

bar = Bukkit.createBossBar(new NamespacedKey(plugin, "vanished"), "Vanished", BarColor.BLUE, BarStyle.SEGMENTED_10);

#

dont do this

#

lmao

#

Store your namespaced keys

tardy delta
#

in a class?

ivory sleet
#

It's a shame NamespacedKey isn't 100% value based

paper viper
#

Yeah

mortal hare
#

for namespaced key you can make it static

#

since its constant

ivory sleet
#

Problem is it sometimes requires the plugin instance

mortal hare
#

wait nvm

#

it has plugin instance

ivory sleet
#

yeah well you can decide whether it is appropriate to make it a bit more coupled Ig

tardy delta
#

aaaaaaah

ivory sleet
#

not a huge deal in this case

paper viper
#

do NOT ever do that

#

lmao

tardy delta
#

i thought there was something going brr 🤔

ivory sleet
#

but its the main class pulse!

paper viper
tardy delta
#

it comes from AbstractCOmmand

#

i should better rename it to CommandHandler but yea

spiral dome
#

stop

quaint mantle
#

Just pass plugin through constructor, no reason to overcomplicate stuff 🙂

tardy delta
#

you re right but yea

#

me and dependency injection 🥺

#

i do it always like this

quaint mantle
#

but why

ivory sleet
#

thats not dependency injection

quaint mantle
#

constructors exists for a reason

paper viper
#

lol

tardy delta
#

it seemed unnecessary to me if there was a static way 🥺

paper viper
#

dont be lazy

ivory sleet
#

Even then there's little to no reason passing your main plugin class instance around to every other class, in fact if you need to use something like BukkitRunnable, create a mid-level component that requires your plugin instance then just pass that mid-level component to the command handler rather than directly passing the plugin instance to the command handler.

rough jay
tardy delta
#

mid-level component?

ivory sleet
#

yes

rough jay
paper viper
#

jesus thats so many things packed into one method

#

lol

tardy delta
#

whats a mid-level component?

ivory sleet
#
//highest ordered class
class JavaPluginImpl extends JavaPlugin {
  @Override public void onEnable() {
    var scheduler = new Scheduler(this);
    this.getServer().getPluginManager().registerEvents(new ListenerImpl(scheduler),this);
  }
}

//mid level component
record Scheduler(Plugin plugin) {
  public BukkitTask run(Consumer<BukkitRunnable> consumer) {
    return new BukkitRunnable() {
      @Override public void run() {
        consumer.accept(this);
      }
    }.runTask(this.plugin);
  }
}

//low level component
record ListenerImpl(Scheduler scheduler) implements Listener {
  
  @EventHandler void onApple(AsyncPlayerPreLoginEvent e) {
    this.scheduler.run((o) -> Bukkit.getPlayer(e.getUniqueId()).sendMessage("Yo"));
  }
}```
#

or smtng

mortal hare
#

why tf bukkit has its own consumer functional interface

#

when Java does provide one

ivory sleet
#

lol does it?

mortal hare
ivory sleet
#

lmao

tardy delta
#

lol

glossy venture
#

lmao

mortal hare
#

this is probably a relic from 1.7.2 craftbukkit days, when NMS was compiled only on java 1.7 or lower

#

because Java 8 introduced lambda expressions and functional interfaces, but still

#

its at least 8 years old

#

in the codebase lol

opal juniper
#

december 2016

mortal hare
#

interesting

#

but why

#

java 8 was released in 2014

#

here's lombok getters and setter impl in java 14

eternal night
#

Still no auto delegate 😪😪

ivory sleet
#

IntelliJ can do that 🍉

shrewd hemlock
#

is there a way to set a player flying an elytra and don't remove the chestplate?

tardy delta
#

when i execute this on a player in survival, they can fly but when i switch to creative and back to survival, their fly is gone

player.setAllowFlight(fly || player.getGameMode() == GameMode.CREATIVE);
#
@EventHandler
    public void onGamemodeChange(PlayerGameModeChangeEvent event) {
        Player player = event.getPlayer();
        if (CommandFly.getFlyingPlayers().contains(player.getUniqueId())
            && event.getNewGameMode() == GameMode.SURVIVAL)
            player.setAllowFlight(true);
    }
mortal hare
#

check the block type

twilit wharf
#

my scheduled delay thing isnt running, I think it has something to do with the delay, but I cant find anything on what the values relate to in seconds/minutes java int task = Bukkit.getScheduler().scheduleSyncDelayedTask(WorldControl.instance, () -> { try { connection = DriverManager.getConnection(UrlString, username, password); if (connection != null && !connection.isClosed()) { //if (useBackup) { loadBackup(); } everMySQLWorked = true; useBackup = false; } iterations[0] = 101; System.out.println("MYSQL Connection Resecured"); isConnected = true; } catch (Exception ignored) { System.out.println("MySQL Connection still unsecured."); } readyForNext[0] = true; System.out.println("ReadForNext is now true"); }, 1L);

mortal hare
#

if you're asking for values in second and minutes, the provided argument value is counted in ticks

#

20 ticks = 1 second

#

you're executing this after 1/20 second passes away

twilit wharf
#

alright, so putting 1L makes it 1 tick?

tardy delta
#

is there no method that accepts a TimeUnit? i think i saw it somewhere

mortal hare
#

yes

twilit wharf
#

hmm

#

but it still doesnt run

#

like

twilit wharf
rough jay
#

Why Suspicious 'List.remove()' in loop ?

tawny horizon
rough jay
#
private boolean removePlayerFromGroup(YamlConfiguration yaml, OfflinePlayer player, String group) {
    List<String> players = yaml.getStringList(group);
    boolean flag = true;
    for (int i = 0; i < players.size(); i++) {
        if (players.get(i).equals(player.getName())) {
            flag = false;
            players.remove(i);
        }
    }
    yaml.set(group, players);
    try {
        yaml.save("plugins/MaxiCity/teams.yml");
    } catch (IOException e) {
        e.printStackTrace();
    }
    return flag;
}
twilit wharf
mortal hare
tardy flame
rough jay
mortal hare
mortal hare
#

thus you should use iterator

foggy estuary
# mortal hare check the block type

``public void PlayerMove(PlayerMoveEvent e) {
Player p = e.getPlayer();
if(e.getFrom() == e.getTo()){
Block block = (((org.bukkit.Location) Location( 1,2,3) ).locToBlock(Material.GOLD_BLOCK));
Material material = block.getType();
if(material.equals(Material.GOLD_BLOCK))
p.addPotionEffect(new PotionEffect(PotionEffectType.HARM, 40, 100000));
}

}

private Object Location(int i, int j, int k) {
// TODO Auto-generated method stub
return null;
}``

#

like this?

rough jay
tawny horizon
#

Change it to @twilit wharf

                          System.out.println("About to run scheduler");
                          Bukkit.getScheduler().scheduleSyncDelayedTask(WorldControl.instance, () -> {
                            System.out.println("Started scheduled task");
                            try {
                                System.out.println("Line 1 of Try statement");
                                connection = DriverManager.getConnection(UrlString, username, password);
                                System.out.println("Line 2 of Try statement");
                                if (connection != null && !connection.isClosed()) {
                                    System.out.println("Line 3 of Try statement");
                                    //if (useBackup) { loadBackup(); }
                                    everMySQLWorked = true;
                                    useBackup = false;
                                }
                                System.out.println("Line 4 of Try statement");
                                iterations[0] = 101;
                                System.out.println("MYSQL Connection Resecured");
                                isConnected = true;
                            } catch (Exception ignored) {
                                System.out.println("MySQL Connection still unsecured.");
                            }
                                System.out.println("Line 5 of Try statement");
                            readyForNext[0] = true;
                            System.out.println("ReadForNext is now true");
                        }, 1L);
#

just to test it

twilit wharf
#

k

foggy estuary
#
    Player p = e.getPlayer();
    if(e.getFrom() == e.getTo()){
     Block block = (((org.bukkit.Location) Location( 1,2,3) ).locToBlock(Material.GOLD_BLOCK));
    Material material = block.getType();    
    if(material.equals(Material.GOLD_BLOCK))
    p.addPotionEffect(new PotionEffect(PotionEffectType.HARM, 40, 100000));    
    }
        
    }

private Object Location(int i, int j, int k) {
    // TODO Auto-generated method stub
    return null;
} ```
twilit wharf
#

thanks

tawny horizon
#

mhm

rough jay
tawny horizon
twilit wharf
tawny horizon
#

so nothing prints?

twilit wharf
#

just says About to run scheduler and then doesnt print anything

tawny horizon
#

send the code

twilit wharf
#
                WorldControl.instance.getLogger().log(Level.SEVERE, "MYSQL connection failed, retrying in 5 minutes.");
                final boolean[] readyForNext = {true};
                for (final int[] iterations = {0}; iterations[0] < 100; iterations[0]++) {
                    if (readyForNext[0]) {
                        readyForNext[0] = false;
                        System.out.println("ReadForNext is now false");
                        System.out.println("About to run scheduler");
                        Bukkit.getScheduler().scheduleSyncDelayedTask(WorldControl.instance, () -> {
                            System.out.println("Started scheduled task");
                            try {
                                System.out.println("Line 1 of Try statement");
                                connection = DriverManager.getConnection(UrlString, username, password);
                                System.out.println("Line 2 of Try statement");
                                if (connection != null && !connection.isClosed()) {
                                    System.out.println("Line 3 of Try statement");
                                    //if (useBackup) { loadBackup(); }
                                    everMySQLWorked = true;
                                    useBackup = false;
                                }
                                System.out.println("Line 4 of Try statement");
                                iterations[0] = 101;
                                System.out.println("MYSQL Connection Resecured");
                                isConnected = true;
                            } catch (Exception ignored) {
                                System.out.println("MySQL Connection still unsecured.");
                            }
                            System.out.println("Line 5 of Try statement");
                            readyForNext[0] = true;```
#

                            System.out.println("ReadForNext is now true");
                        }, 1L);
                    }
                    else {
                        iterations[0]--;
                    }
                }```
#

um, one thing

tawny horizon
#

it could be something wrong with WorldControl.instance

rough jay
#

bruh

#

use pastebin

#

at this point

#

too much code

twilit wharf
#

alright

tawny horizon
#

?paste

undone axleBOT
tardy delta
#

are there entities that are not instanceof Creature?

tawny horizon
#

umm

#

arrows

#

tnt

tardy delta
#

ah yes

twilit wharf
tawny horizon
#

snowballs

#

eya

#

yea*

twilit wharf
#

wait

#

I know

#

it is that

#

cause it is null, until it gets set, and the database connect thing runs before it gets set

tawny horizon
#

ahh

#

well, have that be the first thing set on plugin load