mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-09-30 07:27:49 +02:00
Can now be used by console and removed bugs
This commit is contained in:
parent
867243979a
commit
e911686af4
@ -46,9 +46,12 @@ import fr.zcraft.quartzlib.components.commands.CommandInfo;
|
|||||||
import fr.zcraft.quartzlib.components.i18n.I;
|
import fr.zcraft.quartzlib.components.i18n.I;
|
||||||
import fr.zcraft.quartzlib.components.rawtext.RawText;
|
import fr.zcraft.quartzlib.components.rawtext.RawText;
|
||||||
import fr.zcraft.quartzlib.components.rawtext.RawTextPart;
|
import fr.zcraft.quartzlib.components.rawtext.RawTextPart;
|
||||||
|
import fr.zcraft.quartzlib.tools.PluginLogger;
|
||||||
import fr.zcraft.quartzlib.tools.text.RawMessage;
|
import fr.zcraft.quartzlib.tools.text.RawMessage;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -64,43 +67,64 @@ public class ListCommand extends IoMCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String playerName;
|
String playerName;
|
||||||
|
final boolean isHuman = (sender instanceof Player);
|
||||||
if (arguments.size() == 1) {
|
if (arguments.size() == 1) {
|
||||||
if (!Permissions.LISTOTHER.grantedTo(sender)) {
|
if (!Permissions.LISTOTHER.grantedTo(sender) && isHuman) {
|
||||||
throwNotAuthorized();
|
throwNotAuthorized();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
playerName = arguments.get(0);
|
playerName = arguments.get(0);
|
||||||
} else {
|
} else {
|
||||||
playerName = playerSender().getName();
|
if (isHuman) {
|
||||||
}
|
playerName = playerSender().getName();
|
||||||
|
} else {
|
||||||
final Player sender = playerSender();
|
PluginLogger.warning(I.t("You must give a player name"));
|
||||||
|
|
||||||
|
|
||||||
retrieveUUID(playerName, uuid -> {
|
|
||||||
List<ImageMap> mapList = MapManager.getMapList(uuid);
|
|
||||||
if (mapList.isEmpty()) {
|
|
||||||
info(sender, I.t("No map found."));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String message = I.tn("{white}{bold}{0} map found.",
|
}
|
||||||
"{white}{bold}{0} maps found.",
|
final Player playerSender;
|
||||||
mapList.size());
|
if (isHuman) {
|
||||||
|
playerSender = playerSender();
|
||||||
info(sender, I.tn("{white}{bold}{0} map found.", "{white}{bold}{0} maps found.", mapList.size()));
|
} else {
|
||||||
|
playerSender = null;
|
||||||
RawTextPart rawText = new RawText("");
|
}
|
||||||
rawText = addMap(rawText, mapList.get(0));
|
UUID uuid = Bukkit.getOfflinePlayer(playerName).getUniqueId();
|
||||||
|
List<ImageMap> mapList = MapManager.getMapList(uuid);
|
||||||
//TODO pagination chat
|
if (mapList.isEmpty()) {
|
||||||
for (int i = 1, c = mapList.size(); i < c; i++) {
|
String msg = I.t("No map found.");
|
||||||
rawText = rawText.then(", ").color(ChatColor.GRAY);
|
if (isHuman) {
|
||||||
rawText = addMap(rawText, mapList.get(i));
|
info(playerSender, msg);
|
||||||
|
} else {
|
||||||
|
PluginLogger.info(msg);
|
||||||
}
|
}
|
||||||
RawMessage.send(sender, rawText.build());
|
return;
|
||||||
|
}
|
||||||
|
String msg = I.tn("{white}{bold}{0} map found.",
|
||||||
|
"{white}{bold}{0} maps found.",
|
||||||
|
mapList.size());
|
||||||
|
if (isHuman) {
|
||||||
|
info(playerSender,
|
||||||
|
msg); //TODO merge those into a common info(isHuman,msg) that print to a sender or the console
|
||||||
|
} else {
|
||||||
|
PluginLogger.info(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
RawTextPart rawText = new RawText("");
|
||||||
|
rawText = addMap(rawText, mapList.get(0));
|
||||||
|
|
||||||
|
//TODO pagination chat
|
||||||
|
for (int i = 1, c = mapList.size(); i < c; i++) {
|
||||||
|
rawText = rawText.then(", ").color(ChatColor.GRAY);
|
||||||
|
rawText = addMap(rawText, mapList.get(i));
|
||||||
|
}
|
||||||
|
if (isHuman) {
|
||||||
|
RawMessage.send(playerSender, rawText.build());
|
||||||
|
} else {
|
||||||
|
PluginLogger.info(rawText.build().toPlainText());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private RawTextPart<?> addMap(RawTextPart<?> rawText, ImageMap map) {
|
private RawTextPart<?> addMap(RawTextPart<?> rawText, ImageMap map) {
|
||||||
|
Loading…
Reference in New Issue
Block a user