-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
81db250
commit 9bfd2d8
Showing
3 changed files
with
51 additions
and
1 deletion.
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
47 changes: 47 additions & 0 deletions
47
src/main/java/me/lorenzo0111/multilang/commands/subcommands/admin/DetectCommand.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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package me.lorenzo0111.multilang.commands.subcommands.admin; | ||
|
||
import me.lorenzo0111.multilang.MultiLangPlugin; | ||
import me.lorenzo0111.multilang.api.objects.LocalizedPlayer; | ||
import me.lorenzo0111.multilang.commands.SubCommand; | ||
import me.lorenzo0111.multilang.commands.subcommands.EditCommand; | ||
import me.lorenzo0111.multilang.utils.Reflection; | ||
import me.lorenzo0111.pluginslib.command.ICommand; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
public class DetectCommand extends SubCommand { | ||
|
||
public DetectCommand(ICommand<MultiLangPlugin> command) { | ||
super(command); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "detect"; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Force language auto-detection for a user"; | ||
} | ||
|
||
@Override | ||
public void handleSubcommand(CommandSender sender, String[] args) { | ||
if (args.length != 2) { | ||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', getPlugin().getConfig("prefix") + "&cTry using /alang detect (Player)")); | ||
return; | ||
} | ||
|
||
Player target = Bukkit.getPlayer(args[1]); | ||
if (target == null || !target.isOnline()) { | ||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', getPlugin().getConfig("prefix") + "&cThis user is not online")); | ||
return; | ||
} | ||
|
||
LocalizedPlayer player = LocalizedPlayer.from(target); | ||
EditCommand.setLang(player, Reflection.getLocale(target), this); | ||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', getPlugin().getConfig("prefix") + "&7Locale autodetected to &9" + player.getLocale().getName())); | ||
} | ||
} |