mirror of
https://github.com/SimplexDevelopment/FeelingLucky.git
synced 2024-11-22 09:55:01 +00:00
FeelingLucky v1.0 RC01
Added some more features, this will be now the full official release; this commit is release candidate 1. Changelog: - Added HideCheck, which will break the tracking of any mobs targeting the player. - Added JumpBoost, which adds a little extra height to your jumps. - Modified OreVein as it previously scanned for all ore types rather than the relative mined ore type.
This commit is contained in:
parent
c383b2c546
commit
e6fe9e904e
59
src/main/java/io/github/simplex/luck/listener/HideCheck.java
Normal file
59
src/main/java/io/github/simplex/luck/listener/HideCheck.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package io.github.simplex.luck.listener;
|
||||||
|
|
||||||
|
import io.github.simplex.lib.MiniComponent;
|
||||||
|
import io.github.simplex.luck.FeelingLucky;
|
||||||
|
import io.github.simplex.luck.player.Luck;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class HideCheck extends AbstractListener {
|
||||||
|
public Map<Player, List<Entity>> entityMapList = new HashMap<>();
|
||||||
|
|
||||||
|
public HideCheck(FeelingLucky plugin) {
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void initPlayerMaps(PlayerJoinEvent event) {
|
||||||
|
entityMapList.put(event.getPlayer(), List.of());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void checkTargeting(EntityTargetLivingEntityEvent event) {
|
||||||
|
if (event.getTarget() instanceof Player player) {
|
||||||
|
if (event.getEntity() instanceof LivingEntity entity) {
|
||||||
|
List<Entity> buffer = entityMapList.get(player).isEmpty() ?
|
||||||
|
new ArrayList<>() : entityMapList.get(player);
|
||||||
|
buffer.add(entity);
|
||||||
|
entityMapList.replace(player, buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void checkForSneak(PlayerToggleSneakEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (!player.isSneaking()) return;
|
||||||
|
|
||||||
|
Luck luck = plugin.getHandler().getLuckContainer(player);
|
||||||
|
if (luck.quickRNG(luck.getValue()) && !luck.isMarked(player)) {
|
||||||
|
entityMapList.get(player).forEach(e -> {
|
||||||
|
e.getTrackedPlayers().remove(player);
|
||||||
|
});
|
||||||
|
player.sendMessage(MiniComponent.info("Your luck has hidden you from sight."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void removePlayerOnLeave(PlayerQuitEvent event) {
|
||||||
|
entityMapList.remove(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
26
src/main/java/io/github/simplex/luck/listener/JumpBoost.java
Normal file
26
src/main/java/io/github/simplex/luck/listener/JumpBoost.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package io.github.simplex.luck.listener;
|
||||||
|
|
||||||
|
import com.destroystokyo.paper.event.player.PlayerJumpEvent;
|
||||||
|
import io.github.simplex.lib.MiniComponent;
|
||||||
|
import io.github.simplex.luck.FeelingLucky;
|
||||||
|
import io.github.simplex.luck.player.Luck;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class JumpBoost extends AbstractListener {
|
||||||
|
public JumpBoost(FeelingLucky plugin) {
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void detectJumping(PlayerJumpEvent event) {
|
||||||
|
Player player = event.getPlayer(); // Player is never null; they're in game and jumping.
|
||||||
|
Luck luck = plugin.getHandler().getLuckContainer(player);
|
||||||
|
|
||||||
|
if (luck.quickRNG(luck.getValue()) && !luck.isMarked(player)) {
|
||||||
|
player.setVelocity(new Vector(0, 2, 0));
|
||||||
|
player.sendMessage(MiniComponent.info("Your luck has boosted your jump height!"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -46,6 +46,6 @@ public class OreVein extends AbstractListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return streamBuilder.build();
|
return streamBuilder.build().filter(b -> b.getType().equals(block.getType()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user