mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2024-11-16 23:25:11 +01:00
Merge pull request #137 from zDevelopers/fix_GUI_dupplication_exploit
Fix GUI dupplication exploit and the renderer issue with the bottom left map
This commit is contained in:
commit
d192f55ac7
@ -63,6 +63,7 @@ import fr.zcraft.quartzlib.tools.PluginLogger;
|
||||
import fr.zcraft.quartzlib.tools.UpdateChecker;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
|
||||
public final class ImageOnMap extends QuartzPlugin {
|
||||
private static final String IMAGES_DIRECTORY_NAME = "images";
|
||||
@ -148,11 +149,11 @@ public final class ImageOnMap extends QuartzPlugin {
|
||||
}
|
||||
|
||||
if (PluginConfiguration.COLLECT_DATA.get()) {
|
||||
|
||||
final Metrics metrics = new Metrics(this);
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("rendered-images", MapManager::getImagesCount));
|
||||
metrics.addCustomChart(new Metrics.SingleLineChart("used-minecraft-maps", MapManager::getMapCount));
|
||||
} else {
|
||||
PluginLogger.warning("Collect data disabled");
|
||||
//final Metrics metrics = new Metrics(this);
|
||||
//metrics.addCustomChart(new Metrics.SingleLineChart("rendered-images", MapManager::getImagesCount));
|
||||
//metrics.addCustomChart(new Metrics.SingleLineChart("used-minecraft-maps", MapManager::getMapCount));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,7 @@ public class GetCommand extends IoMCommand {
|
||||
|
||||
//TODO passer en static
|
||||
ImageOnMap.getPlugin().getCommandWorker().offlineNameFetch(playerName, uuid -> {
|
||||
|
||||
if (!sender.isOnline()) {
|
||||
return;
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ import fr.zcraft.quartzlib.components.gui.Gui;
|
||||
import fr.zcraft.quartzlib.components.gui.GuiAction;
|
||||
import fr.zcraft.quartzlib.components.gui.PromptGui;
|
||||
import fr.zcraft.quartzlib.components.i18n.I;
|
||||
import fr.zcraft.quartzlib.tools.Callback;
|
||||
import fr.zcraft.quartzlib.tools.items.ItemStackBuilder;
|
||||
import fr.zcraft.quartzlib.tools.runners.RunTask;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -60,6 +60,7 @@ public class MapDetailGui extends ExplorerGui<Integer> {
|
||||
private String name;
|
||||
|
||||
public MapDetailGui(ImageMap map, OfflinePlayer p, String name) {
|
||||
super();
|
||||
this.map = map;
|
||||
this.offplayer = p;
|
||||
this.name = name;
|
||||
@ -207,23 +208,32 @@ public class MapDetailGui extends ExplorerGui<Integer> {
|
||||
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;
|
||||
}
|
||||
PromptGui.prompt(getPlayer(), 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.");
|
||||
return;
|
||||
}
|
||||
if (newName == null || newName.isEmpty()) {
|
||||
I.sendT(getPlayer(), "{ce}Map names can't be empty.");
|
||||
return;
|
||||
}
|
||||
if (newName.equals(map.getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
map.rename(newName);
|
||||
I.sendT(getPlayer(), "{cs}Map successfully renamed.");
|
||||
map.rename(newName);
|
||||
I.sendT(getPlayer(), "{cs}Map successfully renamed.");
|
||||
|
||||
if (getParent() != null) {
|
||||
RunTask.later(() -> Gui.open(getPlayer(), this), 1L);
|
||||
|
||||
} else {
|
||||
close();
|
||||
}
|
||||
}, map.getName(), this);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@GuiAction("delete")
|
||||
|
@ -136,6 +136,10 @@ public class MapListGui extends ExplorerGui<ImageMap> {
|
||||
Gui.open(getPlayer(), new MapDetailGui(data, getPlayer(), name), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClose() {
|
||||
super.onClose();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemStack getPickedUpItem(ImageMap map) {
|
||||
@ -164,7 +168,6 @@ public class MapListGui extends ExplorerGui<ImageMap> {
|
||||
protected void onUpdate() {
|
||||
ImageMap[] maps = MapManager.getMaps(offplayer.getUniqueId());
|
||||
setData(maps);
|
||||
|
||||
/// The maps list GUI title
|
||||
//Equal if the person who send the command is the owner of the mapList
|
||||
if (offplayer.getUniqueId().equals(getPlayer().getUniqueId())) {
|
||||
|
@ -45,6 +45,7 @@ import fr.zcraft.quartzlib.components.i18n.I;
|
||||
import fr.zcraft.quartzlib.core.QuartzLib;
|
||||
import fr.zcraft.quartzlib.tools.items.ItemStackBuilder;
|
||||
import fr.zcraft.quartzlib.tools.items.ItemUtils;
|
||||
import fr.zcraft.quartzlib.tools.runners.RunTask;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashMap;
|
||||
import java.util.Queue;
|
||||
@ -206,6 +207,7 @@ public class MapItemManager implements Listener {
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
/**
|
||||
* Returns the item to place to display the (col;row) part of the given poster.
|
||||
*
|
||||
@ -249,33 +251,44 @@ public class MapItemManager implements Listener {
|
||||
if (!MapManager.managesMap(mapItem)) {
|
||||
return;
|
||||
}
|
||||
|
||||
frame.setItem(new ItemStack(Material.AIR));
|
||||
if (SplatterMapManager.hasSplatterAttributes(mapItem)) {
|
||||
|
||||
if (!SplatterMapManager.placeSplatterMap(frame, player, event)) {
|
||||
event.setCancelled(true); //In case of an error allow to cancel map placement
|
||||
return;
|
||||
}
|
||||
if (frame.getFacing() != BlockFace.UP && frame.getFacing() != BlockFace.DOWN) {
|
||||
frame.setRotation(Rotation.NONE.rotateCounterClockwise());
|
||||
frame.setRotation(Rotation.NONE);
|
||||
}
|
||||
frame.setRotation(Rotation.NONE);
|
||||
|
||||
} else {
|
||||
if (frame.getFacing() != BlockFace.UP && frame.getFacing() != BlockFace.DOWN) {
|
||||
frame.setRotation(Rotation.NONE.rotateCounterClockwise());
|
||||
frame.setRotation(Rotation.NONE);
|
||||
}
|
||||
// If the item has a display name, bot not one from an anvil by the player, we remove it
|
||||
// If it is not displayed on hover on the wall.
|
||||
if (mapItem.hasItemMeta() && mapItem.getItemMeta().hasDisplayName()
|
||||
&& mapItem.getItemMeta().getDisplayName().startsWith("§6")) {
|
||||
|
||||
//runtask
|
||||
//TODO utiliser run task.later pour essayer de regler le pb d'itemframe bas gauche sans carte
|
||||
final ItemStack frameItem = mapItem.clone();
|
||||
final ItemMeta meta = frameItem.getItemMeta();
|
||||
|
||||
meta.setDisplayName(null);
|
||||
frameItem.setItemMeta(meta);
|
||||
RunTask.later(() -> {
|
||||
frame.setItem(frameItem);
|
||||
frame.setRotation(Rotation.NONE);
|
||||
}, 5L);
|
||||
|
||||
frame.setItem(frameItem);
|
||||
} else {
|
||||
frame.setItem(mapItem);
|
||||
frame.setRotation(Rotation.NONE);
|
||||
RunTask.later(() -> {
|
||||
frame.setItem(mapItem);
|
||||
}, 5L);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,6 +49,7 @@ import fr.zcraft.quartzlib.components.nbt.NBTList;
|
||||
import fr.zcraft.quartzlib.tools.PluginLogger;
|
||||
import fr.zcraft.quartzlib.tools.items.ItemStackBuilder;
|
||||
import fr.zcraft.quartzlib.tools.reflection.NMSException;
|
||||
import fr.zcraft.quartzlib.tools.runners.RunTask;
|
||||
import fr.zcraft.quartzlib.tools.text.MessageSender;
|
||||
import fr.zcraft.quartzlib.tools.world.FlatLocation;
|
||||
import fr.zcraft.quartzlib.tools.world.WorldUtils;
|
||||
@ -121,9 +122,7 @@ public abstract class SplatterMapManager {
|
||||
* prettier).
|
||||
*
|
||||
* @param itemStack The item stack to mark as a splatter map.
|
||||
* @return The modified item stack. The instance may be different if the passed item stack is not
|
||||
a craft item stack; that's why the instance is returned.
|
||||
*
|
||||
* @return The modified item stack. The instance may be different if the passed item stack is not a craft itemstack.
|
||||
*/
|
||||
public static ItemStack addSplatterAttribute(final ItemStack itemStack) {
|
||||
try {
|
||||
@ -254,7 +253,11 @@ public abstract class SplatterMapManager {
|
||||
}
|
||||
//Rotation management relative to player rotation the default position is North,
|
||||
// when on ceiling we flipped the rotation
|
||||
frame.setItem(new ItemStackBuilder(Material.FILLED_MAP).nbt(ImmutableMap.of("map", id)).craftItem());
|
||||
RunTask.later(() -> {
|
||||
frame.setItem(
|
||||
new ItemStackBuilder(Material.FILLED_MAP).nbt(ImmutableMap.of("map", id)).craftItem());
|
||||
}, 5L);
|
||||
|
||||
if (i == 0) {
|
||||
//First map need to be rotate one time CounterClockwise
|
||||
rot = rot.rotateCounterClockwise();
|
||||
@ -310,7 +313,12 @@ public abstract class SplatterMapManager {
|
||||
for (ItemFrame frame : wall.frames) {
|
||||
|
||||
int id = poster.getMapIdAtReverseY(i);
|
||||
frame.setItem(new ItemStackBuilder(Material.FILLED_MAP).nbt(ImmutableMap.of("map", id)).craftItem());
|
||||
|
||||
RunTask.later(() -> {
|
||||
frame.setItem(
|
||||
new ItemStackBuilder(Material.FILLED_MAP).nbt(ImmutableMap.of("map", id)).craftItem());
|
||||
}, 5L);
|
||||
|
||||
|
||||
//Force reset of rotation
|
||||
frame.setRotation(Rotation.NONE);
|
||||
|
Loading…
Reference in New Issue
Block a user