mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-11-25 11:35:35 +01:00
The permissions update.
* NEW: added permissions for everything.
This commit is contained in:
parent
a278a42b01
commit
f92d90683d
33
README.md
33
README.md
@ -1,7 +1,7 @@
|
||||
ImageOnMap
|
||||
==========
|
||||
|
||||
Repo for ImageOnMap, a bukkit plugin
|
||||
Repo for ImageOnMap, a bukkit plugin.
|
||||
|
||||
|
||||
## Features
|
||||
@ -14,7 +14,7 @@ ImageOnMap allows you to load a picture from the Internet to a Minecraft map.
|
||||
- Your image will be centered.
|
||||
- You can put your map in an item frame.
|
||||
|
||||
This plugin is a free software lisensed under the GNU General Public License (version 3 or above). The source code is published on GitHub. You can also get unstable development builds here.
|
||||
This plugin is a free software licenced under the GNU General Public License (version 3 or above). You can also get unstable development builds here.
|
||||
|
||||
|
||||
## Quick guide
|
||||
@ -34,7 +34,7 @@ Renders an image and gives a map to the player with it.
|
||||
- The link must be complete, do not forget that the chat limit is 240 characters.
|
||||
- You can use an URL shortener like tinyURL or bitly.
|
||||
- If you want a picture in one map, type resize after the link.
|
||||
- Permission: `imageonmap.userender`
|
||||
- Permission: `imageonmap.new` (or `imageonmap.userender`—legacy, but will be kept in the plugin).
|
||||
|
||||
|
||||
### `/maps`
|
||||
@ -46,6 +46,7 @@ Opens a GUI to see, retrieve and manage the user's maps.
|
||||
- A book is displayed too to see some usage statistics (maps created, quotas).
|
||||
- An user can retrieve a map by left-clicking it, or manage it by right-clicking.
|
||||
- Maps can be renamed (for organization), deleted (but they won't render in game anymore!), or partially retrieved (for posters maps containing more than one map).
|
||||
- Permission: `imageonmap.list`, plus `imageonmap.get`, `imageonmap.rename` and `imageonmap.delete` for actions into the GUI.
|
||||
|
||||
|
||||
### `/maptool <new|list|get|delete|explore|migrate>`
|
||||
@ -56,10 +57,22 @@ Main command to manage the maps. The less used in everyday usage, too.
|
||||
- `/maptool new` is an alias of `/tomap`.
|
||||
- `/maptool explore` is an alias of `/maps`.
|
||||
- `/maptool migrate` migrates the old maps when you upgrade from IoM <= 2.7 to IoM 3.0. You HAVE TO execute this command to retrieve all maps when you do such a migration.
|
||||
- Permissions:
|
||||
- `imageonmap.new` for `/maptool new`;
|
||||
- `imageonmap.list` for both `/maptool list` and `/maptool explore`;
|
||||
- `imageonmap.get` for `/maptool get`;
|
||||
- `imageonmap.delete` for `/maptool delete`;
|
||||
- `imageonmap.administrative` for `/maptool migrate`.
|
||||
|
||||
### About the permissions
|
||||
|
||||
All permissions are by default granted to everyone, with the exception of `imageonmap.administrative`. We believe that in most cases, servers administrators want to give the availability to create images on maps to every player.
|
||||
Negate a permission using a plugin manager to remove it, if you want to restrict this possibility to a set of users.
|
||||
|
||||
You can grant `imageonmap.*` to users, as this permission is a shortcut for all _user_ permissions (excluding `imageonmap.administrative`).
|
||||
|
||||
|
||||
|
||||
##Configuration
|
||||
## Configuration
|
||||
|
||||
```yaml
|
||||
# Plugin language. Empty: system language.
|
||||
@ -77,7 +90,9 @@ map-global-limit: 0
|
||||
map-player-limit: 0
|
||||
```
|
||||
|
||||
## New features in the 3.0 version
|
||||
## Changelog
|
||||
|
||||
### 3.0
|
||||
|
||||
The 3.0 release is a complete rewrite of the original ImageOnMap plugin, now based on zLib, which adds many feature and fixes many bugs.
|
||||
|
||||
@ -94,8 +109,12 @@ You will find amongst the new features:
|
||||
- Asynchronous maps rendering (your server won't freeze anymore when rendering big maps, and you can queue multiple map renderings !)
|
||||
- UUID management (which requires to run `/maptool migrate`)
|
||||
|
||||
### 3.1
|
||||
|
||||
- Fixed permissions support by adding a full set of permissions for every action of the plugin.
|
||||
|
||||
|
||||
|
||||
## Data collection
|
||||
|
||||
We use metrics to collect basic informations about the usage of this plugin. This can be disabled by setting "collect-data" to false in config.yml.
|
||||
We use metrics to collect basic information about the usage of this plugin. This can be disabled by setting `collect-data` to false in `config.yml`.
|
||||
|
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>fr.moribus</groupId>
|
||||
<artifactId>ImageOnMap</artifactId>
|
||||
<version>3.0</version>
|
||||
<version>3.1</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
|
75
src/main/java/fr/moribus/imageonmap/Permissions.java
Normal file
75
src/main/java/fr/moribus/imageonmap/Permissions.java
Normal file
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright or © or Copr. AmauryCarrade (2015)
|
||||
*
|
||||
* http://amaury.carrade.eu
|
||||
*
|
||||
* 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;
|
||||
|
||||
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
public enum Permissions
|
||||
{
|
||||
NEW("imageonmap.new", "imageonmap.userender"),
|
||||
LIST("imageonmap.list"),
|
||||
GET("imageonmap.get"),
|
||||
RENAME("imageonmap.rename"),
|
||||
DELETE("imageonmap.delete"),
|
||||
ADMINISTRATIVE("imageonmap.administrative")
|
||||
|
||||
;
|
||||
|
||||
|
||||
private final String permission;
|
||||
private final String[] aliases;
|
||||
|
||||
Permissions(String permission, String... aliases)
|
||||
{
|
||||
this.permission = permission;
|
||||
this.aliases = aliases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this permission is granted to the given permissible.
|
||||
*
|
||||
* @param permissible The permissible to check.
|
||||
* @return {@code true} if this permission is granted to the permissible.
|
||||
*/
|
||||
public boolean grantedTo(Permissible permissible)
|
||||
{
|
||||
if (permissible.hasPermission(permission))
|
||||
return true;
|
||||
|
||||
for (String alias : aliases)
|
||||
if (permissible.hasPermission(alias))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
|
||||
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;
|
||||
@ -29,6 +30,7 @@ import fr.zcraft.zlib.components.i18n.I;
|
||||
import fr.zcraft.zlib.components.rawtext.RawText;
|
||||
import fr.zcraft.zlib.tools.PluginLogger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
@ -83,4 +85,10 @@ public class DeleteCommand extends IoMCommand
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecute(CommandSender sender)
|
||||
{
|
||||
return Permissions.DELETE.grantedTo(sender);
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,13 @@
|
||||
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 org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
@CommandInfo (name = "explore")
|
||||
@ -32,6 +34,12 @@ public class ExploreCommand extends IoMCommand
|
||||
@Override
|
||||
protected void run() throws CommandException
|
||||
{
|
||||
Gui.open(playerSender(), new MapListGui());
|
||||
Gui.open(playerSender(), new MapListGui());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecute(CommandSender sender)
|
||||
{
|
||||
return Permissions.LIST.grantedTo(sender);
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,12 @@
|
||||
|
||||
package fr.moribus.imageonmap.commands.maptool;
|
||||
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.commands.IoMCommand;
|
||||
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 org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
@ -47,4 +49,10 @@ public class GetCommand extends IoMCommand
|
||||
return getMatchingMapNames(playerSender(), args[0]);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecute(CommandSender sender)
|
||||
{
|
||||
return Permissions.GET.grantedTo(sender);
|
||||
}
|
||||
}
|
||||
|
@ -18,11 +18,13 @@
|
||||
|
||||
package fr.moribus.imageonmap.commands.maptool;
|
||||
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.commands.IoMCommand;
|
||||
import fr.moribus.imageonmap.ui.MapItemManager;
|
||||
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 org.bukkit.entity.Player;
|
||||
|
||||
@CommandInfo (name = "getremaining", aliases = {"getrest"})
|
||||
@ -50,4 +52,10 @@ public class GetRemainingCommand extends IoMCommand
|
||||
info(I.tn("There is {0} map remaining.", "There are {0} maps remaining.", MapItemManager.getCacheSize(player)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecute(CommandSender sender)
|
||||
{
|
||||
return Permissions.NEW.grantedTo(sender) || Permissions.GET.grantedTo(sender);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
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;
|
||||
@ -31,6 +32,7 @@ import fr.zcraft.zlib.tools.items.ItemStackBuilder;
|
||||
import fr.zcraft.zlib.tools.text.RawMessage;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
@ -81,4 +83,10 @@ public class ListCommand extends IoMCommand
|
||||
.item()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecute(CommandSender sender)
|
||||
{
|
||||
return Permissions.LIST.grantedTo(sender);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package fr.moribus.imageonmap.commands.maptool;
|
||||
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.commands.IoMCommand;
|
||||
import fr.moribus.imageonmap.migration.MigratorExecutor;
|
||||
import fr.zcraft.zlib.components.commands.CommandException;
|
||||
@ -45,6 +46,6 @@ public class MigrateCommand extends IoMCommand
|
||||
@Override
|
||||
public boolean canExecute(CommandSender sender)
|
||||
{
|
||||
return sender.isOp();
|
||||
return sender.isOp() || Permissions.ADMINISTRATIVE.grantedTo(sender);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package fr.moribus.imageonmap.commands.maptool;
|
||||
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.commands.IoMCommand;
|
||||
import fr.moribus.imageonmap.image.ImageRendererExecutor;
|
||||
import fr.moribus.imageonmap.map.ImageMap;
|
||||
@ -26,6 +27,7 @@ import fr.zcraft.zlib.components.commands.CommandInfo;
|
||||
import fr.zcraft.zlib.components.i18n.I;
|
||||
import fr.zcraft.zlib.components.worker.WorkerCallback;
|
||||
import fr.zcraft.zlib.tools.PluginLogger;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
@ -84,4 +86,10 @@ public class NewCommand extends IoMCommand
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExecute(CommandSender sender)
|
||||
{
|
||||
return Permissions.NEW.grantedTo(sender);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package fr.moribus.imageonmap.gui;
|
||||
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.map.ImageMap;
|
||||
import fr.moribus.imageonmap.map.MapManager;
|
||||
import fr.moribus.imageonmap.map.MapManagerException;
|
||||
@ -170,6 +171,14 @@ 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()))
|
||||
{
|
||||
I.sendT(getPlayer(), "{ce}You are no longer allowed to do that.");
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
MapManager.clear(getPlayer().getInventory(), mapToDelete);
|
||||
|
||||
try
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
package fr.moribus.imageonmap.gui;
|
||||
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.map.ImageMap;
|
||||
import fr.moribus.imageonmap.map.PosterMap;
|
||||
import fr.moribus.imageonmap.map.SingleMap;
|
||||
@ -46,43 +47,46 @@ public class MapDetailGui extends ExplorerGui<Short>
|
||||
@Override
|
||||
protected ItemStack getViewItem(int x, int y)
|
||||
{
|
||||
Material partMaterial = Material.PAPER;
|
||||
if((y % 2 == 0 && x % 2 == 0) || (y % 2 == 1 && x % 2 == 1))
|
||||
partMaterial = Material.EMPTY_MAP;
|
||||
final Material partMaterial = y % 2 == x % 2 ? Material.EMPTY_MAP : Material.PAPER;
|
||||
|
||||
return new ItemStackBuilder(partMaterial)
|
||||
final ItemStackBuilder builder = new ItemStackBuilder(partMaterial)
|
||||
.title(I.t(getPlayerLocale(), "{green}Map part"))
|
||||
.lore(I.t(getPlayerLocale(), "{gray}Row: {white}{0}", y + 1))
|
||||
.lore(I.t(getPlayerLocale(), "{gray}Column: {white}{0}", x + 1))
|
||||
.loreLine()
|
||||
.lore(I.t(getPlayerLocale(), "{gray}» {white}Click{gray} to get only this part"))
|
||||
.item();
|
||||
.lore(I.t(getPlayerLocale(), "{gray}Column: {white}{0}", x + 1));
|
||||
|
||||
if (Permissions.GET.grantedTo(getPlayer()))
|
||||
builder.loreLine().lore(I.t(getPlayerLocale(), "{gray}» {white}Click{gray} to get only this part"));
|
||||
|
||||
return builder.item();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getViewItem(Short mapId)
|
||||
{
|
||||
int index = ((PosterMap) map).getIndex(mapId);
|
||||
Material partMaterial = Material.PAPER;
|
||||
if(index % 2 == 0)
|
||||
partMaterial = Material.EMPTY_MAP;
|
||||
final int index = ((PosterMap) map).getIndex(mapId);
|
||||
final Material partMaterial = index % 2 == 0 ? Material.EMPTY_MAP : Material.PAPER;
|
||||
|
||||
return new ItemStackBuilder(partMaterial)
|
||||
final ItemStackBuilder builder = new ItemStackBuilder(partMaterial)
|
||||
.title(I.t(getPlayerLocale(), "{green}Map part"))
|
||||
.lore(I.t(getPlayerLocale(), "{gray}Part: {white}{0}", index + 1))
|
||||
.loreLine()
|
||||
.lore(I.t(getPlayerLocale(), "{gray}» {white}Click{gray} to get only this part"))
|
||||
.item();
|
||||
.lore(I.t(getPlayerLocale(), "{gray}Part: {white}{0}", index + 1));
|
||||
|
||||
if (Permissions.GET.grantedTo(getPlayer()))
|
||||
builder.loreLine().lore(I.t(getPlayerLocale(), "{gray}» {white}Click{gray} to get only this part"));
|
||||
|
||||
return builder.item();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getPickedUpItem(int x, int y)
|
||||
{
|
||||
if(map instanceof SingleMap)
|
||||
if (!Permissions.GET.grantedTo(getPlayer()))
|
||||
return null;
|
||||
|
||||
if (map instanceof SingleMap)
|
||||
{
|
||||
return MapItemManager.createMapItem((SingleMap)map);
|
||||
}
|
||||
else if(map instanceof PosterMap)
|
||||
else if (map instanceof PosterMap)
|
||||
{
|
||||
return MapItemManager.createMapItem((PosterMap)map, x, y);
|
||||
}
|
||||
@ -93,14 +97,17 @@ public class MapDetailGui extends ExplorerGui<Short>
|
||||
@Override
|
||||
protected ItemStack getPickedUpItem(Short mapId)
|
||||
{
|
||||
PosterMap poster = (PosterMap) map;
|
||||
if (!Permissions.GET.grantedTo(getPlayer()))
|
||||
return null;
|
||||
|
||||
final PosterMap poster = (PosterMap) map;
|
||||
return MapItemManager.createMapItem(poster, poster.getIndex(mapId));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getEmptyViewItem()
|
||||
{
|
||||
if(map instanceof SingleMap)
|
||||
if (map instanceof SingleMap)
|
||||
{
|
||||
return getViewItem(0, 0);
|
||||
}
|
||||
@ -114,7 +121,7 @@ public class MapDetailGui extends ExplorerGui<Short>
|
||||
setTitle(I.t(getPlayerLocale(), "Your maps » {black}{0}", map.getName()));
|
||||
setKeepHorizontalScrollingSpace(true);
|
||||
|
||||
if(map instanceof PosterMap)
|
||||
if (map instanceof PosterMap)
|
||||
{
|
||||
PosterMap poster = (PosterMap) map;
|
||||
if(poster.hasColumnData())
|
||||
@ -131,25 +138,41 @@ public class MapDetailGui extends ExplorerGui<Short>
|
||||
setDataShape(1,1);
|
||||
}
|
||||
|
||||
final boolean canRename = Permissions.RENAME.grantedTo(getPlayer());
|
||||
final boolean canDelete = Permissions.DELETE.grantedTo(getPlayer());
|
||||
|
||||
action("rename", getSize() - 7, new ItemStackBuilder(Material.BOOK_AND_QUILL)
|
||||
.title(I.t(getPlayerLocale(), "{blue}Rename this image"))
|
||||
.longLore(I.t(getPlayerLocale(), "{gray}Click here to rename this image; this is used for your own organization."))
|
||||
);
|
||||
int renameSlot = getSize() - 7;
|
||||
int deleteSlot = getSize() - 6;
|
||||
|
||||
action("delete", getSize() - 6, new ItemStackBuilder(Material.BARRIER)
|
||||
.title(I.t(getPlayerLocale(), "{red}Delete this image"))
|
||||
.longLore(I.t(getPlayerLocale(), "{gray}Deletes this map {white}forever{gray}. This action cannot be undone!"))
|
||||
.loreLine()
|
||||
.longLore(I.t(getPlayerLocale(), "{gray}You will be asked to confirm your choice if you click here."))
|
||||
);
|
||||
if (!canRename)
|
||||
deleteSlot--;
|
||||
|
||||
if (canRename)
|
||||
{
|
||||
action("rename", renameSlot, new ItemStackBuilder(Material.BOOK_AND_QUILL)
|
||||
.title(I.t(getPlayerLocale(), "{blue}Rename this image"))
|
||||
.longLore(I.t(getPlayerLocale(), "{gray}Click here to rename this image; this is used for your own organization."))
|
||||
);
|
||||
}
|
||||
|
||||
if (canDelete)
|
||||
{
|
||||
action("delete", deleteSlot, new ItemStackBuilder(Material.BARRIER)
|
||||
.title(I.t(getPlayerLocale(), "{red}Delete this image"))
|
||||
.longLore(I.t(getPlayerLocale(), "{gray}Deletes this map {white}forever{gray}. This action cannot be undone!"))
|
||||
.loreLine()
|
||||
.longLore(I.t(getPlayerLocale(), "{gray}You will be asked to confirm your choice if you click here."))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// To keep the controls centered, the back button is shifted to the right when the
|
||||
// arrow isn't displayed, so when the map fit on the grid without sliders.
|
||||
int backSlot = getSize() - 4;
|
||||
|
||||
if(map instanceof PosterMap && ((PosterMap) map).getColumnCount() <= INVENTORY_ROW_SIZE)
|
||||
if (!canRename && !canDelete)
|
||||
backSlot = getSize() - 5;
|
||||
else if (map instanceof PosterMap && ((PosterMap) map).getColumnCount() <= INVENTORY_ROW_SIZE)
|
||||
backSlot++;
|
||||
|
||||
action("back", backSlot, new ItemStackBuilder(Material.EMERALD)
|
||||
@ -162,11 +185,24 @@ public class MapDetailGui extends ExplorerGui<Short>
|
||||
@GuiAction ("rename")
|
||||
public void rename()
|
||||
{
|
||||
if (!Permissions.RENAME.grantedTo(getPlayer()))
|
||||
{
|
||||
I.sendT(getPlayer(), "{ce}You are no longer allowed to do that.");
|
||||
update();
|
||||
return;
|
||||
}
|
||||
|
||||
PromptGui.prompt(getPlayer(), new Callback<String>()
|
||||
{
|
||||
@Override
|
||||
public void call(String newName)
|
||||
{
|
||||
if (!Permissions.RENAME.grantedTo(getPlayer()))
|
||||
{
|
||||
I.sendT(getPlayer(), "{ce}You are no longer allowed to do that.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (newName == null || newName.isEmpty())
|
||||
{
|
||||
I.sendT(getPlayer(), "{ce}Map names can't be empty.");
|
||||
@ -182,6 +218,13 @@ public class MapDetailGui extends ExplorerGui<Short>
|
||||
@GuiAction ("delete")
|
||||
public void 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);
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
package fr.moribus.imageonmap.gui;
|
||||
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.PluginConfiguration;
|
||||
import fr.moribus.imageonmap.map.ImageMap;
|
||||
import fr.moribus.imageonmap.map.MapManager;
|
||||
@ -57,7 +58,7 @@ public class MapListGui extends ExplorerGui<ImageMap>
|
||||
mapDescription = I.t(getPlayerLocale(), "{white}Poster map ({0} parts)", poster.getMapCount());
|
||||
}
|
||||
}
|
||||
return new ItemStackBuilder(Material.MAP)
|
||||
ItemStackBuilder builder = new ItemStackBuilder(Material.MAP)
|
||||
/// Displayed title of a map on the list GUI
|
||||
.title(I.t(getPlayerLocale(), "{green}{bold}{0}", map.getName()))
|
||||
|
||||
@ -65,20 +66,28 @@ public class MapListGui extends ExplorerGui<ImageMap>
|
||||
.loreLine()
|
||||
/// Map ID displayed in the tooltip of a map on the list GUI
|
||||
.lore(I.t(getPlayerLocale(), "{gray}Map ID: {0}", map.getId()))
|
||||
.loreLine()
|
||||
.lore(I.t(getPlayerLocale(), "{gray}» {white}Left-click{gray} to get this map"))
|
||||
.lore(I.t(getPlayerLocale(), "{gray}» {white}Right-click{gray} for details and options"))
|
||||
.loreLine();
|
||||
|
||||
.item();
|
||||
if (Permissions.GET.grantedTo(getPlayer()))
|
||||
builder.lore(I.t(getPlayerLocale(), "{gray}» {white}Left-click{gray} to get this map"));
|
||||
|
||||
builder.lore(I.t(getPlayerLocale(), "{gray}» {white}Right-click{gray} for details and options"));
|
||||
|
||||
return builder.item();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getEmptyViewItem()
|
||||
{
|
||||
return new ItemStackBuilder(Material.BARRIER)
|
||||
.title(I.t(getPlayerLocale(), "{red}You don't have any map."))
|
||||
.longLore(I.t(getPlayerLocale(), "{gray}Get started by creating a new one using {white}/tomap <URL> [resize]{gray}!"))
|
||||
.item();
|
||||
ItemStackBuilder builder = new ItemStackBuilder(Material.BARRIER)
|
||||
.title(I.t(getPlayerLocale(), "{red}You don't have any map."));
|
||||
|
||||
if (Permissions.NEW.grantedTo(getPlayer()))
|
||||
builder.longLore(I.t(getPlayerLocale(), "{gray}Get started by creating a new one using {white}/tomap <URL> [resize]{gray}!"));
|
||||
else
|
||||
builder.longLore(I.t(getPlayerLocale(), "{gray}Unfortunately, you are not allowed to create one."));
|
||||
|
||||
return builder.item();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,6 +99,9 @@ public class MapListGui extends ExplorerGui<ImageMap>
|
||||
@Override
|
||||
protected ItemStack getPickedUpItem(ImageMap map)
|
||||
{
|
||||
if (!Permissions.GET.grantedTo(getPlayer()))
|
||||
return null;
|
||||
|
||||
if (map instanceof SingleMap)
|
||||
{
|
||||
return MapItemManager.createMapItem(map.getMapsIDs()[0], map.getName());
|
||||
@ -114,6 +126,7 @@ public class MapListGui extends ExplorerGui<ImageMap>
|
||||
{
|
||||
ImageMap[] maps = MapManager.getMaps(getPlayer().getUniqueId());
|
||||
setData(maps);
|
||||
|
||||
/// The maps list GUI title
|
||||
setTitle(I.t(getPlayerLocale(), "{black}Your maps {reset}({0})", maps.length));
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: ImageOnMap
|
||||
main: fr.moribus.imageonmap.ImageOnMap
|
||||
version: 3.0
|
||||
version: 3.1
|
||||
|
||||
commands:
|
||||
tomap:
|
||||
@ -12,6 +12,47 @@ commands:
|
||||
description: manage maps through a GUI
|
||||
|
||||
permissions:
|
||||
imageonmap.*:
|
||||
description: "Grants all the user permissions (excluding administrative ones)."
|
||||
default: true
|
||||
children:
|
||||
imageonmap.userender: true
|
||||
imageonmap.new: true
|
||||
imageonmap.list: true
|
||||
imageonmap.get: true
|
||||
imageonmap.explore: true
|
||||
imageonmap.rename: true
|
||||
imageonmap.delete: true
|
||||
imageonmap.administrative: false
|
||||
|
||||
imageonmap.userender:
|
||||
description: Allows you to use /tomap
|
||||
description: "Allows you to use /tomap and related commands (/maptool getremaing). Alias of imageonmap.new."
|
||||
default: true
|
||||
|
||||
imageonmap.new:
|
||||
description: "Allows you to use /tomap and related commands (/maptool getremaing)."
|
||||
default: true
|
||||
|
||||
imageonmap.list:
|
||||
description: "Allows you to list the images you rendered."
|
||||
default: true
|
||||
|
||||
imageonmap.get:
|
||||
description: "Allows you to get a new map among the ones you already rendered, and related commands (/maptool getremaing)."
|
||||
default: true
|
||||
|
||||
imageonmap.explore:
|
||||
description: "Allows you to open a GUI with all your maps."
|
||||
default: true
|
||||
|
||||
imageonmap.rename:
|
||||
description: "Allows you to rename a map you rendered in the past."
|
||||
default: true
|
||||
|
||||
imageonmap.delete:
|
||||
description: "Allows you to delete a map you rendered in the past."
|
||||
default: true
|
||||
|
||||
imageonmap.administrative:
|
||||
description: "Allows you to perform administrative tasks (like /maptool migrate)."
|
||||
default: op
|
Loading…
Reference in New Issue
Block a user