Skip to content

Commit e246898

Browse files
committed
Updated Holograms API
1 parent 8d60024 commit e246898

17 files changed

+844
-272
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>CMI-API</groupId>
44
<artifactId>CMI-API</artifactId>
5-
<version>9.5.0.8</version>
5+
<version>9.6.4.1</version>
66

77
<dependencies>
88
<dependency>
99
<groupId>io.papermc.paper</groupId>
1010
<artifactId>paper-api</artifactId>
11-
<version>1.17.1-R0.1-SNAPSHOT</version>
11+
<version>1.20.1-R0.1-SNAPSHOT</version>
1212
<scope>provided</scope>
1313
<exclusions>
1414
<exclusion>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.Zrips.CMI.Modules.Display;
2+
3+
import org.bukkit.entity.Display.Billboard;
4+
5+
public enum CMIBillboard {
6+
VERTICAL, CENTER, FIXED, HORIZONTAL;
7+
8+
private Billboard bukkitBoard = null;
9+
10+
public Billboard getBillboard() {
11+
if (bukkitBoard != null)
12+
return bukkitBoard;
13+
return Billboard.valueOf(this.toString());
14+
}
15+
16+
public static CMIBillboard getByName(String name) {
17+
for (CMIBillboard one : CMIBillboard.values()) {
18+
if (one.toString().equalsIgnoreCase(name))
19+
return one;
20+
}
21+
return null;
22+
}
23+
24+
public CMIBillboard next() {
25+
switch (this) {
26+
case CENTER:
27+
return CMIBillboard.VERTICAL;
28+
case FIXED:
29+
return CMIBillboard.CENTER;
30+
case HORIZONTAL:
31+
return CMIBillboard.FIXED;
32+
case VERTICAL:
33+
return CMIBillboard.HORIZONTAL;
34+
default:
35+
return CMIBillboard.CENTER;
36+
}
37+
}
38+
}
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
package com.Zrips.CMI.Modules.Display;
2+
3+
import java.lang.reflect.Constructor;
4+
import java.lang.reflect.Field;
5+
import java.lang.reflect.Method;
6+
7+
import org.bukkit.Location;
8+
import org.bukkit.World;
9+
import org.bukkit.entity.Display.Billboard;
10+
import org.bukkit.entity.Display.Brightness;
11+
import org.bukkit.entity.Player;
12+
13+
import net.Zrips.CMILib.Container.CMINumber;
14+
15+
public class CMIDisplay {
16+
CMIDisplayTransform transform;
17+
18+
private static Constructor<?> TextDisplay;
19+
private static Constructor<?> ItemDisplay;
20+
private static Constructor<?> BlockDisplay;
21+
// private static Class<?> Interaction;
22+
private static Object textDisplayEntityType;
23+
private static Object itemDisplayEntityType;
24+
private static Object blockDisplayEntityType;
25+
// private static Object interactionEntityType;
26+
private static Class<?> worldClass;
27+
// private static Method locMethod;
28+
private static Constructor<?> PacketPlayOutSpawnEntity;
29+
private static Constructor<?> PacketPlayOutEntityMetadata;
30+
private static Constructor<?> PacketPlayOutEntityDestroy;
31+
32+
private static Method sendPacket;
33+
private static Method method1;
34+
private static Method method2;
35+
private static Field playerConnection;
36+
37+
static {
38+
39+
}
40+
41+
protected Location loc;
42+
protected org.bukkit.entity.Display display;
43+
protected Object d = null;
44+
private int id = 0;
45+
46+
public CMIDisplay(CMIDisplayType type, World world) {
47+
48+
}
49+
50+
51+
public void setWidth(double width) {
52+
53+
}
54+
55+
public void setHeight(double height) {
56+
57+
}
58+
59+
public void setInterpolationDuration(int duration) {
60+
display.setInterpolationDuration(duration);
61+
}
62+
63+
public int getInterpolationDuration() {
64+
return display.getInterpolationDuration();
65+
}
66+
67+
public void setInterpolationDelay(int delay) {
68+
display.setInterpolationDelay(delay);
69+
}
70+
71+
public int getInterpolationDelay() {
72+
return display.getInterpolationDelay();
73+
}
74+
75+
public void setLocation(Location loc) {
76+
// display.teleport(loc);
77+
this.loc = loc;
78+
}
79+
80+
public float getRange() {
81+
return display.getViewRange();
82+
}
83+
84+
public void setRange(int range) {
85+
display.setViewRange(range);
86+
}
87+
88+
public void setBrightness(int skyValue, int blockValue) {
89+
display.setBrightness(new Brightness(CMINumber.clamp(skyValue, 0, 15), CMINumber.clamp(blockValue, 0, 15)));
90+
}
91+
92+
public void setBillboard(Billboard billboard) {
93+
display.setBillboard(billboard);
94+
}
95+
96+
public Billboard getBillboard() {
97+
return display.getBillboard();
98+
}
99+
100+
public Location getLocation() {
101+
return loc;
102+
}
103+
104+
public Object getDisplay() {
105+
return d;
106+
}
107+
108+
109+
private static void sendPacket(Object connection, Object packet) {
110+
111+
}
112+
113+
public void show(Player player) {
114+
115+
}
116+
117+
118+
public void update(Player player) {
119+
120+
}
121+
122+
123+
public void destroy(Player player) {
124+
125+
}
126+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.Zrips.CMI.Modules.Display;
2+
3+
public class CMIDisplayTransform {
4+
5+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.Zrips.CMI.Modules.Display;
2+
3+
public enum CMIDisplayType {
4+
Text, Block, Item;
5+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.Zrips.CMI.Modules.Display;
2+
3+
import org.bukkit.Location;
4+
import org.bukkit.entity.ItemDisplay.ItemDisplayTransform;
5+
import org.bukkit.inventory.ItemStack;
6+
7+
import net.Zrips.CMILib.Items.CMIItemStack;
8+
9+
public class CMIItemDisplay extends CMIDisplay {
10+
11+
private org.bukkit.entity.ItemDisplay td;
12+
13+
public CMIItemDisplay(Location loc) {
14+
super(CMIDisplayType.Item, loc.getWorld());
15+
}
16+
17+
public ItemStack getItemStack() {
18+
return td.getItemStack();
19+
}
20+
21+
public void setItemStack(CMIItemStack item) {
22+
setItemStack(item.getItemStack().clone());
23+
}
24+
25+
public void setItemStack(ItemStack item) {
26+
td.setItemStack(item);
27+
}
28+
29+
public void setItemDisplayTransform(ItemDisplayTransform itemTransform) {
30+
this.td.setItemDisplayTransform(itemTransform);
31+
}
32+
33+
public ItemDisplayTransform getItemDisplayTransform() {
34+
return this.td.getItemDisplayTransform();
35+
}
36+
37+
public void setFacing(double pitchRadians, double yawRadians) {
38+
}
39+
40+
public void setDepth(double depth) {
41+
}
42+
43+
public void setScale(double s) {
44+
}
45+
46+
public float getDisplayHeight() {
47+
return td.getDisplayHeight();
48+
}
49+
50+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package com.Zrips.CMI.Modules.Display;
2+
3+
import org.bukkit.entity.TextDisplay.TextAlignment;
4+
5+
public enum CMITextAlignment {
6+
LEFT, CENTER, RIGHT;
7+
8+
private TextAlignment bukkitBoard = null;
9+
10+
public TextAlignment getTextAlignment() {
11+
if (bukkitBoard != null)
12+
return bukkitBoard;
13+
return TextAlignment.valueOf(this.toString());
14+
}
15+
16+
public static CMITextAlignment getByName(String name) {
17+
return null;
18+
}
19+
20+
public CMITextAlignment next() {
21+
switch (this) {
22+
case CENTER:
23+
return CMITextAlignment.RIGHT;
24+
case LEFT:
25+
return CMITextAlignment.CENTER;
26+
case RIGHT:
27+
return CMITextAlignment.LEFT;
28+
default:
29+
return CMITextAlignment.CENTER;
30+
}
31+
}
32+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
package com.Zrips.CMI.Modules.Display;
2+
3+
import java.util.List;
4+
5+
import org.bukkit.Color;
6+
import org.bukkit.Location;
7+
import org.bukkit.entity.TextDisplay.TextAlignment;
8+
9+
import net.Zrips.CMILib.Colors.CMIChatColor;
10+
11+
public class CMITextDisplay extends CMIDisplay {
12+
13+
private org.bukkit.entity.TextDisplay td;
14+
15+
public CMITextDisplay(Location loc) {
16+
super(CMIDisplayType.Text, loc.getWorld());
17+
}
18+
19+
public String getText() {
20+
return td.getText();
21+
}
22+
23+
public void setText(String text) {
24+
this.td.setText(CMIChatColor.translate(text));
25+
}
26+
27+
public void setText(List<String> text) {
28+
}
29+
30+
public int getLineWidth() {
31+
return td.getLineWidth();
32+
}
33+
34+
public void setLineWidth(int lineWidth) {
35+
td.setLineWidth(lineWidth);
36+
}
37+
38+
public byte getTextOpacity() {
39+
return td.getTextOpacity();
40+
}
41+
42+
public void setTextOpacity(byte textOpacity) {
43+
td.setTextOpacity(textOpacity);
44+
}
45+
46+
public TextAlignment getAligment() {
47+
return td.getAlignment();
48+
}
49+
50+
public void setAligment(TextAlignment aligment) {
51+
td.setAlignment(aligment);
52+
}
53+
54+
public void setDefaultBackground(boolean show) {
55+
this.td.setDefaultBackground(show);
56+
}
57+
58+
public boolean isDefaultBackground() {
59+
return this.td.isDefaultBackground();
60+
}
61+
62+
@SuppressWarnings("deprecation")
63+
public void setBackgroundColor(Color color) {
64+
this.td.setBackgroundColor(color);
65+
}
66+
67+
@SuppressWarnings("deprecation")
68+
public void setBackgroundColor(CMIChatColor color) {
69+
this.td.setBackgroundColor(color.getRGBColor());
70+
}
71+
72+
@SuppressWarnings("deprecation")
73+
public Color getBackgroundColor() {
74+
return this.td.getBackgroundColor();
75+
}
76+
77+
public void setFacing(double pitchDegrees, double yawDegrees) {
78+
}
79+
80+
public float getDisplayHeight() {
81+
return td.getDisplayHeight();
82+
}
83+
84+
public void setShadowed(boolean shadow) {
85+
td.setShadowed(shadow);
86+
}
87+
88+
public boolean isShadowed() {
89+
return td.isShadowed();
90+
}
91+
92+
public void setSeeThrough(boolean seeThrough) {
93+
td.setSeeThrough(seeThrough);
94+
}
95+
96+
public boolean isSeeThrough() {
97+
return td.isSeeThrough();
98+
}
99+
100+
}

0 commit comments

Comments
 (0)