Skip to content
This repository was archived by the owner on May 22, 2023. It is now read-only.

Commit ace0778

Browse files
authored
Merge pull request #4 from Sentropic/1.96
Additions: - Added Armor Stand Mechanic - Added Armor Stand Pose Mechanic - Added Armor Mechanic Changes: - Now particle effects work per entity (now possible to have more of each at the same time) - Moved use-custommodeldata option in Skill Bar config to GUI section (please go and set it to true again, sorry :c) - tool.yml now supports CustomModelData - Added separate config option for CustomModelData usage in skill mechanics, in Skill section - Item Mechanic and Item Projectile Mechanic now support CustomModelData option - Fixed durability methods causing error on plugin load under 1.13 API changes: - Optimized durability usage - Added missing dependencies to repo, so the project can now be compiled by Jitpack - The fake EntityDamageByEntity used for targeting is now identifiable by other plugins (check "event instanceof FakeEntityDamageByEntityEvent")
2 parents 7ab6cf8 + e882844 commit ace0778

27 files changed

+844
-173
lines changed

editor/js/component.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ var Condition = {
104104
* Available mechanic component data
105105
*/
106106
var Mechanic = {
107+
ARMOR: { name: 'Armor', container: false, construct: MechanicArmor },
108+
ARMOR_STAND: { name: 'Armor Stand', container: true, construct: MechanicArmorStand },
109+
ARMOR_STAND_POSE: { name: 'Armor Stand Pose', container: false, construct: MechanicArmorStandPose },
107110
ATTRIBUTE: { name: 'Attribute', container: false, construct: MechanicAttribute },
108111
BLOCK: { name: 'Block', container: false, construct: MechanicBlock },
109112
BUFF: { name: 'Buff', container: false, construct: MechanicBuff },
@@ -1517,6 +1520,114 @@ function MechanicAttribute()
15171520
);
15181521
}
15191522

1523+
extend('MechanicArmor', 'Component');
1524+
function MechanicArmor()
1525+
{
1526+
this.super('Armor', Type.MECHANIC, false);
1527+
1528+
this.description = 'Sets the specified armor slot of the target to the item defined by the settings';
1529+
1530+
this.data.push(new ListValue('Slot', 'slot', [ 'Hand', 'Off Hand', 'Feet', 'Legs', 'Chest', 'Head' ], 'Hand')
1531+
.setTooltip('The slot number to set the item to')
1532+
);
1533+
this.data.push(new ListValue('Material', 'material', getMaterials, 'Arrow')
1534+
.setTooltip('The type of item to set')
1535+
);
1536+
this.data.push(new IntValue('Amount', 'amount', 1)
1537+
.setTooltip('The quantity of the item to set')
1538+
);
1539+
this.data.push(new IntValue('Durability', 'durability', 0)
1540+
.setTooltip('The durability value of the item to set')
1541+
);
1542+
this.data.push(new IntValue('Data', 'data', 0)
1543+
.setTooltip('The data value or the CustomModelData (1.14+ only) to apply to the item')
1544+
);
1545+
this.data.push(new ListValue('Custom', 'custom', [ 'True', 'False' ], 'False')
1546+
.setTooltip('Whether or not to apply a custom name/lore to the item')
1547+
);
1548+
this.data.push(new StringValue('Name', 'name', 'Name').requireValue('custom', [ 'True' ])
1549+
.setTooltip('The name of the item')
1550+
);
1551+
this.data.push(new StringListValue('Lore', 'lore', []).requireValue('custom', [ 'True' ])
1552+
.setTooltip('The lore text for the item (the text below the name)')
1553+
);
1554+
this.data.push(new ListValue('Overwrite', 'overwrite', [ 'True', 'False' ], 'False')
1555+
.setTooltip('USE WITH CAUTION. Whether or not to overwrite an existing item in the slot. If true, will permanently delete the existing iem')
1556+
);
1557+
}
1558+
1559+
extend('MechanicArmorStand', 'Component');
1560+
function MechanicArmorStand()
1561+
{
1562+
this.super('Armor Stand', Type.MECHANIC, true);
1563+
1564+
this.description = 'Summons an armor stand that can be used as a marker or for item display (check Armor Mechanic for latter). Applies child components on the armor stand';
1565+
1566+
this.data.push(new StringValue('Armor Stand Key', 'key', 'default')
1567+
.setTooltip('The key to refer to the armorstand by. Only one armorstand of each key can be active per target at the time')
1568+
);
1569+
this.data.push(new AttributeValue('Duration', 'duration', 5, 0)
1570+
.setTooltip('How long the armorstand lasts before being deleted')
1571+
);
1572+
this.data.push(new StringValue('Name', 'name', 'Armor Stand')
1573+
.setTooltip('The name the armor stand displays')
1574+
);
1575+
this.data.push(new ListValue('Name visible', 'name-visible', [ 'True', 'False' ], 'False')
1576+
.setTooltip('Whether or not the armorstand\'s name should be visible from afar')
1577+
);
1578+
this.data.push(new ListValue('Follow target', 'follow', [ 'True', 'False' ], 'False')
1579+
.setTooltip('Whether or not the armorstand should follow the target')
1580+
);
1581+
this.data.push(new ListValue('Apply gravity', 'gravity', [ 'True', 'False' ], 'True')
1582+
.setTooltip('Whether or not the armorstand should be affected by gravity')
1583+
);
1584+
this.data.push(new ListValue('Small', 'tiny', [ 'True', 'False' ], 'False')
1585+
.setTooltip('Whether or not the armorstand should be small')
1586+
);
1587+
this.data.push(new ListValue('Show arms', 'arms', [ 'True', 'False' ], 'False')
1588+
.setTooltip('Whether or not the armorstand should display its arms')
1589+
);
1590+
this.data.push(new ListValue('Show base plate', 'base', [ 'True', 'False' ], 'False')
1591+
.setTooltip('Whether or not the armorstand should display its base plate')
1592+
);
1593+
this.data.push(new ListValue('Visible', 'visible', [ 'True', 'False' ], 'True')
1594+
.setTooltip('Whether or not the armorstand should be visible')
1595+
);
1596+
this.data.push(new ListValue('Marker', 'marker', [ 'True', 'False' ], 'True')
1597+
.setTooltip('Setting this to true will remove the armor stand\'s hitbox')
1598+
);
1599+
this.data.push(new AttributeValue('Forward Offset', 'forward', 0, 0)
1600+
.setTooltip('How far forward in front of the target the armorstand should be in blocks. A negative value will put it behind.')
1601+
);
1602+
this.data.push(new AttributeValue('Upward Offset', 'upward', 0, 0)
1603+
.setTooltip('How far above the target the armorstand should be in blocks. A negative value will put it below.')
1604+
);
1605+
this.data.push(new AttributeValue('Right Offset', 'right', 0, 0)
1606+
.setTooltip('How far to the right the armorstand should be of the target. A negative value will put it to the left.')
1607+
);
1608+
}
1609+
1610+
extend('MechanicArmorStandPose', 'Component');
1611+
function MechanicArmorStandPose()
1612+
{
1613+
this.super('Armor Stand Pose', Type.MECHANIC, false);
1614+
1615+
this.description = 'Sets the pose of an armor stand target. Values should be in the format x,y,z where rotations are in degrees. Example: 0.0,0.0,0.0';
1616+
1617+
this.data.push(new StringValue('Head', 'head', '').setTooltip('The pose values of the head. Leave empty if should be ignored')
1618+
);
1619+
this.data.push(new StringValue('Body', 'body', '').setTooltip('The pose values of the body. Leave empty if should be ignored')
1620+
);
1621+
this.data.push(new StringValue('Left Arm', 'left-arm', '').setTooltip('The pose values of the left arm. Leave empty if should be ignored')
1622+
);
1623+
this.data.push(new StringValue('Right Arm', 'right-arm', '').setTooltip('The pose values of the right arm. Leave empty if should be ignored')
1624+
);
1625+
this.data.push(new StringValue('Left Leg', 'left-leg', '').setTooltip('The pose values of the left leg. Leave empty if should be ignored')
1626+
);
1627+
this.data.push(new StringValue('Right Leg', 'right-leg', '').setTooltip('The pose values of the right leg. Leave empty if should be ignored')
1628+
);
1629+
}
1630+
15201631
extend('MechanicBlock', 'Component');
15211632
function MechanicBlock()
15221633
{

lib/MCCore-1.67.jar

242 KB
Binary file not shown.

lib/Parties-1.13.jar

31.6 KB
Binary file not shown.

lib/RPGInventory-1.0.6.jar

119 KB
Binary file not shown.

pom.xml

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.sucy.skill</groupId>
88
<artifactId>SkillAPI</artifactId>
9-
<version>1.95</version>
9+
<version>s1.96</version>
1010
<packaging>jar</packaging>
1111

1212
<name>SkillAPI</name>
@@ -77,6 +77,10 @@
7777
<id>md_5-snapshots</id>
7878
<url>https://repo.md-5.net/content/repositories/snapshots/</url>
7979
</repository>
80+
<repository>
81+
<id>md_5-public</id>
82+
<url>http://repo.md-5.net/content/groups/public/</url>
83+
</repository>
8084
<repository>
8185
<id>nexus</id>
8286
<name>Lumine Releases</name>
@@ -97,6 +101,11 @@
97101
</repositories>
98102

99103
<dependencies>
104+
<dependency>
105+
<groupId>org.apache.maven.plugins</groupId>
106+
<artifactId>maven-install-plugin</artifactId>
107+
<version>3.0.0-M1</version>
108+
</dependency>
100109
<dependency>
101110
<groupId>org.spigotmc</groupId>
102111
<artifactId>spigot-api</artifactId>
@@ -107,13 +116,15 @@
107116
<groupId>com.rit.sucy</groupId>
108117
<artifactId>mccore</artifactId>
109118
<version>1.67</version>
110-
<scope>provided</scope>
119+
<scope>system</scope>
120+
<systemPath>${basedir}/lib/MCCore-1.67.jar</systemPath>
111121
</dependency>
112122
<dependency>
113123
<groupId>com.sucy.party</groupId>
114124
<artifactId>parties</artifactId>
115125
<version>1.13</version>
116-
<scope>provided</scope>
126+
<scope>system</scope>
127+
<systemPath>${basedir}/lib/Parties-1.13.jar</systemPath>
117128
</dependency>
118129
<dependency>
119130
<groupId>io.netty</groupId>
@@ -125,12 +136,13 @@
125136
<groupId>ru.endlesscode</groupId>
126137
<artifactId>rpginventory</artifactId>
127138
<version>1.0.6</version>
128-
<scope>provided</scope>
139+
<scope>system</scope>
140+
<systemPath>${basedir}/lib/RPGInventory-1.0.6.jar</systemPath>
129141
</dependency>
130142
<dependency>
131143
<groupId>LibsDisguises</groupId>
132144
<artifactId>LibsDisguises</artifactId>
133-
<version>10.0.16-SNAPSHOT-b722</version>
145+
<version>10.0.19</version>
134146
<scope>provided</scope>
135147
</dependency>
136148
<dependency>
@@ -142,10 +154,17 @@
142154
<dependency>
143155
<groupId>net.md-5</groupId>
144156
<artifactId>bungeecord-api</artifactId>
145-
<version>1.16-R0.2-SNAPSHOT</version>
157+
<version>1.16-R0.4-SNAPSHOT</version>
146158
<type>jar</type>
147159
<scope>provided</scope>
148160
</dependency>
161+
<dependency>
162+
<groupId>net.md-5</groupId>
163+
<artifactId>bungeecord-api</artifactId>
164+
<version>1.16-R0.4-SNAPSHOT</version>
165+
<type>javadoc</type>
166+
<scope>provided</scope>
167+
</dependency>
149168
<dependency>
150169
<groupId>fr.neatmonster</groupId>
151170
<artifactId>nocheatplus</artifactId>

src/main/java/com/sucy/skill/SkillAPI.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.rit.sucy.config.CommentedLanguageConfig;
2929
import com.rit.sucy.version.VersionManager;
3030
import com.rit.sucy.version.VersionPlayer;
31+
import com.sucy.skill.api.armorstand.ArmorStandManager;
3132
import com.sucy.skill.api.classes.RPGClass;
3233
import com.sucy.skill.api.particle.EffectManager;
3334
import com.sucy.skill.api.particle.Particle;
@@ -111,9 +112,11 @@ public void onEnable() {
111112
mainThread = new MainThread();
112113
Particle.init();
113114
EffectManager.init();
115+
ArmorStandManager.init();
114116

115117
// Load settings
116118
settings = new Settings(this);
119+
settings.reload();
117120
language = new CommentedLanguageConfig(this, "language");
118121
language.checkDefaults();
119122
language.trim();
@@ -220,6 +223,7 @@ public void onDisable() {
220223

221224
GUITool.cleanUp();
222225
EffectManager.cleanUp();
226+
ArmorStandManager.cleanUp();
223227

224228
mainThread.disable();
225229
mainThread = null;
Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
package com.sucy.skill.api;
22

3-
import org.bukkit.entity.LivingEntity;
4-
import org.bukkit.entity.Player;
3+
import org.bukkit.Bukkit;
4+
import org.bukkit.OfflinePlayer;
5+
import org.bukkit.entity.*;
6+
import org.bukkit.event.entity.EntityDamageByEntityEvent;
7+
import org.bukkit.event.entity.EntityDamageEvent;
8+
import org.jetbrains.annotations.NotNull;
59

610
/**
711
* SkillAPI © 2018
@@ -11,4 +15,27 @@ public interface CombatProtection {
1115
boolean canAttack(final Player attacker, final Player defender);
1216
boolean canAttack(final Player attacker, final LivingEntity defender);
1317
boolean canAttack(final LivingEntity attacker, final LivingEntity defender);
18+
19+
static boolean canAttack(LivingEntity attacker, LivingEntity target, boolean passiveAlly) {
20+
if (attacker == target) {
21+
return false;
22+
} else {
23+
if (target instanceof Tameable) {
24+
Tameable entity = (Tameable)target;
25+
if (entity.isTamed() && entity.getOwner() instanceof OfflinePlayer) {
26+
OfflinePlayer owner = (OfflinePlayer)entity.getOwner();
27+
if (owner.isOnline()) {
28+
return canAttack(attacker, owner.getPlayer(), false);
29+
}
30+
}
31+
} else if (passiveAlly && target instanceof Animals) {
32+
return false;
33+
}
34+
35+
DefaultCombatProtection.FakeEntityDamageByEntityEvent event = new DefaultCombatProtection.FakeEntityDamageByEntityEvent(attacker, target, EntityDamageEvent.DamageCause.CUSTOM, 1.0D);
36+
Bukkit.getPluginManager().callEvent(event);
37+
return !event.isCancelled();
38+
}
39+
}
40+
1441
}

src/main/java/com/sucy/skill/api/DefaultCombatProtection.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,11 @@
33
import com.rit.sucy.player.Protection;
44
import com.sucy.skill.hook.NoCheatHook;
55
import com.sucy.skill.hook.PluginChecker;
6+
import org.bukkit.entity.Entity;
67
import org.bukkit.entity.LivingEntity;
78
import org.bukkit.entity.Player;
9+
import org.bukkit.event.entity.EntityDamageByEntityEvent;
10+
import org.jetbrains.annotations.NotNull;
811

912
/**
1013
* SkillAPI © 2018
@@ -29,8 +32,15 @@ public boolean canAttack(final LivingEntity attacker, final LivingEntity defende
2932
NoCheatHook.exempt(player);
3033
canAttack = Protection.canAttack(attacker, defender);
3134
NoCheatHook.unexempt(player);
32-
} else { canAttack = Protection.canAttack(attacker, defender); }
35+
} else { canAttack = CombatProtection.canAttack(attacker, defender, false); }
3336

3437
return canAttack;
3538
}
39+
40+
public static class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
41+
42+
public FakeEntityDamageByEntityEvent(@NotNull Entity damager, @NotNull Entity damagee, @NotNull DamageCause cause, double damage) {
43+
super(damager, damagee, cause, damage);
44+
}
45+
}
3646
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package com.sucy.skill.api.armorstand;
2+
3+
import org.bukkit.entity.LivingEntity;
4+
5+
import java.util.HashMap;
6+
import java.util.Iterator;
7+
8+
public class ArmorStandData {
9+
private final HashMap<String, ArmorStandInstance> armorStands = new HashMap<>();
10+
private final LivingEntity target;
11+
12+
/**
13+
* @param target target of the armor stands
14+
*/
15+
public ArmorStandData(LivingEntity target)
16+
{
17+
this.target = target;
18+
}
19+
20+
/**
21+
* @return true if should keep the data, false otherwise
22+
*/
23+
public boolean isValid() {
24+
return armorStands.size() > 0 && target.isValid();
25+
}
26+
27+
/**
28+
* Fetches an active armor stand by key
29+
*
30+
* @param key armor stand key
31+
*
32+
* @return active armor stand or null if not found
33+
*/
34+
public ArmorStandInstance getArmorStands(String key) { return armorStands.get(key); }
35+
36+
public void register(ArmorStandInstance armorStand, String key) {
37+
ArmorStandInstance oldArmorStand = armorStands.put(key, armorStand);
38+
if (oldArmorStand != null) oldArmorStand.remove();
39+
}
40+
41+
/**
42+
* Ticks each armor stand for the target
43+
*/
44+
public void tick() {
45+
Iterator<ArmorStandInstance> iterator = armorStands.values().iterator();
46+
while (iterator.hasNext())
47+
{
48+
ArmorStandInstance armorStand = iterator.next();
49+
if (armorStand.isValid()) {
50+
armorStand.tick();
51+
}
52+
else {
53+
armorStand.remove();
54+
iterator.remove();
55+
}
56+
}
57+
}
58+
59+
/**
60+
* Removes and unregisters all armor stands for this target
61+
*/
62+
public void remove() {
63+
armorStands.values().forEach(ArmorStandInstance::remove);
64+
armorStands.clear();
65+
}
66+
}

0 commit comments

Comments
 (0)