-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "Interaction" entity to entity_spec() and set_entity_spec() (#1363)
- Loading branch information
1 parent
f676632
commit e31eb47
Showing
4 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCInteraction.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,63 @@ | ||
package com.laytonsmith.abstraction.bukkit.entities; | ||
|
||
import com.laytonsmith.abstraction.entities.MCInteraction; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.Interaction; | ||
import org.bukkit.entity.Interaction.PreviousInteraction; | ||
|
||
public class BukkitMCInteraction extends BukkitMCEntity implements MCInteraction { | ||
Interaction interaction; | ||
|
||
public BukkitMCInteraction(Entity i) { | ||
super(i); | ||
this.interaction = (Interaction) i; | ||
} | ||
|
||
@Override | ||
public double getWidth() { | ||
return interaction.getInteractionWidth(); | ||
} | ||
|
||
@Override | ||
public void setWidth(double width) { | ||
interaction.setInteractionWidth((float) width); | ||
} | ||
|
||
@Override | ||
public double getHeight() { | ||
return interaction.getInteractionHeight(); | ||
} | ||
|
||
@Override | ||
public void setHeight(double height) { | ||
interaction.setInteractionHeight((float) height); | ||
} | ||
|
||
@Override | ||
public boolean isResponsive() { | ||
return interaction.isResponsive(); | ||
} | ||
|
||
@Override | ||
public void setResponsive(boolean response) { | ||
interaction.setResponsive(response); | ||
} | ||
|
||
@Override | ||
public MCPreviousInteraction getLastAttack() { | ||
PreviousInteraction pi = interaction.getLastAttack(); | ||
if(pi == null) { | ||
return null; | ||
} | ||
return new MCPreviousInteraction(pi.getPlayer().getUniqueId(), pi.getTimestamp()); | ||
} | ||
|
||
@Override | ||
public MCPreviousInteraction getLastInteraction() { | ||
PreviousInteraction pi = interaction.getLastInteraction(); | ||
if(pi == null) { | ||
return null; | ||
} | ||
return new MCPreviousInteraction(pi.getPlayer().getUniqueId(), pi.getTimestamp()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/com/laytonsmith/abstraction/entities/MCInteraction.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,35 @@ | ||
package com.laytonsmith.abstraction.entities; | ||
|
||
import com.laytonsmith.abstraction.MCEntity; | ||
|
||
import java.util.UUID; | ||
|
||
public interface MCInteraction extends MCEntity { | ||
double getWidth(); | ||
void setWidth(double width); | ||
double getHeight(); | ||
void setHeight(double height); | ||
boolean isResponsive(); | ||
void setResponsive(boolean response); | ||
MCPreviousInteraction getLastAttack(); | ||
MCPreviousInteraction getLastInteraction(); | ||
|
||
class MCPreviousInteraction { | ||
private final UUID uuid; | ||
private final long timestamp; | ||
|
||
public MCPreviousInteraction(UUID uuid, long timestamp) { | ||
this.uuid = uuid; | ||
this.timestamp = timestamp; | ||
} | ||
|
||
public UUID getUuid() { | ||
return uuid; | ||
} | ||
|
||
public long getTimestamp() { | ||
return timestamp; | ||
} | ||
} | ||
|
||
} |
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