mirror of
https://github.com/zDevelopers/ImageOnMap.git
synced 2025-02-20 13:21:22 +01:00
1.16 invisible map support
This commit is contained in:
parent
7ef03a0eae
commit
08cb90f560
@ -51,6 +51,7 @@ public enum Permissions {
|
||||
GETOTHER("imageonmap.getother"),
|
||||
RENAME("imageonmap.rename"),
|
||||
PLACE_SPLATTER_MAP("imageonmap.placesplattermap"),
|
||||
PLACE_INVISIBLE_SPLATTER_MAP("imageonmap.placeinvisiblesplattermap"),
|
||||
REMOVE_SPLATTER_MAP("imageonmap.removesplattermap"),
|
||||
DELETE("imageonmap.delete"),
|
||||
DELETEOTHER("imageonmap.deleteother"),
|
||||
|
@ -37,17 +37,16 @@
|
||||
package fr.moribus.imageonmap.ui;
|
||||
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.PluginConfiguration;
|
||||
import fr.moribus.imageonmap.map.ImageMap;
|
||||
import fr.moribus.imageonmap.map.MapManager;
|
||||
import fr.moribus.imageonmap.map.PosterMap;
|
||||
import fr.moribus.imageonmap.map.SingleMap;
|
||||
import fr.zcraft.quartzlib.components.i18n.I;
|
||||
import fr.zcraft.quartzlib.core.QuartzLib;
|
||||
import fr.zcraft.quartzlib.tools.PluginLogger;
|
||||
import fr.zcraft.quartzlib.tools.items.ItemStackBuilder;
|
||||
import fr.zcraft.quartzlib.tools.items.ItemUtils;
|
||||
import fr.zcraft.quartzlib.tools.runners.RunTask;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.HashMap;
|
||||
import java.util.Queue;
|
||||
@ -320,7 +319,6 @@ public class MapItemManager implements Listener {
|
||||
|| !SplatterMapManager.hasSplatterMap(player, poster)) {
|
||||
poster.give(player);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -329,7 +327,7 @@ public class MapItemManager implements Listener {
|
||||
if (!MapManager.managesMap(frame.getItem())) {
|
||||
return;
|
||||
}
|
||||
|
||||
SplatterMapManager.removePropertiesFromFrames(player, frame);
|
||||
frame.setItem(new ItemStackBuilder(item)
|
||||
.title(getMapTitle(item))
|
||||
.hideAllAttributes()
|
||||
|
@ -37,6 +37,7 @@
|
||||
package fr.moribus.imageonmap.ui;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import fr.moribus.imageonmap.Permissions;
|
||||
import fr.moribus.imageonmap.image.MapInitEvent;
|
||||
import fr.moribus.imageonmap.map.ImageMap;
|
||||
import fr.moribus.imageonmap.map.MapManager;
|
||||
@ -53,6 +54,7 @@ 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;
|
||||
import java.lang.reflect.Method;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
@ -242,6 +244,7 @@ public abstract class SplatterMapManager {
|
||||
//Rotation management relative to player rotation the default position is North,
|
||||
// when on ceiling we flipped the rotation
|
||||
RunTask.later(() -> {
|
||||
addPropertiesToFrames(player, frame);
|
||||
frame.setItem(
|
||||
new ItemStackBuilder(Material.FILLED_MAP).nbt(ImmutableMap.of("map", id)).craftItem());
|
||||
}, 5L);
|
||||
@ -303,6 +306,7 @@ public abstract class SplatterMapManager {
|
||||
int id = poster.getMapIdAtReverseY(i);
|
||||
|
||||
RunTask.later(() -> {
|
||||
addPropertiesToFrames(player, frame);
|
||||
frame.setItem(
|
||||
new ItemStackBuilder(Material.FILLED_MAP).nbt(ImmutableMap.of("map", id)).craftItem());
|
||||
}, 5L);
|
||||
@ -361,10 +365,31 @@ public abstract class SplatterMapManager {
|
||||
|
||||
for (ItemFrame frame : matchingFrames) {
|
||||
if (frame != null) {
|
||||
removePropertiesFromFrames(player, frame);
|
||||
frame.setItem(null);
|
||||
}
|
||||
}
|
||||
|
||||
return poster;
|
||||
}
|
||||
|
||||
public static void addPropertiesToFrames(Player player, ItemFrame frame) {
|
||||
if (Permissions.PLACE_INVISIBLE_SPLATTER_MAP.grantedTo(player)) {
|
||||
try {
|
||||
Method setVisible = frame.getClass().getMethod("setVisible", boolean.class);
|
||||
setVisible.invoke(frame, false);
|
||||
} catch (Exception e) {
|
||||
//1.16-
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void removePropertiesFromFrames(Player player, ItemFrame frame) {
|
||||
try {
|
||||
Method setVisible = frame.getClass().getMethod("setVisible", boolean.class);
|
||||
setVisible.invoke(frame, true);
|
||||
} catch (Exception e) {
|
||||
//1.16-
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ permissions:
|
||||
imageonmap.bypassmaplimit: false
|
||||
imageonmap.bypassimagelimit: false
|
||||
imageonmap.ignoreallowlist_hostingsite: true
|
||||
imageonmap.placeinvisiblesplattermap: true
|
||||
|
||||
imageonmap.userender:
|
||||
description: "Allows you to use /tomap and related commands (/maptool getremaining). Alias of imageonmap.new."
|
||||
default: true
|
||||
@ -123,4 +125,8 @@ permissions:
|
||||
|
||||
imageonmap.ignoreallowlist_hostingsite:
|
||||
description: "Allows you to ignore the restriction on the allow list for image hosting website."
|
||||
default: true
|
||||
default: true
|
||||
|
||||
imageonmap.placeinvisiblesplattermap:
|
||||
description: "Allows you to make the item frame on which you placed your splatter map invisible."
|
||||
default: true
|
||||
|
Loading…
Reference in New Issue
Block a user