bug fix and typo

This commit is contained in:
Vlammar 2020-11-07 01:04:24 +01:00
parent 1becb9faf4
commit c769f50835
6 changed files with 96 additions and 78 deletions

View File

@ -62,19 +62,19 @@ public class DeleteOtherCommand extends IoMCommand
@Override
protected void run() throws CommandException
{
if(args.length < 2) {
warning(I.t("Not enough parameters! Usage: /maptool deleteother <playername> <mapname>"));
return;
if(args.length < 2) {
warning(I.t("Not enough parameters! Usage: /maptool deleteother <playername> <mapname>"));
return;
}
Player player = null;
UUID uuid = null;
OfflinePlayer op = null;
Player player = null;
UUID uuid = null;
OfflinePlayer op = null;
player = Bukkit.getPlayer(args[0]);
if(player == null){
op = Bukkit.getOfflinePlayer(args[0]);
if(op.hasPlayedBefore()) uuid = op.getUniqueId();
else warning(I.t("We've never seen that player before!"));
op = Bukkit.getOfflinePlayer(args[0]);
if(op.hasPlayedBefore()) uuid = op.getUniqueId();
else warning(I.t("We've never seen that player before!"));
}
else uuid = player.getUniqueId();
if(player==null){
@ -82,25 +82,25 @@ public class DeleteOtherCommand extends IoMCommand
return;
}
ImageMap map = getMapFromArgs(player, 1, true);
if(player != null) MapManager.clear(player.getInventory(), map);
try
{
MapManager.deleteMap(map);
info(I.t("{gray}Map successfully deleted."));
}
catch (MapManagerException ex)
{
PluginLogger.warning(I.t("A non-existent map was requested to be deleted", ex));
warning(ChatColor.RED+(I.t("This map does not exist.")));
}
try
{
MapManager.deleteMap(map);
info(I.t("{gray}Map successfully deleted."));
}
catch (MapManagerException ex)
{
PluginLogger.warning(I.t("A non-existent map was requested to be deleted", ex));
warning(ChatColor.RED+(I.t("This map does not exist.")));
}
}
@Override
protected List<String> complete() throws CommandException
{
if(args.length == 1)
if(args.length == 1)
return getMatchingMapNames(playerSender(), args[0]);
return null;

View File

@ -43,10 +43,11 @@ import fr.zcraft.zlib.components.commands.CommandException;
import fr.zcraft.zlib.components.commands.CommandInfo;
import fr.zcraft.zlib.components.gui.Gui;
import fr.zcraft.zlib.components.i18n.I;
import fr.zcraft.zlib.tools.PluginLogger;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
import java.util.concurrent.ExecutionException;
import org.bukkit.entity.Player;
@CommandInfo (name = "exploreother")
@ -59,21 +60,31 @@ public class ExploreOtherCommand extends IoMCommand
warning(I.t("Not enough parameters! Usage: /maptool exploreother <playername>"));
return;
}
try{
OfflinePlayer player=getOfflinePlayerParameter(0);
String name=args[0];
if(player!=null)
Gui.open(playerSender(), new MapListGui(player,name));
}
catch (InterruptedException | ExecutionException e){
warning(I.t("Can't find player"));
return;
}
String name=args[0];
Player sender=playerSender();
offlinePlayerParameter(0, uuid -> {
if(uuid==null){
try {
throwInvalidArgument(I.t("Player not found."));
} catch (CommandException e) {
PluginLogger.error("CommandException "+e);
return;
}
}
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
if (offlinePlayer != null) {
Gui.open(sender, new MapListGui(offlinePlayer, name));
}
else{
PluginLogger.warning(I.t("Can't find player"));
return;
}
});
}
@Override
public boolean canExecute(CommandSender sender)
{
return Permissions.LISTOTHER.grantedTo(sender);
return Permissions.LISTOTHER.grantedTo(sender);
}
}

View File

@ -59,24 +59,24 @@ 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;
}
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]);
player = Bukkit.getPlayer(args[0]);
if(player == null){
OfflinePlayer op = Bukkit.getOfflinePlayer(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();
}
}
else {
uuid = player.getUniqueId();
}
ImageMap map = null;
String mapName = "";
mapName = args[1];
@ -93,9 +93,9 @@ public class GetOtherCommand extends IoMCommand
}
return;
}
@Override
public boolean canExecute(CommandSender sender)
{
return Permissions.GETOTHER.grantedTo(sender);
}
@Override
public boolean canExecute(CommandSender sender)
{
return Permissions.GETOTHER.grantedTo(sender);
}
}

View File

@ -61,37 +61,37 @@ import java.util.UUID;
@CommandInfo (name = "listother", usageParameters = "<PlayerName>")
public class ListOtherCommand extends IoMCommand
{
@Override
@Override
protected void run() throws CommandException
{
if(args.length < 1){
warning(I.t("Not enough parameters! Usage: /maptool listother <playername>"));
if(args.length < 1){
warning(I.t("Not enough parameters! Usage: /maptool listother <playername>"));
return;
}
}
Player player = null;
UUID uuid = null;
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!"));
}
OfflinePlayer op = Bukkit.getOfflinePlayer(args[0]);
if(op.hasPlayedBefore()) {
uuid = op.getUniqueId();
}
else {
warning(I.t("We've never seen that player before!"));
}
}
else{
uuid = player.getUniqueId();
uuid = player.getUniqueId();
}
List<ImageMap> mapList = null;
try{
mapList = MapManager.getMapList(uuid);
mapList = MapManager.getMapList(uuid);
}
catch(Exception e){
return;
return;
}
if(mapList.isEmpty())
@ -99,7 +99,7 @@ public class ListOtherCommand extends IoMCommand
info(I.t("No map found."));
return;
}
info(I.tn("{white}{bold}{0} map found.", "{white}{bold}{0} maps found.", mapList.size()));
RawTextPart rawText = new RawText("");
@ -122,7 +122,7 @@ public class ListOtherCommand extends IoMCommand
.then(map.getId())
.color(ChatColor.WHITE)
.command(GetCommand.class, map.getId())
.hover(new RawText()
.hover(new RawText()
.then(map.getName()).style(ChatColor.BOLD, ChatColor.GREEN).then("\n")
.then(map.getId() + ", " + size).color(ChatColor.GRAY).then("\n\n")
.then(I.t("{white}Click{gray} to get this map"))

View File

@ -18,10 +18,13 @@
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.zcraft.zlib.components.commands.CommandException;
import fr.zcraft.zlib.components.commands.CommandInfo;
import fr.zcraft.zlib.components.i18n.I;
import org.bukkit.command.CommandSender;
import java.util.List;
@ -30,13 +33,17 @@ public class RenameCommand extends IoMCommand {
@Override
protected void run() throws CommandException
{
if(args.length == 2)
{
ImageMap map = getMapFromArgs();
map.rename(args[1]);
} else {
info(I.t("Not enough or too many arguments"));
if(args.length != 4) {
warning(I.t("Not enough or too many arguments! Usage: /maptool rename <map name> <new map name>"));
return;
}
//if(args.length == 2)
//{
ImageMap map = getMapFromArgs();
map.rename(args[2]);
// } else {
// info(I.t("Not enough or too many arguments"));
// }
}
@Override
protected List<String> complete() throws CommandException

View File

@ -165,7 +165,7 @@ public class ImageRendererExecutor extends Worker
public ImageMap run() throws Throwable
{
final URLConnection connection = HTTPconnection(url);
final URLConnection connection = connecting(url);
final InputStream stream = connection.getInputStream();
final BufferedImage image = ImageIO.read(stream);