-
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #265 from Sylfare/feat/1_21
feat: 1.21 support
- Loading branch information
Showing
83 changed files
with
1,488 additions
and
858 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 27 additions & 28 deletions
55
vane-admin/src/main/java/org/oddlama/vane/admin/commands/Time.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,53 @@ | ||
package org.oddlama.vane.admin.commands; | ||
|
||
import static com.mojang.brigadier.Command.SINGLE_SUCCESS; | ||
import static io.papermc.paper.command.brigadier.Commands.argument; | ||
import static org.oddlama.vane.util.WorldUtil.change_time_smoothly; | ||
|
||
import java.util.List; | ||
import org.bukkit.World; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.oddlama.vane.admin.Admin; | ||
import org.oddlama.vane.annotation.command.Name; | ||
import org.oddlama.vane.core.command.Command; | ||
import org.oddlama.vane.core.command.argumentType.TimeValueArgumentType; | ||
import org.oddlama.vane.core.command.enums.TimeValue; | ||
import org.oddlama.vane.core.module.Context; | ||
|
||
@Name("time") | ||
public class Time extends Command<Admin> { | ||
import com.mojang.brigadier.builder.LiteralArgumentBuilder; | ||
import com.mojang.brigadier.context.CommandContext; | ||
|
||
public enum TimeValue { | ||
dawn(23000), | ||
day(1000), | ||
noon(6000), | ||
afternoon(9000), | ||
dusk(13000), | ||
night(14000), | ||
midnight(18000); | ||
import io.papermc.paper.command.brigadier.CommandSourceStack; | ||
import io.papermc.paper.command.brigadier.argument.ArgumentTypes; | ||
|
||
private int ticks; | ||
@Name("time") | ||
public class Time extends Command<Admin> { | ||
|
||
private TimeValue(int ticks) { | ||
this.ticks = ticks; | ||
} | ||
public Time(Context<Admin> context) { | ||
super(context); | ||
} | ||
|
||
public int ticks() { | ||
return ticks; | ||
} | ||
@Override | ||
public LiteralArgumentBuilder<CommandSourceStack> get_command_base() { | ||
return super.get_command_base() | ||
.then(help()) | ||
.then(argument("time", TimeValueArgumentType.timeValue()) | ||
.executes(ctx -> { set_time_current_world((Player) ctx.getSource().getSender(), time_value(ctx)); return SINGLE_SUCCESS;}) | ||
.then(argument("world", ArgumentTypes.world()) | ||
.executes(ctx -> { set_time(time_value(ctx), ctx.getArgument("world", World.class)); return SINGLE_SUCCESS;}) | ||
) | ||
) | ||
; | ||
} | ||
|
||
public Time(Context<Admin> context) { | ||
super(context); | ||
// Add help | ||
params().fixed("help").ignore_case().exec(this::print_help); | ||
// Command parameters | ||
var time = params().choice("time", List.of(TimeValue.values()), t -> t.name()).ignore_case(); | ||
time.exec_player(this::set_time_current_world); | ||
time.choose_world().exec(this::set_time); | ||
private TimeValue time_value(CommandContext<CommandSourceStack> ctx) { | ||
return ctx.getArgument("time", TimeValue.class); | ||
} | ||
|
||
private void set_time_current_world(Player player, TimeValue t) { | ||
change_time_smoothly(player.getWorld(), get_module(), t.ticks(), 100); | ||
} | ||
|
||
private void set_time(CommandSender sender, TimeValue t, World world) { | ||
private void set_time(TimeValue t, World world) { | ||
change_time_smoothly(world, get_module(), t.ticks(), 100); | ||
} | ||
} |
Oops, something went wrong.