Skip to content

Commit 5483a94

Browse files
Merge pull request #411 from VolmitSoftware/Development
Development
2 parents f905ea1 + 99fb8c4 commit 5483a94

File tree

5 files changed

+411
-273
lines changed

5 files changed

+411
-273
lines changed

src/main/java/com/volmit/adapt/Adapt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public static void autoUpdateCheck() {
123123
}
124124
}
125125
in.close();
126-
} catch (Exception e) {
126+
} catch (Throwable e) {
127127
error("Failed to check for updates.");
128128
}
129129
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*------------------------------------------------------------------------------
2+
- Adapt is a Skill/Integration plugin for Minecraft Bukkit Servers
3+
- Copyright (c) 2022 Arcane Arts (Volmit Software)
4+
-
5+
- This program is free software: you can redistribute it and/or modify
6+
- it under the terms of the GNU General Public License as published by
7+
- the Free Software Foundation, either version 3 of the License, or
8+
- (at your option) any later version.
9+
-
10+
- This program is distributed in the hope that it will be useful,
11+
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
- GNU General Public License for more details.
14+
-
15+
- You should have received a copy of the GNU General Public License
16+
- along with this program. If not, see <https://www.gnu.org/licenses/>.
17+
-----------------------------------------------------------------------------*/
18+
19+
package com.volmit.adapt.content.adaptation.rift;
20+
21+
import com.volmit.adapt.api.adaptation.SimpleAdaptation;
22+
import com.volmit.adapt.util.C;
23+
import com.volmit.adapt.util.Element;
24+
import com.volmit.adapt.util.J;
25+
import com.volmit.adapt.util.Localizer;
26+
import lombok.NoArgsConstructor;
27+
import org.bukkit.Material;
28+
import org.bukkit.Sound;
29+
import org.bukkit.entity.Player;
30+
import org.bukkit.event.EventHandler;
31+
import org.bukkit.event.EventPriority;
32+
import org.bukkit.event.player.PlayerToggleSneakEvent;
33+
import org.bukkit.potion.PotionEffect;
34+
import org.bukkit.potion.PotionEffectType;
35+
36+
import java.util.ArrayList;
37+
import java.util.List;
38+
39+
public class RiftDescent extends SimpleAdaptation<RiftDescent.Config> {
40+
private final List<Player> cooldown = new ArrayList<>();
41+
42+
public RiftDescent() {
43+
super("rift-descent");
44+
registerConfiguration(Config.class);
45+
setDescription(Localizer.dLocalize("rift", "descent", "description"));
46+
setDisplayName(Localizer.dLocalize("rift", "descent", "name"));
47+
setMaxLevel(1);
48+
setIcon(Material.SHULKER_BOX);
49+
setBaseCost(getConfig().baseCost);
50+
setCostFactor(getConfig().costFactor);
51+
setInitialCost(getConfig().initialCost);
52+
setInterval(9544);
53+
}
54+
55+
@Override
56+
public void addStats(int level, Element v) {
57+
v.addLore(C.YELLOW + Localizer.dLocalize("rift", "descent", "lore1"));
58+
v.addLore(C.GREEN + Localizer.dLocalize("rift", "descent", "lore2") + " " + C.WHITE + getConfig().cooldown + "s");
59+
}
60+
61+
@EventHandler(priority = EventPriority.HIGHEST)
62+
public void on(PlayerToggleSneakEvent e) {
63+
Player p = e.getPlayer();
64+
if (!hasAdaptation(p)) {
65+
return;
66+
}
67+
if (cooldown.contains(p)) {
68+
return;
69+
}
70+
71+
PotionEffect levi = e.getPlayer().getPotionEffect(PotionEffectType.LEVITATION);
72+
73+
if (!e.isSneaking() && (levi != null)) {
74+
p.removePotionEffect(PotionEffectType.LEVITATION);
75+
J.a(() -> {
76+
cooldown.add(p);
77+
try {
78+
Thread.sleep((long) (getConfig().cooldown * 1000));
79+
} catch (InterruptedException ex) {
80+
throw new RuntimeException(ex);
81+
}
82+
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);
83+
cooldown.remove(p);
84+
85+
});
86+
87+
J.s(() -> {
88+
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_FALLING, (int) (20 * getConfig().cooldown), 0));
89+
p.playSound(p.getLocation(), Sound.ENTITY_ENDER_DRAGON_FLAP, 1f, 1f);
90+
});
91+
}
92+
}
93+
94+
95+
@Override
96+
public void onTick() {
97+
}
98+
99+
@Override
100+
public boolean isEnabled() {
101+
return getConfig().enabled;
102+
}
103+
104+
@Override
105+
public boolean isPermanent() {
106+
return getConfig().permanent;
107+
}
108+
109+
@NoArgsConstructor
110+
protected static class Config {
111+
boolean permanent = true;
112+
boolean enabled = true;
113+
double cooldown = 5.0;
114+
int baseCost = 1;
115+
double costFactor = 2;
116+
int initialCost = 3;
117+
}
118+
119+
}

src/main/java/com/volmit/adapt/content/skill/SkillRift.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public SkillRift() {
5757
registerAdaptation(new RiftEnderchest());
5858
registerAdaptation(new RiftGate());
5959
registerAdaptation(new RiftBlink());
60+
registerAdaptation(new RiftDescent());
6061
lasttp = new HashMap<>();
6162
}
6263

src/main/resources/en_US.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -906,6 +906,12 @@
906906
"description": "Open an enderchest by Left-clicking it in your hand.",
907907
"lore1": "Click an Enderchest in your hand to open (Just dont place it)"
908908
},
909+
"descent": {
910+
"name": "Anti-Levitation",
911+
"description": "Are you tired of being stuck in the air? This is the skill for you!",
912+
"lore1": "Just Sneak to descend, and you will fall at a less than normal rate!",
913+
"lore2": "Cooldown:"
914+
},
909915
"gate": {
910916
"name": "Rift Gate",
911917
"description": "Teleport to a marked location.",

0 commit comments

Comments
 (0)