Close #115, Add option to disable /back in config

This commit is contained in:
William committed 2022-01-01 16:17:07 +00:00
1 parent 207ab33c66
commit 82878092e3
3 files changed
+13

No files matched your search

@@ -1,6 +1,7 @@
package me.william278.huskhomes2.commands; package me.william278.huskhomes2.commands;
import me.william278.huskhomes2.HuskHomes; import me.william278.huskhomes2.HuskHomes;
import me.william278.huskhomes2.MessageManager;
import me.william278.huskhomes2.teleport.TeleportManager; import me.william278.huskhomes2.teleport.TeleportManager;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@@ -16,6 +17,7 @@ public class BackCommand extends CommandBase {
@Override @Override
protected void onCommand(Player p, Command command, String label, String[] args) { protected void onCommand(Player p, Command command, String label, String[] args) {
if (HuskHomes.getSettings().getDoBackCommand()) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try (Connection connection = HuskHomes.getConnection()) { try (Connection connection = HuskHomes.getConnection()) {
TeleportManager.queueBackTeleport(p, connection); TeleportManager.queueBackTeleport(p, connection);
@@ -23,5 +25,8 @@ public class BackCommand extends CommandBase {
plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred teleporting you back"); plugin.getLogger().log(Level.SEVERE, "An SQL exception occurred teleporting you back");
} }
}); });
} else {
MessageManager.sendMessage(p, "error_command_disabled");
}
} }
} }
@@ -80,6 +80,9 @@ public class Settings {
private int teleportWarmupTime; private int teleportWarmupTime;
private DisplayStyle teleportWarmupDisplayStyle; private DisplayStyle teleportWarmupDisplayStyle;
// Back command
private boolean doBackCommand;
// Sounds // Sounds
private Sound teleportationCompleteSound; private Sound teleportationCompleteSound;
private Sound teleportWarmupSound; private Sound teleportWarmupSound;
@@ -254,6 +257,8 @@ public class Settings {
this.rtpRange = config.getInt("random_teleport_command.range", 5000); this.rtpRange = config.getInt("random_teleport_command.range", 5000);
this.rtpCoolDown = config.getInt("random_teleport_command.cooldown", 30); this.rtpCoolDown = config.getInt("random_teleport_command.cooldown", 30);
this.doBackCommand = config.getBoolean("general.enable_back_command", true);
this.privateHomesPerPage = config.getInt("general.lists.private_homes_per_page", 10); this.privateHomesPerPage = config.getInt("general.lists.private_homes_per_page", 10);
this.publicHomesPerPage = config.getInt("general.lists.public_homes_per_page", 10); this.publicHomesPerPage = config.getInt("general.lists.public_homes_per_page", 10);
this.warpsPerPage = config.getInt("general.lists.warps_per_page", 10); this.warpsPerPage = config.getInt("general.lists.warps_per_page", 10);
@@ -504,6 +509,8 @@ public class Settings {
return redisPassword; return redisPassword;
} }
public boolean getDoBackCommand() { return doBackCommand; }
public int getHikariMaximumPoolSize() { public int getHikariMaximumPoolSize() {
return hikariMaximumPoolSize; return hikariMaximumPoolSize;
} }
+1
View File
@@ -34,6 +34,7 @@ general:
teleport_warmup_display: ACTION_BAR teleport_warmup_display: ACTION_BAR
teleport_request_expiry_time: 60 teleport_request_expiry_time: 60
allow_unicode_descriptions: true allow_unicode_descriptions: true
enable_back_command: true
sounds: sounds:
teleportation_complete: 'ENTITY_ENDERMAN_TELEPORT' teleportation_complete: 'ENTITY_ENDERMAN_TELEPORT'
teleportation_warmup: 'BLOCK_NOTE_BLOCK_BANJO' teleportation_warmup: 'BLOCK_NOTE_BLOCK_BANJO'