org.inventivetalent.mapmanager.wrapper.MapWrapper Java Examples
The following examples show how to use
org.inventivetalent.mapmanager.wrapper.MapWrapper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MultiMapWrapper.java From MapManager with MIT License | 6 votes |
protected void setContent(Object[][] imageMatrix) { wrapperMatrix = new MapWrapper[imageMatrix.length][imageMatrix[0].length]; for (int x = 0; x < imageMatrix.length; x++) { if (imageMatrix[x].length != imageMatrix[0].length) { throw new IllegalArgumentException("image is not rectangular"); } for (int y = 0; y < imageMatrix[x].length; y++) { Object object = imageMatrix[x][y]; if (object == null) { throw new IllegalArgumentException("null element in image array"); } else if (object instanceof BufferedImage) { wrapperMatrix[x][y] = MapManagerPlugin.instance.getMapManager().wrapImage((BufferedImage) object); } else if (object instanceof ArrayImage) { wrapperMatrix[x][y] = MapManagerPlugin.instance.getMapManager().wrapImage((ArrayImage) object); } } } }
Example #2
Source File: DefaultMapWrapper.java From MapManager with MIT License | 6 votes |
@Override public void update(ArrayImage content) { MapContentUpdateEvent event = new MapContentUpdateEvent(DefaultMapWrapper.this, content); Bukkit.getPluginManager().callEvent(event); if (event.getContent() != null) { if (MapManager.Options.CHECK_DUPLICATES) { MapWrapper duplicate = ((DefaultMapManager) ((MapManagerPlugin) Bukkit.getPluginManager().getPlugin("MapManager")).getMapManager()).getDuplicate(event.getContent()); if (duplicate != null) { DefaultMapWrapper.this.content = duplicate.getContent(); return; } } DefaultMapWrapper.this.content = event.getContent(); } if (event.isSendContent()) { for (UUID id : viewers.keySet()) { sendContent(Bukkit.getPlayer(id)); } } }
Example #3
Source File: MapInteractEvent.java From MapManager with MIT License | 6 votes |
/** * @return the {@link MapWrapper} of the clicked frame */ public MapWrapper getMapWrapper() { if (this.mapWrapper != null) { return this.mapWrapper; } ItemFrame itemFrame = getItemFrame(); if (itemFrame != null) { if (itemFrame.hasMetadata("MAP_WRAPPER_REF")) { List<MetadataValue> metadataValues = itemFrame.getMetadata("MAP_WRAPPER_REF"); for (MetadataValue value : metadataValues) { MapWrapper wrapper = (MapWrapper) value.value(); if (wrapper != null) { return this.mapWrapper = wrapper; } } } } return null; }
Example #4
Source File: AnimatedFrame.java From AnimatedFrames with MIT License | 6 votes |
private void displayCurrentFrame() { MultiMapController controller = ((MultiMapController) this.mapWrappers[this.currentFrame].getController()); for (Iterator<UUID> iterator = this.worldPlayers.iterator(); iterator.hasNext(); ) { OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(iterator.next()); Player player = offlinePlayer != null ? offlinePlayer.getPlayer() : null; if (player != null) { if (player.getWorld().getName().equals(worldName)) { if (player.getLocation().distanceSquared(baseVector.toBukkitLocation(getWorld())) < plugin.maxAnimateDistanceSquared) { controller.showInFrames(player.getPlayer(), this.itemFrameIds); } } } else { iterator.remove(); if (offlinePlayer != null) { for (MapWrapper wrapper : this.mapWrappers) { wrapper.getController().removeViewer(offlinePlayer); } } } } }
Example #5
Source File: AnimatedFrame.java From AnimatedFrames with MIT License | 6 votes |
public void addViewer(Player player) { if (this.mapWrappers != null) { for (MapWrapper wrapper : mapWrappers) { if (wrapper == null) { plugin.getLogger().warning("Null-element in MapWrapper array of " + getName()); continue; } MapController controller = wrapper.getController(); controller.addViewer(player); controller.sendContent(player); } } synchronized (this.worldPlayersLock) { this.worldPlayers.add(player.getUniqueId()); } }
Example #6
Source File: AnimatedFrame.java From AnimatedFrames with MIT License | 6 votes |
public void removeViewer(OfflinePlayer player) { boolean empty; synchronized (this.worldPlayersLock) { this.worldPlayers.remove(player.getUniqueId()); empty = this.worldPlayers.isEmpty(); } if (this.mapWrappers != null) { for (MapWrapper wrapper : mapWrappers) { if (wrapper == null) { plugin.getLogger().warning("Null-element in MapWrapper array of " + getName()); continue; } MapController controller = wrapper.getController(); if (empty) { controller.clearViewers(); } else { controller.removeViewer(player); } } } }
Example #7
Source File: AnimatedFrame.java From AnimatedFrames with MIT License | 6 votes |
public void clearFrames() { if (this.mapWrappers != null) { for (MapWrapper wrapper : this.mapWrappers) { for (UUID uuid : worldPlayers) { Player player = Bukkit.getPlayer(uuid); if (player != null) { ((MultiMapController) wrapper.getController()).clearFrames(player, this.itemFrameIds); } } wrapper.getController().clearViewers(); } for (int[] iA : this.itemFrameIds) { for (int i : iA) { ItemFrame itemFrame = MapManagerPlugin.getItemFrameById(getWorld(), i); if (itemFrame != null) { itemFrame.removeMetadata("ANIMATED_FRAMES_META", plugin); } } } } }
Example #8
Source File: MultiMapWrapper.java From MapManager with MIT License | 5 votes |
@Override public void addViewer(final Player player) { if (!viewerIds.contains(player.getUniqueId())) { matrixIterator(new MatrixCallable() { @Override public void call(MapWrapper wrapper) { wrapper.getController().addViewer(player); } }); viewerIds.add(player.getUniqueId()); } }
Example #9
Source File: DefaultMapManager.java From MapManager with MIT License | 5 votes |
@Override public void unwrapImage(MapWrapper wrapper) { if (wrapper instanceof DefaultMapWrapper) { for (short s : ((DefaultMapWrapper) wrapper).viewers.values()) { MapSender.cancelIDs(new short[] { s }); } } wrapper.getController().clearViewers(); MANAGED_MAPS.remove(wrapper); if (wrapper instanceof MultiMapWrapper) { ((MultiMapWrapper) wrapper).unwrap(); } }
Example #10
Source File: DefaultMapManager.java From MapManager with MIT License | 5 votes |
@Override public MapWrapper wrapImage(ArrayImage image) { if (Options.CHECK_DUPLICATES) { for (int i = 0; i < MANAGED_MAPS.size(); i++) { MapWrapper wrapper = MANAGED_MAPS.get(i); if (image.equals(wrapper.getContent())) { return wrapper; } } } return wrapNewImage(image); }
Example #11
Source File: DefaultMapManager.java From MapManager with MIT License | 5 votes |
@Override public Set<MapWrapper> getMapsVisibleTo(OfflinePlayer player) { Set<MapWrapper> visible = new HashSet<>(); for (MapWrapper wrapper : MANAGED_MAPS) { if (wrapper.getController().isViewing(player)) { visible.add(wrapper); } } return visible; }
Example #12
Source File: DefaultMapManager.java From MapManager with MIT License | 5 votes |
@Override public MapWrapper getWrapperForId(OfflinePlayer player, short id) { for (MapWrapper wrapper : getMapsVisibleTo(player)) { if (wrapper.getController().getMapId(player) == id) { return wrapper; } } return null; }
Example #13
Source File: MultiMapWrapper.java From MapManager with MIT License | 5 votes |
public void unwrap() { matrixIterator(new MatrixCallable() { @Override public void call(MapWrapper wrapper) { MapManagerPlugin.instance.getMapManager().unwrapImage(wrapper); } }); }
Example #14
Source File: MultiMapWrapper.java From MapManager with MIT License | 5 votes |
@Override public void sendContent(final Player player, final boolean withoutQueue) { matrixIterator(new MatrixCallable() { @Override public void call(MapWrapper wrapper) { wrapper.getController().sendContent(player, withoutQueue); } }); }
Example #15
Source File: MultiMapWrapper.java From MapManager with MIT License | 5 votes |
@Override public void clearViewers() { matrixIterator(new MatrixCallable() { @Override public void call(MapWrapper wrapper) { wrapper.getController().clearViewers(); } }); viewerIds.clear(); }
Example #16
Source File: MultiMapWrapper.java From MapManager with MIT License | 5 votes |
@Override public void removeViewer(final OfflinePlayer player) { matrixIterator(new MatrixCallable() { @Override public void call(MapWrapper wrapper) { wrapper.getController().removeViewer(player); } }); viewerIds.remove(player.getUniqueId()); }
Example #17
Source File: DefaultMapManager.java From MapManager with MIT License | 5 votes |
@Override public Set<Short> getOccupiedIdsFor(OfflinePlayer player) { Set<Short> ids = new HashSet<>(); for (MapWrapper wrapper : MANAGED_MAPS) { short s; if ((s = wrapper.getController().getMapId(player)) >= 0) { ids.add(s); } } return ids; }
Example #18
Source File: DefaultMapManager.java From MapManager with MIT License | 5 votes |
public MapWrapper getDuplicate(ArrayImage image) { for (int i = 0; i < MANAGED_MAPS.size(); i++) { MapWrapper wrapper = MANAGED_MAPS.get(i); if (image.equals(wrapper.getContent())) { return wrapper; } } return null; }
Example #19
Source File: CreativeInventoryMapUpdateEvent.java From MapManager with MIT License | 5 votes |
/** * @return the {@link MapWrapper} of the item */ public MapWrapper getMapWrapper() { if (this.mapWrapper != null) { return this.mapWrapper; } if (getItemStack() == null) { return null; } if (getItemStack().getType() != Material.MAP) { return null; } MapManager mapManager = ((MapManagerPlugin) Bukkit.getPluginManager().getPlugin("MapManager")).getMapManager(); return this.mapWrapper = mapManager.getWrapperForId(getPlayer(), getItemStack().getDurability()); }
Example #20
Source File: DefaultMapManager.java From MapManager with MIT License | 4 votes |
@Override public MapWrapper wrapImage(BufferedImage image) { return wrapImage(new ArrayImage(image)); }
Example #21
Source File: DefaultMapManager.java From MapManager with MIT License | 4 votes |
@Override public void clearAllMapsFor(OfflinePlayer player) { for (MapWrapper wrapper : getMapsVisibleTo(player)) { wrapper.getController().removeViewer(player); } }
Example #22
Source File: MapContentUpdateEvent.java From MapManager with MIT License | 4 votes |
public MapContentUpdateEvent(MapWrapper mapWrapper, ArrayImage content) { this.mapWrapper = mapWrapper; this.content = content; this.sendContent = true; }
Example #23
Source File: MapContentUpdateEvent.java From MapManager with MIT License | 4 votes |
public MapContentUpdateEvent(MapWrapper mapWrapper, ArrayImage content, boolean async) { super(async); this.mapWrapper = mapWrapper; this.content = content; this.sendContent = true; }
Example #24
Source File: MapContentUpdateEvent.java From MapManager with MIT License | 4 votes |
/** * @return the updated {@link MapWrapper} */ public MapWrapper getMapWrapper() { return mapWrapper; }
Example #25
Source File: DefaultMapManager.java From MapManager with MIT License | 4 votes |
public MapWrapper wrapNewImage(ArrayImage image) { MapWrapper wrapper = new DefaultMapWrapper(image); MANAGED_MAPS.add(wrapper); return wrapper; }
Example #26
Source File: DefaultMapManager.java From MapManager with MIT License | 4 votes |
@Override public MapWrapper wrapMultiImage(ArrayImage[][] images) { return new MultiMapWrapper(images); }
Example #27
Source File: DefaultMapManager.java From MapManager with MIT License | 4 votes |
@Override public MapWrapper wrapMultiImage(ArrayImage image, int rows, int columns) { //Don't add the wrapper to the MANAGED_MAPS, since we're already registering all the single wrapped maps return new MultiMapWrapper(image, rows, columns); }
Example #28
Source File: DefaultMapManager.java From MapManager with MIT License | 4 votes |
@Override public MapWrapper wrapMultiImage(BufferedImage image, int rows, int columns) { //Don't add the wrapper to the MANAGED_MAPS, since we're already registering all the single wrapped maps return new MultiMapWrapper(image, rows, columns); }
Example #29
Source File: AnimatedFrame.java From AnimatedFrames with MIT License | 4 votes |
protected MapWrapper[] getWrappers() { return this.mapWrappers; }
Example #30
Source File: AnimatedFrame.java From AnimatedFrames with MIT License | 4 votes |
protected void setContent(MapWrapper[] wrappers, int[] delays) { this.length = wrappers.length; this.frameDelays = delays; this.currentFrame = Math.min(this.currentFrame, this.length - 1); this.mapWrappers = wrappers; }