This repository was archived by the owner on Jun 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResendLightingCommand.java
More file actions
39 lines (33 loc) · 1.61 KB
/
ResendLightingCommand.java
File metadata and controls
39 lines (33 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package your.package.name.here;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.CommandSender;
import net.minestom.server.command.builder.Command;
import net.minestom.server.command.builder.CommandContext;
import net.minestom.server.command.builder.condition.CommandCondition;
import net.minestom.server.command.builder.condition.Conditions;
import net.minestom.server.entity.Player;
import net.minestom.server.instance.Chunk;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.LightingChunk;
import net.minestom.server.network.packet.client.ClientPacketsHandler;
import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;
public class ResendLightingCommand extends Command {
public ResendLightingCommand() {
super("resendlighting", "relight");
addSyntax(this::execute);
setCondition(Conditions::playerOnly);
}
private void execute(@NotNull CommandSender commandSender, @NotNull CommandContext commandContext) {
Player player = (Player) commandSender;
Instance currentPlayerInstance = player.getInstance();
player.sendMessage(Component.text("Lighting has been sent.", NamedTextColor.YELLOW));
for(Chunk chunk : currentPlayerInstance.getChunks()) {
LightingChunk lightingChunk = (LightingChunk) chunk;
lightingChunk.sendLighting();
}
System.out.println(player.getUsername() + " manually sent instance lighting.");
}
}