mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-12-01 14:33:27 +01:00
fixed various issues with the admin command, refactored some of the code and added an exploredother command
This commit is contained in:
parent
9b2a48aea3
commit
fcc48cb402
@ -118,13 +118,14 @@ public final class ImageOnMap extends ZPlugin
|
||||
"maptool",
|
||||
NewCommand.class,
|
||||
ListCommand.class,
|
||||
ListOtherCommand.class,
|
||||
GetCommand.class,
|
||||
GetOtherCommand.class,
|
||||
ListOtherCommand.class,
|
||||
DeleteOtherCommand.class,
|
||||
DeleteCommand.class,
|
||||
DeleteOtherCommand.class,
|
||||
GetRemainingCommand.class,
|
||||
ExploreCommand.class,
|
||||
ExploreOtherCommand.class,
|
||||
MigrateCommand.class
|
||||
);
|
||||
|
||||
|
@ -57,14 +57,9 @@ import java.util.List;
|
||||
@WithFlags ({"confirm"})
|
||||
public class DeleteCommand extends IoMCommand
|
||||
{
|
||||
@Override
|
||||
protected void run() throws CommandException
|
||||
{
|
||||
ImageMap map = getMapFromArgs();
|
||||
|
||||
if (!hasFlag("confirm"))
|
||||
{
|
||||
RawText msg = new RawText(I.t("You are going to delete") + " ")
|
||||
private static RawText deleteMsg(Class klass,ImageMap map){
|
||||
return new RawText(I.t("You are going to delete") + " ")
|
||||
.then(map.getId())
|
||||
.color(ChatColor.GOLD)
|
||||
.then(". " + I.t("Are you sure ? "))
|
||||
@ -72,9 +67,18 @@ public class DeleteCommand extends IoMCommand
|
||||
.then(I.t("[Confirm]"))
|
||||
.color(ChatColor.GREEN)
|
||||
.hover(new RawText(I.t("{red}This map will be deleted {bold}forever{red}!")))
|
||||
.command(getClass(), map.getId(), "--confirm")
|
||||
.command(klass, map.getId(), "--confirm")
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run() throws CommandException
|
||||
{
|
||||
ImageMap map = getMapFromArgs();
|
||||
|
||||
if (!hasFlag("confirm"))
|
||||
{
|
||||
RawText msg = deleteMsg(getClass(),map);
|
||||
send(msg);
|
||||
}
|
||||
else
|
||||
@ -89,7 +93,7 @@ public class DeleteCommand extends IoMCommand
|
||||
}
|
||||
catch (MapManagerException ex)
|
||||
{
|
||||
PluginLogger.warning("A non-existent map was requested to be deleted", ex);
|
||||
PluginLogger.warning(I.t("A non-existent map was requested to be deleted", ex));
|
||||
warning(I.t("This map does not exist."));
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Moribus
|
||||
* Copyright (C) 2015 ProkopyL <prokopylmc@gmail.com>
|
||||
* 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 program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This software is a computer program whose purpose is to allow insertion of
|
||||
* custom images in a Minecraft world.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* 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".
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* 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;
|
||||
@ -28,8 +46,8 @@ import fr.zcraft.zlib.components.commands.CommandInfo;
|
||||
import fr.zcraft.zlib.components.commands.WithFlags;
|
||||
import fr.zcraft.zlib.components.i18n.I;
|
||||
import fr.zcraft.zlib.tools.PluginLogger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -44,11 +62,15 @@ public class DeleteOtherCommand extends IoMCommand
|
||||
@Override
|
||||
protected void run() throws CommandException
|
||||
{
|
||||
if(!playerSender().hasPermission("imageonmap.delete.other")) {
|
||||
/*if(!playerSender().hasPermission("imageonmap.delete.other")) {
|
||||
warning(I.t("You do not have permission for this command. (imageonmap.delete.other)"));
|
||||
return;
|
||||
}*/
|
||||
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>"));
|
||||
|
||||
|
||||
Player player = null;
|
||||
UUID uuid = null;
|
||||
@ -60,23 +82,24 @@ public class DeleteOtherCommand extends IoMCommand
|
||||
else warning(I.t("We've never seen that player before!"));
|
||||
}
|
||||
else uuid = player.getUniqueId();
|
||||
String mapName = "";
|
||||
mapName = args[1];
|
||||
if(args.length > 2) for(int i = 2; i < args.length; i++) mapName += (" " + args[i - 1]);
|
||||
|
||||
ImageMap map = MapManager.getMap(uuid, mapName);
|
||||
if(player==null){
|
||||
warning(I.t("Player not found"));
|
||||
return;
|
||||
}
|
||||
ImageMap map = getMapFromArgs(player, 1, true);
|
||||
//ImageMap map = MapManager.getMap(uuid, mapName);
|
||||
|
||||
if(player != null) MapManager.clear(player.getInventory(), map);
|
||||
|
||||
try
|
||||
{
|
||||
MapManager.deleteMap(map);
|
||||
getPlayer().sendMessage(I.t("{gray}Map successfully deleted."));
|
||||
info(I.t("{gray}Map successfully deleted."));
|
||||
}
|
||||
catch (MapManagerException ex)
|
||||
{
|
||||
PluginLogger.warning(I.t("A non-existent map was requested to be deleted", ex));
|
||||
getPlayer().sendMessage(ChatColor.RED+(I.t("This map does not exist.")));
|
||||
warning(ChatColor.RED+(I.t("This map does not exist.")));
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,6 +112,7 @@ public class DeleteOtherCommand extends IoMCommand
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecute(CommandSender sender)
|
||||
{
|
||||
|
@ -52,7 +52,7 @@ public class ExploreCommand extends IoMCommand
|
||||
@Override
|
||||
protected void run() throws CommandException
|
||||
{
|
||||
Gui.open(playerSender(), new MapListGui());
|
||||
Gui.open(playerSender(), new MapListGui(playerSender()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* 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.gui.MapListGui;
|
||||
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 org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
@CommandInfo (name = "exploreother")
|
||||
public class ExploreOtherCommand extends IoMCommand
|
||||
{
|
||||
@Override
|
||||
protected void run() throws CommandException
|
||||
{
|
||||
if(args.length < 1) {
|
||||
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 | IOException e){
|
||||
warning(I.t("Can't find player"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecute(CommandSender sender)
|
||||
{
|
||||
return Permissions.LISTOTHER.grantedTo(sender);
|
||||
}
|
||||
}
|
@ -1,31 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Moribus
|
||||
* Copyright (C) 2015 ProkopyL <prokopylmc@gmail.com>
|
||||
* 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 program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This software is a computer program whose purpose is to allow insertion of
|
||||
* custom images in a Minecraft world.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* 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".
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* 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 java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.commands.IoMCommand;
|
||||
import fr.moribus.imageonmap.map.ImageMap;
|
||||
@ -33,29 +44,36 @@ import fr.moribus.imageonmap.map.MapManager;
|
||||
import fr.zcraft.zlib.components.commands.CommandException;
|
||||
import fr.zcraft.zlib.components.commands.CommandInfo;
|
||||
import fr.zcraft.zlib.components.i18n.I;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@CommandInfo (name = "getother", usageParameters = "<PlayerName> <MapName>")
|
||||
public class GetOtherCommand extends IoMCommand
|
||||
{
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
@Override
|
||||
protected void run() throws CommandException
|
||||
{
|
||||
if(args.length < 2) warning(I.t("Not enough parameters! Usage: /maptool getother <playername> <mapname>"));
|
||||
//Deny those who do not have permission.
|
||||
if(!playerSender().hasPermission("imageonmap.get.other")) {
|
||||
warning(I.t("You do not have permission for this command. (imageonmap.get.other)"));
|
||||
|
||||
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();
|
||||
@ -69,7 +87,11 @@ public class GetOtherCommand extends IoMCommand
|
||||
}
|
||||
}
|
||||
map = MapManager.getMap(uuid, mapName);
|
||||
if(map!=null)
|
||||
map.give(playerSender());
|
||||
else{
|
||||
warning(I.t("Unknown map {0}",mapName));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@Override
|
||||
|
@ -1,34 +1,42 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Moribus
|
||||
* Copyright (C) 2015 ProkopyL <prokopylmc@gmail.com>
|
||||
* 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 program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* This software is a computer program whose purpose is to allow insertion of
|
||||
* custom images in a Minecraft world.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* 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".
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* 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 java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.commands.IoMCommand;
|
||||
import fr.moribus.imageonmap.map.ImageMap;
|
||||
@ -39,8 +47,15 @@ import fr.zcraft.zlib.components.commands.CommandInfo;
|
||||
import fr.zcraft.zlib.components.i18n.I;
|
||||
import fr.zcraft.zlib.components.rawtext.RawText;
|
||||
import fr.zcraft.zlib.components.rawtext.RawTextPart;
|
||||
import fr.zcraft.zlib.tools.items.ItemStackBuilder;
|
||||
import fr.zcraft.zlib.tools.text.RawMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@CommandInfo (name = "listother", usageParameters = "<PlayerName>")
|
||||
@ -49,12 +64,13 @@ public class ListOtherCommand extends IoMCommand
|
||||
@Override
|
||||
protected void run() throws CommandException
|
||||
{
|
||||
if(args.length < 1) warning(I.t("Not enough parameters! Usage: /maptool listother <playername>"));
|
||||
if(!playerSender().hasPermission("imageonmap.list.other")) {
|
||||
warning(I.t("You do not have permission for this command. (imageonmap.list.other)"));
|
||||
|
||||
if(args.length < 1){
|
||||
warning(I.t("Not enough parameters! Usage: /maptool listother <playername>"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Player player = null;
|
||||
UUID uuid = null;
|
||||
player = Bukkit.getPlayer(args[0]);
|
||||
@ -65,7 +81,6 @@ public class ListOtherCommand extends IoMCommand
|
||||
}
|
||||
else {
|
||||
warning(I.t("We've never seen that player before!"));
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
@ -77,8 +92,9 @@ public class ListOtherCommand extends IoMCommand
|
||||
mapList = MapManager.getMapList(uuid);
|
||||
}
|
||||
catch(Exception e){
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(mapList.isEmpty())
|
||||
{
|
||||
info(I.t("No map found."));
|
||||
|
@ -174,6 +174,7 @@ public class ConfirmDeleteMapGui extends ActionGui
|
||||
@GuiAction ("delete")
|
||||
protected void delete()
|
||||
{
|
||||
|
||||
// Does the player still have the permission to delete a map?
|
||||
if (!Permissions.DELETE.grantedTo(getPlayer()))
|
||||
{
|
||||
|
@ -47,21 +47,25 @@ import fr.zcraft.zlib.components.gui.GuiAction;
|
||||
import fr.zcraft.zlib.components.gui.PromptGui;
|
||||
import fr.zcraft.zlib.components.i18n.I;
|
||||
import fr.zcraft.zlib.tools.Callback;
|
||||
import fr.zcraft.zlib.tools.PluginLogger;
|
||||
import fr.zcraft.zlib.tools.items.ItemStackBuilder;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class MapDetailGui extends ExplorerGui<Integer>
|
||||
{
|
||||
private final ImageMap map;
|
||||
private OfflinePlayer p;
|
||||
private String name;
|
||||
|
||||
public MapDetailGui(ImageMap map)
|
||||
{
|
||||
public MapDetailGui(ImageMap map, OfflinePlayer p, String name){
|
||||
this.map=map;
|
||||
this.p=p;
|
||||
this.name=name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getViewItem(int x, int y)
|
||||
{
|
||||
@ -136,7 +140,12 @@ public class MapDetailGui extends ExplorerGui<Integer>
|
||||
protected void onUpdate()
|
||||
{
|
||||
/// Title of the map details GUI
|
||||
if(p.getUniqueId().equals(getPlayer().getUniqueId())) {
|
||||
setTitle(I.t(getPlayerLocale(), "Your maps » {black}{0}", map.getName()));
|
||||
}
|
||||
else{
|
||||
setTitle(I.t(getPlayerLocale(), "{1}'s maps » {black}{0}", map.getName(),name));
|
||||
}
|
||||
setKeepHorizontalScrollingSpace(true);
|
||||
|
||||
if (map instanceof PosterMap)
|
||||
@ -236,13 +245,13 @@ public class MapDetailGui extends ExplorerGui<Integer>
|
||||
@GuiAction ("delete")
|
||||
public void delete()
|
||||
{
|
||||
PluginLogger.info("delete");
|
||||
if (!Permissions.DELETE.grantedTo(getPlayer()))
|
||||
{
|
||||
I.sendT(getPlayer(), "{ce}You are no longer allowed to do that.");
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
Gui.open(getPlayer(), new ConfirmDeleteMapGui(map), this);
|
||||
}
|
||||
|
||||
|
@ -49,12 +49,25 @@ import fr.zcraft.zlib.components.i18n.I;
|
||||
import fr.zcraft.zlib.tools.items.ItemStackBuilder;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.MapMeta;
|
||||
|
||||
|
||||
public class MapListGui extends ExplorerGui<ImageMap>
|
||||
{
|
||||
private OfflinePlayer p;
|
||||
private String name;
|
||||
public MapListGui(Player sender){
|
||||
this.p=sender;
|
||||
this.name=sender.getName();
|
||||
}
|
||||
public MapListGui( OfflinePlayer p,String name){
|
||||
this.p=p;
|
||||
this.name=name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getViewItem(ImageMap map)
|
||||
{
|
||||
@ -106,23 +119,29 @@ public class MapListGui extends ExplorerGui<ImageMap>
|
||||
@Override
|
||||
protected ItemStack getEmptyViewItem()
|
||||
{
|
||||
ItemStackBuilder builder = new ItemStackBuilder(Material.BARRIER)
|
||||
.title(I.tl(getPlayerLocale(), "{red}You don't have any map."));
|
||||
ItemStackBuilder builder = new ItemStackBuilder(Material.BARRIER);
|
||||
if(p.getUniqueId().equals(getPlayer().getUniqueId())) {
|
||||
|
||||
builder.title(I.tl(getPlayerLocale(), "{red}You don't have any map."));
|
||||
|
||||
if (Permissions.NEW.grantedTo(getPlayer()))
|
||||
builder.longLore(I.tl(getPlayerLocale(), "{gray}Get started by creating a new one using {white}/tomap <URL> [resize]{gray}!"));
|
||||
else
|
||||
builder.longLore(I.tl(getPlayerLocale(), "{gray}Unfortunately, you are not allowed to create one."));
|
||||
|
||||
}
|
||||
else{
|
||||
builder.title(I.tl(getPlayerLocale(), "{red}{0} doesn't have any map.",name));
|
||||
}
|
||||
return builder.item();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRightClick(ImageMap data)
|
||||
{
|
||||
Gui.open(getPlayer(), new MapDetailGui(data), this);
|
||||
Gui.open(getPlayer(), new MapDetailGui(data,getPlayer(),name), this);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected ItemStack getPickedUpItem(ImageMap map)
|
||||
{
|
||||
@ -151,19 +170,22 @@ public class MapListGui extends ExplorerGui<ImageMap>
|
||||
@Override
|
||||
protected void onUpdate()
|
||||
{
|
||||
ImageMap[] maps = MapManager.getMaps(getPlayer().getUniqueId());
|
||||
ImageMap[] maps = MapManager.getMaps(p.getUniqueId());
|
||||
setData(maps);
|
||||
|
||||
/// The maps list GUI title
|
||||
//Equal if the person who send the command is the owner of the mapList
|
||||
if(p.getUniqueId().equals(getPlayer().getUniqueId()))
|
||||
setTitle(I.tl(getPlayerLocale(), "{black}Your maps {reset}({0})", maps.length));
|
||||
else
|
||||
setTitle(I.tl(getPlayerLocale(), "{black}{1}'s maps {reset}({0})", maps.length, name ));
|
||||
|
||||
setKeepHorizontalScrollingSpace(true);
|
||||
|
||||
|
||||
/* ** Statistics ** */
|
||||
|
||||
int imagesCount = MapManager.getMapList(getPlayer().getUniqueId()).size();
|
||||
int mapPartCount = MapManager.getMapPartCount(getPlayer().getUniqueId());
|
||||
int imagesCount = MapManager.getMapList(p.getUniqueId()).size();
|
||||
int mapPartCount = MapManager.getMapPartCount(p.getUniqueId());
|
||||
|
||||
int mapGlobalLimit = PluginConfiguration.MAP_GLOBAL_LIMIT.get();
|
||||
int mapPersonalLimit = PluginConfiguration.MAP_PLAYER_LIMIT.get();
|
||||
|
@ -9,5 +9,6 @@ getremaining: Gives you the remaining maps that could not fit in your inventory
|
||||
list: Lists all the map you currently have.
|
||||
listother: list all the map of another player.
|
||||
explore: Opens a GUI to see and manage your maps.
|
||||
exploreother: Opens a GUI to see and manage another player maps.
|
||||
migrate: Lauches the migration process from V2.7 to V3.x.
|
||||
help : Use help for more information about a command.
|
||||
|
@ -20,11 +20,15 @@ permissions:
|
||||
imageonmap.userender: true
|
||||
imageonmap.new: true
|
||||
imageonmap.list: true
|
||||
imageonmap.listother: true
|
||||
imageonmap.get: true
|
||||
imageonmap.getother: true
|
||||
imageonmap.explore: true
|
||||
imageonmap.exploreother: true
|
||||
imageonmap.rename: true
|
||||
imageonmap.removesplattermap: true
|
||||
imageonmap.delete: true
|
||||
imageonmap.deleteother: false
|
||||
imageonmap.bypasssize: false
|
||||
|
||||
imageonmap.userender:
|
||||
@ -39,14 +43,26 @@ permissions:
|
||||
description: "Allows you to list the images you rendered."
|
||||
default: true
|
||||
|
||||
imageonmap.listother:
|
||||
description: "Allows you to list the images a player have rendered."
|
||||
default: false
|
||||
|
||||
imageonmap.get:
|
||||
description: "Allows you to get a new map among the ones you already rendered, and related commands (/maptool getremaining)."
|
||||
default: true
|
||||
|
||||
imageonmap.getother:
|
||||
description: "Allows you to get a new map among the ones a player have already rendered."
|
||||
default: false
|
||||
|
||||
imageonmap.explore:
|
||||
description: "Allows you to open a GUI with all your maps."
|
||||
default: true
|
||||
|
||||
imageonmap.exploreother:
|
||||
description: "Allows you to open a GUI with all of the player maps."
|
||||
default: false
|
||||
|
||||
imageonmap.rename:
|
||||
description: "Allows you to rename a map you rendered in the past."
|
||||
default: true
|
||||
@ -55,6 +71,10 @@ permissions:
|
||||
description: "Allows you to delete a map you rendered in the past."
|
||||
default: true
|
||||
|
||||
imageonmap.deleteother:
|
||||
description: "Allows you to delete a map a player rendered in the past."
|
||||
default: false
|
||||
|
||||
imageonmap.removesplattermap:
|
||||
description: "Allows you to remove a splatter map from a wall by sneaking and breaking a map."
|
||||
default: true
|
||||
|
Loading…
Reference in New Issue
Block a user