-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from DarkKnights22/edit-multiple-displays
Add the ability to edit multiple displays at a time
- Loading branch information
Showing
7 changed files
with
566 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/goldenshadow/displayentityeditor/EditingHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package goldenshadow.displayentityeditor; | ||
|
||
import org.bukkit.entity.Display; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.*; | ||
|
||
public class EditingHandler { | ||
|
||
/** | ||
* The map of player UUIDs to the displays they are currently editing. | ||
*/ | ||
private final Map<UUID, Collection<Display>> editingDisplaysMap = new HashMap<>(); | ||
|
||
/** | ||
* @param player The player that should be editing the displays. | ||
* @param displays The collection of displays the player should be editing. | ||
*/ | ||
public void setEditingDisplays(Player player, Collection<Display> displays) { | ||
editingDisplaysMap.put(player.getUniqueId(), displays); | ||
} | ||
|
||
/** | ||
* @param player The player that should no longer be editing any displays. | ||
*/ | ||
public void removeEditingDisplays(Player player) { | ||
editingDisplaysMap.remove(player.getUniqueId()); | ||
} | ||
|
||
/** | ||
* @param player The player that is editing display(s). | ||
* @param lockSearchToggle Whether the searched entities should be locked/unlocked. | ||
* @return The collection of displays the player is currently editing. | ||
* If the player is not editing any displays, the nearest display entity to the player's location is returned | ||
* as a singleton collection. | ||
* @see Utilities#getNearestDisplayEntity(org.bukkit.Location, boolean) | ||
*/ | ||
public Collection<Display> getEditingDisplays(Player player, boolean lockSearchToggle) { | ||
Collection<Display> displays = editingDisplaysMap.get(player.getUniqueId()); | ||
|
||
if (displays == null) { | ||
return Collections.singleton(Utilities.getNearestDisplayEntity(player.getLocation(), lockSearchToggle)); | ||
} | ||
|
||
return displays; | ||
} | ||
|
||
} |
815 changes: 483 additions & 332 deletions
815
src/main/java/goldenshadow/displayentityeditor/events/Interact.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters