#help-development

1 messages · Page 2235 of 1

humble tulip
#

also using reflection with remapped is a pain

smoky oak
#

?reflection

small current
#

fully server side

humble tulip
#

ye ik there is the screamingsandals thing

#

PURPLE TREEs

smoky oak
#

can someone link me something that explains reflection

humble tulip
#

what does grass look like?

agile anvil
smoky oak
#

how'd that be an issue?

humble tulip
#

like a private field in a class

humble tulip
smoky oak
#

yea hence why i said use remapped

humble tulip
#

so u dont need to import every version of spigot into ur ide

smoky oak
#

remapped reflection should not change on other versions

humble tulip
#

it does?

#

obfuscated names change from version to version

smoky oak
#

the reason i use remapped is because it stays mostly the same

#

at least afaik

humble tulip
#

and even if you use remapped and build for one version only, sometimes, you wanna change a variable, but there is no method to do so and the variable in not public. so u use reflection, make the field accesible and set it

smoky oak
humble tulip
#

remapped leads to having a multimodule project with a module for every version that had a change

#

for sure it's useful

#

but sometimes, u cant avoid reflection/its just easier to go the way of reflection

smoky oak
#

ill just think about it once im told i can only do x with nms

crude loom
#

What's the difference between PlayerInteractAtEntityEvent and PlayerInteractEntityEvent?

small current
rough drift
#

how?

#

no texture pack?

#

oh wait, biome color?

humble tulip
#

setting biome color

#

ye

#

like here

rough drift
#

lemme just

humble tulip
#

how does grass look?

small current
#

not changed grass color

humble tulip
#

but isnt grass color determined by biome color?

rough drift
#

yesn't

#

it's determined by warmth iirc

humble tulip
#

mc is weird man

humble tulip
#

so why tf are trees purple

rough drift
#

they use biome color

#

oh wait

#

grass uses grass color iirc

#

there

#

close enough

humble tulip
#

what site is that?

rough drift
#

mc wiki

#

can you dm me the whole class

#

Making it a nms free implementation

#

Using reflection

small current
#

thats the code

rough drift
#

the whole class, idk the imports n stuff

small current
#

you just need a player object
and a location

rough drift
#

I am aware

#

actually just a World

#

and a location

small current
#

yes and its in a cmd class

rough drift
#

the imports?

#

i need those

small current
#

import net.minecraft.world.level.biome.BiomeFog;

rough drift
#

what abt craft world

small current
#

import lombok.SneakyThrows;
import net.minecraft.core.BlockPosition;
import net.minecraft.world.level.biome.BiomeFog;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.entity.Player;

import java.lang.reflect.Field;
import java.util.Collections;
import java.util.Optional;

#

idk

harsh totem
#
        if (!(entity instanceof EnderDragonPart) && !(entity instanceof Player) && !(entity instanceof Wither)){
            Random random = new Random();
            int chance = random.nextInt(1,4);
            if (chance == 1){
                entity.getWorld().spawnEntity(entity.getLocation(), EntityType.COD);
            } else if (chance == 2){
                entity.getWorld().spawnEntity(entity.getLocation(), EntityType.SALMON);
            } else if (chance == 3){
                entity.getWorld().spawnEntity(entity.getLocation(), EntityType.TROPICAL_FISH);
            }
            entity.remove();
        }
    }

    @EventHandler
    public void set(EntityShootBowEvent event){
        if (event.getProjectile() instanceof Arrow && event.getEntity() instanceof Player){
            if (event.getConsumable().getItemMeta().getCustomModelData() == 500){
                event.getProjectile().setMetadata("fish", new FixedMetadataValue(plugin, true));
            }
        }
    }

    @EventHandler
    public void hit(ProjectileHitEvent event){
        if (event.getEntity() instanceof Arrow && event.getHitEntity() != null && event.getHitEntity() instanceof LivingEntity){
            Arrow arrow = (Arrow) event.getEntity();
            Entity entity = event.getHitEntity();
            if (entity != null){
                if (arrow.hasMetadata("fish") && entity.getType() != EntityType.COD && entity.getType() != EntityType.SALMON && entity.getType() != EntityType.TROPICAL_FISH){
                    event.getEntity().remove();
                    turn(event.getHitEntity());
                }
            }
        }
    }```
rough drift
#

ty

harsh totem
# harsh totem ``` public static void turn(Entity entity){ if (!(entity instanceof E...

I have this code which is supposed to turn mobs to fish if they're shot by an arrow with customModelData of 500. when I shoot at an unliving entity the entity disappears with the arrow and no errors are being sent in console. I checked and the first if statement in hit() is false which means that no lines like entity.remove() are being read by the plugin when I shoot at an unliving entity so I really don't know what can cause it. any ideas?

grim oak
harsh totem
grim oak
#

But i would have to keep transferring the plugin from the build output to the server folder

solid cargo
#

ok serious question: how can i whitelist players in bulk. i aint typing /whitelist add player 15725325 times

grim oak
#

fair enough, but then reloading the plugin wont help right? reloading it only reload the config

#

mine doesnt lmao

#

when i run the reload command its just programmed to reload the config

solid cargo
#

how tho :(

grim oak
#

there is no plugin.reload() function

#

lol im not gonna use plugman

#

i hear that it can break mechanics on your server

chrome beacon
#

^ this is true

harsh totem
#

;-;

harsh totem
old cloud
#

Hi, what is more performant?

  1. Having a repeating task running every second, checking if something is expired (would include a loop with multiple if statements each second)
    or
  2. Having (maybe a lot) active delayed tasks, that just wait a amount of time and then just run one operation?
humble tulip
#

actually it depends

old cloud
#

yea

#

Are all tasks on one scheduler in one thread?

harsh totem
# harsh totem

I unregistered each event one by one and it still happens.

#

I removed the plugin and it still happens

#

wtf?

#

there are no other plugins in the server

#

yes

#

@quaint mantle I deleted all of the plugins in the server

#

and the boat disappears when I shoot at it

solid cargo
#

ok ig this works

#

thats for testing btw

harsh totem
#

every unliving entity

#

ohhhhhhhhhhhhhhhhhhhhh

#

i got it

#

it was disappearing because i was in creative.
if im in survival the boat/whatever drops on the floor

#

its a game mechanic

#

nothing is wrong

solid cargo
#

okay thanks :)

grim oak
delicate lynx
#

you have to set a "mysql_native_password" on mysql 8

humble tulip
#

If you just want to get rid of the error, at the cost of risking the security of the project (e.g. it's just a personal project or dev environment), go with @Pras's answer -- 
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password' 
and then 
flush privileges

#

Have u tried ^^

#

It's clearly a problem with mysql not your code

#

I think that's ur fix tbh

#

getSlot gets the slot of the clicked inv

#

Getrawslot pretends the top and bottom inv is one

#

I'm not smart enf to know

#

Did u flush privileges?

#

Same error?

#

Yea

#

root@localhost

#

Wait what were u using

#

Try running the plugin on 1.18

#

They error is that the client is outdated

#

Maybe 1.8 had an older driver or sumn idk

#

Buildtools and ur plugin

#

Shouldn't be hard

#

Mc server?

#

Or client

#

Check forge ig

#

Maybe u can fork forge

#

Never worked with client

mortal hare
#

more progress on inventory ui lib im working on

#

dynamic titles

#

no flicker

ivory sleet
#

you dont create a new inventory I presume

mortal hare
#

yes but involves some packet trickery (i borrowed this feature from deluxe menus actually)

ivory sleet
#

This event will fire when a player is finishing consuming an item (food, potion, milk bucket).

compact haven
#

because you never use the super user on any system/application for anything other than management

#

and you're also sharing the super user with other applications that don't need such permissions

humble tulip
#

Doesn't matter to u tho since it's to test

outer wadi
#

To which packet and what field should I write to when opening a sign gui? I'm kinda lost here

tender shard
#

what version?

tender shard
#

takes a BlockPos as constructor parameter

iron glade
humble tulip
echo basalt
humble tulip
#

Or if it is is there a regular sign event?

echo basalt
#

likely doesn't let you sign

modest garnet
#

hey can someone help i have source files as a zip but i need them put as a jar

#

can anyone do it for me

humble tulip
#

And import to intellij

outer wadi
echo basalt
#

setVelocity with such speed

#

it takes in an x, y, z vector

#

that's the new velocity in blocks/second iirc

echo basalt
#

For lists

#

Collections.singletonList for a single element list

#

or Arrays.asList

#

not sure about map, I usually just call put methods

lost matrix
#

Either through guava or by creating an anonymous class

echo basalt
#

something like

Map<String, Integer> whatever = new HashMap<>() {{
  put("potato", 123);
}};
#

I remember you could do something like that

#

not sure about semicolon positioning

#

yeah

#

but worky

lost matrix
#

*But dont overdo it. Creating constants like this is ok but dont use it if it gets instantiated too often.

echo basalt
#

probably makes an anonymous class or something stupid

lost matrix
#

But usually classes that contain data structures shouldnt be instantiated too often anyways.

echo basalt
#

can be any object

lost matrix
#

Sure

#

But that should either be a multimap or the list should be encapsulated in a new class.
Nesting raw collections is bad practice.

ornate patio
#

@lost matrix any progress on that pathfinding algorithm

#

if nots its fine lmao

kind hatch
#

I'm currently designing a new file structure that I'm wanting to use for my language system. A sort of "language pack" if you would. I'd appreciate some feedback on it.

Here's an example of the directory structure.

.
├── locale_en
│   ├── default_messages
│   │   ├── default_guis_en.yml
│   │   └── default_locale_en.yml
│   ├── holiday_overrides
│   │   └── christmas_override_en.yml
│   ├── locale_en.yml
│   └── locale_guis_en.yml
└── locale_pl
    ├── default_messages
    │   ├── default_guis_pl.yml
    │   └── default_locale_pl.yml
    ├── holiday_overrides
    │   └── christmas_override_pl.yml
    ├── locale_guis_pl.yml
    └── locale_pl.yml

In this example, I have taken a different approach to the standard one language file most plugins use. There is still a general language file, but it only contains the general messages and error messages. Everything else that can be categorized would be put in a new file. In this case, language options for GUI items are put into a separate file.

Now, I believe that this will offer more benefits than drawbacks.

#

Benefits
+ Modularity
If a server owner disables a part of the plugin's functionality, lets say the GUIs for instance, the GUI locale files wouldn't need to be loaded, saving some memory. Compared to the standard language file, all of those extra sections would just be taking up unnecessary ram. (I know it probably isn't much, but hey, just because you have an abundance of RAM lying around is no excuse to use it unnecessarily!)

+ Expandability
If I wanted to add any future subdirectories, it would be extremely easy.

+ You don't have to delete files to get an updated version from a plugin update. (At least not as often)
In this case, the only files that would are the ones in the default_messages folder because this folder would be used to grab default/backup values incase of mismatched files.
Unless something new is added to an existing file, you can set it and forget it. Say for instance, you are using development builds of a plugin and the dev is changing GUIs pretty often. You wouldn't want to have to delete your language file every single time just to get some new sections. Not to mention all of the work you would have to do to re-update every section with the proper colors and messages.

#

Drawbacks
- Makes it a little more time consuming to setup.
Files like the holiday overrides section would likely have different color formatting and different holiday themed messages. Adding more work for the initial setup.

- Sacrifices some User Friendliness for Functionality.
it would be a little daunting to look at for the first time. As developers, this probably seems pretty straightforward, however, for normal server owners, they are used to the convenience of things being in one file. It wouldn't cause plugin functionality to break if they only modified one file, but would look incomplete if a server owner thought that they only needed to modify the general file.

- Harder to implement into code.
With an infinite expandable system like this, some hard coded methods would need to be made. As this system is intended for translations, sections need to be mapped to proper message values. Things like the plugin prefix which is located in the general language file would need to be used in every other file. Essentially coupling the general language file to every other one.
Also, dealing with multiple files could be a little problematic if they aren't managed properly.

#

These drawbacks aren't the biggest thing in the world, but Ease of Use and Ease of Understanding is nothing but a benefit to the end user. It would be nice if this system could be made a little friendlier, but with the way the files are laid out and labeled, it should hopefully be as straightforward as possible.

That's what I think at least, but what do you guys think?

summer scroll
#

Holy

crude loom
#

How can I make the custom name of an entity always appear? (and not only when the player gets close enough)

sage dragon
#

Isn't that Client Side?

crude loom
#

I'm making irongolems in a bedwars plugin and I want them to always show the name so the player will know what team they belong to

summer scroll
#

It has to be client side, no?

crude loom
#

I don't know? 😅

summer scroll
#

Maybe something to do with spigot.yml

vital mica
sage dragon
earnest forum
#

yes

#

they mean it will show when you aren't hovering over them

#

like how a player's would

#

i think by default the functionality is like name tagging a zombie where u have to be looking at them for the name to appear

vital mica
#

Oh yea, this works with items and armorstands only i guess, sorry

But you may spawn an invisible armorstand and set the name of the armorstand

earnest forum
#

actually maybe it might default it to always visible

charred pond
crisp steeple
vocal cloud
#

?jd

harsh totem
#

what's the name of the particle ambient_entity_effect in spigot?

#

nvm found it

somber hull
#

So I have an old project that I made a while back. And I wanna redo all the insides. What’s the best way to decide what to remove?

#

Should I remove it all at once

#

And redo

#

Or take it one section at a time

#

Maybe make a separate branch in GitHub to mess with?

#

Maybe I’m overthinking

#

It is 2 am

humble tulip
#

How big is it?

bold solstice
#

Hello guys, Quick question. How do I register 2 events from 2 different classes?

#

one class is the main one

humble tulip
#

The same way u register one event

bold solstice
#

and the second is a different one imploments listener

humble tulip
#

Just twice

#

Paste ur code

#

?paste

undone axleBOT
lost matrix
bold solstice
#

but if I do it twice it cancels the first one

lost matrix
#

First of all: You should not let your JavaPlugin class implement Listener.

bold solstice
#

why?(just curious)

humble tulip
lost matrix
#

Its just dirty coding. There are clean code principles like separation of concerns and single responsibility principle that
define how to properly structure code. And creating new classes for new purposes is much cleaner than clumping everything together.

bold solstice
bold solstice
lost matrix
#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

bold solstice
#

xDDDD

#

anyways

#

basically, if I do both of them it cancels the manager.registerEvents(this ,this);

lost matrix
lost matrix
bold solstice
#

whats a sysout

#

I never heard of it

lost matrix
#

Console log. You can use the logger or for quick debugging purpuses you can just call std::out
System.out.prinln("")

bold solstice
#

ah

#

sadly I do not understand why it doesn't work

lost matrix
bold solstice
#

so I just go and take one random event from the main class and put it in there

#

like System.out blabla

#

and then I also do the same in the event in the other class

#

just making sure I understood

lost matrix
#

Sure. This will show you that both listener methods are fired regardless of other registered listeners.

bold solstice
#

I run the program and.. nothing happens it shows me a lot of messages but I dont see A or B

lost matrix
#

Which means nothing works at all? Well is your plugin even enabled?

#

Is it listed (and green) if you type in /pl

bold solstice
#

oh wait u mean in minecraft im an idiot

lost matrix
#

yes. to see which plugins are enabled

bold solstice
#

wait

#

my build messed up just a second

#

When i try to build it now gives me an erro for no reason

lost matrix
#

What is it?

bold solstice
#

cannot find symbol class EnumClass

#

and it does that for all of my enums

lost matrix
#

Sounds like your project has no jdk to build on.
What IDE are you using? And are you using maven/gradle?

bold solstice
#

maven

#

I think it has something to do with me trying to run the program itself

lost matrix
#

You cant "run" a plugin obviously...

bold solstice
#

yea ok I fixed it

#

I had to redebug it because I messed the maven thing up because me be stupid

lost matrix
#

Alright. Btw how do you compile?

bold solstice
#

build

#

build artifacts

lost matrix
lost matrix
lost matrix
# bold solstice build artifacts

Also if you are using maven then you should never add external jars or other dependencies to your project
because thats what maven is for.

bold solstice
#

oh ok

tender shard
bold solstice
#

Alright so I reloaded

#

it doesn't do the enable because it says there is an error

#

because I did the register events twice idk

humble tulip
#

We need to see the error to help

misty current
#

is there a method to make a completable future throw an eventual caught exception without doing it myself?

ivory sleet
#

Uh wym?

lost matrix
ivory sleet
#

Like CF wraps any runtime exception with a CompletionException and determines the stage as a failed stage iirc

misty current
# ivory sleet Uh wym?

not sure if i understand it correctly, but as an example whenComplete takes a biconsumer as an argument with a throwable

#

and i guess the throwable object is an eventual exception that was caught while completing the future or similar

ivory sleet
#

Yes

#

But you also have CompletionStage::exceptionally

#

And fyi using get/join will throw the eventual exception that was caught during computation

misty current
#

aight thanks

smoky oak
#

assuming a player has a shield in each hand, how can i check which shield is raised? Normally it'd be the left one but theres that left hand option

lost matrix
# misty current aight thanks

What you can do is create a method in a utility class ("ExceptionUtils" for example)

  public static <T extends Throwable> T delegatePrint(T throwable) {
    throwable.printStackTrace();
    return throwable;
  }

This allows a shorter form

CompletableFuture.failedFuture(new RuntimeException("Test")).exceptionally(ExceptionUtils::delegatePrint);
misty current
#

oke thanks

lost matrix
misty current
#

btw i've just noticed that vault uses doubles to represent player's balances

misty current
#

isn't that bad because of floating point precision?

smoky oak
#

if your economy has so much inflation that you get precision errors you've got different problems

misty current
#

my economy doesn't exist yet but i'm wondering if the numbers are close to billions will you get noticeable precision errors

smoky oak
#

its got sixteen decimal points precision

#

so no

lost matrix
misty current
#

wow

lost matrix
misty current
#

i thought the precision was worse

smoky oak
#

googled it

#

said sixteen points precision

lost matrix
#

The precision worsens the bigger your number is

#

IEEE 754

smoky oak
#

its still got sixteen decimal numbers precision

#

eleven exponent bits and fifty two fraction bits

lost matrix
#

1.000000000000000000000023 will be more precise than
254,532,545,123.000000000000000000000023

misty current
#

i just need 2 numbers after the dot and i'm not making op prison economy so no 20 digit balance

#

so it should not be a problem

lost matrix
misty current
#

also another issue with vault is that there are no separate methods to distinguish between removing money and transfering money

lost matrix
misty current
#

most probably i won't

#

i was planning on implementing vault eco but i've already given up on the idea

lost matrix
#

Then why bother using vault. Just create your own economy.

misty current
#

also because of methods with player names as strings

#

oh and also because i need to retrieve data from a database for offline players

agile anvil
#

You can do all of that easily actually

lost matrix
#

Thats one of the biggest drawbacks of vault. No async integration.

agile anvil
misty current
#

yep, what im doing now is i've taken most of the vault methods i think are useful for my eco and making sync and async ones

misty current
#

yeah 2011

smoky oak
#

also

#

checking main and off hand doesnt tell me if the off hand is the right or left one

lost matrix
smoky oak
#

im aware of that but i do need to know if the raised shield is in the right or left hand

#

im doing geometry with it

agile anvil
#

Or ask the player

smoky oak
#

nms it is

agile anvil
#

I don't know any packets that refers about it

#

I think it's juste client side design

#

But do you guys know someone that change the main hand?

#

Oh wait, does it change the apparence of other players ?

smoky oak
#

login packet

#

main/off hand

#

0x7

agile anvil
#

So just listen to that packet and save it

#

Then when the player use a shield you know which side

lost matrix
#

HumanEntity#getMainHand() -> LEFT | RIGHT

smoky oak
#

huh well then

#

eh whats the full <dependency> entry again for the spigot api?

lost matrix
#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.18.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
#

Dont forget

        <repository>
            <id>spigotmc-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
mortal hare
#

unpopular opinion i hate rounded corner design boom

#

rounded corners are more harder to compute than square ones, also they seem not uniform to computer's screen, at least on computer screens we don't have rounded corners

agile anvil
#

Feels way smoother, squared corners bring hardness

ivory sleet
#

Rounded corners help us to follow lines

#

So by user experience its a little bit more appealing

smoky oak
#

uh i cant find how to check if the player is blocking with the main hand or off hand

lost matrix
smoky oak
#

well yes but two shields

#

im trying to cover that specific edge case

lost matrix
#

If blocking -> if main hand has shield : its the main heand -> if not : its the offhand

smoky oak
#

ah right

#

k

#
boolean swap = player.getMainHand() == MainHand.LEFT;
boolean shieldLeft = true;
if(player.getInventory().getItemInMainHand().getType() == Material.SHIELD)
  shieldLeft = false;
if(swap)
  shieldLeft = !shieldLeft;
#

sounds about right?

#

welp i have a completely different issue now. I cant seem to find anything online for the shield hitbox except 'visually it's dependent on the texture pack', and a mention that its handled by the server. Does anyone know how i can get the hitbox the server uses for calculating if a projectile is blocked or not?

lost matrix
#
  public enum Side {
    LEFT, RIGHT, NONE
  }
  
  public static Side getRaisedSide(Player player) {
    if(!player.isHandRaised()) {
      return Side.NONE;
    }
    boolean invert = player.getMainHand() == MainHand.LEFT;
    if(player.getInventory().getItemInMainHand().getType() == Material.SHIELD) {
      return invert ? Side.LEFT : Side.RIGHT;
    } else {
      return invert ? Side.RIGHT : Side.LEFT;
    }
  }
smoky oak
#

uh i guess... seems like it does about the same, i have a israised check before

smoky oak
#

urgh

#

see what im trying to do is fix the shield bug

#

but without access to that hitbox i can do squat

#

you recon it needs nms?

lost matrix
#

What is "the shield bug"?

smoky oak
#

if you block a projectile that was already shot

#

it does not get blocked

#

so if someone shoots you from fifty blocks away and you see that arrow flying at you and you block

#

you still get shot

lost matrix
#

No this sounds ridiculously stupid. Is this a thing in the newest version still?

smoky oak
#

yes

#

im fairly sure at least

#

one sec

#

yup its still a thing

#

so about that hitbox?

quaint mantle
#

is there a better way to do this?

private void setupListeners() {
        final Listener[] listeners = new Listener[]{new PlayerBuild(), new PlayerChat(), new PlayerDamage(), new PlayerJoin(), new PlayerQuit(), new WeatherChange()};
        Arrays.stream(listeners).forEach(listener -> getServer().getPluginManager().registerEvents(listener, this));
    }```
lost matrix
quaint mantle
lost matrix
#

Why?

quaint mantle
#

more clean

ivory sleet
lost matrix
#

You actual troll

#
List.of(new XListener(), new YListener(), new ZListener()).forEach(listener -> Bukkit.getPluginManager().registerEvents(listener, this));

What ive posted is technically one line

vocal cloud
#

Use a reflection library and it'll be 1 line Kek

ivory sleet
#

You definitely beyond all programmers do not want to have it in one line

quaint mantle
ivory sleet
#

As long as you can eliminate as many illusions as possible it’s pretty good

lost matrix
# quaint mantle What is the best way to do it then?
    PluginManager pluginManager = Bukkit.getPluginManager();
    pluginManager.registerEvents(new XListener(), this);
    pluginManager.registerEvents(new YListener(), this);
    pluginManager.registerEvents(new ZListener(), this);

There is nothing wrong with this one.

smoky oak
#

I've been staring at Projectile and Arrow in net.minecraft.world.entity.projectile for what feels the last half hour and cant seem to find where it deals with shields... can anyone give me a pointer?

lost matrix
smoky oak
#

i hate that i knew you'd say that

#

anything constructive you might want to add

lost matrix
#

dig

smoky oak
#

i tried already

#

thats why i ask

earnest forum
#

maybe try look at where damage is done in the player

#

i doubt the shield has its own hitbox

smoky oak
#

you were damn close but the method i found is to handle stuff after the player blocked

#

unluckily i cant search for usages in the nms code

earnest forum
#

.toString()

#

send message takes in a string and online players is an int

lost matrix
earnest forum
#

oh wait no

#

.length

wide dirge
#

you can make
Player p = Bukkit. get...

earnest forum
#

u cant print a list

wide dirge
earnest forum
#

what are you trying to do?

#

@viral hazel

wide dirge
smoky oak
#

wtf is this java else if ("sonic_boom".equals(source.msgId)) { cause = DamageCause.SONIC_BOOM; }

earnest forum
#

that works?

wide dirge
#

are you understand javafx?

#

wait

#

you wanna check the player amount?

earnest forum
#

player and them are the same

wide dirge
earnest forum
#

why make 2 variables the exact same

wide dirge
#

its just take rams

#

delete them

earnest forum
#

player and them are the exact same object

wide dirge
#

are you traying to send message on player join?

earnest forum
#

just use player

wide dirge
#

your code is trash

#

wait

lost matrix
earnest forum
wide dirge
#

chatcolor. bold +" " +chatcolor.anycolor +""

wide dirge
#

will die his server

earnest forum
#

help him learn

wide dirge
#

dont make spam space

#

just one

earnest forum
#

no you need that

wide dirge
#

so any error you get?

earnest forum
#

nvm

wide dirge
#

but its usles

#

ok

#

lenght is work

earnest forum
#

the way you are doing it is fine

wide dirge
earnest forum
#

also instead of hard coding theres a method to get the max players

#

yeah thats good

lost matrix
#
    int numberOfOnlinePlayer = Bukkit.getOnlinePlayers().size();
    int maxNumberOfPlayers = Bukkit.getMaxPlayers();
wide dirge
#

but mouse on it

#

i want see error

earnest forum
#

no error

#

size maybe

lost matrix
#

no need. Collection sizes are retrieved by calling .size() and not .length

earnest forum
#

try size

#

yeah

wide dirge
#

size

#

bruh

#

size for int

#

i Remember now

lost matrix
#

Take a look at the two lines of code ive sent above pls.

wide dirge
#

look

#

just make this

earnest forum
#

yeah thats good

wide dirge
#

wait everyone

earnest forum
#

also u dont need to show us the imports

wide dirge
#

dont talk

earnest forum
#

cut down the message size

lost matrix
#
yourCodeGoesHere
wide dirge
#

look bro just make like this

#

Bukkit. getOnlinePlayer(). size() + Bukkit. getMaxPlayers();

#

just do this

#

im slow cuz im phone

earnest forum
#
player.sendMessage(Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers());
#

dont forget the "/"

wide dirge
#

🎉 thanks bro

#

@viral hazel everythink ok?

#

ok

#

put space

#

and try

#

its will take time

#

but its the way

#

or

#

try put

#

=======

lost matrix
#

Centering a message is quite difficult because clients can have different settings for their chat width.
There are also a lot of resourcepacks that add different fonts.

dark harness
#

Can I get the Drops count from a mined ore?

wide dirge
#

and you can edit it

#

brb 10m

smoky oak
#

correct jar when using nms was shaded right?

#

uh wait a sec

golden raven
#

so hello I start in the code I try to create an lg to train me, my code is it good?

import org.bukkit.ChatColor;
@SuppressWarnings({"unused"})
public enum Aura {
    LIGHT("werewolf.role.oracle.light", ChatColor.GREEN),
    NEUTRAL("werewolf.role.oracle.neutral", ChatColor.GRAY),
    DARK("werewolf.role.oracle.dark", ChatColor.DARK_RED);

    private final String key;
    private final ChatColor chatColor;

    Aura(String key, ChatColor chatColor){
        this.key = key;
        this.chatColor = chatColor;
    }

    public ChatColor getChatColor() {
        return chatColor;
    }

    public String getKey() {
        return key;
    }
}```
smoky oak
#

i only get a bunch of remapped files?

smoky oak
#

which is the correct one?

tender shard
#

lowest one

golden raven
lost matrix
#

@SuppressWarnings({"unused"})

Why is that there?

golden raven
#

it means for me I introduce and it is to use a single role

lost matrix
golden raven
#

ok ty

crude snow
#

Any way to make a fake hurt effect on an entity without damaging it?

smoky oak
#

damage it with damage set to 0

lost matrix
smoky oak
#

different topic... CraftPlayer cannot be cast to EntityLiving

#

uh

#

help?

lost matrix
tender shard
#

wtf is EntityLiving

#

is that some kind of un-remapped NMS class?

earnest forum
#

nms version of livingentity i think

tender shard
#

you cannot cast a bukkit entity to NMS entity

#

CraftEntity.getHandle() returns the NMS entity

smoky oak
#

ah ok

mortal hare
#

can you call super class externally

#

like i have overriden the method

#

inside second method

#

but i need to execute baseclass method

#

ik this is possible with cpp due to virtual functions

#

but i dont know about java

#

nvm

#

what I hypothetically thought would work, not gonna

smoky oak
#

the only part where you can call super is if its the first instruction in the constructor

smoky oak
#

why

lost matrix
visual tide
smoky oak
#

isBlocking() is a condition for deflecting an arrow

#

however

#

there is a delay between isRising and isBlocking returning true (start of raising shield to having the shield up)

#

the idiotic part is that the animation is only about 30% of the delay

#

so you think you raised your shield

#

but actually its still 'being readied'

visual tide
#

theres a reopened bug report on the bug tracker

smoky oak
#

the vertical component of that 'related' bug with the upwards facing shield is there too

#

they remove y from the vector representing view direction

#

as a result you get hit

visual tide
#

weird

#

is it still indexing

#

restart ide maybe

smoky oak
#

under what category do plugins fall that change game mechanics

golden turret
#

wait the project to load

harsh totem
#

how do I get the two added arrows in EntityShootBowEvent when the bow is a crossbow with multishot?

lost matrix
#

File -> Project structure -> Modules -> press on + -> add the root as a module

lost matrix
golden turret
#

?jd-s

undone axleBOT
lost matrix
#

wrong path name for your main class

#

Just read the exception...

harsh totem
#

is there a crossbow load event?

#

haven't found anything like it

lost matrix
harsh totem
#

it doesn't exist

lost matrix
tender shard
#

its paper only

harsh totem
#

😢

tender shard
#

there was some way in spigot too

#

but i dont remember it rn lol

harsh totem
#

is there a work around it in spigot?

tender shard
#

fix your xml syntax

harsh totem
#

what's the problem

tender shard
#

they are closing <proejct> before the actual content

tardy delta
#

<project xlmns = blablabama and other stuff >

harsh totem
tender shard
#

you could listen to playerinteractevent, then schedule a repeating runnable to check whether Player#getItemInUse is not null and once it's null again, check if their main hand item has an arrow loaded

#

dirty workaround though lol

harsh totem
#

hmm

#

i have another idea.
it there a way to make the event EntityShootBowEvent execute only once when the bow is a multishot crossbow?

tender shard
#

you could create a Set<UUID> with the player's UUID once an arrow is shot, and then clear that entry in the next tick, and ignore every event called for a shooter that's in the set

harsh totem
#

i'll try

#

thanks

#

thank you very much

#

it works

#

finally

mortal hare
#

you forgot dot

earnest forum
#

missing a . in between dev and tobys

mortal hare
#

dev.tobys.aqualand.Aqualand

lost matrix
#

Again: Read the exception. Your path is wrong

earnest forum
#

in your plugin.yml

mortal hare
#

not devtobys.aqualand.Aqualand

tardy delta
dark harness
#

How can i easly double the drop amount from ores like diamonds

lost matrix
pallid forge
#

I have a question, how do you select one string out of a list from a config.yml? is there a place I can learn how to do that?

#

randomly select one string out of a list

lost matrix
#

You should not read configs often in general. Load everything into classes and fields when the server starts and use this data instead of configs.

pallid forge
#

hmmm ok

tardy delta
#

my pi has an uptime of 30 days i love it

#

wait what channel am i in lol

misty current
#
    public CompletableFuture<Void> transferBalance(UUID from, UUID to, double amount) {
        CompletableFuture<Void> future = new CompletableFuture<>();

        playerRegistry.getOrLoadPlayer(from).whenComplete((cosmicFrom, throwable) -> {
            playerRegistry.getOrLoadPlayer(to).whenComplete((cosmicTo, throwable1) -> {
                transferBalance(cosmicFrom, cosmicTo, amount);
            });
        });

        return future;
    }

how can I make this cleaner?

#

ie making the two completable futures run at the same time and when both are completed, invoke transferBalance()

lost matrix
#

Could also just use thenAccept

#

But other than that it looks ok. Just wondering when you are saving the data again.
And also what happens if this method is called too fast. Because this could lead to stale data if you dont use any locks.

#

currencies should always be done transaction based

misty current
misty current
lost matrix
#

And you only access data from this single map? So there are no other minecraft instances interacting with playerdata?

outer wadi
misty current
#

oh i have noticed something bad

lost matrix
#

You can pass an executor to your CompletableFuture.

reef lagoon
#
PersistentDataContainer data = player.getPersistentDataContainer();```
This used to work until I added vault as a maven dependency anyone knows why
lost matrix
reef lagoon
#

vault first then spigot?

#

nvm

#

tysm

tender shard
coarse shadow
#

which event is caused when we click ender crystal, entitydeathevent or entityexplodeevent?

earnest forum
#

probably both

dark harness
coarse shadow
#

i tried to cancel the death event but it didnt work

misty current
dark harness
hasty prawn
#

getBlock() is air because the block is already broken

dark harness
#

But i can use the same methods like getitems in BlockBreakEvent where the gettype works

hasty prawn
#

Well, no, because that wouldn't take into account stuff like fortune.

dark harness
#

Oooof

lost matrix
# misty current how can I do that? In the constructor?

Btw you can take a look at caffeine if you want

  private final AsyncLoadingCache<UUID, CosmicPlayer> cache = Caffeine.newBuilder()
          .expireAfterAccess(45, TimeUnit.MINUTES)
          .removalListener(this::saveToDatabase)
          .buildAsync(this::loadFromDatabase);
  
  private CosmicPlayer loadFromDatabase(UUID key) {
    // load data from DB
  }

  private void saveToDatabase(UUID key, CosmicPlayer player, RemovalCause cause) {
    // Save data to DB
  }

  public CompletableFuture<CosmicPlayer> getOrLoad(UUID key) {
    return this.cache.get(key);
  }

Its a hashmap backed by a loader and writer

lost matrix
ivory sleet
lost matrix
lost matrix
# misty current how can I do that? In the constructor?

By passing an executor i mean this:

  private final ExecutorService executorService = Executors.newFixedThreadPool(4);

  private CompletableFuture<CosmicPlayer> loadFromDBAsync(UUID key) {
    return CompletableFuture.supplyAsync(() -> loadFromDBSync(key), executorService);
  }

  private CosmicPlayer loadFromDBSync(UUID key) {
    // Access DB
  }
misty current
#

yea i have found the method

#

now i need to change some methods

dark harness
#

That makes no sense...
Why is this dropping me 9 Redstone Dust when i just drop the same the same amount (4) again?

    @EventHandler
    public void onOreMine(BlockBreakEvent e) {
        if (ores.contains(e.getBlock().getType())) {
            e.getPlayer().sendMessage(e.getBlock().getDrops().toString());
            e.getBlock().getDrops().forEach(item -> {
                int amount = (item.getAmount());
                e.getBlock().getLocation().getWorld().dropItemNaturally(e.getBlock().getLocation(), new ItemStack(item.getType(), amount));
            });
        }
    }
lost matrix
sage dragon
#

If I execute the syncCommands method, could it freeze the server if it is done when shutting down?

smoky oak
#

what does it do

lost matrix
sage dragon
#

Problem is that I want to clean up when my plugin is disabled, but sometimes the plugin disables because of a server shutdown

(Sometimes my plugin freezes the server when shutting down)

smoky oak
#

isnt that basically the same thing?

sage dragon
misty current
#
    public CompletableFuture<Void> transferBalance(UUID from, UUID to, double amount) {
        CompletableFuture<Void> future = new CompletableFuture<>();

        playerRegistry.getOrLoadPlayer(from).thenAccept(cosmicFrom -> {
            playerRegistry.getOrLoadPlayer(to).thenAccept(cosmicTo -> {
                transferBalance(cosmicFrom, cosmicTo, amount);
            });
        });

        return future;
    }
``` Can I make both futures complete at once and then execute the code? right now when the first future is completed, the second one starts completing
smoky oak
#

different topic, can i send particles to players async?

sage dragon
reef lagoon
#

How do I get the vault colored prefix, because it is just "&4Owner Wihy" and I want it to be "(red)Owner Wihy"

#

String prefix = chat.getPlayerPrefix(player);

lost matrix
# misty current ```java public CompletableFuture<Void> transferBalance(UUID from, UUID to, d...

Sure. You can compose futures.

  public CompletableFuture<Void> transfer(UUID from, UUID to, double amount) {
    CompletableFuture<CosmicPlayer> fromStage = getPlayer(from);
    CompletableFuture<CosmicPlayer> toStage = getPlayer(to);
    return fromStage.thenAcceptBoth(toStage, (fromPlayer, toPlayer) -> transfer(fromPlayer, toPlayer, amount));
  }
  
  private void transfer(CosmicPlayer from, CosmicPlayer to, double amount) {
    // transfer
  }

  private CompletableFuture<CosmicPlayer> getPlayer(UUID key) {
    // fetch player
  }
lost matrix
misty current
#

so this will only run when both futures are completed won't it

misty current
#

kk thanks a lot

south prawn
#

Can somebody help me

lost matrix
#

You can also have something returned. This is then a combination of those two futures to another future of a different type like a result

  public CompletableFuture<TransactionResult> transfer(UUID from, UUID to, double amount) {
    CompletableFuture<CosmicPlayer> fromStage = getPlayer(from);
    CompletableFuture<CosmicPlayer> toStage = getPlayer(to);
    return fromStage.thenCombine(toStage, (fromPlayer, toPlayer) -> transfer(fromPlayer, toPlayer, amount));
  }

  private TransactionResult transfer(CosmicPlayer from, CosmicPlayer to, double amount) {
    // transfer
  }
undone axleBOT
#
CafeBabe Help Menu
*Red V3*
**__Admin:__**

selfrole Add or remove a selfrole from yourself.

**__Cleanup:__**

cleanup Base command for deleting messages.

**__Core:__**

embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.

**__Downloader:__**

findcog Find which cog a command comes from.

**__Mod:__**

names Show previous names and nicknames of a member.
userinfo Show information about a member.

**__ModLog:__**

listcases List cases for the specified member.
reason Specify a reason for a modlog case.

**__Permissions:__**

permissions Command permission management tools.

lost matrix
#

tha fk=

#

?ask

undone axleBOT
#

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

lost matrix
#

Ah this one

south prawn
# lost matrix ?ask

I have to send an image but I can't send it here, can I send it to you privately?

quaint mantle
#

link

lost matrix
#

Nope

#

?verify

lost matrix
tardy delta
# misty current wdym

CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> "wooo", someExecutor)

misty current
#

bit late but thanks

#

:p

tardy delta
#

im an idiot who doesnt look at the messages above

misty current
#

so i can also do stuff like

    public CompletableFuture<Boolean> has(UUID uuid, double amount) {
        return playerRegistry.getOrLoadPlayer(uuid).thenApply(cosmicPlayer -> has(cosmicPlayer, amount));
    }
tardy delta
#

primitive generics when :(

misty current
lost matrix
south prawn
lost matrix
south prawn
lost matrix
south prawn
lost matrix
arctic moth
#

the daily life of any programmer

#

dont ask me how i got 6 gb of errors

tender shard
ancient jackal
arctic moth
humble tulip
#

Wtf

paper viper
#

I'm using JDA and it's printing the bot logs into console:

[17:36:23 INFO]: [net.dv8tion.jda.api.JDA] Login Successful!
[17:36:24 INFO]: [net.dv8tion.jda.internal.requests.WebSocketClient] Connected to WebSocket
[17:36:24 INFO]: [net.dv8tion.jda.api.JDA] Finished Loading!
[17:36:24 ERROR]: [DeluxeMediaPlugin] [STDERR] SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
[17:36:24 WARN]: Nag author(s): '[PulseBeat02, itxfrosty]' of 'DeluxeMediaPlugin' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).
[17:36:24 ERROR]: [DeluxeMediaPlugin] [STDERR] SLF4J: Defaulting to no-operation (NOP) logger implementation
[17:36:24 ERROR]: [DeluxeMediaPlugin] [STDERR] SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Is there anyway to avoid this?

#

JDA seems to Sysout since no log4j configuration was specified

waxen plinth
#

I know there's a way but I forget what it is

#

Wait no

#

It was a long time ago and it was jnativehook not jda

paper viper
#

it seems that logback is the only way

tardy delta
#

i was adding my own handler to the logger

#

and the logger is just Logger.getLogger("my bot")

#

love digging thro my old code ;D

twilit roost
#

how to use Hex Colors?
1.18.1
This is my current code but it just returns the Hex Code

private static final Pattern pattern = Pattern.compile("#[a-fA-F0-9]{6}");
public static String getColor(String msg){
    if(Bukkit.getVersion().contains("1.16")){
        Matcher match = pattern.matcher(msg);
        while(match.find()){
            String color = msg.substring(match.start(),match.end());
            msg = msg.replace(color, ChatColor.of(color) + "");
            match = pattern.matcher(msg);
        }
    }
    return ChatColor.translateAlternateColorCodes('&',msg);
}
humble tulip
#

Think u need chatcolr char before every char of the hex code

twilit roost
#

oh nooo

humble tulip
#

I could be wrong

#

Not sure

#

Mfnalex has something in his utils

#

U can check his github

twilit roost
#

thx

humble tulip
#

Why would that work?

twilit roost
humble tulip
#

You didn't set it

steel swan
#

Hey, anyone knows a way to display something on top of th head of a player BUT to only certain player.
Exemple :
player1 has written smth above their head
player2 sees it
player 3 doesnt

mortal hare
#

trading gui without title looks cursed

humble tulip
pallid forge
#

quick question, how would you detect a player death that isnt a player? to detect player to player death im using
p instanceof Player && killer instanceof Player
but how would i do if the killer is not player? (this is just simple java i dont know i think lol)

steel swan
mortal hare
#

Armorstands wouldnt work in this example

#

what you need are packets

steel swan
#

So

mortal hare
#

you need to send packet to that player

#

whom you would like to display nametag

#

are you talking about nametags?

steel swan
#

create an armor stand that will follow a player, and only show it to certain players

#

@mortal hare yeah that should work

#

lemme test

mortal hare
#

that's not easy, but I have something like this created but that is old and broken

#

it requires more than that since you need to handle all the cases

#

e.g moving to dimension

sacred mountain
#

not spigot, but would this work?

dark harness
#

Can i get the Name from the Dropped Item in the players language?

humble tulip
#

I dont think he's talking abt a prefix

subtle folio
#

armor stands and packets to hide it from certain players would be best solution

twilit roost
#

any clues why it adds 001 ?

           int newLvl = (getRenownLevel(p))+1;
           setRenownLevel(p,newLvl);
           LvlAnnouncer.announceRenown(p,newLvl);
public static void announceRenown(Player p, int lvlTo){
    p.sendTitle(ColorUtils.hex(Colors.RENOWN_UP.toString())+"Renown Level Up!",ColorUtils.hex(Colors.GOLD_COLOR.toString())+"You are now Renown Level " + lvlTo + "!");
}
ivory sleet
#

+1

twilit roost
#

oh

ivory sleet
twilit roost
#

it adding to a text

steel swan
#

so ok i figured out a few things about earlier but i=now i m stuck : how can i make an armor stand invisible to certain players

#

(or the oposite)

#

like only show it to some players

twilit roost
sterile token
#

Hi i have a question, how i can call the method PaginatedMenu#getPage(index) ? Knowing that im tracking players as Map<UUID, InventoryMenu>. Where InventoryMenu is the super class of PaginatedMenu.

Atm i have this method: InventoryMenu getMenu(UUID uuid);
And method getPage(index) is not in the super class

dark harness
lost matrix
sacred mountain
chrome beacon
#

Spigot has hideEntity api now iirc

humble tulip
subtle folio
humble tulip
#

Yeah but it maybe does the same packet trickery internally

sterile token
steel swan
#

imma try to use packets

lost matrix
humble tulip
#

And you probably don't have to reupdate it on world change

chrome beacon
steel swan
lost matrix
sacred mountain
humble tulip
#

7 smile won't player.hideEntity work?

sacred mountain
#

com.googlecode

humble tulip
sterile token
# lost matrix Which json library is this?

"It should be PaginatedMenu extends InventoryMenu, not PaginatedMenu implements Menu" Do you remember you told me that? But now im stucked trying to call methods from the class that extends InventoryMenu

steel swan
#

wait but to use PacketPlayOutEntityDestroy what do i need to implement?

undone axleBOT
sterile token
#

Let me check

humble tulip
#

Why won't player.hideEntity work?

sterile token
humble tulip
#

And?

sterile token
#

You should not use depreated things

#

If someone use depretaed thing in most cases will not get help

chrome beacon
#

It's draft api. You can give it a try

humble tulip
#

It's draft api

#

Doesn't that mean it's there to be added in the future?

sterile token
#

Oh lmao no one help :/

#

Maybe i open a thread hahaha

humble tulip
#

Cast it?

#

Do an instanceof check and cast it

steel swan
#

so to use PacketPlayOutEntityDestroy and CraftPlayer for instance what do i need to import?

sterile token
#

Its not possible to do it without casting it?

humble tulip
#

Well you can't run a method from another class without casting no

#

Alternatively, you can make the singlepaged one always return the single page no matter the int requested

steel swan
#

@sterile token i implemented ProtocolLib but still can't use PacketPlayOutEntityDestroy

#

nvm sorry

sterile token
#

Maybe you find what you are looking

#

Oh sorry

#

so wait let me read it

#

And see if find what you need

#

So you need to give all privileges to root user right?

#

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert_password';

#

Allright

#

Let me stil lcheck

mortal hare
sterile token
#

Could you fix it?

ornate patio
#

will decimal values this small cause issues

if (isPlayerNearby) {
    superiorHorse.comfortabilityStat().add(0.000000833333);
} else {
    superiorHorse.comfortabilityStat().add(-0.000000138888889);
}
undone axleBOT
ornate patio
#

bruh

sterile token
#

yeah what more i can said

ornate patio
#

im saying like will it cause incomprehendable issues in the future

sterile token
#

just test it

ornate patio
#

in the long run

iron palm
#

yo ik that this is not related to spigot api really but i can't find the problem seriously so i've decided to ask here.
Im having problem with SQLite/MySQL commands which throws a SQLException
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (unrecognized token: "574144a0")

    public static String CREATE_TABLE = "CREATE TABLE IF NOT EXISTS players (uuid CHAR(36) PRIMARY KEY,balance DOUBLE, deaths INT, kills INT, class STRING)";
    public static String FIND = "SELECT EXISTS(SELECT * FROM players WHERE uuid =uid)";
    public static String INSERT_INTO = "INSERT OR IGNORE INTO players(uuid,balance,deaths,kills,class) VALUES(?,?,?,?,?)";
    public static String UPDATE = "UPDATE players SET balance =?,deaths =?,kills =?,class =? WHERE uuid =?";

this is all of my commands and it throws the error on finding a data...
any idea what should i do?
the code that throws me the error:

    public DwarvRes getResultOf(UUID uuid) {
        Statement statement = null;
        String FIND_TABLE = "SELECT EXISTS(SELECT * FROM players WHERE uuid ="+uuid+")";
        ResultSet res = null;
        try {
            statement = connection.createStatement();
            assert statement != null;
            res = statement.executeQuery(FIND_TABLE);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return new DwarvRes(res);
    }
sterile token
#

That why i prefer mongo

#

Its pretty much simply

#

And you dont get ilnesses caused of mysql shit commands

quiet ice
#

And that is why I do not use any database engines at all

sterile token
#

Also is not okay using the uuid="+uuid+""

#

Its recommend to use:

PreparedStatement statement = new PreparedStatement("SELECT * FROM players WHERE uuid=?");
statement.setString(0, uuid);

#

If im not wrong

worldly ingot
#

Sometimes when I'm feeling bold, I just don't care about saving any data at all. Players can just re-apply their settings every time they log in or switch servers Kappa

iron palm
#

btw i found that select exists prevents from sqlexception

waxen plinth
#

Better to pause all server activity to prompt the player for their choice anytime a choice needs to be made

worldly ingot
#

+1

sterile token
#

Althought mongo has shits too

#

He get annoyed when im telling him to add a codec for Location, because the class doesnt have native types (String, int, double, boolean) instead the class have Boolean, Integer

#

Haha

#

Database in general are a problem

worldly ingot
#

If you're wanting to create a PreparedStatement, use Connection#prepareStatement()

eternal oxide
#

they are not a problem, just another thing to learn

sterile token
#

It had happen 1y since las time i touched Mysql

#

Any recommendations for building a menu api?

twilit roost
#

Im using custom resource pack which replaces some unicode characters for textures

And yet here I am wondering how to change the fonts programatically
aka can I have multiple .json files, multiple textures binded on same Unicode?

sterile token
ornate patio
#

i have a really simple math problem but its not really working in game-

#

this will run every tick right

#
new BukkitRunnable() {
    @Override
    public void run() {
        for (SuperiorHorse horse : superiorHorses) {
            ComfortabilityStat.tick(horse);
        }
    }
}.runTaskTimer(SuperiorSteed.getInstance(), 1, 1);
waxen plinth
#

BukkitRunnable 😒

sterile token
waxen plinth
#

Here

ornate patio
#

i was told to use this a long time ago lmao

iron palm
#

im still getting that stupid error
org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (unrecognized token: "97a2")
the only thing that ik from this error is that "97a2" is a part of my UUID

sterile token
#

?status

ornate patio
#

whats wrong with it

sterile token
#

Is the bot down?

#

?di

undone axleBOT
sterile token
#

Oh not its active

ornate patio
#

i know what dependency injection is-

sterile token
#

So why you dont use it?

ornate patio
#

what does that have to do with a bukkit runnable

sterile token
#

Not bukkit runnable, use DI for java in general

waxen plinth
#
Bukkit.getScheduler().runTaskTimer(plugin, () -> superiorHorses.forEach(ComfortabilityStat::tick), 1, 1);```
#

:)

ornate patio
#

but that doesnt have anything to do with the bukkit runnable stuff lmao

sterile token
#

I know but we are giving advices

ornate patio
#

where in my code does it show that im not using dependency injection

sterile token
#

Redempt could know that im still ith the manu fact

iron palm
waxen plinth
ornate patio
#

this runs every tick right

waxen plinth
#

Yes

ornate patio
#

i'm trying to add 0.01 to the "comfortability" stat to the horse every minute if the player is standing next to it

sterile token
waxen plinth
#

That's not a good way to do it then

ornate patio
#

so I simply add .01 / 60 / 20 every tick

waxen plinth
#

Loop over players, get nearby horses, and add the stat

ornate patio
waxen plinth
#

Rather than looping over every horse and checking for nearby players

ornate patio
#

if a player is not next to it

waxen plinth
#

Oh

#

In that case you should store timestamps so you can calculate the stat on demand

ornate patio
#

the thing is that theres a ton of factors that is constantly altering the stat

#

it'll be a pain to set up timestamps like that

waxen plinth
#

Tick is fine then I guess

#

Set the task timer to run every 20 * 60 ticks

#

Leave it as 20 * 60, not 1200

#

It's more explicit about intent

ornate patio
waxen plinth
#

Ok then schedule another task for that

ornate patio
#

like every tick theres 5 functions that needs to be run on the horse every tick

iron palm
waxen plinth
#

Then schedule a task for those

ornate patio
#

a seperate task for each one?

#

isnt that inneficient

waxen plinth
#

And a separate task that runs every 60 seconds

#

No, 2 tasks

ornate patio
#

oh

#

i guess

waxen plinth
#

Though 6 tasks wouldn't make much of a difference

sterile token
waxen plinth
#

Slightly more memory usage and slightly more overhead

ornate patio
#

whatever ill create a new task for every 60 seconds

waxen plinth
#

Could be floating point errors

ornate patio
#

doubles have 16 decimals places tho

#

the result is less than 16 digits

#

i guess floating point errors could still do something

humble tulip
#

Override the tick method and make sure you call the super method then do ur custom stuff that ubwanna run each tick

#

Actually it depends

#

On what ur doing each tick

ornate patio
humble tulip
#

What u wanna do each tick?

ornate patio
#

also i have a structured setup

ornate patio
ornate patio
#

so I sometimes need to loop over the wrappers

ornate patio
pallid forge
#

Hey, so all I wanna do is when a command is run, flip a boolean.

    public static boolean ctfstartBool;
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        ctfstartBool = !ctfstartBool;
        if (ctfstartBool = true) {
            sender.sendMessage("CTFSTART = TRUE");
        }
        if (ctfstartBool = false) {
            sender.sendMessage("CTFSTART = FALSE");
        }
        return true;
    }
}```

The command works, but all it will give me is true, no matter how many times I run it. Obviously, i did something wrong lol. Any idea what?
#

the command works, but it just gives true no matter what

eternal oxide
#

== to compare bool. you are setting it in your if check

pallid forge
#

oh lolol

#

that makes sense lol

eternal oxide
#

Better to use java if (ctfstartBool) { sender.sendMessage("CTFSTART = TRUE"); } else { sender.sendMessage("CTFSTART = FALSE"); }

gritty urchin
#

Hey

#

does anyone know how to place two portal blocks

#

with no frame next to eachother

twilit roost
#

How to set Inventory Title to BaseComponent?

gritty urchin
#

As per this image

#

@eternal oxide

twilit roost
#

pseudocode
1: get 2 locations where you want those portal to be
2: get Block from those locations
3: setType to portal

gritty urchin
#

done that, portals seem to place 1 block apart

twilit roost
#

can I get ur code?

#

?paste

undone axleBOT
chrome beacon
twilit roost
#

not looking forward for using any API

#

soo should I get NMS version of the inventory and set the name to BaseComponent ?
Same with entities?

gritty urchin
# twilit roost ?paste
   Location loc2 = new Location(Bukkit.getWorld("world"), 55, 68, 284);
   loc1.getBlock().setType(Material.PORTAL);
   loc2.getBlock().setType(Material.PORTAL);```
twilit roost
#

🤦
the paste was for u to paste into that website

#

nvm

gritty urchin
#

yeh ik

#

its easier to just paste in chat

gritty urchin
#

but not for portal

humble tulip
#

Can u send a ss?

#

?

#

Of the portals

gritty urchin
#

of it not working?

#

They dont place at all

humble tulip
gritty urchin
#

when I use this code

#

they place 1 block apart

#
loc.add(0, 2, 0).getBlock().setType(Material.PORTAL);```
humble tulip
#

Ofc it does

#

loc.add modifys the loc itself

gritty urchin
#

yes I know that

humble tulip
#

Then add 1 in the second line

gritty urchin
#

yeah doesnt work

#

nothing appearing

humble tulip
#

If the y is 0 initially, you add 1 and set the block at y=1 to portal and then add 2 so y is now 3 and sets to portal

gritty urchin
#

yeah i understand

#

no portal produced

grim oak
#

fucking hell my message keeps sending before i finish it

twilit roost
#

How to get NMS Entity from CraftEntity?

humble tulip
chrome beacon
humble tulip
#

Cqncel the blockphysics event that tries to break ur portal

river oracle
#

wjat

#

is this

twilit roost
#

How to convert BaseComponent into Component?

gritty urchin
#

not working still

gritty urchin