mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-09-29 06:57:29 +02:00
Merged get and getother
This commit is contained in:
parent
5c02a287dd
commit
50008de052
@ -42,7 +42,6 @@ import fr.moribus.imageonmap.commands.maptool.DeleteOtherCommand;
|
||||
import fr.moribus.imageonmap.commands.maptool.ExploreCommand;
|
||||
import fr.moribus.imageonmap.commands.maptool.ExploreOtherCommand;
|
||||
import fr.moribus.imageonmap.commands.maptool.GetCommand;
|
||||
import fr.moribus.imageonmap.commands.maptool.GetOtherCommand;
|
||||
import fr.moribus.imageonmap.commands.maptool.GetRemainingCommand;
|
||||
import fr.moribus.imageonmap.commands.maptool.GiveCommand;
|
||||
import fr.moribus.imageonmap.commands.maptool.ListCommand;
|
||||
@ -133,7 +132,6 @@ public final class ImageOnMap extends QuartzPlugin {
|
||||
NewCommand.class,
|
||||
ListCommand.class,
|
||||
GetCommand.class,
|
||||
GetOtherCommand.class,
|
||||
RenameCommand.class,
|
||||
DeleteCommand.class,
|
||||
DeleteOtherCommand.class,
|
||||
|
@ -36,11 +36,15 @@
|
||||
|
||||
package fr.moribus.imageonmap.commands.maptool;
|
||||
|
||||
import fr.moribus.imageonmap.ImageOnMap;
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.commands.IoMCommand;
|
||||
import fr.moribus.imageonmap.map.ImageMap;
|
||||
import fr.moribus.imageonmap.map.MapManager;
|
||||
import fr.zcraft.quartzlib.components.commands.CommandException;
|
||||
import fr.zcraft.quartzlib.components.commands.CommandInfo;
|
||||
import fr.zcraft.quartzlib.components.i18n.I;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -49,11 +53,46 @@ import org.bukkit.entity.Player;
|
||||
public class GetCommand extends IoMCommand {
|
||||
@Override
|
||||
protected void run() throws CommandException {
|
||||
Player player = playerSender();
|
||||
if (getMapFromArgs().give(player)) {
|
||||
info(I.t("The requested map was too big to fit in your inventory."));
|
||||
info(I.t("Use '/maptool getremaining' to get the remaining maps."));
|
||||
ArrayList<String> arguments = getArgs();
|
||||
if (arguments.size() > 2) {
|
||||
warning(I.t("Too many parameters! Usage: /maptool getother [playername] <mapname>"));
|
||||
return;
|
||||
}
|
||||
|
||||
final String playerName;
|
||||
final String mapName;
|
||||
final Player sender = playerSender();
|
||||
if (arguments.size() == 2) {
|
||||
if (!Permissions.GETOTHER.grantedTo(sender)) {
|
||||
info(sender, I.t("You can't use this command"));
|
||||
return;
|
||||
}
|
||||
|
||||
playerName = arguments.get(0);
|
||||
mapName = arguments.get(1);
|
||||
} else {
|
||||
playerName = sender.getName();
|
||||
mapName = arguments.get(0);
|
||||
}
|
||||
|
||||
//TODO passer en static
|
||||
ImageOnMap.getPlugin().getCommandWorker().OfflineNameFetch(playerName, uuid -> {
|
||||
if (uuid == null) {
|
||||
info(sender, I.t("The player {0} does not exist.", playerName));
|
||||
return;
|
||||
}
|
||||
ImageMap map = MapManager.getMap(uuid, mapName);
|
||||
|
||||
if (map == null) {
|
||||
info(sender, I.t("This map does not exist."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (map.give(sender)) {
|
||||
info(I.t("The requested map was too big to fit in your inventory."));
|
||||
info(I.t("Use '/maptool getremaining' to get the remaining maps."));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright or © or Copr. Moribus (2013)
|
||||
* Copyright or © or Copr. ProkopyL <prokopylmc@gmail.com> (2015)
|
||||
* Copyright or © or Copr. Amaury Carrade <amaury@carrade.eu> (2016 – 2020)
|
||||
* Copyright or © or Copr. Vlammar <valentin.jabre@gmail.com> (2019 – 2020)
|
||||
*
|
||||
* This software is a computer program whose purpose is to allow insertion of
|
||||
* custom images in a Minecraft world.
|
||||
*
|
||||
* This software is governed by the CeCILL-B license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL-B
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited
|
||||
* liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
*
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL-B license and that you accept its terms.
|
||||
*/
|
||||
|
||||
package fr.moribus.imageonmap.commands.maptool;
|
||||
|
||||
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.commands.IoMCommand;
|
||||
import fr.moribus.imageonmap.map.ImageMap;
|
||||
import fr.moribus.imageonmap.map.MapManager;
|
||||
import fr.zcraft.quartzlib.components.commands.CommandException;
|
||||
import fr.zcraft.quartzlib.components.commands.CommandInfo;
|
||||
import fr.zcraft.quartzlib.components.i18n.I;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@CommandInfo(name = "getother", usageParameters = "<PlayerName> <MapName>")
|
||||
public class GetOtherCommand extends IoMCommand {
|
||||
|
||||
@Override
|
||||
protected void run() throws CommandException {
|
||||
if (args.length < 2) {
|
||||
warning(I.t("Not enough parameters! Usage: /maptool getother <playername> <mapname>"));
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = null;
|
||||
UUID uuid = null;
|
||||
player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]);
|
||||
if (op.hasPlayedBefore()) {
|
||||
uuid = op.getUniqueId();
|
||||
} else {
|
||||
warning(I.t("We've never seen that player before!"));
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
uuid = player.getUniqueId();
|
||||
}
|
||||
ImageMap map = null;
|
||||
String mapName = "";
|
||||
mapName = args[1];
|
||||
if (args.length > 2) {
|
||||
for (int i = 2; i < args.length; i++) {
|
||||
mapName += (" " + args[i - 1]);
|
||||
}
|
||||
}
|
||||
map = MapManager.getMap(uuid, mapName);
|
||||
if (map != null) {
|
||||
map.give(playerSender());
|
||||
} else {
|
||||
warning(I.t("Unknown map {0}", mapName));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecute(CommandSender sender) {
|
||||
return Permissions.GETOTHER.grantedTo(sender);
|
||||
}
|
||||
}
|
@ -77,11 +77,15 @@ public class ListCommand extends IoMCommand {
|
||||
}
|
||||
|
||||
final Player sender = playerSender();
|
||||
|
||||
//TODO passer en static
|
||||
ImageOnMap.getPlugin().getCommandWorker().OfflineNameFetch(playerName, uuid -> {
|
||||
List<ImageMap> mapList = MapManager.getMapList(uuid);
|
||||
|
||||
if (uuid == null || mapList.isEmpty()) {
|
||||
if (uuid == null) {
|
||||
info(sender, I.t("Player {} not found.", playerName));
|
||||
return;
|
||||
}
|
||||
if (mapList.isEmpty()) {
|
||||
info(sender, I.t("No map found."));
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user