-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEarthShift.java
More file actions
168 lines (139 loc) · 4.72 KB
/
EarthShift.java
File metadata and controls
168 lines (139 loc) · 4.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.AddonAbility;
import com.projectkorra.projectkorra.ability.ComboAbility;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.SandAbility;
import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation;
import com.projectkorra.projectkorra.attribute.Attribute;
import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.util.ClickType;
import com.projectkorra.projectkorra.util.ParticleEffect;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
public class EarthShift extends SandAbility implements AddonAbility, ComboAbility {
private final String path = "";
@Attribute(Attribute.COOLDOWN)
private long cooldown;
@Attribute(Attribute.DURATION)
private long duration;
@Attribute(Attribute.SELECT_RANGE)
private double select_range;
@Attribute(Attribute.RADIUS)
private double radius;
private Block target;
public EarthShift(Player player) {
super(player);
if (!bPlayer.canBendIgnoreCooldowns(this)) {
return;
} else if (bPlayer.isOnCooldown(this)) {
return;
} else if (CoreAbility.hasAbility(player, EarthShift.class)) {
return;
}
this.cooldown = ConfigManager.getConfig().getLong(path + "Cooldown");
this.duration = ConfigManager.getConfig().getLong(path + "Duration");
this.select_range = ConfigManager.getConfig().getDouble(path + "SelectRange");
this.radius = ConfigManager.getConfig().getDouble(path + "Radius");
this.target = rayTraceBlock(player, this.select_range);
if (target == null) return;
if (GeneralMethods.isRegionProtectedFromBuild(this, player.getLocation())) {
return;
} else if (GeneralMethods.isRegionProtectedFromBuild(this, this.target.getLocation())) {
return;
}
playSandbendingSound(this.target.getLocation());
start();
}
@Override
public void progress() {
for (Block block : GeneralMethods.getBlocksAroundPoint(this.target.getLocation(), this.radius)) {
if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) continue;
Block top = GeneralMethods.getTopBlock(block.getLocation(), 3);
ParticleEffect.FALLING_DUST.display(top.getLocation(), 2, 0.5, 0.5, 0.5, 0);
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(top.getLocation(), 1)) {
if (entity instanceof ArmorStand || entity.getUniqueId() == player.getUniqueId()) continue;
if (entity instanceof LivingEntity) {
if (entity instanceof Player) {
if (Commands.invincible.contains(entity.getName())) continue;
}
((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 50, 0));
}
}
}
if (System.currentTimeMillis() > getStartTime() + this.duration) {
bPlayer.addCooldown(this);
remove();
return;
}
}
public static Block rayTraceBlock(Player player, double range) {
RayTraceResult result = player.getWorld().rayTraceBlocks(player.getEyeLocation().clone(), player.getEyeLocation().getDirection(), range);
if (result != null) {
return result.getHitBlock();
}
return null;
}
@Override
public boolean isSneakAbility() {
return false;
}
@Override
public boolean isHarmlessAbility() {
return false;
}
@Override
public long getCooldown() {
return cooldown;
}
@Override
public String getName() {
return "EarthShift";
}
@Override
public Location getLocation() {
return null;
}
@Override
public void load() { }
@Override
public void stop() { }
@Override
public boolean isEnabled() {
return ConfigManager.getConfig().getBoolean("EarthShift.Enabled", true);
}
@Override
public String getAuthor() {
return "Prride";
}
@Override
public String getVersion() {
return "1.0.0";
}
@Override
public String getDescription() {
return Element.EARTH.getColor() + "Shift the earth, changing it to favorable terrain for all of your sandbending needs.";
}
@Override
public String getInstructions() {
return "Shockwave (Right click block) > Shockwave (Left click)";
}
@Override
public Object createNewComboInstance(Player player) {
return new EarthShift(player);
}
@Override
public ArrayList<AbilityInformation> getCombination() {
ArrayList<AbilityInformation> info = new ArrayList<>();
info.add(new AbilityInformation("Shockwave", ClickType.RIGHT_CLICK_BLOCK));
info.add(new AbilityInformation("Shockwave", ClickType.LEFT_CLICK));
return info;
}
}