7
7
import com .liphium .elfhunt .game .team .impl .ElfTeam ;
8
8
import com .liphium .elfhunt .game .team .impl .HunterTeam ;
9
9
import com .liphium .elfhunt .listener .machines .impl .PresentReceiver ;
10
- import com .liphium .elfhunt .screens .ItemShopScreen ;
11
10
import com .liphium .elfhunt .util .LocationAPI ;
12
11
import com .liphium .elfhunt .util .Messages ;
13
12
import net .kyori .adventure .text .Component ;
@@ -54,7 +53,7 @@ public void start() {
54
53
55
54
// Change the amount of presents based on team size
56
55
final var hunterSize = Elfhunt .getInstance ().getGameManager ().getTeamManager ().getTeam ("Elves" ).getPlayers ().size ();
57
- int maxPresents = hunterSize * 10 ; // 10 per member of the team seems fine for 15 minutes
56
+ int maxPresents = hunterSize * 4 ; // 4 per member of the team seems fine for 15 minutes
58
57
presentsLeft = maxPresents ;
59
58
60
59
// Give every single present receiver a random name
@@ -133,32 +132,35 @@ public void onInteract(PlayerInteractEvent event) {
133
132
ItemStack usedItem = event .getItem ();
134
133
if (usedItem .getType ().equals (Material .GRAY_DYE ) && event .getClickedBlock () != null ) {
135
134
traps .add (new SlowTrap (event .getClickedBlock ().getLocation ().clone ().add (0.5 , 1 , 0.5 ), team ));
136
- reduceMainHandItem (event .getPlayer ());
135
+ reduceMainHandItem (event .getPlayer (), Material . GRAY_DYE );
137
136
} else if (usedItem .getType ().equals (Material .GREEN_DYE ) && event .getClickedBlock () != null ) {
138
137
traps .add (new PoisonTrap (event .getClickedBlock ().getLocation ().clone ().add (0.5 , 1 , 0.5 ), team ));
139
- reduceMainHandItem (event .getPlayer ());
138
+ reduceMainHandItem (event .getPlayer (), Material . GREEN_DYE );
140
139
} else if (usedItem .getType ().equals (Material .FEATHER ) && event .getClickedBlock () != null ) {
141
140
traps .add (new FlyTrap (event .getClickedBlock ().getLocation ().clone ().add (0.5 , 1 , 0.5 ), team ));
142
- reduceMainHandItem (event .getPlayer ());
141
+ reduceMainHandItem (event .getPlayer (), Material . FEATHER );
143
142
} else if (usedItem .getType ().equals (Material .LIGHT_BLUE_DYE ) && event .getClickedBlock () != null ) {
144
143
traps .add (new FreezeTrap (event .getClickedBlock ().getLocation ().clone ().add (0.5 , 1 , 0.5 ), team ));
145
- reduceMainHandItem (event .getPlayer ());
144
+ reduceMainHandItem (event .getPlayer (), Material . LIGHT_BLUE_DYE );
146
145
} else if (usedItem .getType ().equals (Material .WHITE_DYE ) && event .getClickedBlock () != null ) {
147
146
traps .add (new WebTrap (event .getClickedBlock ().getLocation ().clone ().add (0.5 , 1 , 0.5 ), team ));
148
- reduceMainHandItem (event .getPlayer ());
149
- } else if (usedItem .getType ().equals (Material .FEATHER ) && event .getPlayer ().getCooldown (Material .FEATHER ) <= 0 ) {
150
- event .getPlayer ().setVelocity (event .getPlayer ().getLocation ().getDirection ().normalize ().multiply (event .getPlayer ().isOnGround () ? 1.8 : 1.1 ));
151
- event .getPlayer ().setCooldown (Material .FEATHER , 50 );
152
- ItemShopScreen .removeAmountFromInventory (event .getPlayer (), Material .FEATHER , 1 );
147
+ reduceMainHandItem (event .getPlayer (), Material .WHITE_DYE );
153
148
}
154
149
}
155
150
}
156
151
157
- void reduceMainHandItem (Player player ) {
158
- int amount = player .getInventory ().getItemInMainHand ().getAmount ();
159
- if (amount == 1 ) {
160
- player .getInventory ().setItemInMainHand (null );
161
- } else player .getInventory ().getItemInMainHand ().setAmount (amount - 1 );
152
+ void reduceMainHandItem (Player player , Material material ) {
153
+ if (player .getInventory ().getItemInMainHand ().getType () == material ) {
154
+ int amount = player .getInventory ().getItemInMainHand ().getAmount ();
155
+ if (amount == 1 ) {
156
+ player .getInventory ().setItemInMainHand (null );
157
+ } else player .getInventory ().getItemInMainHand ().setAmount (amount - 1 );
158
+ } else if (player .getInventory ().getItemInOffHand ().getType () == material ) {
159
+ int amount = player .getInventory ().getItemInOffHand ().getAmount ();
160
+ if (amount == 1 ) {
161
+ player .getInventory ().setItemInOffHand (null );
162
+ } else player .getInventory ().getItemInOffHand ().setAmount (amount - 1 );
163
+ }
162
164
}
163
165
164
166
@ Override
@@ -255,7 +257,7 @@ public void onMove(PlayerMoveEvent event) {
255
257
}
256
258
257
259
// Kill the player in case they fell down
258
- if (event .getPlayer ().getLocation ().getY () <= 180 ) {
260
+ if (event .getPlayer ().getLocation ().getY () <= 156 ) {
259
261
event .getPlayer ().setHealth (0 );
260
262
return ;
261
263
}
@@ -302,11 +304,19 @@ public void onPlace(BlockPlaceEvent event) {
302
304
return ;
303
305
}
304
306
305
- if (event .getBlockPlaced ().getLocation ().getY () >= 220 ) {
307
+ if (event .getBlockPlaced ().getLocation ().getY () >= 250 ) {
306
308
event .setCancelled (true );
307
309
return ;
308
310
}
309
311
312
+ for (DroppableTrap trap : traps ) {
313
+ if (trap .location .distance (event .getBlock ().getLocation ()) <= 2 ) {
314
+ event .getPlayer ().sendMessage (Component .text ("You can't place a block near a trap!" , NamedTextColor .RED ));
315
+ event .setCancelled (true );
316
+ return ;
317
+ }
318
+ }
319
+
310
320
// Place a machine if it is one
311
321
final var machine = Elfhunt .getInstance ().getMachineManager ().newMachineByMaterial (event .getBlockPlaced ().getType (), event .getBlockPlaced ().getLocation ());
312
322
if (machine != null ) {
@@ -324,7 +334,8 @@ public void onPlace(BlockPlaceEvent event) {
324
334
Material .AZURE_BLUET , Material .RED_TULIP , Material .ORANGE_TULIP ,
325
335
Material .WHITE_TULIP , Material .PINK_TULIP , Material .OXEYE_DAISY , Material .SUNFLOWER ,
326
336
Material .LILAC , Material .ROSE_BUSH , Material .PEONY ,
327
- Material .LILY_OF_THE_VALLEY , Material .WITHER_ROSE , Material .COBWEB
337
+ Material .LILY_OF_THE_VALLEY , Material .WITHER_ROSE , Material .COBWEB ,
338
+ Material .FERN , Material .SWEET_BERRY_BUSH
328
339
);
329
340
330
341
@ Override
@@ -354,7 +365,11 @@ public void onBreak(BlockBreakEvent event) {
354
365
public void onDeath (PlayerDeathEvent event ) {
355
366
final var player = event .getPlayer ();
356
367
357
- event .setKeepInventory (true );
368
+ player .getInventory ().clear ();
369
+ player .getInventory ().setBoots (null );
370
+ player .getInventory ().setLeggings (null );
371
+ player .getInventory ().setChestplate (null );
372
+ player .getInventory ().setHelmet (null );
358
373
event .deathMessage (null );
359
374
event .setKeepLevel (true );
360
375
@@ -390,7 +405,6 @@ public void onRespawn(PlayerRespawnEvent event) {
390
405
} else {
391
406
event .setRespawnLocation (Objects .requireNonNull (LocationAPI .getLocation ("Elves" )));
392
407
}
393
- team .giveKit (event .getPlayer (), false );
394
408
}
395
409
396
410
public void handleWin (Team team ) {
@@ -424,7 +438,7 @@ public DroppableTrap(Location location, Team team, Material material) {
424
438
this .location = location ;
425
439
this .team = team ;
426
440
427
- item = (Item ) location .getWorld ().spawnEntity (location .clone ().add (0 , 1 , 0 ), EntityType .ITEM );
441
+ item = (Item ) location .getWorld ().spawnEntity (location .clone ().add (0 , 0.5 , 0 ), EntityType .ITEM );
428
442
item .setItemStack (new ItemStackBuilder (material ).buildStack ());
429
443
item .setVelocity (new Vector (0 , 0 , 0 ));
430
444
item .setPickupDelay (1000000000 );
@@ -472,7 +486,6 @@ public static class FreezeTrap extends DroppableTrap {
472
486
@ Override
473
487
public void onEnter (Player player ) {
474
488
player .addPotionEffect (new PotionEffect (PotionEffectType .SLOWNESS , 100 , 255 , true , false ));
475
- player .addPotionEffect (new PotionEffect (PotionEffectType .JUMP_BOOST , 100 , 128 , true , false ));
476
489
player .addPotionEffect (new PotionEffect (PotionEffectType .GLOWING , 300 , 0 ));
477
490
}
478
491
}
0 commit comments