MCPcopy Create free account
hub / github.com/Neop/mudmap2 / canPaste

Method canPaste

src/main/java/mudmap2/CopyPaste.java:101–120  ·  view source on GitHub ↗

Checks whether the places can be pasted relatively to x,y on layer @param x @param y @param layer @return

(final int x, final int y, final Layer layer)

Source from the content-addressed store, hash-verified

99 * @return
100 */
101 public static boolean canPaste(final int x, final int y, final Layer layer) {
102 if (copyPlaces == null || copyPlaces.isEmpty()) {
103 return false;
104 }
105 if (copyPlaceLocations != null && layer != null) {
106 for (final Pair<Integer, Integer> coordinate : copyPlaceLocations) {
107 final LayerElement collision = layer.get(x + coordinate.first, y + coordinate.second);
108 if (collision != null) {
109 if (copyMode) {
110 return false;
111 } else { // if places are moved: checkif the colliding place is in the movied group, too
112 if (!copyPlaces.contains(collision)) {
113 return false;
114 }
115 }
116 }
117 }
118 }
119 return true;
120 }
121
122 /**
123 * Pastes the cut / copied places to layer, if possible

Callers 3

pasteMethod · 0.95
ContextMenuMethod · 0.80
keyPressedMethod · 0.80

Calls 3

isEmptyMethod · 0.65
getMethod · 0.65
containsMethod · 0.65

Tested by

no test coverage detected