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+ }
0 commit comments