#config

1 messages · Page 1 of 1 (latest)

sage warren
torn smelt
#

llol

#

so i just changed the config by changing the config.yml file in the server and doing my reload command

#

nothing changes the config during the runnable

sage warren
#

alright, you could try running a for loop with getConfig().getKeys(true) and print them

#

see what the config contains after a reload

torn smelt
#

where

sage warren
#

after you reload

torn smelt
#

in reload?

#

k

sage warren
torn smelt
#

um the reason it wasnt printing is cuz i did print not println xD

sage warren
#

nice

torn smelt
#

i did this but its still not printing

@Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if(label.equalsIgnoreCase("decayreload")) {
            if(sender.hasPermission("decay.reload")) {
                plugin.reloadConfig();
                sender.sendMessage(ChatColor.GREEN + "Config reloaded successfully");
                System.out.println(plugin.getConfig().getKeys(true));
            }
            else {
                sender.sendMessage(ChatColor.RED + "You do not have permission to use this command");
            }
            return true;
        }
        return false;
    }
#

im guessing getKeys returns a list or smth

#

[11:33:40 WARN]: Nag author(s): '[TristanDaSavage]' of 'World-Decay' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).
[11:33:40 INFO]: [World-Decay] [STDOUT] radius
[11:33:40 WARN]: Nag author(s): '[TristanDaSavage]' of 'World-Decay' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).

#

the second one didnt print anything

#

nvm

#

it said it above

#

lol

#

so it said decaydelay and radius

#

@sage warren

sage warren
#

no idea either then

torn smelt
#

ima try System.out.println(plugin.getConfig().get(key));

sage warren
#

yeah

torn smelt
#

didnt print

#

for(String key : plugin.getConfig().getKeys(true)) {
System.out.println(plugin.getConfig().get(key));
}

#

isnt that right

#

god the indents lol

sage warren
#

should be right

torn smelt
#

huh @sage warren its erroring but its still working

#

i moved somewhere else and its still moving blocks

sage warren
#

please use JavaPlugin.getLogger().info("") btw

torn smelt
#

lol ik

sage warren
#

huh weird

torn smelt
#

whats the index out of bounds thing doesnt that mean its part of a for loop?

sage warren
#

could be

torn smelt
#

maybe one of these?

public static List<Block> getNearbyBlocks(Location location, int radius) {
        List<Block> blocks = new ArrayList<Block>();
        for (int x = location.getBlockX() - radius; x <= location.getBlockX() + radius; x++) {
            for (int y = location.getBlockY() - radius; y <= location.getBlockY() + radius; y++) {
                for (int z = location.getBlockZ() - radius; z <= location.getBlockZ() + radius; z++) {
                    if (!location.getWorld().getBlockAt(x, y, z).getBlockData().getMaterial().isAir() || location.getWorld().getBlockAt(x, y ,z).getBlockData().getMaterial() != Material.BEDROCK) {
                        blocks.add(location.getWorld().getBlockAt(x, y, z));
                    }
                }
            }
        }
        return blocks;
    }

    public static List<Block> getNearbyAirBlocks(Location location, int radius) {
        List<Block> blocks = new ArrayList<Block>();
        for (int x = location.getBlockX() - radius; x <= location.getBlockX() + radius; x++) {
            for (int y = location.getBlockY() - radius; y <= location.getBlockY() + radius; y++) {
                for (int z = location.getBlockZ() - radius; z <= location.getBlockZ() + radius; z++) {
                    if (location.getWorld().getBlockAt(x, y, z).getBlockData().getMaterial().isAir()) {
                        blocks.add(location.getWorld().getBlockAt(x, y, z));
                    }
                }
            }
        }
        return blocks;
    }
sage warren
#

send me the line where it happens

torn smelt
#

its not telling me the line in the error

#

lol

sage warren
#

send the error

torn smelt
#

[11:42:24 WARN]: [World-Decay] Task #1467 for World-Decay v1.0 generated an exception
java.lang.IndexOutOfBoundsException: Index 1008730 out of bounds for length 914367
at jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64) ~[?:?]
at jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70) ~[?:?]
at jdk.internal.util.Preconditions.checkIndex(Preconditions.java:266) ~[?:?]
at java.util.Objects.checkIndex(Objects.java:359) ~[?:?]
at java.util.ArrayList.get(ArrayList.java:427) ~[?:?]
at me.tristandasavage.worlddecay.WorldDecay$1.run(WorldDecay.java:45) ~[World Decay.jar:?]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:101) ~[patched_1.17.1.jar:git-Paper-187]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:483) ~[patched_1.17.1.jar:git-Paper-187]
at net.minecraft.server.MinecraftServer.b(MinecraftServer.java:1490) ~[patched_1.17.1.jar:git-Paper-187]
at net.minecraft.server.dedicated.DedicatedServer.b(DedicatedServer.java:479) ~[patched_1.17.1.jar:git-Paper-187]
at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:1406) ~[patched_1.17.1.jar:git-Paper-187]
at net.minecraft.server.MinecraftServer.x(MinecraftServer.java:1188) ~[patched_1.17.1.jar:git-Paper-187]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:316) ~[patched_1.17.1.jar:git-Paper-187]
at java.lang.Thread.run(Thread.java:831) [?:?]

sage warren
#

I'll teach you how to read errors :)

torn smelt
#

lol

sage warren
#

You know how a stracktrace works?

torn smelt
#

i dont like how java has so much stuff in errors

#

im used to python

#

xD

sage warren
#

java is harder but more stable

sage warren
torn smelt
#

ye

#

its in Block block1 = airblocks.get(rand.nextInt(blocks.size()));

#

i thikn

#

line 45

sage warren
#

alright

#

one sec

torn smelt
#

and Block block2 = blocks.get(rand.nextInt(blocks.size())); would be the same

#

so ye its in those methods

sage warren
#

blocks and airblocks aren't the same size

torn smelt
#

oh

#

i forgot lol

sage warren
torn smelt
#

i kinda copy/pasted one thing

#

o rip

#

lol

sage warren
#

you are only using 2 blocks from those array every time right?

torn smelt
#

ye

sage warren
#

try generating random coordinates, check if it's air or not, if it's not the correct one generate another one

#

since putting so many blocks in an array every single time will kill the tps

torn smelt
#

they have to be within a radius of the player tho

#

also im running client and server on one pc and not lagging at all lol

#

ok maybe im lagging

#

lol

sage warren
#

you could do int blockX = -radius + r.nextInt(radius*2)

sage warren
torn smelt
#

xD

sage warren
#

maybe you could do it your way if it's personal use only

#

like messing around and you don't care

#

but if you plan on releasing it though I suggest you optimise it a bit

torn smelt
sage warren
#

check if it's air and if not run again

torn smelt
#

bruh how did it find netherrack

#

xD its been running in the background this whole time

torn smelt
sage warren
#

a for loop with like 10000 and a break;

sage warren
#

maybe a portal?

#

do they spawn netherack?

torn smelt
#

idk

torn smelt
sage warren
#

more like a square

#

but I use it in all my plugins too

#

except that I check after generating a coordinate if the distance < radius and if not run again

#

so it turns into a circle again

torn smelt
#

i dont really care about shape tbh

#

but how does that make the coords relative to the player?

#

@sage warren

#

what about this

while(true) {
            Random rand = new Random();
            int x = ThreadLocalRandom.current().nextInt((int)location.getX()-radius, (int)location.getX()+radius);
            int y = ThreadLocalRandom.current().nextInt((int)location.getY()-radius, (int)location.getY()+radius);
            int z = ThreadLocalRandom.current().nextInt((int)location.getZ()-radius, (int)location.getZ()+radius);
            if (!location.getWorld().getBlockAt(x, y, z).getBlockData().getMaterial().isAir()) {
                Block block = location.getWorld().getBlockAt(x, y, z);
                return block;
            }
        }
#

@sage warren

#
public static Block getNearbyAirBlocks(Location location, int radius) {
        while(true) {
            Random rand = new Random();
            int x = ThreadLocalRandom.current().nextInt((int)location.getX()-radius, (int)location.getX()+radius);
            int y = ThreadLocalRandom.current().nextInt((int)location.getY()-radius, (int)location.getY()+radius);
            int z = ThreadLocalRandom.current().nextInt((int)location.getZ()-radius, (int)location.getZ()+radius);
            if (location.getWorld().getBlockAt(x, y, z).getBlockData().getMaterial().isAir()) {
                Block block = location.getWorld().getBlockAt(x, y, z);
                return block;
            }
        }
    }
#

that

#

lol

sage warren
torn smelt
#

lol

#

it seems to be working fine now

sage warren
#

so actualBlockX = p.getLocation().getBlockX() + blockX

#

awesome!

torn smelt
#

the only thing is even tho its set to 20 tick delay it seems to happen like every 1/2 second

#

hears anvil breaking

sage warren
#

that's weird

#

you sure you removed the first onJoin code xD?