Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 187a95b

Browse files
committed
bug fixes
* fix earthkick bug * fix plantarmor bug * add new flight passive
1 parent 1b71802 commit 187a95b

File tree

7 files changed

+204
-10
lines changed

7 files changed

+204
-10
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<modelVersion>4.0.0</modelVersion>
33
<groupId>me.simplicitee</groupId>
44
<artifactId>projectaddons</artifactId>
5-
<version>1.1.0</version>
5+
<version>1.1.1</version>
66
<name>ProjectAddons</name>
77

88
<repositories>
@@ -23,7 +23,7 @@
2323
<dependency>
2424
<groupId>com.projectkorra</groupId>
2525
<artifactId>projectkorra</artifactId>
26-
<version>1.8.9</version>
26+
<version>1.9.0</version>
2727
<scope>provided</scope>
2828
</dependency>
2929
</dependencies>

src/me/simplicitee/project/addons/MainListener.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.Map;
55

66
import org.bukkit.ChatColor;
7+
import org.bukkit.GameMode;
78
import org.bukkit.Sound;
89
import org.bukkit.entity.Entity;
910
import org.bukkit.entity.FallingBlock;
@@ -27,6 +28,7 @@
2728
import org.bukkit.event.player.PlayerJoinEvent;
2829
import org.bukkit.event.player.PlayerQuitEvent;
2930
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
31+
import org.bukkit.event.player.PlayerToggleFlightEvent;
3032
import org.bukkit.event.player.PlayerToggleSneakEvent;
3133
import org.bukkit.inventory.EquipmentSlot;
3234
import org.bukkit.potion.PotionEffectType;
@@ -50,6 +52,7 @@
5052
import com.projectkorra.projectkorra.util.ClickType;
5153

5254
import me.simplicitee.project.addons.ability.air.Deafen;
55+
import me.simplicitee.project.addons.ability.air.FlightPassive;
5356
import me.simplicitee.project.addons.ability.air.GaleGust;
5457
import me.simplicitee.project.addons.ability.air.SonicWave;
5558
import me.simplicitee.project.addons.ability.air.VocalMimicry;
@@ -276,7 +279,9 @@ public void onSneak(PlayerToggleSneakEvent event) {
276279
@EventHandler
277280
public void onAbilityStart(AbilityStartEvent event) {
278281
if (BloodGrip.isBloodbent(event.getAbility().getPlayer())) {
279-
event.setCancelled(ProjectAddons.instance.getConfig().getStringList("Abilities.Water.BloodGrip.BasicAbilities").contains(event.getAbility().getName()));
282+
event.setCancelled(!ProjectAddons.instance.getConfig().getStringList("Abilities.Water.BloodGrip.BasicAbilities").contains(event.getAbility().getName()));
283+
} else if (CoreAbility.hasAbility(event.getAbility().getPlayer(), FlightPassive.class)) {
284+
event.setCancelled(ProjectAddons.instance.getConfig().getStringList("Passives.Air.Flying.AbilityBlacklist").contains(event.getAbility().getName()));
280285
}
281286
}
282287

@@ -634,6 +639,25 @@ public void onSlotChangeEvent(PlayerItemHeldEvent event) {
634639
plugin.getBoardManager().update(player, event.getNewSlot());
635640
}
636641

642+
@EventHandler
643+
public void onFlightToggle(PlayerToggleFlightEvent event) {
644+
Player player = event.getPlayer();
645+
if (!CoreAbility.hasAbility(player, FlightPassive.class)) {
646+
return;
647+
}
648+
649+
FlightPassive passive = CoreAbility.getAbility(player, FlightPassive.class);
650+
651+
if (player.getGameMode() == GameMode.CREATIVE && player.getGameMode() == GameMode.SPECTATOR) {
652+
return;
653+
} else if (player.getInventory().getContents().length != 0) {
654+
event.setCancelled(true);
655+
return;
656+
}
657+
658+
passive.fly(event.isFlying());
659+
}
660+
637661
@EventHandler
638662
public void onOffhandToggle(PlayerSwapHandItemsEvent event) {
639663
if (event.isCancelled()) {
@@ -647,6 +671,14 @@ public void onOffhandToggle(PlayerSwapHandItemsEvent event) {
647671
return;
648672
}
649673

674+
if (CoreAbility.hasAbility(player, FlightPassive.class)) {
675+
FlightPassive passive = CoreAbility.getAbility(player, FlightPassive.class);
676+
if (passive.isActive()) {
677+
passive.toggleGlide();
678+
return;
679+
}
680+
}
681+
650682
if (player.hasPermission("bending.offhandswap")) {
651683
if (MultiAbilityManager.hasMultiAbilityBound(player)) {
652684
return;

src/me/simplicitee/project/addons/ProjectAddons.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ private void setupConfig() {
130130
c.addDefault("Abilities.Avatar.EnergyBeam.EasterEgg", true);
131131

132132
// ---- Airbending ----
133+
// Flying
134+
c.addDefault("Passives.Air.Flying.Enabled", true);
135+
c.addDefault("Passives.Air.Flying.FlySpeed", 0.05);
136+
c.addDefault("Passives.Air.Flying.Glide.StartSpeed", 0.8);
137+
c.addDefault("Passives.Air.Flying.Glide.MaxSpeed", 1.6);
138+
c.addDefault("Passives.Air.Flying.Acceleration", 0.001);
133139

134140
// Deafen
135141
c.addDefault("Abilities.Air.Deafen.Enabled", true);
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
package me.simplicitee.project.addons.ability.air;
2+
3+
import org.bukkit.Location;
4+
import org.bukkit.entity.Player;
5+
6+
import com.projectkorra.projectkorra.ability.AddonAbility;
7+
import com.projectkorra.projectkorra.ability.FlightAbility;
8+
import com.projectkorra.projectkorra.ability.PassiveAbility;
9+
10+
import me.simplicitee.project.addons.ProjectAddons;
11+
12+
public class FlightPassive extends FlightAbility implements AddonAbility, PassiveAbility {
13+
14+
private boolean toggled = false, active = false;
15+
private float original = 0.8f, speed, flySpeed, startSpeed, maxSpeed, acceleration;
16+
17+
public FlightPassive(Player player) {
18+
super(player);
19+
20+
flySpeed = (float) ProjectAddons.instance.getConfig().getDouble("Passives.Air.Flying.FlySpeed");
21+
speed = startSpeed = (float) ProjectAddons.instance.getConfig().getDouble("Passives.Air.Flying.Glide.StartSpeed");
22+
maxSpeed = (float) ProjectAddons.instance.getConfig().getDouble("Passives.Air.Flying.Glide.MaxSpeed");
23+
acceleration = (float) ProjectAddons.instance.getConfig().getDouble("Passives.Air.Flying.Acceleration");
24+
}
25+
26+
@Override
27+
public void progress() {
28+
if (player.getLocation().getBlock().isLiquid()) {
29+
clear();
30+
return;
31+
}
32+
33+
player.setAllowFlight(true);
34+
35+
if (active && toggled) {
36+
player.setGliding(true);
37+
38+
if (player.isSneaking() && player.getFlySpeed() < maxSpeed) {
39+
speed = speed + (float) acceleration;
40+
if (speed > maxSpeed) {
41+
speed = (float) maxSpeed;
42+
}
43+
}
44+
45+
player.setVelocity(player.getEyeLocation().getDirection().multiply(speed));
46+
}
47+
}
48+
49+
private void clear() {
50+
active = false;
51+
toggled = false;
52+
player.setFlying(false);
53+
player.setGliding(false);
54+
}
55+
56+
@Override
57+
public boolean isSneakAbility() {
58+
return false;
59+
}
60+
61+
@Override
62+
public boolean isHarmlessAbility() {
63+
return true;
64+
}
65+
66+
@Override
67+
public long getCooldown() {
68+
return 0;
69+
}
70+
71+
@Override
72+
public String getName() {
73+
return "Flying";
74+
}
75+
76+
@Override
77+
public Location getLocation() {
78+
return player.getLocation();
79+
}
80+
81+
@Override
82+
public boolean isInstantiable() {
83+
return isEnabled();
84+
}
85+
86+
@Override
87+
public boolean isProgressable() {
88+
return true;
89+
}
90+
91+
@Override
92+
public void load() {}
93+
94+
@Override
95+
public void stop() {}
96+
97+
@Override
98+
public String getAuthor() {
99+
return "Simplicitee";
100+
}
101+
102+
@Override
103+
public String getVersion() {
104+
return ProjectAddons.instance.version();
105+
}
106+
107+
public void toggleGlide() {
108+
this.toggled = !toggled;
109+
if (!toggled) {
110+
player.setGliding(false);
111+
player.setFlying(true);
112+
speed = startSpeed;
113+
} else {
114+
player.setGliding(true);
115+
player.setFlying(false);
116+
}
117+
}
118+
119+
public void fly(boolean flying) {
120+
if (flying) {
121+
active = true;
122+
original = player.getFlySpeed();
123+
player.setFlySpeed(flySpeed);
124+
} else {
125+
player.setFlySpeed(original);
126+
active = false;
127+
}
128+
}
129+
130+
public boolean isActive() {
131+
return active;
132+
}
133+
134+
public boolean isGliding() {
135+
return toggled;
136+
}
137+
138+
@Override
139+
public boolean isEnabled() {
140+
return ProjectAddons.instance.getConfig().getBoolean("Passives.Air.Flying.Enabled");
141+
}
142+
143+
@Override
144+
public String getDescription() {
145+
return "A very rare ability for airbenders is being able to fly freely, without the need of any glider. The only airbenders known to have this ability were Guru Laghima and Zaheer";
146+
}
147+
148+
@Override
149+
public String getInstructions() {
150+
return "Use double jump to toggle flight, offhand swap to toggle between gliding and creative flight, and sneak while gliding to accelerate!";
151+
}
152+
}

src/me/simplicitee/project/addons/ability/earth/EarthKick.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@ public void progress() {
113113
while (iter.hasNext()) {
114114
FallingBlock fb = iter.next();
115115

116-
if (!BLOCKS.contains(fb)) {
116+
if (fb == null || fb.isDead()) {
117+
BLOCKS.remove(fb);
117118
iter.remove();
118-
fb.remove();
119119
continue;
120120
}
121121

122-
if (fb == null || fb.isDead()) {
123-
BLOCKS.remove(fb);
122+
if (!BLOCKS.contains(fb)) {
124123
iter.remove();
124+
fb.remove();
125125
continue;
126126
}
127127

@@ -133,6 +133,8 @@ public void progress() {
133133
((LivingEntity) e).setNoDamageTicks(0);
134134
iter.remove();
135135
fb.remove();
136+
BLOCKS.remove(fb);
137+
break;
136138
}
137139
}
138140
}

src/me/simplicitee/project/addons/ability/water/PlantArmor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,9 @@ public void remove() {
325325

326326
this.sources.clear();
327327
this.shield.clear();
328-
this.bar.removeAll();
328+
if (this.bar != null) {
329+
this.bar.removeAll();
330+
}
329331
}
330332

331333
private void reset() {

src/plugin.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: ProjectAddons
22
author: Simplicitee
3-
api-version: 1.15
4-
version: 1.1.0
3+
api-version: 1.16
4+
version: 1.1.1
55
main: me.simplicitee.project.addons.ProjectAddons
66
depend: [ProjectKorra]
77
commands:

0 commit comments

Comments
 (0)