#help-development

1 messages Β· Page 2058 of 1

craggy sapphire
#

github

viral crag
#

different purpose

eternal oxide
#

I told you how to do it with Eclipse, but you are now in IJ

craggy sapphire
#

it just said

#

no project found

tardy delta
#

lol

eternal oxide
#

yes, because you didn;t inteligent import

midnight shore
#

i don't think that you understood what i'm trying to do, i want to specify a piece of code when creating a Queue() instance that will run whenever an entry from the Queue is picked

viral crag
grim ice
#

i would use a Dequeue

tardy delta
#

never used a queue 😳

grim ice
#

youre trying to reinvent the wheel

#

from what i can see

viral crag
grim ice
#

you can just an ArrayDeque

midnight shore
#

well i'm assuming i'm dumb

grim ice
#

wait

#

dont use a stack

#

a stack is LIFO

midnight shore
#

so?

viral crag
#

Ah yes it is in Java

grim ice
#

if u use a stack

#

the last player that joins ur queue

viral crag
#

Queue is FIFO

grim ice
#

will get in

#

so u wanna use an ArrayDeque not a stack

#

an arraydeque will make it so

#

first player joining ur queue

#

will get transferred first

viral crag
#

not really

#

DeQueue is bi-directional

grim ice
#

shh

#

simple terms

#

yeah it is double ended

viral crag
#

Queue is FIFO First in First Out

grim ice
#

but it doesnt matter

#

yes

grim ice
viral crag
#

actually thats a decent article

midnight shore
#

guys but i know how to have a list of objects, i want to know how to specify a piece of code while instantiating a class, then this class will have a method called Run() that will start a bukkit runnable and execute the code you specified when creating the instance of the class.

Something like Queue queue = new Queue(
likeThis();
);

#

idk if its possible

viral crag
#

... normally you only have one Queue and add or remove from it

midnight shore
#

But this is what i'm trying to change! The system is just that, having multiple queues for an Hub system.

#

like the Shop Queue that will process everything bought recently for example

#

or a Ban Queue that will ban every player added to the queue

#

how many 'queues' are there in my messages? πŸ˜…

viral crag
#

yes those are valid to have separate queues

midnight shore
#

those? the stacks? the ArrayDeque? wdym?

viral crag
#

wonders how many bad player you have if you have a queue for bans now

quaint mantle
# grim ice

pretty sure you can have both of these just by having a linkedlist

midnight shore
quiet ice
viral crag
quiet ice
#

Either way, I recommend against using java's stack implementation unless you are aware of it's synchronisation details

midnight shore
#

Again, thats not what i'm asking. The problem is specifying code to be executed in a variable

crimson terrace
#

is it a bad idea to spawn and shoot arrows async or does that not matter whatsoever?

grim ice
quaint mantle
grim ice
#

no need to confuse him now

#

also heres some ugly paint image i made

viral crag
#

as arrows are entities I broke a server that way

midnight shore
grim ice
#

Then?

crimson terrace
#

ok thanks, didnt know wether your first message was sarcasm XD

grim ice
#

you wanna accept a function so you can use it in ur class

#

if so use Runnable

#

if you want it to accept a param

#

use Consumer

#

if u want it to accept a param and return something

#

use a function

viral crag
grim ice
#

if u want it to accept no param and return something use a supplier

crimson terrace
#

oh I was thinking of spawning one per half second for a few mobs (sentry duty)

midnight shore
#

Well i'll just assume i can't do this. I don't understand the system behind functions

grim ice
#

holy shit

#

talk

craggy sapphire
#

i have a question for somebody in DMs since I need to send a picture, who knows how to compile plugins

viral crag
midnight shore
#

so many names i don't understand

grim ice
#

just tell me

#

what do u wanna do

ivory sleet
crimson terrace
#

I will do it sync then XD

midnight shore
#

what changes between a Function and a Consumer

grim ice
#

Function accepts param and returns something

#

Consumer accepts param and returns nothing

ivory sleet
#

a function takes an object and returns an object

midnight shore
#

do you guys understand that i don't know how Function and Consumers work? You are talking about air for me : (

ivory sleet
#

and yeah function takes an object but returns void

#

do you know how

void epic(Object o) {

}

work?

grim ice
#

Function<Integer, Short> is

public Short method(){
return Integer;
}

grim ice
crimson terrace
ivory sleet
#

thats a Consumer<Object> equivalent

ivory sleet
#

and then we have

String apply(Object o) {

}
craggy sapphire
#

who knows how to compile plugins

ivory sleet
#

this would be a Function<Object,String>

grim ice
#

Consumer lets the consumer consume the object

midnight shore
#

So, the Consumer is what i want if i understand correctly

grim ice
#

Function performs a functionality on an object, and returns another one

grim ice
#

you dont want it to return anything

#

you want your class to accept a Consumer

#

and then do consumer.apply(...);

#

Consumer is generic so

#

Consumer<Integer> for example

#

would .accept(Integer)

midnight shore
#

what is the Type <T> it requires?

grim ice
#

any thing

midnight shore
#

ohhh

#

i see

grim ice
#

as long as its an object

#

it hands the object you pass with .accept() to the consumer

ivory sleet
#

will0mane if you really wanna understand classes such as Consumer, Runnable, Supplier and Function then you need to know a little bit about how Java abstract works as well as interfaces

midnight shore
#

for example Consumer<UUID> will accept only uuids

grim ice
#

yes

#

and the user will do

midnight shore
crimson terrace
#

if I want to remove an arrow a fixed time after it is fired, do I have any other choice but to create a task for each arrow?

grim ice
#

new Clazz(uuid -> System.out::println);
the uuid here is what you pass with consumer.accept(UUID uuid);

crimson terrace
#

dangit

grim ice
#

why is it a problem

tender shard
#

just create one task that runs every second or so?

grim ice
crimson terrace
#

I just wanted a method in arrow which is like "removeAfterTime(int ticks)"XD

crimson terrace
tender shard
#

no of course you must keep track of the time whe nit was fired lol

grim ice
#

overcomplicating stuff

#

KISS

midnight shore
#

what do i have to put here?

tender shard
crimson terrace
#

oh you mean a hashMap of arrows with the System millis as values?

grim ice
#

there is a simpler solution

#

<:

crimson terrace
#

thats not a bad idea

grim ice
#

variable

#

that consumer.accept() passes to you

#

u name it whatever u want

#

follow naming conventions and keep it descriptive

midnight shore
viral crag
grim ice
#

u didnt write the lambda correct;y

#

correctly

midnight shore
#

oh

#

i'm dumb

#

ty

crimson terrace
#

I just want to prevent lag by removing arrows which didnt hit πŸ˜›

viral crag
#

"hit" is any block or entity they come in contact with

tender shard
#
    private static final Map<Projectile, Long> projectiles = new HashMap<>();
    private static final int delay = 10; // remove arrows after 10 seconds

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
        getServer().getScheduler().runTaskTimer(this, () -> {
            long currentTime = System.currentTimeMillis();
            Iterator<Map.Entry<Projectile,Long>> iterator = projectiles.entrySet().iterator();
            while(iterator.hasNext()) {
                Map.Entry<Projectile,Long> entry = iterator.next();
                if(currentTime > entry.getValue() + delay * 1000) {
                    iterator.remove();
                    entry.getKey().remove();
                }
            }
        }, 20, 20);
    }

    @EventHandler
    public void onShoot(ProjectileLaunchEvent event) {
        projectiles.put(event.getEntity(), System.currentTimeMillis());
    }

This isn't really very complicated

#

@crimson terrace

grim ice
#

way more complicated then it can be tbf

crimson terrace
#

yeah thats exactly what I was thinking of

limpid bronze
#

Hey I want to work with NMS so I imported spigot-1.18.1-R0.1-SNAPSHOT-remapped-mojang.jar in my build.gradle but i have this error:

And I don't know how to solve this issue even with researches on Internet, can someone help me?

lavish hemlock
#

You can simplify that even more in newer versions

viral crag
#

wonders what happens in @tender shard 's code when the delay is less than natural despawn decy

lavish hemlock
#

Replace some of the types with var

crimson terrace
#

this shouldnt cause any problems with the amount of arrows I am planning for.

tardy delta
#

primitives in generics when

tender shard
crimson terrace
#

its not

ivory sleet
tardy delta
#

kek

#

lets try it out in rust first

chrome beacon
crimson terrace
limpid bronze
# chrome beacon Could you show your build.gradle
plugins {
    id 'java'
    id 'kr.entree.spigradle' version '2.2.4'
    id "com.github.johnrengelman.shadow" version "7.1.2"
    id 'de.undercouch.download' version '5.0.2'
}

apply from: rootProject.file('buildtools.gradle')

group 'org.example'
version '1.0-SNAPSHOT'

tasks.prepareSpigotPlugins.dependsOn shadowJar
tasks.runSpigot.dependsOn prepareSpigotPlugins

repositories {
    mavenCentral()
    mavenLocal()
    protocolLib()
    maven {
        name = "SunderiaRepo"
        url = "https://maven.galaxyfight.fr/snapshots"
    }
    maven {
        name = "Jeff"
        url = 'https://hub.jeff-media.com/nexus/repository/jeff-media-public/'
    }
}

dependencies {
    compileOnly spigot('1.18.1')
    compileOnly ('org.spigotmc:spigot:1.18.1-R0.1-SNAPSHOT:remapped-mojang')
    compileOnly protocolLib('4.7.0')
    implementation 'fr.sunderia:SunderiaUtils:1.1.1-SNAPSHOT'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}

test {
    useJUnitPlatform()
}

spigot {
    name = 'SunderiaSkyblock'
    version = '1.18.1'
    depends('ProtocolLib')
    permissions {
        'sunderiaskyblock.visibleholo' {
            description = 'Allows to use the visibleholo command.'
            defaults = 'op'
        }
        'sunderiaskyblock.test' {
            description = 'Allows to use the test command.'
            defaults = 'op'
        }
    }
    debug {
        args '--nojline', '--max-players', '4'
        jvmArgs '-Xmx4G'
        serverPort 25565
        eula = true
    }
    authors 'noalegeek68', 'minemobs'
    apiVersion '1.18'
}
ivory sleet
#

does it have to be async?

tender shard
tardy delta
#

well i guess the arrow is a bukkit entity

#

and doing api stuff async will break some stuff

crimson terrace
#

ok, never use async, got it XD

tardy delta
grim ice
tender shard
crimson terrace
tender shard
#

it's a pretty shitty idea to spawn 10 thousands of scheduled tasks if you could just instead use one

crimson terrace
#

and honestly, that could be used every minute or so, reducing the constant performance hit more (even tho running it more often would reduce the spike)

tender shard
#

lol

crimson terrace
#

if you get 100 arrows per minute, iterating over those isnt bad. doing it after 20 minutes you would have to iterate over 2000 entries

#

basically

tender shard
#

yes, that's no problem

grim ice
#

yeah

tardy delta
#

why is there no scheduler method which takes a timeunit as parameter lol

#

follow the future

tender shard
#

bungee has one

tardy delta
#

i barely know what bungee is

viral crag
grim ice
ivory sleet
#

even for its async variants

grim ice
tardy delta
#

internal calculation 🀩

grim ice
#

e.g TimeUnit.SECONDS will just *20

tardy delta
#

maths lol

ivory sleet
#

ye you can do that 2hex

viral crag
#

not all servers run at 20 ticks per second

ivory sleet
#

^

tardy delta
#

what would even happen if you could screw the tps up?

ivory sleet
#

it gets delayed

#

for instance if you have 10 tps, then it will take double the time

tardy delta
#

but what if all tasks also arrive faster?

#

would that mean you could get a higher fps?

viral crag
#

no

ivory sleet
#

nope

#

iirc the game tick engine uses Thread::sleep to ensure the tps doesnt go higher or sth

tardy delta
#

sounds to make sense

viral crag
#

FPS is bottlenecked by the network and is ultimately a clientside phenomenon

tender shard
#

isn't there a private field somewhere that you can just change from 50 to 10 to go from 20 to 100 tps?

viral crag
#

yes

#

there are a few accelerated servers out there - most seem to be skyblock

limpid bronze
tender shard
#

run buildtools with the --remapped option

limpid bronze
#

like that? java -jar BuildTools.jar --rev 1.18.1 --remapped

tender shard
#

yep

limpid bronze
#

Ok thanks!

tender shard
ivory sleet
#

πŸ₯²

tender shard
#

oh btw you also must use the special source plugin to reobfuscate your NMS code

#

otherwise it won't work

#

but no idea how it works in gradle

ivory sleet
#

paperweight userdev is pretty much the alternative

eternal night
#

And then kind of hope you don't use paper only methods πŸ˜…

wary harness
#

any one can tell me what do I need to put in start.bat to generate remaped spigot jar

eternal night
#

I don't think you get to run spigot with Mojang mappings

#

If that is what you are after

#

Or do you just want build tools to install It in your maven repo

wary harness
#

--remapped

#

needed it for maven repo

sharp bough
#

so i have blocks like this , server side locations are saved and items are moving from one block to another, client side its impossible to tell without clicking it, how could i represent this?

#

im looking for ideas

#

mine was particles, that follow the path of the items but you wont be able to see most blocks

#

just the ones in the outside

#

maybe a scoreboard updating whenever you see one of this blocks, showing the state of it?

tardy delta
#

im not understanding the question

sharp bough
#

well it gets as simple as "do you see anything happening in the image"?

#

(a video would be the exact same)

tardy delta
#

i see blocks being added

sharp bough
#

each image is individual from each other, those are 3 different setups

#

now server side you have items in each block, with are moving to the next block

#

based on the type of each block, different actions happen

#

based on the speed of the blocks the items more faster or slower

midnight shore
#

How do you have items in blocks?

sharp bough
#

but the player has no idea

sharp bough
midnight shore
#

So the item entity?

tardy delta
#

what items?

#

dropped items?

midnight shore
#

You mean that?

sharp bough
# tardy delta dropped items?

yes something like that, you also have a generator ( either bedrock or the white concrete, depending on the situation)

#

each color has a function

tardy delta
#

so if you start running, the items run away from you?

sharp bough
#

no, its like factorio or a few modpacks

#

for example

#

now in that video, theres a single player world

#

so the mod edits the blocks and allows you to see whats going on

#

i want something similar, a way for the player to see whats going on

sacred mountain
#

ive been messing around with packets and stuff, and got the demo screen to work, are there any other things that still exist that i could have fun with

#

i was thinking the steve co crate but that seems too long ago cant find anything on it either

chrome beacon
#

Yeah I don't think that one still exists

sacred mountain
#

damn

tender shard
#

steve co crate?

#

what's that

sacred mountain
#

steve co supply crate

#

mc 1.4 easter egg

#

2010 ish i think

tender shard
#

aaah the fake things to buy

#

I remember

sacred mountain
#

yeah

#

are there any more that are still accessible

viral crag
#

the giant still exists

sacred mountain
#

i just think it would be funny

sacred mountain
#

the mob you mean

viral crag
#

yeah

sacred mountain
#

yeah ik that

#

im more looking for on-screen guis/screens that havent been used but still exist

#

and i could possibly send to the player using a packet

viral crag
#

there are a few libraries to create forms, but i dont recall any other random screens

sacred mountain
#

and also, is it possible to modify the text on the 'loading world' screen or is that client side

tardy delta
#

or alt f4

spring minnow
#

I mean I don’t need it but idk I want to see cuz idk

noble lantern
#

He just has a better programmer chair

modern vigil
#

nvm got it

opal sluice
#

hi, I have an issue with SQLLite and HikariCP usage. When I do

    public ResultSet getQueryResult(final String query)
    {
        getSQLConnection();
        PreparedStatement ps;
        try
        {
            ps = getConnection().prepareStatement(query);
            return ps.executeQuery();
        }
        catch (SQLException e)
        {
            e.printStackTrace();
        }
        return null;
    }

I get a connection is closed if I make multiple requests.

I do close the connection every time I finish the query

tardy delta
#

getSQLConnection();

#

ps = getConnection().prepareStatement(query);

opal sluice
#

Sorry for not making the precision, but getConnection = the connection instance

#

getSQLConnection set the actual connection instance to a valid one

#
    public Connection getSQLConnection()
    {
        try
        {
            if ((getDs() != null && getDs().isClosed()) || getConnection() == null || getConnection().isClosed())
            {
                setConnection(getDs().getConnection());
            }
            return getConnection();
        }
        catch (SQLException ex)
        {
            plugin.getLogger().log(Level.SEVERE, "SQLite exception on initialize", ex);
        }
        return null;
    }
tardy delta
#

the best thing to do is just

try (Connection conn = ...;
    PreparedStatement ps = conn.prepareStatement(query)) {
  // execute stuff
}```
opal sluice
#

can't do that with a result set like that

#

since it will close on return and I'll not be able to use the ResultSet later

#

btw I have that error only when I stresstest the system

#

If it goes slowly, it doesn't occur

late stag
#

Who can help me? I want to send and receive the message for bungeecord. There are no plugin messaging guides, the official one only says how to send messages to bungee, but not how to send from it. It was supposed to work, but I debugged and did not see a single message received by the bukkit. Bungeecord gets it, bukkit doesn't

sacred mountain
#

without having to overload it

sacred mountain
tardy delta
#

uhh

#

reflection probably

#

theres a functions that shuts the server down gracefully

viral crag
#

would be rather curious to know what happens when you unload a world with a player in it

tardy delta
#

lets try it out

west oxide
#

hey so i found the reason why player wouldnt get tpd to the given location earlier but now am left with this not actually working

            if (event.getEntity() instanceof Player){

                player = ((Player) event.getEntity()).getPlayer();
                player.teleport(Utils.getSpawnLocation());

            }
        }```
#

the damage is cancelled but player doesnt get tpd

tardy delta
#

player.getPlayer() why?

viral crag
#

a player is getting void damage ... where are they getting void damage from?

west oxide
#

i jumped in the void and didnt get tpd

#

after falling for very long

viral crag
#

so they continue falling or do they get respawned?

west oxide
#

for a while

viral crag
#

is your connection lagging?

west oxide
#

i waited for like 5 seconds down there its too dark

west oxide
#

i typed in chat

#

and ran commands

#

working fine

desert musk
#

what is WorldServer called now?

#

oh ServerLevel

#

mb

#

answered myself

viral crag
west oxide
#

okay

viral crag
#

muses if the void is an entity

west oxide
viral crag
west oxide
#

and it worked

viral crag
#

hmm void is a material structure

west oxide
late stag
#

Guys! Who can help me? I want to send and receive the message for bungeecord. There are no plugin messaging guides, the official one only says how to send messages to bungee, but not how to send from it. It was supposed to work, but I debugged and did not see a single message received by the bukkit. Bungeecord gets it, bukkit doesn't

viral crag
west oxide
viral crag
#

so it teleports you with the comment?

tender shard
#

does World#getChunkAt(x,z) load a chunk?

grim ice
tender shard
#

wow that sucks

#

how can I check if a chunk is loaded if I only have the coordinates?

grim ice
#

oh wait

tender shard
#

ah yes

grim ice
#

this'

tender shard
#

it also takes x,z

#

yes thx

#

I also didnt see the xz method at first

#

lol

grim ice
#

lo

tender shard
#

somehow I still think this won't work lol

    public List<ChunkSnapshot> getChunkSnapshots(final World world, final BoundingBox box, final boolean onlyLoadedChunks) {
        final int minX = (int) box.getMinX() >> 4;
        final int maxX = (int) box.getMaxX() >> 4;
        int minZ = (int) box.getMinZ() >> 4;
        int maxZ = (int) box.getMaxZ() >> 4;

        List<ChunkSnapshot> chunks = new ArrayList<>();
        for(int x = minX; x <= maxX; x++) {
            for(int z = minZ; z <= maxZ; z++) {
                if(!onlyLoadedChunks || world.isChunkLoaded(x,z)) {
                    Chunk chunk = world.getChunkAt(x,z);
                    chunks.add(chunk.getChunkSnapshot(true, false, false));
                }
            }
        }
        return chunks;
    }
grim ice
#

that doesnt look like it needs to be ordered

viral crag
#

see, if you wrote the frames library he could use that πŸ˜›

grim ice
#

but it will load the chunks

grim ice
#

it seemed like a pain so i didnt search about it

#

can u explain it

viral crag
#

"A frame is useful to define the position, orientation and magnitude of an arbitrary object which may represent a point-of-view." pretty much sums it up

grim ice
#

sir thats a structure

#

exists in spigot api

west oxide
#

can i just import a plugin to intellijidea and not have it as a dependency on maven if the plugin is going to be on the server ?

west oxide
#

ohhh nvm

viral crag
#

"A structure is a mutable template of captured blocks and entities that can be copied back into the world."

grim ice
#

Yeah

#

why would u need frames if that exists

desert musk
#
    public Nest(Location loc) {
        super(EntityType.VILLAGER,((CraftWorld) loc.getWorld()).getHandle());

        this.setPos(loc.getX(),loc.getY(),loc.getZ());

        this.setCustomName(new TextComponent(ChatColor.GOLD + "" + ChatColor.BOLD + "Unnamed Nest"));
        this.setCustomNameVisible(true);
        this.setHealth(10000);          // **this line does not work**

        //List goalB = (List)getPrivateField("b", PathFinder.class, goalSelector); goalB.clear();
        //List goalC = (List)getPrivateField("c", PathFinder.class, goalSelector); goalC.clear();
        //List targetB = (List)getPrivateField("b", PathFinder.class, targetSelector); targetB.clear();
        //List targetC = (List)getPrivateField("c", PathFinder.class, targetSelector); targetC.clear();
        
        // above commented code throws many errors, likely to do with PathFinder.class
    }```
#

Trying to make a custom entity

#

Setting its health does not work

#

Also i'm trying to make it stationary, no AI

#

not sure how to

tall dragon
#

u need to set its maxhealth iirc

#

before health

viral crag
#

i think it would be rather confusing to code the location, movement, or size of one structure in reference to another structure

desert musk
#

setMaxHealth isn't a method

#

do you mean like attributes?

worldly ingot
#

It's an attribute

desert musk
#

mm

worldly ingot
#

Would also avoid use of legacy colour codes in a text component

#

It should have some colour methods

grim ice
#

wdym to reference another structure

desert musk
#

this.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(1000);
gets red underlined

#

required type different than provided

viral crag
#

The classic, simple, example to that would be a Car in the world. The Car frame is in relation to the World frame, however they are independent to each other as they exist/move on their own

#

Airplane would be Plane, Airspace, Ground, World etc

tender shard
viral crag
#

in both those cases there are two locations and at least two movements

tender shard
#
private BlockVector chunkToWorldCoordinates(BlockVector chunkVector, int chunkX, int y, int chunkZ) {
        return new BlockVector(chunkVector.getBlockX() + (chunkX << 4), y, chunkVector.getBlockZ() + (chunkZ << 4));
    }

hm will this work lol?

#

chunkVector is a block vector with inside-chunk coordinates

desert musk
tall dragon
#

what type is different

desert musk
#

i wish

grim ice
#

Chunk chunk = world.getChunkAt(x,z);

#

@tender shard

#

this gon load it

tall dragon
desert musk
#

an entity extending off of Villager

tall dragon
#

ok

grim ice
#

ur using spigot api one

#

use nms one

desert musk
#

is there like a separate javadocs for that πŸ˜“

grim ice
#

ide literally told u it

desert musk
#

cause im running into all these issues with nms

grim ice
#

thats the point of nms

desert musk
#

lol

grim ice
#

running into issues

#

and suffering to death

desert musk
#

nice

#

sounds fun

#

No documentation found

#

pepela

#

rare intellij L

tall dragon
grim ice
#

no he cant

#

hes using nms

desert musk
#

nopers

#

i found something

tender shard
grim ice
#

use net.minecraft.world.entity.ai.attributes.Attribute not the bukkit one

desert musk
#

so ig i guess the name of the attribute

#

lol

desert musk
tall dragon
#

wasnt there somthng like getBukkitEntity()?

#

which u can use to then modify attributes with the api?

tender shard
#

if only someone would write a wrapper API for all the NMS stuff so we wouldn't have to use NMS classes directly all the time

#

wait -

desert musk
#

modCheck

#

i'm noob so i've been advised to do NMS like this

desert musk
chrome beacon
#

Those are the method names

desert musk
#

they don't show

chrome beacon
#

For that specific version

desert musk
#

oh

#

do you know what they are now? just wondering

tall dragon
#

do u even have nms in ur project?

desert musk
#

yea

tender shard
#

why aren't you using remapped?

desert musk
#

i am

#

πŸ˜„

#

per your instructions

tall dragon
#

again, cant u do this.getBukkitEntity() in your class?

desert musk
#

oh i can

#

clutch

#

πŸ™

shut solar
#

anyone here able to help me with my custom yml files problem? would be best to talk in dms

tall dragon
#

actually would be best if u dont talk in dms if u want the best help

desert musk
tall dragon
desert musk
tall dragon
tender shard
#
new BlockVector(1,2,3).toBlockVector().toBlockVector().toBlockVector().toBlockVector();
desert musk
shut solar
tall dragon
tall dragon
#

wooow, thats crazy

#

np :D

desert musk
#

so many convoluted answers online rn lol

#

πŸ‘Œ verynice

tender shard
#

ugh I'm currently rewriting one of my oldest plugin and I'm using ArrayList EVERYWHERE

#

every method takes an ArrayList as argument instead of a List

desert musk
#

lol

tall dragon
tender shard
shut solar
#

https://pastebin.com/Hm9ji3A1 ok so im trying for like 2hrs now and i cant figure it out, i tried a lot of stuff so its kinda mess rn, it looks like main problem is "addIslandData" cuz it works up until it should set something in my yml file, so it just copies the template data file (witch i think is not needed but i did it anyways) and it doesnt write new data

tall dragon
tender shard
#

yes exacty lol

#

I mean wtf

#

wtf is this

#

this is 10 lines just to get the center of a block

#

oh wait I get it, it takes double chests into account

#

okay so it's not as stupid as I thought

tall dragon
#

il be looking at a piece of code for 10 min and think, what the heck went thruh my mind here? how did i come up with this piece of garbage?

tall dragon
tender shard
#

yes and almost everything in one package

#

that plugin is 4 years old, I was a noob πŸ˜„

tall dragon
#

yea i did that shit too

tender shard
#

for example I had a method to get all blocks in a radius

#

as an arraylist

shut solar
tender shard
#

then I filtered the arraylist to remove all non-chest blocks

tall dragon
#

ah yea il take a look

tender shard
#

so I first added a million blocks, then removed 9999999 again

#

so smart lol

tender shard
#

somehow noone ever reported lag lol

tall dragon
#

ur lucky looping generally is pretty fast

tender shard
#

I do it like this now, that's a TINY bit more efficient lmao

tall dragon
#

hmm i see

#

coulnt u just get all tileentities from a chunk for chests?

#

and then filter those

tender shard
#

chests was just an example

tall dragon
#

ahh alright

#

looks alot better than ur previous example xD

tender shard
#

but yeah for the plugin I'm rewriting, getting the tile entities is a good idea

grim ice
#

im so bored i need a lib idea

fossil lily
#

How can I wait in a loop without thread.sleep?

tender shard
#

why do you want to wait?

fossil lily
#

I want to run something 75 times but wait 20 ticks between every run

tender shard
#

use a scheduled task

grim ice
#

Scheduler#runTaskTiemr

warm trout
#

Why is spigot converting the location +0.5 blocks more?

tender shard
#

?scheduling

undone axleBOT
fossil lily
#

oh im dunmb

#

thanks lol

grim ice
#

is it for performance

warm trout
# tender shard ?

If I'm teleporting to -189 71 -73, it's teleporting to -188.5 61 -72.5

#

Even in the code

grim ice
#

cuz if so that sucks

warm trout
#

I can't figure out why

#

I'm on 1,17

tall dragon
#

@shut solar well there is alot there could be better looking at ur class, but when u add the data ur using getResource() thats what taking ur file in the jar.

tender shard
fossil lily
fossil lily
warm trout
tall dragon
#

@shut solar i dont rlly understand why ur doing this at all

 try (InputStream in = Skyblock.getInstance().getResource("IslandData.yml");
                 OutputStream out = new FileOutputStream(this.getDataFile(island.getUniqueId()))) {
                ByteStreams.copy(in, out);
            } catch (IOException e) {
                e.printStackTrace();
            }
shut solar
tall dragon
#

just create a yml file, load it as file configuration. set ur data

tender shard
grim ice
#

and dont do it on main thread

tall dragon
shut solar
tall dragon
#

yea. so remove that

#

and if i were you i would store a FileConfiguration in ur Island

#

so u avoid loading it every time it needs changes

shut solar
#

damn

#

thats smart

#

ima do that and update u if i dont go to sleep

tender shard
tall dragon
#

sure, il be here for another hot minute

tall dragon
tender shard
#

PlayerInteractEvent

tall dragon
#

oh, yea ig that works too

tender shard
#

i think blockdamage is too late since it would then reset the first tick of having mined the block

tall dragon
#

how do u know the right tool tho?

#

is there a method to find out

#

?

hexed hatch
#

I think block has a method for that

tender shard
#

I have some complicated methods for that

tall dragon
#

pliz show :)

tender shard
#

e.g. profitsFromSilktouch(Material)

#

BestTools, it's on GitHub and it's very ugly

tall dragon
#

Is discord dyin?

hexed hatch
tender shard
#

discord back alive

tender shard
tall dragon
#

discord just completely died

#

for me

tender shard
#

I'll rewrite it SOME day

#

yes for me too

rough drift
#

do color codes work in usage messages

tender shard
#

if you use Β§, they should work

rough drift
#

alright

#

another thing

#

can i disable usage on a command

tender shard
#

I think there's something like getCommand("asd").setUsage

#

but it's @ NotNull

tall dragon
#

why would u wanna disable usage

#

just never send it

rough drift
#

because

#

return false

tall dragon
#

so dont return false?

tender shard
#

just don't return false

#

yeah lol

rough drift
#

since sonarlint is like "don't always return true"

tall dragon
#

just send ur own msg

rough drift
#

like bruhv

tender shard
tall dragon
#

i have never in my life ever returned false in a cmd

tender shard
#

you can also just do sth like this to trick it out

public static boolean true() {
  return !System.getProperties().isEmpty();
}
#

then return true();

tall dragon
#

but i have my cmd lib that automatically handles usage

quaint mantle
#

discord just died

rough drift
#

If you don't want a static instance

#

just use

public static MyPlugin getInstance() {
  return JavaPlugin.getPlugin(MyPlugin.class);
}
#

no static

#

and no need to do the getPlugin yourself

tall dragon
#

still uses static method

rough drift
#

I mean

#

you'd still have to use one

#

its just nicer to do it that way

tall dragon
#

or dont use it at all

rough drift
#

eh

tall dragon
#

and use dep injection

rough drift
#

Eh

#

I still need to get into that habit

tender shard
#

I inherently dislike dependency injection for spigot plugins

tall dragon
#

why is that

tender shard
#

some people have a badge on their github repo that shows the latest versions, does someone know where to get it?

tender shard
#

in my plugins I just do

public final class SomeListener implements Listener {
    private static final StackResize main = StackResize.getInstance();
tall dragon
#

eh, i dont mind it

#

i find my plugins way more clean with di

rough drift
#

because I am too dumb to realize that the class loads after the main

#

anyways gtg

#

cya

tall dragon
#

thats pretty acceptable most times

tender shard
tall dragon
#

yea ig its preference

tender shard
#

what I just hate is when people start crying "uuugh something is static, that's sooo bad, bruh learn java" etc

rough drift
#

^

#

gn for real tho

tender shard
#

gn

tall dragon
#

i mean. in some cases those people are right. but there are indeed alot of cases where static is acceptable and people still whine about it

#

but generally i stick to only using static for util and my config

tender shard
#

static is ALWAYS acceptable and actually it'd be stupid not to use it, when something doesn't need any class fields/methods

ivory sleet
#

stutihc bad

tender shard
#

conclure speling bed

ivory sleet
#

bed mhhhh

tall dragon
# tender shard static is ALWAYS acceptable and actually it'd be stupid not to use it, when some...

i handle my config like this for example

public class Settings extends SimpleSettings
{


    @Override
    protected int getConfigVersion() {
        return 1;
    }


    public static Boolean DEBUG;
    public static Action STACKER_ADD_ACTION;
    public static Action STACKER_TAKE_ACTION;
    public static String STORAGE_TYPE;
    public static String HOLOGRAM_PROVIDER_TYPE;

    private static void init()
    {
        DEBUG = getBoolean("DebugMessages");
        STACKER_ADD_ACTION = Enum.valueOf(Action.class, getString("Stacker_Add_Action"));
        STACKER_TAKE_ACTION = Enum.valueOf(Action.class, getString("Stacker_Take_Action"));
        STORAGE_TYPE = getString("StorageType");
        HOLOGRAM_PROVIDER_TYPE = getString("HologramType");
    }

}
noble lantern
#

like a sane human being

ivory sleet
#

but like

#

kinda sus

tall dragon
#

naaa i think its fine

ivory sleet
#

like the only issue I have with it, and to be fair is insinuated into most plugins, is in fact the tight coupling

#

ofc thats generally not an issue at first

vestal barn
#

how do i make something wait but not stop my task, i tried Thread.sleep(); but that paused the task

ivory sleet
#

?scheduling perhaps

undone axleBOT
tender shard
#
public final class MyThing {

    private static final MyThing myThing;

    static {
        myThing = new MyThing();
    }

    public static MyThing getMyThing() {
        return myThing;
    }
    
    private MyThing() {
        
    }
}

One of my better work ^

tall dragon
#

lmfao

ivory sleet
#

looks like a singleton

tardy delta
#

static block kek

tender shard
ivory sleet
#

how so?

tall dragon
#

would this create a infiite amount of MyThing objects?

#

or how does java handle this

tender shard
tender shard
#

the static { } gets called exactly once, when the class is first loaded

ivory sleet
#

myes but its still effectively a singleton

tender shard
#

the normal { } gets called everytime you use a constructor

ivory sleet
#

only thing that makes it a bad singleton is the name of the static method to retrieve the instance

tender shard
ivory sleet
#

nah

tender shard
#

getYourThing

#

getAnyThing

#

getRekd

ivory sleet
#

if its a singleton suffixing with instance is the general rule for the pattern

#

getBlahInstance or blahInstance (or just getInstance)

tender shard
#
@SuppressWarnings("conclureDoesntLikeIt")
public final class Instance extends Object {

    private static final Instance instanceInstance;

    static {
        instanceInstance = new Instance();
    }

    public static Instance getInstanceInstance() {
        return instanceInstance;
    }

    private Instance() {

    }
}

#

what about this

tardy delta
#

πŸ‘Œ

ivory sleet
#

both flattered and enraged concurrently

noble lantern
#

i liked it better as MyThing idk man

tender shard
#

btw does conclure mean sth? is it a word or sth?

noble lantern
#

getMyThing() was pretty clean

ivory sleet
#

apparently conclude in french

tardy delta
#

concluder

tender shard
#

french always sounds like if a snail was speaking

noble lantern
#

how tf would you even say sth

#

ss t hhh?

ivory sleet
tardy delta
#

bonjour je suis fromage

#

kek

tender shard
#

Caoutchouc

#

that means rubber

#

wtf

ivory sleet
#

not that the convention is crucial, cuz u know bukkit and a lot other libs

#

but ye

tardy delta
#

i hate learning french at school

tender shard
#

there should be a french coding language

ivory sleet
#

lol

#

baguette

tardy delta
#

let fromage = baguette()

ivory sleet
#

πŸ₯–

tardy delta
#

bonk

tender shard
#
laissez le nom Γͺtre "mfnalex"Β ;
si nom est Γ©gal Γ  "mfnalex" {
   print "je suis mfnalex"Β ;
}
tardy delta
#

shit its already 12 pm

tender shard
#

yes and I still havent completed the spaghetti quest in sneaky sasquatch

tardy delta
#

i was planning to do some rust but uhm ye

desert musk
#

does anyone have a good, updated tutorial on hand for doing yaml configs?

tardy delta
#

yall know what happened

tender shard
desert musk
#

sweet

#

ty

tender shard
desert musk
#

how fancy

tender shard
#

the most relevant things are in MemorySection and FileConfiguration, which this extends

desert musk
#

πŸ‘

ivory sleet
#

and ye alex gave u a good link there

#

but a YamlConfiguration is a fancy LinkedHashMap adapter

tender shard
#

I have the best links

ivory sleet
#

most of the times

#

and then you have FileConfiguration (superclass of YamlConfiguration) which has a save(File) and load(File) method

#

save would obviously save the content of the backing map to the file

#

and load would load it

#

pretty simple

tender shard
#

I still have to look at the whole "save comments" stuff that was added

ivory sleet
#

oo ye

tender shard
#

I heard it was added, I was happy, then I never looked at it lmao

ivory sleet
#

comments supported hahayes

tardy delta
#

sheessh

tender shard
#

the bad thing is that it makes my ConfigUpdater library useless lmao

#

well okay not completely useless

#

but 90% of it

tender shard
tardy delta
#

πŸ₯–

west oxide
tender shard
#

lol not really

west oxide
#

lmao rip i got exited for a sec

tender shard
#

πŸ˜„

west oxide
#

i would baguetting on those coders

west oxide
west oxide
#

anyways, i have question,

is there a way to store data similar in config file similar to hashmaps ?

#

key,value type thing

#

i know thers this plugin.getConfig().getMapList("something");

tranquil valley
#

Shakiz

west oxide
west oxide
tranquil valley
#

Could i send you something? it is a awesome plugin

tender shard
west oxide
#

but am curious

ivory sleet
#

Shakiz just be careful when downloading stuff from arbitrary people (:

tender shard
#

I bet it's some furry plugin

tranquil valley
#

are we allow to send some video? here

tender shard
#

I want to receive it too

ivory sleet
west oxide
tranquil valley
#

NO

noble lantern
#

can i see the plugin

tranquil valley
#

IRTS NOT LIKE THAT

west oxide
echo basalt
#

I expect y'all to receive the "youareanidiot" video

tender shard
echo basalt
#

that would just be perfec

tender shard
#
on join:
    send  "Are you a furry" to player
    send "&a&l<command:/furryfound >>>Click here<<<reset> &6if you are!" to player

command furryfound:
    trigger:
        make console execute command "Ban %player% Reason: furrys are not accepted on this server"

#

best skript ever

west oxide
noble lantern
west oxide
#

config.set ?

quaint mantle
west oxide
#

i need some way to store data in yaml file as Key,Value

tender shard
noble lantern
tender shard
#

the whole idea of yaml is basically key: value

noble lantern
#

if you dont, i will

west oxide
tender shard
#
YamlConfiguration config = new YamlConfiguration();
// Now the code from above
west oxide
#

Servers:
Key:value

#

getservers().getKey => returns the value

#

somthing like this

noble lantern
#

okay discord just says fuck you to me and my color scheming with code blocks, thanks discord

west oxide
#

and then how to add data to "something" for example here

          somethingcool : verycool
#

as a value and key

noble lantern
west oxide
#

oh

#

wouldnt that replace this ?

noble lantern
#
ConfigurationSection section = config.getConfigurationSection("something");

for(Entry<String,Object> entry : myMap.entrySet()) {
  section.set(entry.getKey(), entry.getValue());
}

Say you have a entry in the Map of
Key: Hey, Value: there

Using the code above, it should do this:

something:
    "Hey": "There"
west oxide
#

thank you

vestal barn
#

how can i fire arrows one after another using player.launchProjectile?

noble lantern
#

Argument should be Arrow.class but im not entirely sure

west oxide
noble lantern
#

never done that

west oxide
west oxide
noble lantern
#

try setting that value of set(arg1, null) (second argument to null)

Not sure if that would work but worth trying

noble lantern
#

section.getString("ThatKey");

#

if you want the path

#

you need to loop through the section

#

one second

west oxide
#
        servers.set("server", position);
    }

    public void removeServer ( String server){

        plugin.getConfig().set(servers.getCurrentPath() + server + servers.get(server),null);
        plugin.getConfig().set(servers.getCurrentPath() + server ,null);

    }```
west oxide
#

servers = plugin.getConfig().getConfigurationSection("Servers");

noble lantern
#
for (String key : section.getKeys(false)) {
  // key here
}
vestal barn
#

how can i fire arrows one after another using player.launchProjectile(Arrow.class)

noble lantern
#

so if you have lets say:

settings:
  "THat": "Value"

key in that code snipped would be "THat"

#

(Considering the configuration section you grabbed was settings)

noble lantern
#

Doubt this is how it works though

vestal barn
noble lantern
#

but you can try

#

loop it

vestal barn
#

it fire them all at once

noble lantern
#

BukkitRunnable with runTaskLater

vestal barn
#

still fires them all at once just a bit later

#

and the runTaskLaterasync gives me Asynchronous entity add!

west oxide
noble lantern
#

nonoonono

#

dont use async

#

this will launch an arrow every 3 seconds 6 times

west oxide
noble lantern
#

like said, cant remember how you remove config values, iirc you just nullify them

west oxide
noble lantern
#

it should remove it, but i could be wrong

#

only way to know is to test it

#

never hurts to test things

west oxide
#

okay will

#

yeah

#

ty

noble lantern
#

dont use async for spigot methods like that

vestal barn
noble lantern
#

Show the code you have

#

oh wait

#

i see

#

one moment

vestal barn
#
                new BukkitRunnable() {
                    @Override
                    public void run() {
                        player.launchProjectile(Arrow.class);
                    }
                }.runTaskLater(getInstance(), 20 * 3);
            }```
noble lantern
#

yeah one moment my bad

#

sorry im bad at math

vestal barn
#

that works

#

thanks

noble lantern
#

πŸ‘Œ

#

that will only make it fire whatever ticks later x is, so youll need to figure out a value that works for you

spring minnow
#

Why doesn't speed attribute go back to normal?

#

Player.getAttribute(Attribute)

#

i used setBaseValue(getDefaultValue)

#

Oh wait i just found on a spigot thread another user that had the same problem and looks like the only fix is use setBaseValue(0.1) for speed, probably a spigot bug right?

noble lantern
#

or server restart, one of the 2

spring minnow
#

What does IIRC mean? xD

#

i'm italian

tall dragon
#

if i remember correctly.

noble lantern
#

^

spring minnow
#

thx

tall dragon
#

i just knew it was a rick roll

spring minnow
#

I can also use attribute modifiers

tall dragon
#

yet i scanned anyway

patent horizon
#

whats the enum name for cyan

spring minnow
#

Color dye

#

Cyan_Dye

spring minnow
noble lantern
#

depends on version too iirc

spring minnow
patent horizon
#

no like the chat color

noble lantern
#

oh uh

patent horizon
#

they dont have light_blue or cyan

#

not aqua but the &3 one

noble lantern
#

&33

#

oh wait

#

shit doesnt work on discord

#

lets forget i did that

tall dragon
#

there is aqua tho

#

&b

noble lantern
#

Wouldnt it just be BLUE?

#

ChatColor.BLUE?

tall dragon
#

or dark aqua &3

noble lantern
#

ah ^

patent horizon
#

ye

tall dragon
#

thats dark aqua

patent horizon
#

its dark_aqua?

#

ah

tall dragon
#

on 1.18 u can use hex colors as well btw

#

so rlly any color

#

if u want

desert musk
#

made a CustomConfig file to operate the user's config but the CustomConfig.get() method returns null, here's the setup

    public static void setup() {
        file = new File(Bukkit.getServer().getPluginManager().getPlugin("HearthNest").getDataFolder(),"config.yml");
        if (!file.exists()) {
            try {
                file.createNewFile();
            } catch (IOException e) {

            }
            config = YamlConfiguration.loadConfiguration(file);
        }
    }```
noble lantern
#

why use ChatColor just translateAlternateColorCodes

crisp steeple
#

why use chatcolor just \u00a7

lost matrix
noble lantern
#

^

desert musk
noble lantern
#

always log IOExceptions

#

e.printStackTrace()

desert musk
#

i see

#

ty

lost matrix
#

Because thats the problem most likely

desert musk
noble lantern
#

another thing too thats not gonna copy data from a config file in your plugin

#

its just gonna create a blank yml file

lost matrix
desert musk
#

yeah it is

#

https://www.youtube.com/watch?v=3en6w7PNL08
following this old ass tutorial btw

In this episode, I show you how to create custom configuration files for your plugins. This means that you can use other files to store data other than the typical config.yml file. These are used by every major plugin, usually. #Spigot #Bukkit #MinecraftPluginDevelopment

Code: https://snippets.cacher.io/snippet/e1f3bdc29b1739dc374c

⭐ Kite is a...

β–Ά Play video
noble lantern
#

use JavaPlugin#saveResource("string", booleanReplaceValue);

If your saving a file inside your /resources folder

lost matrix
noble lantern
#

it will handle all of the if exists all that

tall dragon
#

it teaches u bad coding standards.

crisp steeple
desert musk
desert musk
shut solar
#

Epic fun fact for epicgodmc: i got it to work thx

lost matrix
#

You only create the config if the file doesnt exist. Move the config init further down

desert musk
tall dragon
noble lantern
desert musk
#

oh great

#

ok cool

noble lantern
#

πŸ‘Œ

crisp steeple
#

also it looks like that's just using the default config anyways?

desert musk
#

shrug

crisp steeple
#

why not just do Main.getConfig() or whatever it is

noble lantern
#

that wiki wont show you how to make getters and setters, but you should know how to do that already

(Considering you learned java before trying to learn SpigotAPI)

noble lantern
#

If you are using just the default config file

#

JavaPlugin#saveDefaultConfig()

#

just use that

#

and JavaPlugin#getConfig()

#

anything else use JavaPlugin#saveResource

#

unless your wanting to write to a yaml file via code instead of copying a config file over from /resources

#

then the way you were doing it is fine, some cases you want to do this for configs but not often

desert musk
#

kk

tall dragon
#

i aint a fan of the default shit

#

since it only supports one file

#

i rather have my own system that can create as many as i want.

crisp steeple
#

yeah but for his it was only using one

west oxide
#

is this called when a player right clicks ?

noble lantern
#

saveResource supports all files in /resources

crisp steeple
west oxide
#

okay thank you

tall dragon
noble lantern
#

ohhh

#

okay i see

#

my bad

tall dragon
#

for both hands.

west oxide
#

you mean like if i left click it could be called twice ?

tall dragon
#

yea. once for the main hand and once for the offhand

west oxide
tall dragon
#

yea

#

if ur pre 1.9 thats not a thing obvs.

west oxide
#

modern problems require very old solutions

hexed hatch
#

Unbased opinion

west oxide
#

thank you

tall dragon