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