Skip to content

Commit

Permalink
clean some module code dup
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Feb 10, 2019
1 parent 43b2c96 commit 3b45404
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 722 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.UUID;

public abstract class NMSHandler {

Expand Down Expand Up @@ -144,8 +147,32 @@ public static Vector fixOffset(Vector offset, double yaw, double pitch) {
return offsetPatched;
}


public HashMap<UUID, UUID> attachmentsA = new HashMap<>(); // Key follows value
public HashMap<UUID, UUID> attachments2 = new HashMap<>(); // Value follows key
public HashMap<UUID, Vector> attachmentOffsets = new HashMap<>();
public HashSet<UUID> attachmentRotations = new HashSet<>();
public HashMap<UUID, Vector> visiblePositions = new HashMap<>();

public void forceAttachMove(Entity a, Entity b, Vector offset, boolean matchRotation) {
throw new RuntimeException("Unsupported forceAttachMove!");
if (!getVersion().isAtLeast(NMSVersion.v1_12_R1)) {
throw new RuntimeException("Unsupported forceAttachMove!");
}
if (attachmentsA.containsKey(a.getUniqueId())) {
attachments2.remove(attachmentsA.get(a.getUniqueId()));
attachmentsA.remove(a.getUniqueId());
attachmentOffsets.remove(a.getUniqueId());
attachmentRotations.remove(a.getUniqueId());
}
if (b == null) {
return;
}
attachmentsA.put(a.getUniqueId(), b.getUniqueId());
attachments2.put(b.getUniqueId(), a.getUniqueId());
attachmentOffsets.put(a.getUniqueId(), offset);
if (matchRotation) {
attachmentRotations.add(a.getUniqueId());
}
}

public Boolean getSwitchState(Block b) {
Expand Down
Loading

0 comments on commit 3b45404

Please sign in to comment.