#help-development

1 messages · Page 2020 of 1

wet breach
#

nothing in Java stops you

rotund pond
#

Not gonna discuss on this

wet breach
#

because the Convention isn't part of the JVM

#

you are free to make your own rules around what style you want to use

#

as long as the compiler is happy, you can do whatever

rotund pond
#

Okay

lime jolt
#

does anyone know what version of spigot I need to run

#

array.get(0).sendTitle("Hello!", "This is a test.", 1, 20, 1);

wet breach
lime jolt
#

it still seems to not be working though

dire marsh
#

define not working

wet breach
#

their code for sending the title most likely

desert tinsel
#

so, cause the java plugin.getTokenMiner().getInt("Player."+p.getName()) = 1000 and it isn't equal with 0, and it isn't less or equal with 250
i expect to happen the

plugin.tokens.put(p, plugin.tokens.get(p)+TokenMare(level));
                p.sendMessage("3");```, but it happens 
```java
Random r = new Random();
            Integer rr = r.nextInt(5);
            if (rr == 1){
                plugin.tokens.put(p, plugin.tokens.get(p)+1);
            }
            p.sendMessage("1");```
lime jolt
dire marsh
#

what error

lime jolt
#

The method sendTitle(String, String) in the type Player is not applicable for the arguments (String, String, int, int, int)

wet breach
#

I am going to let others help you both, I am not awake enough for this XD

young knoll
#

Did you actually update to latest

lime jolt
#

1.18.2

young knoll
#

Did you update the version in maven

#

Or gradle

#

Or whatever

lime jolt
#

wait so where do I get new version

young knoll
#

?bt

undone axleBOT
dire marsh
#

what build system are you using

#

maven, gradle

lime jolt
#

1.18.2 is a very new version

#

1.8.8 is old

young knoll
#

Correct

dire marsh
#

yes...

young knoll
#

The method you want is 1.12+

lime jolt
#

so why would it not work

#

so if its 1.18 why is it no working

dire marsh
#

is there a place with all the javadoc versions

lime jolt
#

yes

dire marsh
lime jolt
#

but I am?

dire marsh
#

again

#

what build system do you use

#

show your build.gradle / pom.xml

young knoll
#

Inb4 what’s a build system

lime jolt
dire marsh
lime jolt
#

build system?

dire marsh
lime jolt
#

IDE

dire marsh
#

right

#

show that

#

the dependency

lime jolt
#

Eclipse

#

I am using Eclipse

dire marsh
#

yes, show the spigot dependency you have

lime jolt
#

1.18.2?

#

:/

dire marsh
#

well check it

lime jolt
#

it is 1.18.2

dire marsh
#

I can't really help much anyway, I haven't used eclipse and IDE dependencies in years

lime jolt
#

BUT

#

I also have downloaded 1.8.8

#

with it

#

2

#

could that be why

#

_>

#

I have 2 paths

young knoll
#

Lol

#

Just use one

lime jolt
#

it wont let me delete

#

the other one

#

eeeeeek

young knoll
#

Be aware that your plugin won’t run on 1.8 now

lime jolt
#

how delete a path

#

on explipse

dire marsh
lime jolt
#

i right click

#

I hover over

#

delete

#

but it wont let me

dire marsh
#

idk

#

you added it, work it out

#

but you should look into gradle and/or maven

young knoll
#

Should be a remove button on the side

lime jolt
#

there is

#

but it wont let me click it

#

it does not want to die

#

new question

#

how do you get y pos of player

#

._.

abstract sleet
#

player.getLocation().getY()

lime jolt
#

thx

abstract sleet
#

i highly recommend you check the javadocs by the way whenever you want to know how to use anything in the spigot api

young knoll
#

?jd-s

undone axleBOT
lime jolt
#

I am looking through them but whenver I try it it does not work

#

for example

#

for location

#

all I saw was getY()

abstract sleet
#

yeah, don't you want the Y?

lime jolt
#

and did not understand what to do withgetY()

#

yes

crimson terrace
#

Whenever I dont know how to do something I just look for appropriately named methods for whatever I can find and try using those

lime jolt
#

but I did not understand the player and get location thing needed before that

abstract sleet
#

the getY() method returns a float from memory.

lime jolt
#

how did u know u needed player.getlocation though

#

I understand player

abstract sleet
#

you're asking how to get a player's Y coordinate

lime jolt
#

but why getlocation

#

why not location

crimson terrace
#

well the coordinates are part of the location if you think about it

#

so thats how people figure that out

lime jolt
#

okok

abstract sleet
#

getLocation is a method in Player which returns the Location object of a player

lime jolt
#

ookoko, I get it now

#

thanks

abstract sleet
#

in Location you can do things like getWorld, getY, etc :)

lime jolt
#

i see i see

abstract sleet
#

by the way, I highly recommend getting all the basics of Java nailed down before doing anything with the Spigot-API, it will make your life so much easier

#

you don't need to learn the entire language, just the bare basics

crimson terrace
#

how bad are streams for performance in comparison to for example a for each loop?

lime jolt
abstract sleet
#

depends on what you use them for really

crimson terrace
#

so streaming a players inventory contents and filtering a couple of times into a collect wouldnt be bad at all?

crimson terrace
#

in response to a command the player issued that is, sorry

abstract sleet
#

oh, if it's from command and not an event, I can't vision any performance issue at all with using streams especially on inventories

crimson terrace
#

gotcha

fickle frost
#

I started a plugin for replacing villages with cities, and I really want to use my algorithm for generating smooth steps from arbitrary position a to b, (because vanilla village roads are garbage) but doing so requires knowing the blocks along the y axis at those coordinates, which basically means all chunks contained within the city need to have finished generating before it can start populating roads and structures.

Obviously far from ideal to delay chunk population like that.

Any brilliant ideas?

young knoll
#

Ooh fancy

#

Although you could just use a datapack

crimson terrace
#

can I play tic tac toe on that map?

fickle frost
#

Datapack structures are limited to 64x64 blocks iirc, and I'd really like to generate very large buildings, so not going to be using that.

young knoll
#

The chunks only need to be past basegen, not finished

#

Datapack structures are limited to 48x48

#

But you can use jigsaws

fickle frost
#

😬

young knoll
#

Although worldgen plugins are nice to see, not many people like to tackle worldgen

fickle frost
#

The chunks only need to be past basegen, not finished
I can't queue up all of those chunks to only load in partially, especially not without breaking the no recursive chunk loading rules.
So kinda have to deal with letting the chunks load in whatever order they happen to.

fickle frost
# young knoll But you can use jigsaws

My plan was to let the plugin's users add in schematics of buildings they want to be included in generation, because there's basically no server admin friendly customizability for villages at the moment.

young knoll
#

That sounds fun

#

Really should expand the spigot worldgen API

#

I’d love to add an API to add new biomes and structures

crimson terrace
#

is there a reason why plugins cant add new items?

young knoll
#

Because you can’t add new items to the game server side

#

You need a client mod

#

Of course you can basically add new items with custom model data

crimson terrace
#

yeah, if only you could make a server force the client to have an ItemPack or something like it already does with resource packs

young knoll
#

One day datapacks will do that

#

I imagine

crimson terrace
#

I hope that spigot will be able to aswell 😄

hasty prawn
#

Someone should make a client mod that allows servers to inject custom content

crimson terrace
#

I really like the spigot api

fickle frost
#

My thoughts at the moment are, whenever a chunk generates, check a radius for a valid source chunk for spawning a city, and if it finds a valid one, plot a y-blind road map for the city, and any chunks where those roads are contained, queue for generation, and once they've all generated, populate it with a city.
As long as the radius is larger than the max city size and the view radius, the city would theoretically have generated in before a player gets a chance to see it.

young knoll
#

I think someone has for fabric

#

Maybe

hasty prawn
#

That'd be awesome lol

young knoll
#

Still need a client mod though

#

Sadly

hasty prawn
#

Yeah... Maybe we should just annoy Mojang so much that they add it

lost matrix
crimson terrace
young knoll
#

That’s false

#

The server already sends data to clients

lime jolt
#

anyone know why i am in a void when I do this

#
                
                
                try {
                    Thread.sleep(10);
                }
                catch(Exception e) {}
                
                if(array.get(1).getLocation().getY() < 30) {
                    array.get(0).sendTitle("You Won", "Winner: " + array.get(0));
                    array.get(1).sendTitle("You Lost", "Winner: " + array.get(0));
                    Bukkit.broadcastMessage(array.get(0).getName() + " has beat " + array.get(1).getName() + " in sumo!");
                    gameIsRunning = false;
                    array.remove(0);
                }
                if(array.get(0).getLocation().getY() < 30) {
                    array.get(1).sendTitle("You Won", "Winner: " + array.get(1));
                    array.get(0).sendTitle("You Lost", "Winner: " + array.get(1));
                    Bukkit.broadcastMessage(array.get(1).getName() + " has beat " + array.get(0).getName() + " in sumo!");
                    gameIsRunning = false;
                    array.remove(0);
                }
                
            }```
#

threads are messing me up

lost matrix
#

Dont use while loops on the main thread. You just block it forever this way.

lime jolt
#

?

lost matrix
#

So minecraft naturally just crashes

young knoll
#

The game sends the entire biome registry to clients as json

#

So there’s no reason they can’t do the same with the block or item registry

lime jolt
young knoll
#

?scheduling

undone axleBOT
lost matrix
lime jolt
#

how do i do that ._.

young knoll
#

We send you a wiki entry

lost matrix
#

Look above my msg. Scheduling

young knoll
#

?event-api for events

undone axleBOT
young knoll
#

Yes

#

That’s how datapack biomes work

hasty prawn
#

So custom biomes are possible

young knoll
#

Sure

hasty prawn
#

Interesting

young knoll
#

Have been since 1.16.2

tall dragon
#

custom biomes are indeed possible

young knoll
#

Look at the terralith datapack

hasty prawn
#

Structures/World Gen/Biomes is something I've yet to work with so I don't know much about it

tall dragon
#

its very cool

hasty prawn
#

That's sick, ty for the resources

#

I do plan to mess with those things fairly soon, but gotta finish other stuff first lol

young knoll
#

I really want to learn to make cool worldgen

#

But noise is hard to wrap my head around

hasty prawn
#

That's why I've avoided it tbh

#

Seems complicated

#

monke brain no understand 3head

dull whale
#
        ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(Skyblock.main, ListenerPriority.NORMAL, PacketType.Play.Client.USE_ENTITY) {
            @Override
            public void onPacketReceiving(PacketEvent event){
                WrapperPlayClientUseEntity packet = new WrapperPlayClientUseEntity(event.getPacket());
                Entity clickable = packet.getTarget(event);
            }
        });
#
[17:42:29] [Netty Server IO #1/ERROR]: [ShulkonSkyblock] Unhandled exception occured in onPacketReceiving(PacketEvent) for ShulkonSkyblock
java.lang.RuntimeException: Cannot retrieve entity from ID.
    at com.comphenix.protocol.wrappers.BukkitConverters$11.getSpecific(BukkitConverters.java:727) ~[?:?]
    at com.comphenix.protocol.wrappers.BukkitConverters$11.getSpecific(BukkitConverters.java:706) ~[?:?]
    at com.comphenix.protocol.reflect.StructureModifier.readInternal(StructureModifier.java:229) ~[?:?]
    at com.comphenix.protocol.reflect.StructureModifier.read(StructureModifier.java:197) ~[?:?]
    at TheLudoBile.Utils.WrapperPlayClientUseEntity.getTarget(WrapperPlayClientUseEntity.java:37) ~[?:?]
    at TheLudoBile.Utils.WrapperPlayClientUseEntity.getTarget(WrapperPlayClientUseEntity.java:46) ~[?:?]
    at TheLudoBile.Listeners.EventPlayerJoin$1.onPacketReceiving(EventPlayerJoin.java:74) ~[?:?]
Caused by: com.comphenix.protocol.reflect.FieldAccessException: Cannot find entity from ID 27.
    at com.comphenix.protocol.injector.EntityUtilities.getEntityFromID(EntityUtilities.java:271) ~[?:?]
    at com.comphenix.protocol.injector.PacketFilterManager.getEntityFromID(PacketFilterManager.java:851) ~[?:?]
    at com.comphenix.protocol.wrappers.BukkitConverters$11.getSpecific(BukkitConverters.java:721) ~[?:?]
    ... 55 more
```  whats the problem
fickle frost
#

There are generation techniques that don't deal with noise, which might be a good way to dip your toes into it if you want to avoid noise specifically.

young knoll
#

You’d think I’d know some stuff about it being on the dev team of a large worldgen project :p

#

But I don’t

fickle frost
#

Ask your colleagues to give you some pointers?

lost matrix
hasty prawn
#

Yeah yeah go ask them and then when I tackle it you can help me peepoGiggles

young knoll
#

Hehe

#

I’ve gotten some resources from them

lime jolt
#

how would I stop my code from consistnelty doing something by checking each tick, instead of using a while loop

#

since while loops aint working

tall dragon
#

use a repeating runnable

lime jolt
#

how would I stop it

#

though

tall dragon
#

BukkitRunnable#cancel() exists

lost matrix
lime jolt
#

would I just wrtie BukkitRunnable#cancel() ;

tall dragon
#

no

young knoll
#

No

lime jolt
#

oh

young knoll
#

You need an instance of the runnable

lost matrix
# lime jolt how would I stop it

I prefer using a runnable that is sheduled once and where i can just add/remove tickables.
But you can also cancel runnables by their id or use BukkitRunnable#cancel()

tall dragon
#

you would call cancel on your instance

dull whale
lost matrix
lime jolt
#

BukkitRunnable#cancel()

dull whale
#

copy paste

lost matrix
young knoll
tall dragon
# lime jolt so how would the line look like

very simple example

public class ExampleRunnable extends BukkitRunnable
{
    
    int ticks = 0;

    @Override
    public void run() {
        if (ticks >= 10)
        {
            //stop after 10 ticks
            cancel();
            return;
        }
        ticks++;
    }
}
dull whale
young knoll
#

Yes you can also cancel from within the runnable

lime jolt
#

i see

#

alright thx

#

does anyone know how many ticks are in a second

lost matrix
# dull whale 1.18

The wrapper is from 2014. The packet content has probably changed since then.
Look at the protocol and try to get the content by using raw modifiers.

hybrid spoke
lime jolt
#

okok

tall dragon
#

if the server is on 20 tps

tall dragon
#

😉

fossil lily
#

How can I check if there is an entity in a chunk before unloading it?

young knoll
#

Chunk.getEntities

fossil lily
#

oh thats easy

#

thanks :D

dull whale
carmine pecan
dire marsh
dull whale
#
        Preconditions.checkNotNull(world, "world cannot be NULL.");
        return this.structureModifier.withType(Integer.TYPE, BukkitConverters.getEntityConverter(world));
    }
#

some class named abstractstrecture

#

public Entity getTarget(World world) {
return handle.getEntityModifier(world).read(0);
}

#

handle is packetcontainer which comes from protocollib

lost matrix
dull whale
#

i dont really know whatu mean by type of packet

#

but I want entity

lost matrix
#

org.bukkit.Entity from which packet?

dull whale
#

the client entity sent to server with parameters i suppose

lost matrix
#

What do you mean you suppose? What packet are you listening for?

dull whale
lost matrix
#

PacketType.Play.Client.USE_ENTITY this one? @dull whale

lime jolt
#

guys does this make sense (tring to make a loop with ticks)

#
            Plugin plugin = null;
            task.runTaskTimer(plugin, 0, 1);```
#

import org.bukkit.scheduler.BukkitRunnable;

public class Loop extends BukkitRunnable
{
    
    int ticks = 0;

    @Override
    public void run() {
        HelloCommand.array.get(0).sendTitle("woosh", "Game Starting!");
        if (ticks >= 100)
        {
            
            cancel();
            return;
        }
        ticks++;
    }
}```
young knoll
#
 Plugin plugin = null;
 task.runTaskTimer(plugin, 0, 1);
lime jolt
#

...

young knoll
#

That ain't gonna run chief

lime jolt
#

oh dam

tall dragon
#

is you want a title to get send 100 times in 5 seconds

trail pilot
#

why null lol

lost matrix
lime jolt
#

what plugin object am I supposed to put in

trail pilot
#

anyway, im trying to do max length and min leght for home with custom msg

lime jolt
trail pilot
#

but the logic is fucked

#

there are many else if

young knoll
#

Get an actual instance of your plugin

#

?di

undone axleBOT
quaint mantle
lime jolt
#

ohhh

#

so I do Plugin plugin = new Main();

young knoll
#

no

#

You cannot make an instance of main

lime jolt
#

i see i see

trail pilot
#

Something.getClass(Something.class);

trail pilot
lavish hemlock
#

No

#

Just no

trail pilot
#

hihihihih

quaint mantle
#

hihi

trail pilot
#

many ppl use it

quaint mantle
#

dependency injection ftw

lavish hemlock
#

Well then many people shouldn't

lime jolt
#

JavaPlugin plugin = JavaPlugin: ??!?!?!?

lost matrix
#

?learnjava

undone axleBOT
lime jolt
#

i am so confused about what the object Plugin really is

fickle frost
#

It's an instance of (very likely) your plugin.

#

Unless you've retrieved it from elsewhere.

lime jolt
#

but I dont have an instance called Plugin

#

I have Main and 3 other objects

fickle frost
#

Your plugin's main class extends JavaPlugin, no?

lime jolt
#

it does

lavish hemlock
#

Learn inheritance :p

#

?learnjava

undone axleBOT
fickle frost
#

Therefore your 'Main' is also a JavaPlugin and therefore you have an instance of JavaPlugin.

lime jolt
#

ok

#

so with this information

#

what would I put in

#

task.runTaskTimer(plugin, 0, 1);

#

that

#

instead of plugin

fickle frost
#

Your Main instance.

lime jolt
#

task.runTaskTimer(new Main(), 0, 1);

#

?

fickle frost
#

Absolutely not.

lime jolt
#

is that not creating an instance?

fickle frost
#

You should be using the instance that was already created by the server.

lime jolt
#

how do I use that

fickle frost
#

If you're creating that task in your Main class, then pass "this"

lavish hemlock
#

It does create an instance, you should just never instantiate Plugins.

lime jolt
#

no task is in a diffrent class

lavish hemlock
#

Then use dependency injection

#

?di

undone axleBOT
lime jolt
#

???

fickle frost
#

Most plugin developers store their plugin instance as a singleton in their main class and use a static getter to fetch it from other classes.

#

I'm not going to argue about the validity of that design choice, but it is an option.

lime jolt
#

is there a work around to this, like could I just use while loops instead of ticks

#

I dont understand why a while loop aint working

lavish hemlock
#

No because while and the Scheduler are completely different

fossil lily
#

So im trying to make it so ythat when a chunk is unloaded, it teleports the entity to you. I get the message "Unloading", but the entity wont teleport. Any idea why?

lavish hemlock
#

It's to do with concurrency

lost matrix
# dull whale play client use entity??
    public Entity getClickedEntity(Player sender, PacketContainer packet, ProtocolManager manager) {
        Preconditions.checkArgument(packet.getType() == PacketType.Play.Client.USE_ENTITY);
        int entityID = packet.getIntegers().read(0);
        return manager.getEntityFromID(sender.getWorld(), entityID);
    }
lime jolt
#

but like while(true){do stuff} u know

fervent gate
#

Now this doesn't work due to the + in between the ChatColors, how can I make the text bold?

lime jolt
#

why cant I just do stuff

lavish hemlock
fervent gate
lime jolt
#

but dont threads run sepreatly

lavish hemlock
#

The server runs on the main thread, the plugin runs on the main thread

fossil lily
lime jolt
#

_<

#

tears of sadness

lavish hemlock
#

Running based off ticks w/ the scheduler is basically the only accurate, reliable way to do things.

lime jolt
#

does someone know how to dumbdown how to implement a "dependency injection"

fickle frost
#

Making some assumptions about your project design, you should pass 'this' as a parameter in the constructor to whatever class you're creating the task in, store it in an instance field, and use it when you go to make your task.

wooden fable
#

Eh? Cancelling the EntityToggleSwimEvent doesn't work?

    @EventHandler
    public void onToggle(EntityToggleSwimEvent e) {
        if(e.isSwimming()) e.setCancelled(true);
        getLogger().info(String.valueOf(e.isCancelled()));
    }

It will send "true" in the console, but the player will still swim.

hasty prawn
#

ta-da

lavish hemlock
#
public class Dependent {
    private final Plugin plugin;

    public Dependent(Plugin plugin) {
        this.plugin = plugin;
    }
}
#

There

#

That's all dependency injection is

hasty prawn
#

yeah that lol

fickle frost
#

^ As Maow has demonstrated.

lavish hemlock
#

The concept of dependency injection is that plugin is a "dependency," as our dependent class requires it to function.

lavish hemlock
#

Instead of creating a new plugin, which (for Bukkit) can cause issues or (for everywhere) lead to sloppy code, we inject the dependency via the dependent class's constructor.

young knoll
#

Instead of creating a new plugin, which (for Bukkit) can cause issues

#

It will cause issues

lime jolt
#

so in my main class could I do something like

#

public static MyPlugin instance = this;

young knoll
#

As in, the plugin won't work

wet breach
#

you know there is a post somewhere on this already

lavish hemlock
wet breach
#

?DI

#

?di

undone axleBOT
fickle frost
#

That's what you would call a singleton.

lavish hemlock
#

That is a singleton.

lime jolt
#

would a singleton not work?

lavish hemlock
#

Well it would work, it's just messier.

#

A lot of people advise against it

fickle frost
#

It would, but OOP fanatics hate it.

lavish hemlock
#

it's also unconventional

wet breach
#

wouldn't say messier, unnecessary more like it

lime jolt
#

oh ok

#

so how physically would I make this dependincy injection

lavish hemlock
#

See, in your plugin class you can just like
new Dependent(this)

fickle frost
#

If you're going to use a singleton, best practice is to at least hide it behind a static getter.

lime jolt
fickle frost
#

But prefer dependency injection where at all possible.

wet breach
lime jolt
#

alrigh altight

#

do I need to have like Dependent something = new Dependent(this)

#

or just

#

new Dependent(this)

#

so like

#

Dependent something = new Dependent(this)

fickle frost
#

Ay, there ya go.

lime jolt
#

less gooo

lavish hemlock
#

If you want to keep the instance of something, then yeah

lime jolt
#

okok

#

so I have done that

#

then in my other class

fickle frost
#

Store the JavaPlugin instance you've passed it, and access it when creating your task.

lime jolt
#

what would I add for inicitaing the ticks

lime jolt
#

as in

#

is it not already stored?

#

in Main

fickle frost
#

Assuming you're not creating the task within your constructor, you'll need to store it in an instance field in order for it to not fall out of scope.

lavish hemlock
#

instance field*

fickle frost
#

Maow already gave an example.

lavish hemlock
#

Or actually "member field" might work better

lime jolt
#

field?!?!?!

#

....

fickle frost
#

public class Dependent {
private final Plugin plugin;

public Dependent(Plugin plugin) {
    this.plugin = plugin;
}

}

lavish hemlock
#

"field" is probably one of the most common terms aside from "method," "function," or "variable"

lime jolt
#

oh ok

fickle frost
#

'private final Plugin plugin' is the instance field in this case.

rough drift
lime jolt
#

now what ._.

fickle frost
#

Now within your method for creating the task, you can use the plugin you've stored in that field.

rough drift
#

or

#

or

lime jolt
#

NO OR

rough drift
#

just use my lib

#

lmao

lavish hemlock
#

Don't use Ike's lib when it's not even finished lmao

rough drift
#

i only have two parts that aint

#

lmao

lavish hemlock
#

Also don't recommend libs to people who don't understand the basics

fickle frost
#

You're going to give him an aneurysm.

lavish hemlock
lime jolt
#

i started like 6 months ago, I consider myself pro in java (🤣)

lavish hemlock
#

Haha yeah right

#

Anyway

rough drift
#

i started like, in 2017

lime jolt
#

tears roll down left eye

lavish hemlock
#

I started in 2019

fickle frost
#

I started in 2014 and I'm far from calling myself a Pro.

lavish hemlock
#

I personally am actually a pro

lime jolt
#

tear roles down right eye

lavish hemlock
#

But that's because I don't have a life

rough drift
#

i racommended someone my lib

fickle frost
#

That's what a non-pro would say.

lavish hemlock
#

I literally do nothing besides watch YouTube and code

fickle frost
#

Real pros realize they're not pros.

lime jolt
#

WAIT GUYS

fickle frost
#

Be more specific.

rough drift
carmine pecan
#

Timer lag

lime jolt
#

Plugin plugin = null;
task.runTaskTimer(plugin, 0, 1);

#

that is what I had before

rough drift
#

hm

lime jolt
#

I remove Plugin plugin = null

rough drift
#

big brain time

fickle frost
#

That's a good first step.

lime jolt
#

and instead of plugin

#

in

#

task.runTaskTimer(plugin, 0, 1);

#

I add something else

#

something much more powerful

#

which iss ....

fickle frost
#

You're adding the JavaPlugin you stored.

#

Because you actually need to give it your plugin, not null.

lime jolt
#

dont I need an acessor to get the plugin thoigh

rough drift
fickle frost
#

You've already created a reference to your plugin?

lavish hemlock
#

Okay so @lime jolt, that wasn't a suggestion to actually create a Dependent class, like I assume you did.

fickle frost
#

It'd be helpful if you maybe showed us your dependent class.

lavish hemlock
#

I used that as an example to show you the general idea of dependency injection.

lime jolt
#

wait slow down 2 steps back

fickle frost
#

We don't know what class you're creating a task in, so the name "Dependent" was used as an example.

lime jolt
#

is

#
    private final Plugin plugin;

    public Dependent(Plugin plugin) {
        this.plugin = plugin;
    }
}````
#

that the dependincy class

fickle frost
#

That was supposed to be inside the class you're creating the task in.

lime jolt
#

or is my code the dependicy class where I do the tick

rough drift
lime jolt
lime jolt
#

now

#

before I show u my code

rough drift
#

i forgot the cmd

lime jolt
#

I just want u all to know

fickle frost
#

I already know how bad it is.

lime jolt
#

that I have not deleted a lot of the bugs

rough drift
#

bro i have 8 bugs in my plugin and counting

#

its fine

tall dragon
rough drift
undone axleBOT
lavish hemlock
#

Also he's already seen like 2 learnjavas- okay

lime jolt
#

guys

rough drift
#

yet they forgot like

lime jolt
#

I cant paste my code

rough drift
lime jolt
#

it to long

tall dragon
#

?paste

undone axleBOT
rough drift
#

verify yourself

#

and send file

#

or that

lime jolt
#

ok

rough drift
#

yeah that

wooden fable
#

Eh, i'm confused:
https://www.toptal.com/developers/hastebin/kowawabiri.sql

    @EventHandler
    public void onToggle(EntityToggleSwimEvent e) {
        if(!(e.getEntity() instanceof Player)) return;

        if(((Player) e.getEntity()).isSwimming()) ((Player) e.getEntity()).setSwimming(false);
    }

Looks like Player#setSwimming doesn't work, is this the right way to do it (I'm trying to block the player from sprint-swimming)?

lime jolt
#

there

fickle frost
lime jolt
#

u can sell my code to elon musk if u guys want

#

but yeah

tall dragon
#

That code has to be divided into at least 3 methods

lime jolt
#

for now its ok

#

FOR NOW

#

line 77 is where I make mistake

fickle frost
#
private final Main plugin;

public HelloCommand(Main plugin) {
  this.plugin = plugin;
}
    
lime jolt
#

brain explodes

tall dragon
#

Ur also storing an arraylist of plauers

lime jolt
#

what that all it is

fickle frost
#

💥

tall dragon
#

Which is bad

lime jolt
rough drift
#

name it like

tall dragon
#

;_;

rough drift
#

YourPlugin

lime jolt
#

I started minecraft coding less then 24 hours ago

young knoll
#

?main

fickle frost
#

His plugin's main class is literally called Main @rough drift

#

One issue at a time.

tall dragon
#

Lots to learn then

lime jolt
#

_<

chrome beacon
lavish hemlock
#

Imagine storing a player count alongside a list of players when collections allow you to retrieve their size

wooden fable
#

True

lime jolt
#

crys inside

#

so

signal meteor
#
        itemStack = new ItemStack(Material.PLAYER_HEAD, 1);
        itemMeta = itemStack.getItemMeta();
        if (itemMeta != null) {
            itemMeta.setDisplayName(displayname);
            itemMeta.skullOwner(skullOwner);
        }
    }```

hi, the "skullOwner" method doesnt work anymore how can i do this in 1.18.1 ?
quaint mantle
#

Unchecked call to 'add(E)' as a member of raw type 'java.util.List'

lime jolt
#
            task.runTaskTimer(plugin, 0, 1);``` is this the code I now need
#

other than

quaint mantle
#

Can somebody explain this error to me?

quaint mantle
#

Very confused on what that means.

tall dragon
wooden fable
lost matrix
signal meteor
chrome beacon
quaint mantle
#

nvm

tall dragon
signal meteor
#

how can i implement your idea in my code ?

wooden fable
fossil lily
#

Is it possible to find the the nearest solid block to a player to spawn an entity? If the horse gets teleported to you while you're flying it dies :/

tall dragon
fossil lily
#

mkay

lost matrix
lime jolt
#

import org.bukkit.scheduler.BukkitRunnable;

public class Loop extends BukkitRunnable
{
    
    int ticks = 0;

    @Override
    public void run() {
        if (ticks >= 100)
        {
            HelloCommand.array.get(0).sendTitle("woosh", "Game Starting!");
            HelloCommand.array.get(1).sendTitle("woosh", "Game Starting!");

            
        }
        
        if (ticks >= 10000)
        {
            cancel();
            return;
            
        }
        
        
        ticks++;
    }
}```
#

no working

#

it does not display nothing

crimson terrace
#

gonna need a bit more info

lime jolt
#

I am trcing to make a loop

#

trying

#

using ticks

#

in my other code

tall dragon
#

does your runnable even begin

lunar schooner
#

Hey folks, I'm a little stuck in reflection wonderland again. I'm trying to instantiate a PacketPlayOutRespawn, which changed in 1.18.2. to require a Holder<DimensionManager>, I'm retrieving the holder like so:

Class<?> holderClass = ReflectionUtil.getMinecraftClass("core.Holder");
Object dimensionManagerHolder = ReflectionUtil.invokeMethod(holderClass, null, "a", new Class<?>[] { Object.class }, new Object[] { dimensionManager });

When calling the constructor I'm getting a argument type mismatch error, printing the holderclass and dimensionManagerHolder gives:

[16:56:15] [Server thread/INFO]: interface net.minecraft.core.Holder
[16:56:15] [Server thread/INFO]: class net.minecraft.core.Holder$a

While yes they are different, Holder$a implents Holder, so that should work should it not?

lime jolt
lost matrix
lunar schooner
#

I don't want to switch 🙂

lime jolt
#

._.

tall dragon
lime jolt
#

;-;

tall dragon
#

and u were messing with it before

lost matrix
undone axleBOT
lime jolt
#

Thread thread = new Thread();
?

lunar schooner
#

Btw, I'm using this method from Holder to get my instance of it:

  static <T> Holder<T> a(T var0) {
    return new a<>(var0);
  }
``` and that returns a Holder<T>, which PacketPlayOutRespawn accepts, so it should work I'd say
crimson terrace
tall dragon
#

where do you start your runnable

lime jolt
#

umm

lost matrix
lime jolt
#

'thinking'

tall dragon
#

its probably somethn like runTaskTimer()

lunar schooner
tall dragon
#

you should have that somewhere.

tardy delta
#

lel

lime jolt
#

here?

lunar schooner
#

I've also tried holderClass.cast(dimensionManagerHolder);

tall dragon
lime jolt
#

Loop task = new Loop();
task.runTaskTimer(plugin, 0, 1);

        try {
            Thread.sleep(1000000);
        }
        catch(Exception e) {}
        
         boolean gameIsRunning = true;
#

Loop task = new Loop();
task.runTaskTimer(plugin, 0, 1);

#

dont mind the long thread.sleep

tall dragon
#

you should print a text message to console just before you start the runnable

tardy delta
#

never do the main thread sleep

#

neither other ones

tall dragon
#

yea, there are alot of issues. one at a time :D

tardy delta
#

in spigot context

lime jolt
#

how do I stop code then

#

thats why I catch the exceptions

tardy delta
#

it will stop the game from running

tall dragon
#

Thread#sleep on the main thread will stop the whole server from proccessing anything

tardy delta
#

what are you tryin to do?

lime jolt
#

but it is in an ObjEct

#

Not In THe Main

#

right/??

#

so it fine??!?!??

tall dragon
#

that has nothing to do with threads

lime jolt
#

?!?!?!?

tardy delta
#

what are you tryin to do?

lime jolt
#

ticks

#

I want to make a loop

tardy delta
#

just a loop?

lime jolt
#

yes

#

just a loop

crimson terrace
#

do scheduling

lost matrix
fossil lily
#

In real life, X and Y is size to side, and Z is up. In minecraft Y is up. How does spigot work?

lost matrix
#

?scheduling

undone axleBOT
crimson terrace
#

you can make a runnable run every couple of ticks or however frequent you want

tardy delta
#

thats not just a loop

fossil lily
#

thanks

tall dragon
#

its so weird

crimson terrace
fervent gate
#

Code: Location loc = new Location(block.getWorld(), block.getX() + 0.5, block.getY() + 3.5, block.getZ() + 0.5); final Hologram hologram = HologramsAPI.createHologram(plugin, loc); hologram.appendItemLine(new ItemStack(Material.DIRT));

If anyone has experience with the holographicdisplays API, why are my holograms deleted after a restart. Everything works as intended, no errors.

lost matrix
tall dragon
#

u will need to recreate them on start

fervent gate
lost matrix
#

Im always astound with how much plugins like Holographic Displays get away. They literally send all changes
to every player all the time and never unload a hologram for a player. Not even when the chunk unloads.

tardy delta
fervent gate
lost matrix
tardy delta
#

i never understood when you have to clone it

tall dragon
lost matrix
#

In older versions that messed up quite a bit. But nowadays you receive a cloned Location everywhere.

crimson terrace
tardy delta
#

nowadays does that also mean 1.17?

wooden fable
#

Hey, can anyone help me "turning off" sprint swimming?
I've tried these things but neither of them works

    @EventHandler
    public void onToggle(EntityToggleSwimEvent e) {
        e.setCancelled(true);
    }

    @EventHandler
    public void onToggle(EntityToggleSwimEvent e) {
        if(!(e.getEntity() instanceof Player)) return;
        final Player p = (Player) e.getEntity();

        p.setSwimming(false);
    }
lost matrix
fervent gate
tall dragon
fervent gate
#

Alr, thx

fickle frost
wooden fable
#

Yes i did

tardy delta
#

try setting the swimming to false and cancelling the event?

wooden fable
#

So just both?

tardy delta
#

i would give it a try

#

as in the second one, you set the swimming to false but still allow the toggle which sets it to true i guess

#

doesnt make sense lol

fickle frost
#

It’s interesting that the event is cancellable but the cancel supposedly isn’t respected.

tardy delta
#

add a sysout?

#

to make sure its called

ebon stratus
#

how do i make an entity look at a block (NMS) ?

wooden fable
tardy delta
#

hmm weird

lost matrix
tardy delta
#

wondering if you just change the yaw or pitch of the players location that will immediately affect the players view

lunar schooner
#

hey folks, what did isFlatWorld get renamed to in net.minecraft.level.WorldServer? In 1.18.1 and prior it was D(), but that seems to be a long now. Mini's mapping viewer doesn't have WorldServer either

quaint mantle
#

How would I get the items Position that I clicked it on in a inventoryUI?

#

(EXAMPLE: If an item were in the third slot, and I clicked it, it return 3)

tardy delta
#

event.getSlot / event.getRawSlot

lapis widget
#

nee man

wooden fable
#

🇳🇱

tardy delta
#

sus

#

🇧🇪

ancient jackal
quaint mantle
#

how do I get an inventories name?

#

EX: If a chest was named "Epic", it return epic

#

(sorry lol)

#

(im making a shop ui)

tardy delta
#

are Executors.newFixedThreadPool(1) and Executors.newSingleThreadExecutor() the same?

ivory sleet
#

myes

#

as of now

#

but that might change in the future

lean gull
#

is there an event for when an armorstand touches any block? like if it was launched towards a celling, a wall or the floor

gleaming grove
#

hi does somebody know how to fix this kind of error? I tried to reset Intelji, reload project, reset PC and none of those thinks had helped

tardy delta
#

reloaded your pom?

#

if using maven

quaint mantle
#

ty

gleaming grove
#

ok my bad, i was running spigot project instead of build it

viral crag
#

strange package name

fickle frost
tardy delta
#

strange ide lol

viral crag
#

blockchangeevent

fickle frost
#

Doubt a block gets changed when an armor stand collides with a ceiling.

viral crag
#

ArrmorStand being an Entity and all

tardy delta
#

EntityColideEvent or is that only entities with each other?

viral crag
#

mmm isnt that only on ones affected by knockback?

tardy delta
#

dunno lol

lean gull
#

so... what do i do

#

i could use a projectile but that's lame

viral crag
#

did you not read what i gave you?

lean gull
#

but they don't change the block when they collide

#

or atleast i don't think they do

viral crag
lean gull
#

?

fickle frost
#

If you have a reference to the armor stand stored, you could run a repeating task that uses its velocity to determine the next block in its path and checks if it’s solid or not.

lean gull
#

btw this is what i'm tryna do, it's for bounce physics

#

just sharing in case anyone has a better method for doing so

fickle frost
#

Why don't you want to use projectiles?

lean gull
#

idk

#

feels like it'd be better with just the armorstand

#

(i wanna have an armorstand to have a head on it for the bouncy ball)

night torrent
#

how would I make a straight line of air to bedrock from the player?

#

or even break the bedrock

fickle frost
#

Could use a custom model for the projectile.

fickle frost
night torrent
#

block.setType(Material.AIR)?

fickle frost
#

Yep

night torrent
#

thanks

night torrent
night torrent
#

1 2 4 3 5 obviously

viral crag
#

then you would go from your location to the bottom

night torrent
#

for loop?

viral crag
#

depending if you are using worldedit api, yes

night torrent
#

well im not

quaint mantle
#

How do you add command argument suggestion??

For example, /rank [set/remove/add..] and it gives you a suggestion list of what you can use?
Example of a usage:

viral crag
#

then yes, you would have to handle each block

rough drift
#

aw

#

its not a command

rough drift
#

tab completers bruh

tardy delta
tribal holly
#

Hello ! Is it normal that the Block::breakNaturally doesn't drop XP of the block ?

rough drift
quaint mantle
tardy delta
viral crag
night torrent
#

1.18.2

tribal holly
# tacit drift yes

well not cool, is there a way to implement xp drop properly or did i need to calculate all potential xp of the block ?

viral crag
#

then you know and would use the new max depth from your location

night torrent
#

?

tardy delta
#

when i have an executor service with a few threads and i add a few tasks in the order: task 1 first, then task 2, etc. Is it possible that the outcome doesnt execute task 1 first and then 2 etc because of the number of threads?

night torrent
#

so get the lowest block?

viral crag
#

you know the lowest block, you need your y coordinate and remove everything inbetween

night torrent
#

I have the y cords with player.getLoc().getBlockY, but how would I remove everythin in between?

viral crag
#

count and set every block to air

night torrent
#

alright

viral crag
#

if you utilized teh worldedit api, you would only need the start and end coordinates

fickle frost
#
for (int y = startingY; y >= world.getMinHeight(); y--) {
  world.getBlockAt(x, y, z).setType(Material.AIR);
}

Something along those lines.

night torrent
#

thank you guys for your help!

viral crag
fickle frost
#

Yeah my bad.

viral crag
#

he said either - just verifying in my head that java decriments after the test this way

fickle frost
#

If you don't want to break bedrock, check if the block at the coord is bedrock, and if so, break out of the loop rather than changing it to air.

lean gull
#

anyone have a good tutorial on the basics of vectors in spigot? i google searched but didn't find anything helpful

#

i wanna make a circle with particles

quaint mantle
fickle frost
#

Did you just agree to your own message, Ike?

rough drift
#

yes

#

ofc

fickle frost
#

(int)home.location().getX(),
There is #getBlockX(), which returns an int.

tardy delta
#

Location#getBlockX?

rough drift
fickle frost
#

Yeah.

tardy delta
#

oeh i should use that

fickle frost
#

I can appreciate the consistency.

tardy delta
#

😊

fickle frost
#

Oh, I was talking to Ike, not you.

tardy delta
#

🙁

rough drift
#

lmao

fickle frost
#

There there. I'm sure you're very consistent in your own way too.

rough drift
#

Theather in 4 messages

tardy delta
#

im sad now

rough drift
tardy delta
#

i've probably never eaten that lol

viral crag
#

extra hot salsa - remember if you don't cry you didnt try

grim ice
#

how to loop through a bounding box blocks

viral crag
tardy delta
#

i just ate ice cream

grim ice
#

a bounding box

tardy delta
#

the blocks which a bounding box covers?

grim ice
#

yeah

viral crag
grim ice
#

isnt there some cool .getBlocks() methods

rough drift
grim ice
#

yea

tardy delta
#

why?

lost matrix
tardy delta
#

nah

rough drift
#

you can use

#

my lib!

#

i got a region thingy

grim ice
rough drift
#

which you can use a populator for

viral crag
#

what part of it would you be looping through or looking for?

rough drift
#

:P

grim ice
#

:)

rough drift
#

yes

#

:)

tardy delta
#

probably manually looping based on the #getX and #getZ stuff

rough drift
#

its much easier using a lib

grim ice
grim ice
#

ill make my own lib

tardy delta
#

maths kek

lost matrix
#

I got this utility method if you want to use it:

  public static void forEachBlock(final BoundingBox box, final World world, final Consumer<Block> blockConsumer) {
    for (int x = (int) box.getMinX(); x <= (int) box.getMaxX() - 1; x++) {
      for (int y = (int) box.getMinY(); y <= (int) box.getMaxY() - 1; y++) {
        for (int z = (int) box.getMinZ(); z <= (int) box.getMaxZ() - 1; z++) {
          blockConsumer.accept(world.getBlockAt(x, y, z));
        }
      }
    }
  }
tardy delta
#

kekw my head

grim ice
#

o dayum

rough drift
viral crag
#

the consumer is pacman!

tardy delta
#

is cast to int or -1 executed first?

#

i forgot

rough drift
#

i think -1

lost matrix
#

Im currently really getting into kotlin and i which java had extension methods...

rough drift
#

but, did you try scala's operator overloading?

grim ice
#

uwu

#

lombok my beloved

tardy delta
#

what are extension methods?

rough drift
lost matrix
vivid cave
#

how can I convert an itemframe's itemstack to ItemFrame (entity)
I wanna change its properties: item that it is holding, fixed, and visible

tardy delta
#

oh right

grim ice
rough drift
grim ice
#

yeah

#

injecting a method

#

into a class

rough drift
#

and using this inside the method refers to the object you called the method on

#

which makes sense

tardy delta
#

so writing a method outside of a class but throw it to a certain class?

grim ice
#

ye

tardy delta
#

weird

grim ice
#

its mad pog

tardy delta
#

why would you even-

rough drift
#

because

#

you can define

#

things that you can't normally use can be added

lost matrix
# grim ice injecting a method

Its more of a wrapper than actual injection. You cant use any private fields/methods in there. So in reality its just a static method
that receives the object as a parameter.

lost matrix
left swift
#

how can i make entity look at player?

tardy delta
#

LivingEntity#setTarget iirc?

left swift
#

hmm, i want to use only yaw and pitch, because i want to rotate only armorstands head

lost matrix
# vivid cave exactly

Hm thats a bit tricky because the ItemFrame is not a Block. So it wont have a BlockDataMeta.

lost matrix
vivid cave
#

yeah and there ain't any ItemFrameMeta class

#

but it's definitly possible cuz it's doable with commands

lost matrix
lost matrix
lost matrix
#

Might be there but ive never seen this

vivid cave
#

give @s minecraft:item_frame{EntityTag: {Fixed: 1b, Invisible: 1b}}

#

this gives you an invisible & fixed item frame

tardy delta
#

wdym fixed?

vivid cave
#

when you place it, it will in fact be invisible and fixed

viral crag
vivid cave
lost matrix
#

So thats at least the structure if we would have to use something like nbtapi or nms for this

vivid cave
#

i use nms for other stuff anyway

#

i'd prefer to avoid using nbtapi tho cuz i don't use it

lost matrix
#

But we want to set the Fixed tag to 1 and the Invisible tag to 1. And preferably by using spigot

vivid cave
#

^^

tardy delta
#

might be wrong im still learning it

lost matrix
viral crag
#

there is nothing to say that the thread is not interrupted or deferred

rough drift
#

should i add

#

nms lib

#

to omnilib

#

i hate having to deal with fixing serialization rn

#

its a pain in the ass

tardy delta
#

ah so interrupted threads will get tasks too?

rough drift
#

xD

lost matrix
tardy delta
#

ah

#

i get it

#

lets continue watching that tutorial kek

vivid cave
viral crag
#

you have to remember that threads get priorities as well

lost matrix
#

Bukkit.getUnsafe().modifyItemStack(ItemStack, String)

vivid cave
#

i see

lost matrix
visual tide
warm trout
#

Yeah, meant mobs, how would I place it on their head

#

Im pretty much clueless

rough drift
#

imma just

#

make an entire lib for that

#

o_O

warm trout
#

I know Mythicmobs can do it, but I'm tryna do it within my plugin

visual tide
rough drift
#

i am working on my own lib

#

called omnilib

#

you can see what i am aiming for

vivid cave
lost matrix
lost matrix
vivid cave
lost matrix
#

Then just use moj mappings and use nms. If you already use nms then this is probably the most convenient route.

#

But this smells PR-y

vivid cave
#

PR-y?

visual tide
#

pull request-ish

vivid cave
#

aha, i still don't get what he meant by that tho

digital haven
#

Does anyone know how to exclude a dependency from the output jar in maven? I'm importing another plugin and spigot doesn't like it when you're importing a jar that's already installed as a plugin.

warm trout
digital haven
#

thanks

viral crag
digital haven
viral crag
#

show your pom

digital haven
#

I fixed it

mighty bane
#

Can someone explain this to us, so we have a plug-in that checks for when someone left clicks, and it summons a fireball. However the fireball also appears whenever you drop an item, and occasionally whenever you open a door. Does anyone know why this happens?

lost matrix
# viral crag show your pom

After reading his issue several times i came to the conclusion that his problem isnt dependency related.
He just shaded the dependency in because of mavens default scope. He just had to make it provided.

mighty bane
#

Do you mean which hand the item is in?

digital haven
#

The problem was there being 2 of the same classes and I was getting cast exceptions

viral crag
viral crag
# mighty bane ?

you can left click in both hands, you need to know which one you are checking

lost matrix
mighty bane
viral crag
#

you can, but the setup is clearer

mighty bane
#

playerInteractEvent.getAction().isLeftClick()

lost matrix
mighty bane
#

1.18.2

tiny wolf
#

Is there a way to change the metadata of an itemstack after it's been added to an inventory without just setting the slot again?

lost matrix
# mighty bane 1.18.2

"This is because the LEFT_CLICK_AIR in PlayerInteract event is essentially a hack and listens to your arm swinging. Now that dropping items swings your arm, it fires LEFT_CLICK_AIR if you're not looking at a block."

lost matrix
mighty bane
#

So anyway to stop it from triggering?

tiny wolf
#

Or a way to get where the same itemstack is in the inv

lost matrix
tiny wolf
#

No kidding I already understood they clone it when adding to inventory

lost matrix
#

ItemStack is a really werid API layer that might lose its nms reference at any time in quite unpredicting events

tiny wolf
#

The reference just can't be used from what I've understood

#

I might just do it in packets, which is anyways better for what I'm doing

lost matrix
#

What are you trying to do anyways?

tiny wolf
#

Buy God damn are packets a pain sometimes

tiny wolf
#

It's pretty nice and basically done other then this issue

lost matrix
# tiny wolf I made a dynamic item system

Oh i also made one. All the data is stored in PDCs and how this raw data is displayed is
defined by a neat little adapter that changes all outgoin ItemStack packets.

tiny wolf
#

PDC?

lost matrix
#

PersistentDataContainer.

tiny wolf
#

Ah ye, I just am storing in nbt since I wanted it to work 1.8-1.18 so I just used nbt api

lost matrix
#

This way the same ItemStack could look different to several people.
Or if we want to change the design of how an ItemStack is displayed we dont
have to touch the ItemStack at all. We just change the adapter a bit.

tiny wolf
#

Nice nice

#

Is it os?

#

Or not at all

lost matrix
#

Whats "os"?

tiny wolf
#

open source

lost matrix
#

+oh no its not

#

But its not too hard with ProtocolLib

tiny wolf
#

it would allow something like this to be created super duper easily with no code

lost matrix
#

Yeah basically like this