1818
1919package com .volmit .adapt .content .adaptation .rift ;
2020
21+ import com .volmit .adapt .Adapt ;
2122import com .volmit .adapt .api .adaptation .SimpleAdaptation ;
2223import com .volmit .adapt .api .recipe .AdaptRecipe ;
2324import com .volmit .adapt .content .item .BoundEyeOfEnder ;
2627import com .volmit .adapt .util .J ;
2728import com .volmit .adapt .util .Localizer ;
2829import lombok .NoArgsConstructor ;
29- import org .bukkit .Location ;
30- import org .bukkit .Material ;
31- import org .bukkit .Particle ;
32- import org .bukkit .Sound ;
30+ import org .bukkit .*;
3331import org .bukkit .entity .Player ;
3432import org .bukkit .event .EventHandler ;
3533import org .bukkit .event .player .PlayerInteractEvent ;
3634import org .bukkit .event .player .PlayerTeleportEvent ;
37- import org .bukkit .inventory .EquipmentSlot ;
3835import org .bukkit .inventory .ItemStack ;
3936import org .bukkit .potion .PotionEffect ;
4037import org .bukkit .potion .PotionEffectType ;
41- import org .bukkit .util .Vector ;
4238
4339
4440public class RiftGate extends SimpleAdaptation <RiftGate .Config > {
@@ -74,45 +70,44 @@ public void addStats(int level, Element v) {
7470 public void on (PlayerInteractEvent e ) {
7571 Player p = e .getPlayer ();
7672 ItemStack hand = p .getInventory ().getItemInMainHand ();
77- Location location ;
73+ Location location = e . getClickedBlock () == null ? p . getLocation () : e . getClickedBlock (). getLocation () ;
7874
79- ItemStack offhand = p .getInventory ().getItemInOffHand ();
80- if (e .getHand () != null && e .getHand ().equals (EquipmentSlot .OFF_HAND ) && BoundEyeOfEnder .isBindableItem (offhand )) {
81- e .setCancelled (true );
82- return ;
83- }
75+ if (p .getInventory ().getItemInMainHand ().getType ().equals (Material .ENDER_EYE )
76+ && !p .hasCooldown (Material .ENDER_EYE )
77+ && hasAdaptation (p )
78+ && BoundEyeOfEnder .isBindableItem (hand )) {
8479
85- if (BoundEyeOfEnder .isBindableItem (hand ) && hasAdaptation (p )) {
8680 e .setCancelled (true );
87- if (!hasAdaptation (p )) {
88- return ;
89- }
90- if (e .getClickedBlock () == null ) {
91- location = p .getLocation ();
92- } else {
93- location = new Location (e .getClickedBlock ().getLocation ().getWorld (), e .getClickedBlock ().getLocation ().getX () + 0.5 , e .getClickedBlock ().getLocation ().getY () + 1 , e .getClickedBlock ().getLocation ().getZ () + 0.5 );
94- }
81+ Adapt .verbose (" - Player Main hand: " + hand .getType ());
9582 switch (e .getAction ()) {
9683 case LEFT_CLICK_BLOCK -> {
9784 if (p .isSneaking ()) {
85+ Adapt .verbose ("Linking eye" );
9886 linkEye (p , location );
9987 }
10088 }
10189 case LEFT_CLICK_AIR -> {
10290 if (p .isSneaking () && isBound (hand )) {
91+ Adapt .verbose ("Unlinking eye" );
10392 unlinkEye (p );
10493 } else if (p .isSneaking () && !isBound (hand )) {
94+ Adapt .verbose ("Linking eye" );
10595 linkEye (p , location );
10696 }
10797 }
10898 case RIGHT_CLICK_AIR , RIGHT_CLICK_BLOCK -> // use
99+ {
100+ if (isBound (hand )) {
109101 openEye (p );
102+ }
103+ }
110104 }
111105 }
112106 }
113107
114108
115109 private void openEye (Player p ) {
110+ Adapt .verbose ("Using eye" );
116111 Location l = BoundEyeOfEnder .getLocation (p .getInventory ().getItemInMainHand ());
117112 ItemStack hand = p .getInventory ().getItemInMainHand ();
118113
@@ -126,37 +121,38 @@ private void openEye(Player p) {
126121 }
127122 p .setCooldown (Material .ENDER_EYE , 150 );
128123
129- if (getPlayer (p ).getData ().getSkillLines ().get ("rift" ).getAdaptations ().get ("rift-resist" ) != null
130- && getPlayer (p ).getData ().getSkillLines ().get ("rift" ).getAdaptations ().get ("rift-resist" ).getLevel () > 0 ) {
124+ if (RiftResist .hasRiftResistPerk (getPlayer (p ))) {
131125 RiftResist .riftResistStackAdd (p , 150 , 3 );
132126 }
127+
133128 p .addPotionEffect (new PotionEffect (PotionEffectType .BLINDNESS , 100 , 10 , true , false , false ));
134129 p .addPotionEffect (new PotionEffect (PotionEffectType .LEVITATION , 85 , 0 , true , false , false ));
135130 p .playSound (l , Sound .BLOCK_LODESTONE_PLACE , 1f , 0.1f );
136131 p .playSound (l , Sound .BLOCK_BELL_RESONATE , 1f , 0.1f );
137- J .a (() -> {
138- double d = 2 ;
139- double pcd = 1000 ;
140- double y = 0.1 ;
141- while (pcd > 0 ) {
142132
143- for (int i = 0 ; i < 16 ; i ++) {
144- if (getConfig ().showParticles ) {
145133
146- p .getWorld ().spawnParticle (Particle .ASH , p .getLocation ().clone ()
147- .add (Vector .getRandom ().subtract (Vector .getRandom ()).setY (y ).normalize ().multiply (d )), 1 , 0 , 0 , 0 , 0 );
148- }
149- }
150- pcd = pcd - 20 ;
151- d = d - 0.04 ;
152- y = y * 1.07 ;
153- J .sleep (80 );
134+ J .a (() -> {
135+ long dur = 4000 ; // time in miliseconds
136+ double radius = 2.0 ;
137+ double adder = 0.0 ;
138+ Color color = Color .fromBGR (0 , 0 , 0 );
139+ vfxFastRing (p .getLocation (), radius , color );
140+ while (dur > 0 ) {
141+ dur -= 50 ;
142+ adder += 0.02 ;
143+ radius *= 0.9 ; // reduce the radius by 20%
144+ vfxFastRing (p .getLocation ().add (0 , adder , 0 ), radius , color );
145+ J .sleep (50 );
154146 }
155- vfxLevelUp (p );
156- p .getLocation ().getWorld ().playSound (p .getLocation (), Sound .BLOCK_ENDER_CHEST_OPEN , 5.35f , 0.1f );
157- J .s (() -> p .teleport (l , PlayerTeleportEvent .TeleportCause .PLUGIN ));
158147 });
159- }
148+ vfxLevelUp (p );
149+ p .playSound (p .getLocation (), Sound .BLOCK_ENDER_CHEST_OPEN , 5.35f , 0.1f );
150+ J .s (() -> {
151+ p .teleport (l , PlayerTeleportEvent .TeleportCause .PLUGIN );
152+ vfxLevelUp (p );
153+ p .playSound (p .getLocation (), Sound .BLOCK_ENDER_CHEST_OPEN , 5.35f , 0.1f );
154+ },85 );
155+ }
160156
161157 private boolean isBound (ItemStack stack ) {
162158 return stack .getType ().equals (Material .ENDER_EYE ) && BoundEyeOfEnder .getLocation (stack ) != null ;
@@ -202,11 +198,11 @@ public boolean isPermanent() {
202198 return getConfig ().permanent ;
203199 }
204200
205- @ NoArgsConstructor
206- protected static class Config {
207- boolean permanent = false ;
208- boolean enabled = true ;
209- boolean consumeOnUse = true ;
210- boolean showParticles = true ;
211- }
201+ @ NoArgsConstructor
202+ protected static class Config {
203+ boolean permanent = false ;
204+ boolean enabled = true ;
205+ boolean consumeOnUse = true ;
206+ boolean showParticles = true ;
207+ }
212208}
0 commit comments