@@ -44,99 +44,93 @@ public static void startParticles() {
44
44
return ;
45
45
}
46
46
47
- id = Bukkit .getScheduler ().scheduleSyncRepeatingTask (SavageFactions .plugin , new Runnable () {
48
- @ Override
49
- public void run () {
47
+ id = Bukkit .getScheduler ().scheduleSyncRepeatingTask (SavageFactions .plugin , () -> {
48
+ for (String name : flyMap .keySet ()) {
49
+ Player player = Bukkit .getPlayer (name );
50
+ if (player == null ) {
51
+ continue ;
52
+ }
53
+ if (!player .isFlying ()) {
54
+ continue ;
55
+ }
56
+ if (!SavageFactions .plugin .mc17 ) {
57
+ if (player .getGameMode () == GameMode .SPECTATOR ) {
58
+ continue ;
59
+ }
60
+ }
61
+
62
+ if (FPlayers .getInstance ().getByPlayer (player ).isVanished ()) {
63
+ // Actually, vanished players (such as admins) should not display particles to prevent others from knowing their vanished assistance for moderation.
64
+ // But we can keep it as a config.
65
+ if (SavageFactions .plugin .getConfig ().getBoolean ("ffly.Particles.Enable-While-Vanished" )) {
66
+ return ;
67
+ }
68
+ continue ;
69
+ }
70
+ if (SavageFactions .plugin .useNonPacketParticles ) {
71
+ // 1.9+ based servers will use the built in particleAPI instead of packet based.
72
+ // any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working.
73
+ // So setting the amount to 0 spawns 1 in the precise location
74
+ player .getWorld ().spawnParticle (Particle .CLOUD , player .getLocation ().add (0 , -0.35 , 0 ), 0 );
75
+ } else {
76
+ ParticleEffect .CLOUD .display ((float ) 0 , (float ) 0 , (float ) 0 , (float ) 0 , 3 , player .getLocation ().add (0 , -0.35 , 0 ), 16 );
77
+ }
78
+
79
+ }
80
+ if (flyMap .keySet ().size () == 0 ) {
81
+ Bukkit .getScheduler ().cancelTask (id );
82
+ id = -1 ;
83
+ }
84
+ }, 10L , 3L );
85
+ }
86
+
87
+ public static void startFlyCheck () {
88
+ flyid = Bukkit .getScheduler ().scheduleSyncRepeatingTask (SavageFactions .plugin , () -> { //threw the exception for now, until I recode fly :( Cringe.
89
+ checkTaskState ();
90
+ if (flyMap .keySet ().size () != 0 ) {
50
91
for (String name : flyMap .keySet ()) {
92
+ if (name == null ) {
93
+ continue ;
94
+ }
51
95
Player player = Bukkit .getPlayer (name );
52
96
if (player == null ) {
53
97
continue ;
54
98
}
55
99
if (!player .isFlying ()) {
56
100
continue ;
57
101
}
58
- if (!SavageFactions .plugin .mc17 ) {
59
- if (player .getGameMode () == GameMode .SPECTATOR ) {
60
- continue ;
61
- }
102
+ FPlayer fPlayer = FPlayers .getInstance ().getByPlayer (player );
103
+ if (fPlayer == null ) {
104
+ continue ;
62
105
}
63
-
64
- if (FPlayers .getInstance ().getByPlayer (player ).isVanished ()) {
65
- // Actually, vanished players (such as admins) should not display particles to prevent others from knowing their vanished assistance for moderation.
66
- // But we can keep it as a config.
67
- if (SavageFactions .plugin .getConfig ().getBoolean ("ffly.Particles.Enable-While-Vanished" )) {
68
- return ;
69
- }
106
+ if (player .getGameMode () == GameMode .CREATIVE ) {
70
107
continue ;
71
108
}
72
- if (SavageFactions .plugin .useNonPacketParticles ) {
73
- // 1.9+ based servers will use the built in particleAPI instead of packet based.
74
- // any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working.
75
- // So setting the amount to 0 spawns 1 in the precise location
76
- player .getWorld ().spawnParticle (Particle .CLOUD , player .getLocation ().add (0 , -0.35 , 0 ), 0 );
77
- } else {
78
- ParticleEffect .CLOUD .display ((float ) 0 , (float ) 0 , (float ) 0 , (float ) 0 , 3 , player .getLocation ().add (0 , -0.35 , 0 ), 16 );
109
+ if (!SavageFactions .plugin .mc17 && player .getGameMode () == GameMode .SPECTATOR ) {
110
+ continue ;
79
111
}
80
-
81
- }
82
- if (flyMap .keySet ().size () == 0 ) {
83
- Bukkit .getScheduler ().cancelTask (id );
84
- id = -1 ;
85
- }
86
- }
87
- }, 10L , 3L );
88
- }
89
-
90
- public static void startFlyCheck () {
91
- flyid = Bukkit .getScheduler ().scheduleSyncRepeatingTask (SavageFactions .plugin , new Runnable () {
92
- @ Override
93
- public void run () throws ConcurrentModificationException { //threw the exception for now, until I recode fly :( Cringe.
94
- checkTaskState ();
95
- if (flyMap .keySet ().size () != 0 ) {
96
- for (String name : flyMap .keySet ()) {
97
- if (name == null ) {
98
- continue ;
99
- }
100
- Player player = Bukkit .getPlayer (name );
101
- if (player == null ) {
102
- continue ;
103
- }
104
- if (!player .isFlying ()) {
105
- continue ;
106
- }
107
- FPlayer fPlayer = FPlayers .getInstance ().getByPlayer (player );
108
- if (fPlayer == null ) {
109
- continue ;
110
- }
111
- if (player .getGameMode () == GameMode .CREATIVE ) {
112
- continue ;
113
- }
114
- if (!SavageFactions .plugin .mc17 && player .getGameMode () == GameMode .SPECTATOR ) {
115
- continue ;
116
- }
117
- Faction myFaction = fPlayer .getFaction ();
118
- if (myFaction .isWilderness ()) {
112
+ Faction myFaction = fPlayer .getFaction ();
113
+ if (myFaction .isWilderness ()) {
114
+ fPlayer .setFlying (false );
115
+ flyMap .remove (name );
116
+ continue ;
117
+ }
118
+ if (fPlayer .checkIfNearbyEnemies ()) {
119
+ continue ;
120
+ }
121
+ FLocation myFloc = new FLocation (player .getLocation ());
122
+ Faction toFac = Board .getInstance ().getFactionAt (myFloc );
123
+ if (Board .getInstance ().getFactionAt (myFloc ) != myFaction ) {
124
+ if (!checkBypassPerms (fPlayer , player , toFac )) {
119
125
fPlayer .setFlying (false );
120
126
flyMap .remove (name );
121
127
continue ;
122
128
}
123
- if (fPlayer .checkIfNearbyEnemies ()) {
124
- continue ;
125
- }
126
- FLocation myFloc = new FLocation (player .getLocation ());
127
- Faction toFac = Board .getInstance ().getFactionAt (myFloc );
128
- if (Board .getInstance ().getFactionAt (myFloc ) != myFaction ) {
129
- if (!checkBypassPerms (fPlayer , player , toFac )) {
130
- fPlayer .setFlying (false );
131
- flyMap .remove (name );
132
- continue ;
133
- }
134
- }
135
-
136
129
}
137
- }
138
130
131
+ }
139
132
}
133
+
140
134
}, 20L , 20L );
141
135
}
142
136
@@ -226,20 +220,17 @@ private void toggleFlight(final boolean toggle, final Player player) {
226
220
227
221
if (fme .canFlyAtLocation ())
228
222
229
- this .doWarmUp (WarmUpUtil .Warmup .FLIGHT , TL .WARMUPS_NOTIFY_FLIGHT , "Fly" , new Runnable () {
230
- @ Override
231
- public void run () {
232
- fme .setFlying (true );
233
- flyMap .put (player .getName (), true );
234
- if (id == -1 ) {
235
- if (SavageFactions .plugin .getConfig ().getBoolean ("ffly.Particles.Enabled" )) {
236
- startParticles ();
237
- }
238
- }
239
- if (flyid == -1 ) {
240
- startFlyCheck ();
223
+ this .doWarmUp (WarmUpUtil .Warmup .FLIGHT , TL .WARMUPS_NOTIFY_FLIGHT , "Fly" , () -> {
224
+ fme .setFlying (true );
225
+ flyMap .put (player .getName (), true );
226
+ if (id == -1 ) {
227
+ if (SavageFactions .plugin .getConfig ().getBoolean ("ffly.Particles.Enabled" )) {
228
+ startParticles ();
241
229
}
242
230
}
231
+ if (flyid == -1 ) {
232
+ startFlyCheck ();
233
+ }
243
234
}, this .p .getConfig ().getLong ("warmups.f-fly" , 0 ));
244
235
}
245
236
0 commit comments