#config
1 messages · Page 1 of 1 (latest)
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
alright, you could try running a for loop with getConfig().getKeys(true) and print them
see what the config contains after a reload
where
after you reload
I think this returns some kind of string array
um the reason it wasnt printing is cuz i did print not println xD
nice
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
no idea either then
ima try System.out.println(plugin.getConfig().get(key));
yeah
didnt print
for(String key : plugin.getConfig().getKeys(true)) {
System.out.println(plugin.getConfig().get(key));
}
isnt that right
god the indents lol
should be right
huh @sage warren its erroring but its still working
i moved somewhere else and its still moving blocks
please use JavaPlugin.getLogger().info("") btw
lol ik
huh weird
whats the index out of bounds thing doesnt that mean its part of a for loop?
could be
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;
}
send me the line where it happens
send the error
[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) [?:?]
I'll teach you how to read errors :)
lol
You know how a stracktrace works?
java is harder but more stable
like from top from bottom
ye
its in Block block1 = airblocks.get(rand.nextInt(blocks.size()));
i thikn
line 45
and Block block2 = blocks.get(rand.nextInt(blocks.size())); would be the same
so ye its in those methods
change blocks.size() to airblocks.size()
blocks and airblocks aren't the same size
the array you are scanning is huge though
you are only using 2 blocks from those array every time right?
ye
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
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
you could do int blockX = -radius + r.nextInt(radius*2)
wait until 2 ppl join lol
xD
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
but how do i get it to be specifically air or not air
check if it's air and if not run again
bruh how did it find netherrack
xD its been running in the background this whole time
k
a for loop with like 10000 and a break;
lmao wtf
maybe a portal?
do they spawn netherack?
idk
that wouldnt rlly be a radius around the player tho
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
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
oh yeah I forgot blockX is a coordinate relative to the player