mirror of
https://github.com/rockyhawk64/CommandPanels.git
synced 2025-11-18 07:14:17 +01:00
Compare commits
2 Commits
4aa87cc88a
...
d75d69ebcc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d75d69ebcc | ||
|
|
b6941a137a |
@ -30,7 +30,7 @@ items:
|
||||
- French
|
||||
- German
|
||||
- Japanese
|
||||
default: English
|
||||
default: 3
|
||||
actions:
|
||||
commands:
|
||||
- '[msg] &aLanguage set to: %commandpanels_session_dropdown_language%'
|
||||
|
||||
@ -84,7 +84,8 @@ public class CustomForm {
|
||||
}
|
||||
form.dropdown(
|
||||
parseText(dropdown.getName()),
|
||||
parsedOptions
|
||||
parsedOptions,
|
||||
parseInt(dropdown.getDefault())
|
||||
);
|
||||
inputOrder.add(dropdown);
|
||||
}
|
||||
|
||||
@ -37,12 +37,43 @@ public class CommandRunner {
|
||||
|
||||
}
|
||||
|
||||
public void runCommands(Panel panel, Player player, List<String> commands){
|
||||
for(String command : commands){
|
||||
runCommand(panel, player, command);
|
||||
}
|
||||
public void runCommands(Panel panel, Player player, List<String> commands) {
|
||||
runCommands(panel, player, commands, 0);
|
||||
}
|
||||
|
||||
private void runCommands(Panel panel, Player player, List<String> commands, int index) {
|
||||
if (index >= commands.size()) return;
|
||||
|
||||
String command = commands.get(index).trim();
|
||||
|
||||
// Handle the delay tag at flow level
|
||||
if (command.startsWith("[delay]")) {
|
||||
String delayStr = ctx.text.applyPlaceholders(
|
||||
player,
|
||||
command.replace("[delay]", "").trim());
|
||||
|
||||
int ticks;
|
||||
try {
|
||||
ticks = Integer.parseInt(delayStr);
|
||||
} catch (NumberFormatException e) {
|
||||
ticks = 0;
|
||||
}
|
||||
|
||||
int nextIndex = index + 1;
|
||||
ctx.plugin.getServer().getScheduler().runTaskLater(ctx.plugin,
|
||||
() -> runCommands(panel, player, commands, nextIndex),
|
||||
ticks);
|
||||
return;
|
||||
}
|
||||
|
||||
// Run the command
|
||||
runCommand(panel, player, command);
|
||||
|
||||
// Move to the next command
|
||||
runCommands(panel, player, commands, index + 1);
|
||||
}
|
||||
|
||||
|
||||
public void runCommand(Panel panel, Player player, String command) {
|
||||
for (CommandTagResolver resolver : resolvers) {
|
||||
if (command.isEmpty()) return;
|
||||
|
||||
@ -4,7 +4,6 @@ import me.rockyhawk.commandpanels.Context;
|
||||
import me.rockyhawk.commandpanels.interaction.commands.CommandTagResolver;
|
||||
import me.rockyhawk.commandpanels.session.Panel;
|
||||
import me.rockyhawk.commandpanels.session.SessionManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class RefreshPanelTag implements CommandTagResolver {
|
||||
@ -16,20 +15,6 @@ public class RefreshPanelTag implements CommandTagResolver {
|
||||
|
||||
@Override
|
||||
public void handle(Context ctx, Panel panel, Player player, String raw, String command) {
|
||||
int delayTicks = 0; // Default to 0 (immediate)
|
||||
|
||||
if (!command.isEmpty()) {
|
||||
try {
|
||||
delayTicks = Integer.parseInt(command);
|
||||
if (delayTicks < 0) delayTicks = 0; // Clamp negative to 0
|
||||
if (delayTicks > 5) delayTicks = 5; // Maximum delay 0.25 seconds or 5 ticks
|
||||
} catch (NumberFormatException ignore) {
|
||||
// leave delayTicks at 0
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(ctx.plugin, () -> {
|
||||
panel.open(ctx, player, SessionManager.PanelOpenType.REFRESH);
|
||||
}, delayTicks);
|
||||
panel.open(ctx, player, SessionManager.PanelOpenType.REFRESH);
|
||||
}
|
||||
}
|
||||
@ -8,13 +8,19 @@ import java.util.List;
|
||||
public class FloodgateDropdown extends FloodgateComponent {
|
||||
|
||||
private final List<String> options;
|
||||
private final String defaultValue;
|
||||
|
||||
public FloodgateDropdown(String id, ConfigurationSection section) {
|
||||
super(id, section);
|
||||
this.options = section.getStringList("options");
|
||||
this.defaultValue = section.getString("default", "0");
|
||||
}
|
||||
|
||||
public List<String> getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public String getDefault() {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user