#help-development

1 messages · Page 1708 of 1

solar sable
#

it shows .addPlayer

young knoll
#

They did say it's deprecated

solar sable
#

hmm

#

hmm how to fix this 🤔

neon nymph
#

You may also try Team.addEntry(player.getName());

#

That's the non deprecated one

solar sable
#

oh speaking of that

#

theres this thing in the cod

#

that idk what it does

#

(i didnt write the code, someone said he was gonna fix it a bit so i didnt put the scheduler)

#

idk what it do cause it wasnt showing in game

eternal oxide
#

its not a static method of Team

solar sable
#

oh

neon nymph
#

Get the team first

solar sable
#

how?

neon nymph
#

Probably something like Team damage = player.getScoreboard().getTeam("damage");

solar sable
#

in the scoreboard yes?

neon nymph
#

Then damage.addEntry(player.getName());

#

I haven't dealt with scoreboard yet so not entirely sure how it operates

solar sable
#

it shows that "damage" is already used in this scope

vague oracle
#

You should learn Java first

solar sable
solid cargo
#

change it to something else

quaint mantle
#

Is there a way to like enable every shulker box type (blue, green, red, etc..) without having to multiply the recipes or smth like that?

ShapedRecipe recipe = new ShapedRecipe(NamespacedKey.minecraft("wand"), PokeballApi.getPokeball());
        recipe.shape(
                " E ",
                 "DSD",
                 " N ");

        recipe.setIngredient('E', Material.ENDER_PEARL);
        recipe.setIngredient('D', Material.DRAGON_BREATH);
        recipe.setIngredient('S', Material.SHULKER_BOX);
        recipe.setIngredient('N', Material.NAME_TAG);

        pokeballMain.getServer().addRecipe(recipe);

toxic hazel
#

hi guys, I apparently need org.bukkit.event.world.EntitiesLoadEvent, but my gradle build script can't seem to find it; I have compileOnly("org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT") as a resource and api-version 1.17 is declared in plugin.yml, what do I miss?

neon nymph
solid cargo
patent horizon
#

anyone have an up to date resource for scoreboards?

young knoll
river spear
#

At the InventoryClickEvent, the event is canceled, but when I press Shift on the items, they bug into my inventory

quaint mantle
#

tag?

vague oracle
#

Inventory click event is supply buggy, it doesn’t get run half the time

young knoll
#

Never had an issue with it

solid cargo
#

@solar sable you have defined "damage" twice

quaint mantle
#

How would I approach making an drag and drop enchant book

#

oh um and how do i implement that tag never worked with it

solar sable
quaint mantle
#

like Tag<Material.SHULKER_BOX>

solid cargo
#

did you refactor?

solar sable
#

i changed it to Team player = player.getScoreboard().getTeam("damage")

quaint mantle
quaint mantle
solid cargo
#

change it to something like damage2

quaint mantle
#

is there a way to know the BlockFace which the Player is looking at ? nvm found it

solar sable
eternal oxide
#

if (Tag.SHULKER_BOX.isTagged(itemHere))

solid cargo
eternal oxide
#

oh however its spelt

ancient plank
#

SHULKER_BOX

young knoll
#

They want it for a recipe

solar sable
solid cargo
solar sable
#

you told me to make it damage2

neon nymph
#

To set the player's team

#

It should be placed in a playerJoinEvent

solar sable
solid cargo
#

what is the error now btw @solar sable

solar sable
#

@neon nymph like this?

ancient plank
#

"hi i have issue, idk what's causing it so here's a screenshot. there's red lines but i choose to ignore them because idk what they are"

solar sable
# solid cargo what is the error now btw <@!471969865453010944>
[00:11:54] [Server thread/INFO]: [CoolPluginTest] [STDOUT] damage Team was either deleted, or doesn't exist
[00:11:54] [Server thread/WARN]: java.lang.IllegalAccessException: Damage cannot be null
[00:11:54] [Server thread/WARN]:     at testing-1.0.jar//me.amxyargaming.testing.PlayerScoreboard.updateDamage(PlayerScoreboard.java:48)
[00:11:54] [Server thread/WARN]:     at testing-1.0.jar//me.amxyargaming.testing.PlayerScoreboard.lambda$showScoreboard$0(PlayerScoreboard.java:37)
[00:11:54] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101)
[00:11:54] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483)
[00:11:54] [Server thread/WARN]:     at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1559)
[00:11:54] [Server thread/WARN]:     at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:479)
[00:11:54] [Server thread/WARN]:     at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1475)
[00:11:54] [Server thread/WARN]:     at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1274)
[00:11:54] [Server thread/WARN]:     at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319)
[00:11:54] [Server thread/WARN]:     at java.base/java.lang.Thread.run(Thread.java:833)
solid cargo
#

wait @solar sable can you explain what you want to achieve today?

neon nymph
quaint mantle
solid cargo
#

damage dealt?

shadow tide
solar sable
quaint mantle
dry pike
#

How would I set a location yaw and pitch to match a vectors direction?

neon nymph
#

Tag.SHULKER_BOXES.getValues().forEach(material -> recipe.setIngredient('S', material));

#

@quaint mantle

quaint mantle
#

thanks

neon nymph
#

Idk if that works, but try

solar sable
#

do i ignore it or

young knoll
#

No

#

Just

neon nymph
#

Ensure damage != null

young knoll
#

Sigh

shadow tide
solar sable
neon nymph
#

if (damage != null) return; Or something like that

young knoll
#

new RecipeChoice.MaterialChoice(Tag.SHULKER_BOXES)

solar sable
#

better?

neon nymph
#

Yea sure

solar sable
#

or this lol

neon nymph
#

Either you prefer

solar sable
#

ill just use the if (damage != null)

shadow tide
#

or if (damage != null) return;

quaint mantle
shadow tide
neon nymph
#

And for debugging purposes, add a temporary else that prints out "damage is null sad"

solar sable
#

lol

#

crossing fingers hoping this will work rn

#

also whats the difference from POSTWORLD and STARTUP ?

toxic hazel
neon nymph
#

Your plugin gets loaded before the world itself is loaded or after

solar sable
#

what about making it load first than the other plugins lol its a just a thing that is funny to learn

neon nymph
#

It's fine, but if your plugin depends on another plugin, that other plugin needs to be loaded first

solar sable
#

aah

#

okeh ok

#

also can i just say that, using this --> ChatColor.translateAlternateColorCodes('&', "<put message here>")); is just wonderful

shadow tide
#

help

#

@eternal oxide

eternal oxide
#

?paste your class

undone axleBOT
shadow tide
#

I did

solar sable
#

and it is still not updating 🙂 @neon nymph

#

theres no error in console either

#

its just not updating

shadow tide
#

my brain java if (CJ.hasProblem == true && ElgarL isOnline true || imaginedev isOnline true) { System.out.println("At one of them")} lol

eternal oxide
shadow tide
#

lol

solar sable
neon nymph
#

Yep, figures

#

You're missing lots in your project

solar sable
#

that i know

neon nymph
#

To start, save your new scoreboard somewhere

solar sable
#

okeh

neon nymph
#

Then when a player joins, set their scoreboard to that

solar sable
#

lemme try hold on

#

imma just create another scoreboard class

ivory sleet
solar sable
#

or reuse this one

neon nymph
#

I highly suggest you learn java first, plugin development assumes you already know the basics

shadow tide
undone axleBOT
shadow tide
#

I did some some now me intermediate yay

ivory sleet
#

Ye same lol

quaint mantle
#

sorry for asking a lot, can anyone help me with this ?

eternal oxide
ivory sleet
#

You know default runs regardless ?

shadow tide
eternal oxide
#

Home is using a

shadow tide
#

lol

ivory sleet
#

I believe it even bypasses break @quaint mantle

shadow tide
#

I was being dumb

#

forgot to change that

quaint mantle
ivory sleet
#

The default

quaint mantle
#

i removed it

ivory sleet
#

It will run on all cases

quaint mantle
#

and it is the same

#

none will get detected

ivory sleet
#

Send

#

?paste

undone axleBOT
ivory sleet
#

(:

slim kernel
#

I just copied it to IntelliJ and it says "cannot resolve symbol lombok" How can I fix that?

ivory sleet
#

Add the Lombok plugin in IntelliJ

#

Or just not use Lombok imo

quaint mantle
solar sable
young knoll
#

default does not run regarless

quaint mantle
#

im going to eat dinner

shadow tide
#

@eternal oxide Still not working

lost matrix
ivory sleet
#

Then pmz check if hologramManager still is null, if it is then prompt the console with the abnormal version message

ivory sleet
#

Well haven’t used switches in ages so that’s probably why

eternal oxide
slim kernel
shadow tide
#

when I do /home, it just says "You do not yet have a home set! Set one with /sethome"

eternal oxide
#

I assume you did already set one?

shadow tide
#

yes

#

I think

#

idk if it actually set one

#

I did /sethome

#

it could be a problem with either one

eternal oxide
#

put a sysout in the sethome to tell you when you set it

#

and make sure line 23 in Home uses "home"

slim kernel
slim kernel
tardy delta
#

i'll try

gaunt saffron
#

any tipps? anything? the minecraft version is called limbo

neon nymph
solar sable
# neon nymph Yes

so i create a new scoreboard and then set the onPlayerJoin to that scoreboard, got it

quaint mantle
#

Can i somehow serialize or save all the values about a Entity class (Zombie, etc...) to yaml config?

neon nymph
#

After creating a new scoreboard create a new team in it as well

ivory sleet
#

Get it’s tag compound probably Pavlyi

#

Using nms

#

An easy way to do it but not flexible

quaint mantle
#

eehh and how do i get the tag compound ?

ivory sleet
#

((CraftEntity)entity).getHandle().getTag() or smtng

#

Basically the nms nbt tag

quaint mantle
#

oh okaay

shadow tide
#

@eternal oxide I got it working!

quaint mantle
#

if i dont have the CraftEntity class i need the spigot and not ther spigot-api right?

quaint mantle
#

you mean should i check if

#

hologrammanager == null ?

ivory sleet
#

Yeah

quaint mantle
#

after the switch

#

right ?

ivory sleet
#

Ya

solar sable
#

?paste

undone axleBOT
quaint mantle
ivory sleet
#

Yeah probably named something else

shadow tide
#

@eternal oxide I thought it was working, for some reason it works for me, but I got one of my friends to get on and they tried it and nothing happened

eternal oxide
#

do your commands need permissions to use?

shadow tide
#

nope

#

the commands work

#

I think

#

wait

#

lemme ask him something

#

I asked him, and it didn't say "You do not yet have a home set! Set one with /sethome" to him

eternal oxide
#

if you added permissions to the plugin.yml

shadow tide
#

like I said, I didn't

eternal oxide
#

didn;t you set it to ops?

shadow tide
eternal oxide
#

ok, only heal is op

shadow tide
#

ye

eternal oxide
#

no clue then. There is nothing in your code that I've seen which would make it work for one person and not another.

shadow tide
#

I'm using the player name as the key

eternal oxide
#

what?

#

use "home"

shadow tide
#

oh

#

lol

#

would that ruin it

#

cuz its working 4 me

eternal oxide
#

players can change names

shadow tide
#

I know

#

but

#

like

eternal oxide
#

then they would be left with junk data in their player file and would lose their homes

shadow tide
#

ok, I will. But I'm guessing that wouldn't fix the big problem

balmy coyote
#

Is there a way to find out whenever Player is feeding Animal and prevent that?

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onAnimal1(PlayerInteractEvent e){
        e.setCancelled(true);
    }
      @EventHandler(priority = EventPriority.HIGHEST)
    public void onAnimal2(EntityInteractEvent e){
        e.setCancelled(true);
    }

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onAnimal3(PlayerInteractAtEntityEvent e)
        e.setCancelled(true);
    }```
Tried cancelling those events with both HIGHEST and also LOWEST priority and it seems to just be ignoring it.
Any clues?
quaint mantle
balmy coyote
#

I'm cancelling all at the same time

#

And it still bypasses them

#

And feeds and consumes the items

eternal oxide
#

did you register the listeners?

balmy coyote
#

Yes

#

Anything else in the Sever it's cancelled due to events also cancelled

#

Literally i can't do anything

#

But feed Animals

#

Somehow?

#

Tried searching in Google,Bukkit,Spigot any other forum i could find

#

No clues

acoustic pendant
#

What's the javadoc to give an user an item when he joins?

balmy coyote
#

Still bypassing

patent horizon
#
    public void createScoreboard(Player player) {

        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard scoreboard = manager.getNewScoreboard();
        Objective objective = scoreboard.registerNewObjective("title", "dummy", ChatColor.translateAlternateColorCodes('&', "&b&lCYBERCADE &7["+Bukkit.getOnlinePlayers().size()+"&7]"));
        objective.setDisplaySlot(DisplaySlot.SIDEBAR);

        // I left out the lines

        player.setScoreboard(scoreboard);

when a player disconnects from the server, does the server automatically add the scoreboard to the garbage collector? i've seen other people delete thier scoreboards from helpers when the players disconnect. should i do this too?

balmy coyote
dense remnant
#

Hey, I am currently trying to import another plugins source code to make my own (private) version.
It is made with gradle and I have got everything imported in. My only problem now is that there is a .kt (kotlin?) file for the "volatile code" (I guess for making it work on multiple versions) and my problem is, that it somehow cant find the craftbukkit & the net.minecraft packages even though I have manually imported them.

patent horizon
#

does your private plugin allow kotlin files in it?

#

if not, intellij has a kotlin>java converter

ancient plank
#

show code at JoinListener line 20

#

gg

rain igloo
#

I have a question about IntelliJ
Can I compile just certain files into a jar file? and if yes, how?
I know that there is a plugin for MC developement,a nd I also have it, but I am following a book I was gifted about making MC plugins, so I'm trying to do what it says, and it wants me to use eclipse, but I prefer IntelliJ's look (bcz I'm used to PyCharm lol)
but idk how to compile my files into a jar file..
I have a plugin.yml and a pluginname.java file so far, and ig the IDE can make a .jar file out of those somehow... i just don't know how...

naive drift
#

Hello,

I have a little problem with Spring, I am not sure if there is someone good with it. But i am
using spring boot (https://github.com/Alan-Gomes/mcspring-boot), And sometimes i have a trouble, it throw
me a up an exception (NoClassDefFoundException). But i dont know why. I looked up something about it, but i couldnt
solve the problem out.

Code on Enable:

 Thread.currentThread().setContextClassLoader(getClassLoader());
      
        ResourceLoader loader = new DefaultResourceLoader(getClassLoader());
        SpringApplication application = new SpringApplication(loader, Application.class) {
            @Override
            public void setListeners(Collection<? extends ApplicationListener<?>> listeners) {
               super.setListeners(listeners
                       .stream()
                        .filter((listener) -> !(listener instanceof org.springframework.boot.context.logging.LoggingApplicationListener))
                        .collect(Collectors.toList()));
            }
        };

        application.addInitializers(new SpringSpigotInitializer(this));
        Properties properties = new Properties();
        try {
            properties.load(getClassLoader().getResourceAsStream("application.properties"));
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        setupDatabase(properties);
        application.setDefaultProperties(properties);
        this.context = application.run();```
ancient plank
#

there's a book for making minecraft plugins? sounds like a waste of money lol

rain igloo
#

seemingly there is
but hey it teaches me the basics of java and plugin dev so why not

#
  • it's rude to just tell my big bro "f off with that waste u bought" lol
    I appreciate it ^^
ivory sleet
#

yes you can compile only certain files

#

however you would have to modularise your structure

#

unlike python

#

java has to compile

#

so it would be a big problem if you could handfully select a few classes contained in a source set

rain igloo
ivory sleet
#

Yeah I enjoy python for small stuff

#

but it becomes quite messy when trying to scale projects from my experience

rain igloo
ivory sleet
#

at least if you take an object oriented approach that is

balmy coyote
rain igloo
ivory sleet
#

yes

rain igloo
#

nice

ivory sleet
#

it is multiparadigm after all x)

rain igloo
#

yo what does that mean? xD

ivory sleet
#

style of programming - paradigm

#

multiparadigm means it contains the features which provides the developer to use different styles

#

there's mainly functional, object oriented and procedural iirc

#

well logical

#

also

rain igloo
#

I think it's kinda obvious that I'm a true noob to programming haha
I barely have any experience, and only know C++ basics, and just a lil bit of python

ivory sleet
#

yeah

rain igloo
#

well anyway...
would you mind explaining to me how I can compile these two files I have intoa jar file? ':D

ivory sleet
#

anyways by modularize I mean that you can have multiple source sets and then select which sourcesets to include into your jar

rain igloo
ivory sleet
#

you said earlier that you used intellij?

rain igloo
#

and tbh I have no clue what I could / should do with the .idea folder

ivory sleet
rain igloo
ivory sleet
#

I recommend reading that guide

#

I'd recommend IntelliJ

#

but the importance is that you give every ide a try before deciding which one to use

rain igloo
#

yeah it was recommended to me too

ivory sleet
#

even when you become more advanced

#

try them all out once in a while

rain igloo
ivory sleet
#

yeah

#

but you can get quite productive with eclipse nevertheless

opal frigate
#

Sublime text 😁

rain igloo
#

I agree, because IMO if you know how to use your IDE, then it doesn't matter which one you are using

rain igloo
ivory sleet
#

pretty much

naive drift
ivory sleet
#

if you havent done that

#

and thats a huge lib

rain igloo
naive drift
#

I have dont that, its work sometimes, but sometimes It throw up this exception

ivory sleet
#

?paste the entire stacktrace

undone axleBOT
naive drift
#

I have that(Spring-Boot) in lib folder, and plugin is separated

chrome beacon
#

Spring is a good framework. Setup some basic REST api and a simple frontend and backend in less than 30min

naive drift
#

I just have spring-boot 😄 not other thinks

chrome beacon
#

20mb ish

ivory sleet
#

yuaa

#

all the AbstractFactoryProviderVisitorImpl

#

or smtng lol

chrome beacon
#

I'm not making a plugin so that's perfectly fine for me

ivory sleet
#

yeah

#

quite nice with kotlin also btw

chrome beacon
#

Kotlin :kekw:

ivory sleet
#

😏

naive drift
ivory sleet
#

well

#

I am still going to ask for the stacktrace

#

just the NCDFE doesnt say much else than that some class couldnt be loaded during runtime due to absence

naive drift
#

I looked up for it, but didnt find anything

digital rain
#

just a quick question, why does the server memorize the attribute max_health, but not the attribute movement_speed (entity is a player) after reconnecting

#

ping when you respond ty :)

ivory sleet
#

that at blah
at blah.blah

#

is the stack trace

ivory sleet
digital rain
#

let me check

digital rain
ivory sleet
#

hmm

#

maybe movement speed is just considered transient data

young knoll
#

Shouldn't be

#

All attributes should persist

ivory sleet
#

¯_(ツ)_/¯

#

presumably yeah

naive drift
#

Hmmm

digital rain
#

i even cleared all the other plugins, and so its not a cause for sure

plain scroll
#
                } else if (e.getCurrentItem().getType() == Material.RED_BED) {
                    String name = ChatColor.stripColor(e.getClickedInventory().getItem(4).getItemMeta().getDisplayName());
                    Player playerwhoisban = Bukkit.getPlayer(name);
                    Location bedloc = playerwhoisban.getBedLocation();
                    p.teleport(bedloc);
                    playerwhoisban.playEffect(playerwhoisban.getBedLocation(), Effect.DRAGON_BREATH, 0);
                    p.sendMessage(ChatColor.GREEN + "TP'd to" + name + "'s Bed!'");
                    System.out.println(ChatColor.WHITE + "[" + ChatColor.RED + "BAN EM" + ChatColor.WHITE + "]" + " " + ChatColor.RED + "Just Gone TO " + " " + name + "'s Bed!");
                    p.playNote(p.getEyeLocation(), Instrument.PIANO, Note.flat(1, Note.Tone.A));```
#

anyone know why this aint working ?

#

nvm

#

works

naive drift
#

What do u think?

digital rain
#

ive found out that the attribute saves but when i relog it resets

#

if thats helpful

ivory sleet
#

ah

#

@naive drift

#

is that sk.westland.world your code?

naive drift
#

yea

ivory sleet
#

send ur repo again

#

Ill have a closer look

naive drift
#

repo ?

ivory sleet
#

gh repo

#

I think you did link one before

digital rain
#

slovakia instead of montenegro smh 😄

naive drift
#

😄

#

This is my forked repository and modified for 1.17 version

#

Just upgraded spring boot version to newest and changed compile version to java 16

ivory sleet
#

where is the sk.westland.world code?

naive drift
#

oh u look after for my code its private 😄

#

but what do u need from this code ? just command ?

ivory sleet
#

well I dont need the code

#

but the build structure

#

because it says one of your classes is missing (not contained in ur jar presumably)

#

(the exception and the stacktrace)

echo basalt
#

This might sound dumb but how can I want for an event to get called inside a CompletableFuture?

#

Or some action to happen

ivory sleet
#

Just call PluginManager#callEvent inside the future?

echo basalt
#

I mean

#

Wait for an event to get called

#

not call it

naive drift
#

I know what do u mean, but it throws me sometimes not always

ivory sleet
#

inside the future?

echo basalt
#

Yeah

#

Maybe a lock system of some kind?

ivory sleet
#

Idk I mean the callEvent method will call the event on the thread which invoked the function

echo basalt
#

My idea is like

ivory sleet
#

so naturally it will be blocking on that thread which the future runs on

eternal oxide
#

you don't wait for an event in a Future, you start the Future when the event fires

echo basalt
#
wait for event to get called
return some event value on the future
ivory sleet
#

oh yeah then locking might be need

#

probably want to go with a fifo reentrant lock here

echo basalt
#

Could you give an example?

naive drift
#

List is null ?

echo basalt
#

seems to me that the lock would require a while loop 🤔

naive drift
#

show to us a main.bossBar

echo basalt
#

that might tank performance

balmy coyote
ivory sleet
#

If I understood correctly

Lock lock = new ReentrantLock(true);
Condition condition = lock.newCondition();
AtomicReference<V> ref = new AtomicReference<>();

CompletableFuture<?> future = CompletableFuture.supplyAsync(() -> {
  condition.await(); //try and catch ofc
  Value value = ref.get();
});
void on(E e) {
  lock.lock()
  try {
    ref.set(e.getValue());
    condition.signal();
  } finally {
    lock.unlock();
  }
}```
Might want something like this but with a reusable condition
#

also yeah

#

the locking might not even be needed

#

and if thats the case

#

maybe a CyclicBarrier would be better here

#

assuming you wanna await some value

echo basalt
#

Basically my code looks a bit like this

ivory sleet
#

oh

echo basalt
#

Packet system is proprietary

ivory sleet
#

btw

#

check that out

#

idk if a reentrant lock is totally necessary here

#

and (condition)

echo basalt
#

The packet is sent through some handler and another packet is sent back with the response

ivory sleet
#

oo yeah

naive drift
#
public class Main extends JavaPlugin {
    
    BossBar bossBar;
    private static Main main;

    @Override
    public void onEnable() {
      main = this;
        Bukkit.getPluginManager().registerEvents(new JoinListener(this), this);
        
        BossBar bossBar = Bukkit.createBossBar(
                ChatColor.BLUE + "Welcome To LaserTag Have Fun",
                BarColor.BLUE,
                BarStyle.SOLID);
        
    }

public static Main getInstance(){
   return main;
}

public BossBar getBossBar(){
   return bossBar;
}
        
    
}```


--- JoinListener:
```Main.getInstance().getBossBar().addPlayer(...);```

do something like this
echo basalt
#

why

#

why are you doing singleton + dependency injection

#

naming your class Main and not making your bossBar private

#

while having no indentation

ivory sleet
#

oh god

ancient plank
#

monka

echo basalt
#

how tf does this lock stuff work

#

I kinda gotta double lock

#

Like

#

I block the thread until another method gets called 🤔

lavish hemlock
#

Senor, the main does not have error, if you bothered to hover over it you'd see your IDE is warning you to make the field final.

worldly ingot
#

and if you're passing through your main instance, use it. Don't use the static accessor you've created

#

You have an instance there 😛

lavish hemlock
#

God even my codestyle as someone learning Java was better than whatever the fuck is going on here.

worldly ingot
#

Everyone learns differently

digital rain
#

ok so back to the attribute movement speed, ive tried it on all levels do i report it as a bug?

worldly ingot
#

On what entity? Not all entities support that attribute

digital rain
#

player

#

i mean that after logging back on the attribute resets

#

everything works fine just that one thing, i mean its easy to go around it and save the number, and then after relogging setting his speed again, but its annoying

worldly ingot
#

Oh, of course it does. afaik player attributes aren't persistent

digital rain
#

max health is persistent

worldly ingot
#

Well, that depends. How are you setting it? With a modifier? Or just setting the base value?

digital rain
#

setting the base value

worldly ingot
#

That may be why. afaik, modifiers are saved

#

Should be using modifiers anyways

digital rain
#

whats exactly a modifier, like a link or smth ;)

digital rain
#

oh ok thanks

worldly ingot
#

new AttributeModifier(UUID.fromString("a-constant-uuid-here"), "some unique name here", 2.0, Operation.ADD_NUMBER)

#

That will add 2.0 to the base value

#

I'd make that UUID.fromString() a constant somewhere so you can easily refer to it. If you just use UUID.randomUUID(), it will make a new one each time and re-apply it. Not ideal

digital rain
#

hmm okay

torn oyster
#

is PlayerTeleportEvent called after or before the teleport?

#

nvm

mystic terrace
#

Can someone help me? I'm making a plugin and the code doesn't give me any error but when I put in on the Minecraft server, the console shows this:

java.lang.IllegalArgumentException: Plugin already initialized!
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:224) ~[patched_1.17.1.jar:git-Paper-278]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:53) ~[patched_1.17.1.jar:git-Paper-278]
        at me.mrstreeet.logintitle.LoginTitle.<init>(LoginTitle.java:21) ~[LoginTitle-1.0-SNAPSHOT.jar:?]
        at me.mrstreeet.logintitle.LoginTitle.onEnable(LoginTitle.java:28) ~[LoginTitle-1.0-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[patched_1.17.1.jar:git-Paper-278]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[patched_1.17.1.jar:git-Paper-278]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:500) ~[patched_1.17.1.jar:git-Paper-278]
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugin(CraftServer.java:535) ~[patched_1.17.1.jar:git-Paper-278]
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.enablePlugins(CraftServer.java:449) ~[patched_1.17.1.jar:git-Paper-278]
        at net.minecraft.server.MinecraftServer.loadWorld(MinecraftServer.java:725) ~[patched_1.17.1.jar:git-Paper-278]
        at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:306) ~[patched_1.17.1.jar:git-Paper-278]
        at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1212) ~[patched_1.17.1.jar:git-Paper-278]
        at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:319) ~[patched_1.17.1.jar:git-Paper-278]
        at java.lang.Thread.run(Thread.java:831) [?:?]
Caused by: java.lang.IllegalStateException: Initial initialization
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:227) ~[patched_1.17.1.jar:git-Paper-278]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:53) ~[patched_1.17.1.jar:git-Paper-278]
        at me.mrstreeet.logintitle.LoginTitle.<init>(LoginTitle.java:21) ~[LoginTitle-1.0-SNAPSHOT.jar:?]
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
        at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:78) ~[?:?]
        at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
        at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
        at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) ~[?:?]
        at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:350) ~[?:?]
        at java.lang.Class.newInstance(Class.java:642) ~[?:?]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:83) ~[patched_1.17.1.jar:git-Paper-278]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:153) ~[patched_1.17.1.jar:git-Paper-278]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:414) ~[patched_1.17.1.jar:git-Paper-278]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:322) ~[patched_1.17.1.jar:git-Paper-278]
        at org.bukkit.craftbukkit.v1_17_R1.CraftServer.loadPlugins(CraftServer.java:410) ~[patched_1.17.1.jar:git-Paper-278]
        at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:276) ~[patched_1.17.1.jar:git-Paper-278]
        ... 3 more```
lost matrix
worldly ingot
#

That or you have two of the same plugin in the plugins folder

worldly ingot
#

Then yeah, strange constructor business

mystic terrace
#

1s

#

lemme do a pastebin better

worldly ingot
#

Was your first line in onEnable()

#

You're doing new LoginTitle()

mystic terrace
worldly ingot
#

getServer().getPluginManager().registerEvents(new LoginTitle(), this);
You can't create new instances of your plugin

lost matrix
worldly ingot
#

Besides. You have an instance. It's itself

#

Refer to this instead

mystic terrace
#

Okey, tsym ^^

#

done

worldly ingot
#

👍

mystic terrace
#

My plugins folder:

opal juniper
#

did you instantiate your main class

lost matrix
mystic terrace
#

nope

#
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;

public final class LoginTitle extends JavaPlugin implements Listener {


    public static LoginTitle instance;

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
        getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "[LoginTitle] Plugin it's working in the version 1.0 BETA.");
        getCommand("reload").setExecutor(new Reload());

        createFiles();
        instance=this;

    }

    @Override
    public  void onDisable() {
        getServer().getConsoleSender().sendMessage(ChatColor.RED + "[LoginTitle] Plugin has stopped.");
    }

    @EventHandler
    public void onLogin(PlayerJoinEvent event) {
        Player p = event.getPlayer();
        Bukkit.getScheduler().runTaskLater(this, () -> { p.playSound(p.getLocation(), Sound.valueOf(getConfig().getString("sound")), 1, 1); }, 20L);
        Bukkit.getScheduler().runTaskLater(this, () -> { p.sendTitle(getConfig().getString("title"), getConfig().getString("subtitle"), -1, -1, -1); }, 20L);
    }

    private File configf;
    private FileConfiguration config;

    private void createFiles() {
        configf = new File(getDataFolder(), "config.yml");
        if (!configf.exists()) {
            configf.getParentFile().mkdirs();
            saveResource("config.yml", false);
        }
        config = new YamlConfiguration();

        try {
            config.load(configf);

        } catch (IOException | InvalidConfigurationException e) {
            e.printStackTrace();
        }
    }

}
#

Maybe this?

worldly ingot
#

Constructor of Reload does

mystic terrace
worldly ingot
#

Yeah, you're extending JavaPlugin

mystic terrace
#

what I need to do then?

worldly ingot
#

If you need an instance of your JavaPlugin class you're going to have to pass an instance through its constructor

mystic terrace
#

If I remove it, then this happens

worldly ingot
#
private final LoginTitle plugin;

public Reload(LoginTitle plugin) {
    this.plugin = plugin;
}```
#

Then you can refer to plugin.reloadConfig()

#

When constructing the reload class, pass in this

mystic terrace
minor garnet
#

Instance = this

worldly ingot
#

Yes

mystic terrace
#

oke

minor garnet
#

So when u use it

#

Are u using maven @mystic terrace ?

mystic terrace
worldly ingot
#

public, not plugin ;p

ancient plank
#

kekeke

#

simple mistake

mystic terrace
worldly ingot
#

When constructing the reload class, pass in this

mystic terrace
ancient plank
#

java is hard 🤔

mystic terrace
#

wdym "pass in this" (sorry not english speaker)

worldly ingot
#

this

mystic terrace
worldly ingot
#

Inside of the constructor for reload

#

new Reload(this)

mystic terrace
#

still having the same problem

ancient plank
#

?di

undone axleBOT
mystic terrace
#

Alredy did all the things you did

ancient plank
#

you gotta access the config from your main class using the plugin variable you made

worldly ingot
#

Then you can refer to plugin.reloadConfig()

hasty prawn
#

Whats the main benefit for dependency injection over singleton? Singleton IMO seems so much cleaner

worldly ingot
#

Tight coupling

mystic terrace
#

lemme test now

worldly ingot
#

If you can pass through instances, you're better to do so

lost matrix
worldly ingot
#

There are times however where doing so is either impossible or extremely awkward to do

#

Bukkit's schedulers sometimes makes that clear

#

In which case singleton access is fine PES_SadShrug

#

My general rule of thumb for plugins is that if you can pass through an instance, do it. If you absolutely can't without breaking plugin flow, singleton. It's a last resort

mystic terrace
worldly ingot
#

Commands and event listeners are by far among the most simple instances to pass plugin instances. You're only ever creating single instances of these objects and it's generally in the plugin class anyways. Using this does not hurt

ancient plank
#

😔 putting your listeners in the main class

undone axleBOT
mystic terrace
#

Now I have a question, the command runs perfectly, but it works with this

lost matrix
# ancient plank 😔 putting your listeners in the main class
  private Block block;

  @Override
  public void onEnable() {
    Bukkit.getPluginManager().registerEvents(new Listener() {
      @EventHandler
      public void onSneak(final PlayerToggleSneakEvent event) {
        if (event.isSneaking()) {
          return;
        }
        SpigotSandbox.this.block = event.getPlayer().getLocation().getBlock();
      }
    }, this);
  }

😄

mystic terrace
#

How I can make it like this?

opal juniper
#

have y’all seen the recent pr to spigot - not merged but from the looks of it a lot of the enums are getting changed

#

as in the names

lost matrix
lost matrix
mystic terrace
#

how

hasty prawn
#

I guess I still don't really understand the DI benefit over Singleton. The link provided by Conclure has 3 reasonings ¯_(ツ)_/¯

#

wheres

#

the rest of it

#

Guess I'll retype it ffs

#

First of all it will be difficult to unit test an instance of that class, since we will inherently test the static singleton also. - I know literally nothing about unit testing, so this benefit doesn't really do anything for me specifically. Maybe I should start, but I don't even know what it is!

Second, we will not be able to reuse the class for another MyPluginDataManager instance. - This makes sense when working with other classes, but for the main plugin class, we only ever need 1 instance anyways.

Third by using a static singleton you have complexified your code architecture. - I don't understand how Singletons make it more complicated.

For example, if you're instantiating a class within another class, that's instantiated within another class, etc etc, you'd have to pass y our plugin instance across every single one of the classes, JUST so you can use it in the one you're trying to get to, regardless of whether the first 2 classes actually use the plugin instance or not. It seems like that would be far more complicated than just "oh, I need my plugin instance for this class. Main.getInstance() done."

balmy coyote
#

Any idea how i can prevent Animals from being Right clicked and fed by Food?
Interact Events doesn't work.

balmy coyote
#

Doesn't work

#

Tried already

#

On every priority

#

Literally tried

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onInteract(PlayerInteractAtEntityEvent e){
        e.setCancelled(true);
    }
#

And it ignores it

#

Tried also HIGH, NORMAL, LOW and LOWEST

#

None of them seems to work at all

hasty prawn
#

Are you registering the event

balmy coyote
#

Yes

#

Anything else it's entirely disabled

#

But Feeding animals with food is not

#

Could that be Client sided ?

#

And there is no event for that?

paper viper
#

Uh no

#

I’ve tried the event before, it works

balmy coyote
#

You can infinite feed Animals with Food

young knoll
#

Did you try just the PlayerInteractEntityEvent

balmy coyote
lost matrix
balmy coyote
#

With a wheat

#

it continuosly consumes it

paper viper
#

What server version?

balmy coyote
#

1.16.5

paper viper
#

Also what server type

#

Spigot right

balmy coyote
#

Yes

paper viper
#

You implemented listener too right?

balmy coyote
#

Yes

#

I've tried to System.Out the Event

#

debug

#

It does fire the event

#

But even tho cancelled. It doesn't matter to the Baby cow

lost matrix
#

Very interesting. It blocks the interaction with adult animals but not with babies...

balmy coyote
#

Exactly

#

You can feed Babies

#

FOREVER

#

And no event handles that

#

Therefore i thought it might be Client sided?

worldly ingot
#

Ehm, well, the server would still have to consume the item

lost matrix
#

Oh the event is still cancelled. THe client just shows some particles.

balmy coyote
#

I've read you can player.UpdateInventory

#

As it's "visual"

#

Apparently that's not the case

#

It right away consumes the item

worldly ingot
#

Did you delay the updateInventory()?

#

Because if you're doing it in the event, it won't work

balmy coyote
#

Tried 1 tick

worldly ingot
ancient plank
#

man inventories make me cry

lost matrix
ancient plank
#

I thought my code was broken because the display on my inventory wasn't working, but it was just an issue with viaversion/the server being on 1.12

balmy coyote
lost matrix
hasty prawn
#

I get the ghost item as well ^ I guess it just likes 7smile more Sadge

#

Delaying updateInventory() works though

balmy coyote
#

Let me try once again then

#

Then i guess either one of those Plugins

#

It's just doing it wrong

#

AS they continue consuming for me

#

While my plugin LCCommands being as Highest priority and cancelling the event

#
    @EventHandler(priority = EventPriority.HIGHEST)
    public void onInteract(PlayerInteractAtEntityEvent e){
        e.setCancelled(true);
        plugin.getServer().getScheduler().runTaskLater(plugin, () -> e.getPlayer().updateInventory(),1L);
    }
#

Either i'm doing it wrong or i don't know

#

I don't know what i am doing wrong tho

#
    @EventHandler(priority = EventPriority.HIGHEST)
    public void onInteract(PlayerInteractAtEntityEvent e){
        System.out.println("Event Fired");
        e.setCancelled(true);
        plugin.getServer().getScheduler().runTaskLater(plugin, () -> e.getPlayer().updateInventory(),1L);
    }```
#

But it literally fires the event and it spoon feeds the Cow

young knoll
#

You are using a different event

balmy coyote
#

Oh

#

AtEntity

#

I see now

#

Thanks for Noticing

carmine nacelle
#

AtEntity is for armorstands

#

and other things im sure.

balmy coyote
#

I literally quick-finished it

#

And never noticed

#

it is At

ancient plank
#

"PlayerInteractEntityEvent"
"PlayerInteractAtEntityEvent"
🤔 not confusing at all /s

balmy coyote
#

It seems i'm extremely blind and didn't seen the At

#

As it looks quite similar

shadow tide
#

How would I make a spigot plugin with maven, I can't find anything to help me and I would like to start using maven. (I'm using Eclipse IDE)

#

wut

ancient plank
#

dont use the slash commands they don't work

lost matrix
#

PortalCreateEvent

mystic terrace
#

Hello! I have a problem, I'm doing subcommands in my plugin and when i want to put private final LoginTitle plugin; public ReloadCommand(LoginTitle plugin){ this.plugin = plugin; }
appears a problem

#

this one

lost matrix
# mystic terrace

You defined a constructor that demands one instance of LoginTitle but you dont provide it with one.

mystic terrace
#

What I need to do?

lost matrix
mystic terrace
#

How? (I'm new coding)

lost matrix
# mystic terrace How? (I'm new coding)

Jumping into spigot development without learning the very basics of Java is a recipe for failure.

  1. Get an instance of your LoginTitle class
  2. Pass it via the constructor as an argument

There are several ways of obtaining an instance of your JavaPlugin class.

mystic terrace
#

?di

undone axleBOT
mystic terrace
#

u mean this?

lost matrix
mystic terrace
#

thats what I did

lost matrix
#

Yes this defines a constructor.
Now when you call this constructor you need to pass all arguments like you would with a normal method.

mystic terrace
#

im lost

lost matrix
#
  LoginTitle title = ...;
  ReloadCommand command = new ReloadCommand(title);
mystic terrace
lost matrix
#

You need to do this when you create an instance of ReloadCommand. Aka calling the constructor of ReloadCommand.

vague oracle
#

smh

zealous glen
#

is there a way to check for every glass type

#

ik there is Tag.Leaves etc but I can't find one for glass

quaint mantle
#
private boolean isGlass(Material mat) {
    return mat.name().endsWith("_GLASS") || mat.name().endsWith("_GLASS_PANE");
}
zealous glen
#

thats the only way?

quaint mantle
#

unless you wanna make a set of the materials, idk why you would

paper viper
#

You could use an EnumSet but nah thats too much work

#

lol

lost matrix
# zealous glen ik there is Tag.Leaves etc but I can't find one for glass

This is probably the best performing way:

  private static final Set<Material> GLASSES = EnumSet.copyOf(Arrays.stream(Material.values())
      .map(Enum::name)
      .filter(mat -> mat.endsWith("_GLASS"))
      .map(Material::matchMaterial)
      .collect(Collectors.toSet()));
    Material material = ...
    if (GLASSES.contains(material)) {

    }
zealous glen
#

hmmm I did something similar with mob eggs before but I'm just surprised there isn't a easy way checking with the Tag class

#

because it works for wool

lost matrix
# quaint mantle Enum::name?

Yeah name() is usually the better way as toString might be overwritten for readability. In this case it makes no dif

solar sable
#

guys the scoreboard updates now, but when i leave the game, it immediately floods my console with error message

lost matrix
#

Are you doing some reflection fkery?

dry forum
#

so i have https://pastebin.com/12zjawgR, its sort of working i guess, when i do /moneygive 39 for the first time it gives me 39$, but if i do it a 2nd time for example /moneygive 21 it stays at 39

lost matrix
quaint mantle
solar sable
#

are you talking to me?

#

oh

dry forum
solar sable
#

well wdym by reflection fu*kery?

quaint mantle
#
    something something;

    @Override
    public void onEnable() {

        something= new something(this);```
Main
Main plugin;

public something(something plugin) {
    this.plugin = plugin;

}```

lost matrix
dry forum
lost matrix
#

So it will always return a null section

dry forum
#

how does that work though? if im getting the same file after "economy" has been created?

lost matrix
dry forum
#

i load it in the else section though?

#

also save it in the other one

lost matrix
#

Yeah but the else will never be executed because your FileConfiguration will always be empty.

dry forum
#

im still a bit confused, would i just need to add a load or something before the if part?

lost matrix
#

What does this do?
File f = new File(plugin.getDataFolder() + "/economy/" + p.getUniqueId() + ".yml");

dry forum
#

creates a file thats named the player's uuid

lost matrix
#

Almost right. It defines a File. It is not created and not loaded. It just defines a File.
2)
What does this line do?
FileConfiguration fc = new YamlConfiguration();

dry forum
#

gets the configuration for the file so you can do stuff like getting strings and default config stuff

lost matrix
#

Nope this creates a new, clean, blank YamlConfiguration.
It has nothing in it and is completely empty.

#

The code doesnt know that you want to load the data from your File into this YamlConfiguration because you never told it to.

#

So fc is always empty no matter what you did before.
What is the implication for this line then:
if (fc.getConfigurationSection("economy") == null) {

dry forum
#

wdym? like what will it do or what do i have it there for?

lost matrix
#

What will it do if fc is always empty.

dry forum
#

always return null so the else part wont get activated

lost matrix
#

Correct

lost matrix
lost matrix
# hasty prawn Seems dangerous

You can just flush your data async every 15 minutes or so. Its def 100x better than just manually using FileConfigurations.

dry forum
#

so that would be try { fc.load(f); } catch (IOException | InvalidConfigurationException e) { e.printStackTrace(); } correct?

lost matrix
# dry forum so that would be ``` try { fc.load(f)...

You can also just do this:

    File file = new File(plugin.getDataFolder() + "/economy/" + p.getUniqueId() + ".yml");
    FileConfiguration config = YamlConfiguration.loadConfiguration(file);
    if (config.getConfigurationSection("economy") == null) {
dry forum
#

i dont get any errors or anything, but im back to square one having the same issue as i orgininally was

dusky lynx
#

What’s the original problem?

dusky lynx
#

Looks to me like your only saving the file if it doesn’t exist.

dry forum
#

im saving it in both?

dusky lynx
#

Both sections are like this

#

It’s only being saved if the file doesn’t exist

dry forum
lost matrix
# dry forum im saving it in both?

Scrap this approach.
Just create an EconomyPlayer class and load your data when the player joins or the server starts.
Its much, much cleaner, and performs way better.

dusky lynx
#

Remove the ! In the second one

dry forum
#

oh dang it works thanks for the help 😄

torn oyster
#

how do i allow remote connections to my msql server

quaint mantle
#

How do I get server plugins to work with Minehut?

grand bronze
#

is there an event for radius?

#

if (onPlayerTillBlock.getLocation().distance(player.getLocation())) > 5){ I'm really fucking stupid what is wrong with this

drowsy helm
#

looks fine to me

#

should probably make them things variables, but otherwise fine

lost matrix
grand bronze
#

This is my first time trying to code so dont judge me please

#

`public class TillBlock implements Listener {
@EventHandler
public void onPlayerTillBlock(BlockBreakEvent event) {
Block blockBroken = event.getBlock();

    if (blockBroken.getType() == Material.DIRT) {
        event.setCancelled(true);
        (blockBroken.setType(Material.LEGACY_SOIL);

        Block onPlayerTillBlock;
        Player player;
        if (onPlayerTillBlock.getLocation().distance(player.getLocation())) > 5){

        }


    }
}

}`

lavish hemlock
#

(blockBroken.setType(Material.LEGACY_SOIL); you put a ( at the start by accident

drowsy helm
#

both variables will be null

lavish hemlock
#

and you have too many ) on the second if statement too

drowsy helm
#
            Player player;
``` are declared but null
#

that aswell

hasty prawn
#

How is your IDE not bullying you

grand bronze
drowsy helm
#

you are declaring a variable, but assinging no value to it

#

how is the plugin supposed to know what "Player" means when you have no context for it

grand bronze
#

good point

lost matrix
# grand bronze why are they null though

Because you never initialised them.
Block block; <- This creates a Block variable named block without content.
Block block = event.getBlock(); <- This creates a Block variable named which and stores the value returned from the getBlock() method inside.

drowsy helm
#

its like telling the server: "Give me block" - What block do you mean? What position, etc etc

grand bronze
#

I defined block but having trouble on how I would define the player

lost matrix
#

Player player = event.getPlayer()

#

Something like this

drowsy helm
#

event.getPlayer() for BlockBreakEvent i think

grand bronze
#

you guys are legends I spend like 3 hours trying to solve that small issue

torn shuttle
#

is there a server tick time?

#

not world

lost matrix
torn shuttle
#

yeah

drowsy helm
#

not that im aware of

#

you could easily do that manually thoiugh

torn shuttle
#

not that easy

lost matrix
torn shuttle
#

to get the exact tick at which specific events are happening to an object of mine

#

making this inaccurate defeats the whole purpose of this system

lost matrix
torn shuttle
#

sure it depends, and based on my needs it makes it useless, hence why I said it

#

this is specifically so I can measure delays both in real time and in ticks between different parts of the code running

#

and it's important that I check if the code is trying to run within the same tick

lost matrix
#

Then you only need delta ticks and having a total offset is no problem.

torn shuttle
#

how do you imagine this working without me querying what tick it is to the server?

lost matrix
#
public class TickTask implements Runnable {

  @Getter
  private static int currentTick = 0;
  private static boolean started = false;

  public static void start(final JavaPlugin plugin) {
    Preconditions.checkState(!started);
    Bukkit.getScheduler().runTaskTimer(plugin, new TickTask(), 0, 1);
    started = true;
  }

  @Override
  public void run() {
    TickTask.currentTick++;
  }
}
grand bronze
#

how do you make it colorful my boy

drowsy helm
#

3 "`" and java infront

lavish hemlock
#

```java
```

drowsy helm
#

idk how to do it without formatting lol

grand bronze
#

ty

young knoll
#

Sadly mobile doesn’t support the colouring

lost matrix
young knoll
#

I’m surprised that’s not exposed

drowsy helm
young knoll
#

Then again I say that a lot

#

Like with this

// TODO NMS
if (!((CraftBlockData) material.createBlockData()).getState().canPlace(((CraftWorld) target.getWorld()).getHandle(), new BlockPosition(target.getX(), target.getY(), target.getZ())))
      return;
torn shuttle
drowsy helm
#

seems like a really core methdo that should have been implemented already

torn shuttle
#

yeah hence why I asked here, was surprised that it didn't exist already

young knoll
#

I mean we only got player.breakBlock recently

lost matrix
torn shuttle
#

I actually found a feature suggestion for this where md_5 got into it with some rando

young knoll
#

You should do mine too because lazy

torn shuttle
young knoll
#

Hey I remember that one

torn shuttle
#

I get that it's an "abstract concept" but the scheduler is built on top of this concept, which makes it way less abstract than it sounds

lost matrix
drowsy helm
#

tick really doesn't seem abstract considering we use schedulers

#

then again that was 5 years ago, so maybe his thoughts have changed

torn shuttle
#

off I go necroposting

#

it says unresolved so I guess I won't open a different ticket for this

torn oyster
#

MySQL Statement Executed Event?

grand bronze
#

Is there a way to set a radius on an event

drowsy helm
#

what do you mean by that

lost matrix
grand bronze
#

in other words multiply the event by whatever the radius is

drowsy helm
#

could you give us an example?

grand bronze
#

Sure

formal prawn
#

I want a compass to point a player but if the player moves its location changes. How do I make the compass point a variable location?

lost matrix
#

An event is not a number. You cant do any arithmetic with it...

young knoll
#

Tell that to python

grand bronze
#

if someone wanted to make a pickaxe break a 5 block radius every swing

#

would that be possible

lost matrix
drowsy helm
#

yeah definitely

#

on block break you can get the location then get neighbouring blocks

grand bronze
#

is there an event for neighboring blocks?

#

or how would I do that

drowsy helm
#

no but its some pretty easy maths

young knoll
#

Block.getRelative

drowsy helm
#

oh nvm there is lol

young knoll
#

Or in this case a loop would probably be better

lost matrix
grand bronze
#

alr bet thank you

steep comet
#

Can you recommend me some library that will help me write nice-looking easy-to-follow Minecraft command plugins? There are many many libraries that gives you simple functions to create CLI commands. Has anyone created such a library for Minecraft? So we don't have to carry about splitting and writing same boilerplate over and over again?

chrome beacon
#

I like Commodore and Brigadier

lavish hemlock
#

Brigadier is pretty

#

Mojang's libraries are actually surprisingly well-designed

chrome beacon
#

Yeah

#

Time for them to open source the rest ;/

lavish hemlock
#

open-source Minecraft when

torn shuttle
#

never

lavish hemlock
#

😭

formal prawn
#

Event is not working 😦

quaint mantle
#

?paste

undone axleBOT
torn shuttle
#

I'm surprised you managed to keep that under the character limit lol

formal prawn
#

My event not working

torn shuttle
#

make sure you provide fewer details

formal prawn
#

I even tried to sysout the event but it doesn't give the sysout

eternal night
#

Missing Event handler annotation

torn shuttle
#

that is one

formal prawn
torn shuttle
#

are you listening to the event ?

formal prawn
#

wait

#

i am stupid

quaint mantle
formal prawn
#

i didn't put @EventHandler

#

sorry

quaint mantle
#

And interact event is not right click @formal prawn

eternal night
#

You sure about that one chief ?

quaint mantle
#

Check if event.getAction is right click air or right click block

formal prawn
quaint mantle
#

Use ||

formal prawn
#

if(e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK))

quaint mantle
#

Yes

formal prawn
quaint mantle
#

That was not in the code

#

Was it ?

formal prawn
#

it is

#

yeah

quaint mantle
#

Im blind then 😂

formal prawn
#

kek

quaint mantle
#

Better to put at the top

formal prawn
torn shuttle
#

yep

quaint mantle
#

i guess more optimized

formal prawn
#

ah ok

torn shuttle
#

always exit early

quaint mantle
#

It checks any interact before the if

formal prawn
#

oh ok

#

will try that too ty

#

also yeah the plugin is working now

#

ty

torn shuttle
#

nice ping

formal prawn
#

fjkdlsjfkjdskfs

#

ok

#

whoever got pinged

#

sorry

#

fff

torn shuttle
#

I should rename my username to EventHandler

#

oh Override

quaint mantle
#

And dont put a lot of if and else
Better to do it with return

formal prawn
torn shuttle
#

alright now for my next magic trick, I will find a way to output my code execution log to the admins

quaint mantle
#

And i have a question

#

The Bukkit.broadcast()

#

Requires a perm node

#

So the players with this perm will recive the message ?

lost matrix
quaint mantle
#

The one that requires

#

What is it

#

Players with the permission

lost matrix
#

Ill just quote the javadocs:
"Broadcasts the specified message to every user with the given permission name."

quaint mantle
#

Oh thanks

torn shuttle
#

hm

#

I regret making my debug menu a book

ivory sleet
carmine nacelle
#

ok i got a dumb question for anyone that cares to answer.

I made my own hologram plugin with a gui and stuff but I wanna turn it into a dependency/api for 2 other plugins that im making. Think I should move the interaction/gui stuff into each of the dependent plugins so they can do different things, and just leave the dependency holograms as a way to display the info

#

if that makes sense

#

yeah? ok sick

torn shuttle
#

gradle makes me want to leave technology behind and go live as a hermit off in the mountains

#

whether or not it will work is based on star alignment and the feng shui of the room you're in

lost matrix
torn shuttle
#

yeah but my house has a north-northwest exposure to the dragon's veins and mars is out of alignment this month so it refused to work until I pressed the refresh button for the 15th time and restarted intellij for the 3rd time

#

at which point it worked without me altering any of the code that was making it not work previously

#

might be because I put down the 2nd cup of coffee in a different place from the 1st one which altered the feng shui of the room

#

brb debugging my coffee cups

ivory sleet
#

lmao

opaque frost
#

I need somone who can do the plugins and skripts and setup them both I need help bad who can join my server to help plss ping me

eternal oxide
quaint mantle
#

Hi, I have a problem. When I try to use the getConfig method from a class of my own configuration file, this method returns null. I can't find what could be causing it.

lost matrix
lost matrix
quaint mantle
#

okay, done.

lost matrix
quaint mantle
#

hmm

quaint mantle
pastel stag
#

Would anyone here be willing to baby me through an issue i'm having w/ the plugin i'm trying to code lmao

#

java.lang.NullPointerException: Cannot invoke "com.n0grief.WatchBlock.SQL.FriendsHandler.createPlayer(org.bukkit.entity.Player)" because "this.friendshandler" is null

#

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import com.n0grief.WatchBlock.SQL.FriendsHandler;

public class Join implements Listener {
    public FriendsHandler friendshandler;
    @EventHandler
    public void onJoin(PlayerJoinEvent event) {
        Player player = event.getPlayer();
        friendshandler.createPlayer(player);
    }
    
}
idle grotto
#

You didn't initialize friendsHandler

#

Make it private and final and pass it through the constructor

analog ore
#

I hope it's alright to ask more of a general question about MC programming. It's not exactly related to spigot.

I've been creating a backend over redis for more servers. I've created a simple wrapper for a User class, that simply has fields queried from redis on access. But, I have added a cache for the value. To synchronize properly I added TTL (after for ex. 500ms, cached value is queried from redis again) and a messaging broker (RabbitMQ) to call invalidate on other servers (aka sends a message to other caches on different servers, so they query the value from redis again when edited).

My question is whether this isn't just overly complicated for no reason and I could go without caching. I know that caching the value brings me some extra access time savings (from 0.1ms, depending on connection, on redis to like +-10ns for in-mem) and reduces the load on redis, which might be used widely. I just can't decide whether it's relevant or not. Or whether I should go only with TTL and ditch invalidation.

ivory sleet
#

What is this backend for?

analog ore
#

It's intended for all user data. Will have a standalone java app to save into database, then a public Rest API for the web.

ivory sleet
#

Yes but like what’s the system for?

#

What type of web app is it going to be?

#

An online shop? A forum? Etc

analog ore
#

well, mc servers? 🤔

pastel stag
#

@idle grotto any chance you might be willing to show me an example of passing it through to the constructor, im literally a -2iq programmer when it comes to this stuff im legit learning as i go stumbling through lmao

ivory sleet
#

Alright

analog ore
#

That was, too ironic of a response, sorry. It's for minecraft servers, yh.

drowsy helm
#

What sort of data are we talking about? Because in most cases redis is over the top

#

and what magnitude/player count are you projecting

analog ore
#

I'm not doing it for a target production, it's mostly for fun of building it. The intention was to move as much load from the server. Hence moving db work to a standalone

idle grotto
drowsy helm
analog ore
#

I wouldn't consider the player count that relevant, the more the better. Mostly asking for another opinion.

ivory sleet
#

If it saves 0.1ms then it sounds like a very negligible optimization

drowsy helm
#

i really only use redis for pubSub and there are very few cases where i use it for data persistence

pastel stag
#

@idle grotto this is what my ide spits out ```package com.n0grief.WatchBlock.EventHandler;

import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import com.n0grief.WatchBlock.SQL.FriendsHandler;

public class Join implements Listener {
private final FriendsHandler friendshandler = null;
@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
friendshandler.createPlayer(player);
}

}

drowsy helm
#

minecraft doesn't really need it

ivory sleet
#

Sure caching will reduce the load on redis but afaik redis is very scalable given the right resources of course

#

Redis is mainly for caching data fast

analog ore
#

I implemented the caching to have immediate results when working with the values in code

ivory sleet
#

RabbitMQ is a better message broker than redis

drowsy helm
#

Personally there has never been a usecase where i have benefitted caching data through redis rather than directly to a db

ivory sleet
#

Though wertik I believe for testing purposes locally caching the values might be a great idea

analog ore
drowsy helm
#

and that is with netweorks with 1000+ concurrent players

ivory sleet
#

But really redis is good at handling caching

drowsy helm
#

I assume you are reading/writing directly to redis?

#

rather than keeping a local cache on mem

idle grotto
analog ore
#

Doing both right now

#

Changes the value locally in cache, then writes to redis & calls invalidate over Rabbit.

ivory sleet
#

@analog ore anyways for scalability I’d recommend actually locally caching the values from redis in a short period of time actually

analog ore
#

I'm doing that right now. The code base is a bit messy, but I could make the implementation public if you wanted to see.

drowsy helm
#

sure id like to see

#

yeah but Conclure is right, far more efficient to locally cache then keep querying redis

#

but it really depends on what type of data you are holding

ivory sleet
analog ore
drowsy helm
#

if its shared data that is constantly changing, 100% use redis

#

but for player data that will only be accessed from one thing at a time its not entirely necessary

analog ore
#

The data would be used & be able to change on multiple servers at a time, so redis seemed better than doing SQL/Mongo operations & queries on the server.

ivory sleet
#

Yeah definitely

drowsy helm
#

whats the whole fieldContainer thing

analog ore
analog ore
ivory sleet
#

Although should be said redis shouldn’t be used for persistent storage

analog ore
#

I'm not using it for persistent-persistent, all will be saved into database & loaded on request.

ivory sleet
#

Alr good

drowsy helm
#

may be a bit more inefficient but why not use reflection?

analog ore
#

// Since I'm using SQL & redis, which are key-value I thought it would be better to work with fields directly instead of caching the whole user btw.

drowsy helm
#

yeah fair enough

analog ore
ivory sleet
#

Wait what

analog ore
#

SQL is not key-value yh

#

mb

ivory sleet
#

No not about that

#

Why not cache the whole user?

analog ore
#

because on each load of the user, I'd have to query all the fields instead of querying only the fields I'm working with

drowsy helm
#

you could have an exclusion system

ivory sleet
#

Well you most likely will have the entire user in your redis cache regardless?

analog ore
analog ore
#

I mean

#

hm.

drowsy helm
#

maybe its just me but i think an annotation based approach would be far easier

analog ore
#

it feels more "optimized" to work only with fields