mirror of
https://github.com/SimplexDevelopment/FeelingLucky.git
synced 2024-11-22 09:55:01 +00:00
parent
0ad60075da
commit
d282c2e982
10
build.gradle
10
build.gradle
@ -1,6 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id 'com.github.johnrengelman.shadow' version '7.1.0'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'io.github.simplex'
|
group = 'io.github.simplex'
|
||||||
@ -10,19 +9,10 @@ repositories {
|
|||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url = uri("https://s01.oss.sonatype.org/content/groups/public/") }
|
maven { url = uri("https://s01.oss.sonatype.org/content/groups/public/") }
|
||||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/")}
|
maven { url = uri("https://papermc.io/repo/repository/maven-public/")}
|
||||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT")
|
|
||||||
compileOnly("io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT")
|
||||||
shadow("org.jetbrains:annotations:16.0.2")
|
|
||||||
shadow("net.kyori:adventure-api:4.11.0")
|
|
||||||
shadow("io.papermc:paperlib:1.0.7")
|
|
||||||
}
|
|
||||||
|
|
||||||
shadowJar {
|
|
||||||
relocate("io.papermc.lib", "io.github.simplex.paperlib")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def targetJavaVersion = 17
|
def targetJavaVersion = 17
|
||||||
|
@ -21,17 +21,17 @@ public class MiniComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Contract("_ -> new")
|
@Contract("_ -> new")
|
||||||
public static String info(String content) {
|
public static Component info(String content) {
|
||||||
return new MiniComponent(content).color(ChatColor.GREEN).send();
|
return new MiniComponent(content).color(ChatColor.GREEN).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract("_ -> new")
|
@Contract("_ -> new")
|
||||||
public static String warn(String content) {
|
public static Component warn(String content) {
|
||||||
return new MiniComponent(content).color(ChatColor.YELLOW).decorate(TextDecoration.ITALIC).send();
|
return new MiniComponent(content).color(ChatColor.YELLOW).decorate(TextDecoration.ITALIC).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Contract("_ -> new")
|
@Contract("_ -> new")
|
||||||
public static String err(String content) {
|
public static Component err(String content) {
|
||||||
return new MiniComponent(content).color(ChatColor.RED).decorate(TextDecoration.BOLD).send();
|
return new MiniComponent(content).color(ChatColor.RED).decorate(TextDecoration.BOLD).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public class MiniComponent {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String send() {
|
public Component send() {
|
||||||
if (color == null) {
|
if (color == null) {
|
||||||
if (decoration == null) return Component.empty().content(content);
|
if (decoration == null) return Component.empty().content(content);
|
||||||
|
|
||||||
|
@ -7,14 +7,11 @@ import io.github.simplex.luck.util.LuckCMD;
|
|||||||
import io.github.simplex.luck.util.RegenerateConfigCMD;
|
import io.github.simplex.luck.util.RegenerateConfigCMD;
|
||||||
import io.github.simplex.luck.util.SpecialFootItem;
|
import io.github.simplex.luck.util.SpecialFootItem;
|
||||||
import io.github.simplex.metrics.Metrics;
|
import io.github.simplex.metrics.Metrics;
|
||||||
import io.papermc.lib.PaperLib;
|
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -27,17 +24,11 @@ public final class FeelingLucky extends JavaPlugin {
|
|||||||
|
|
||||||
private PlayerHandler handler;
|
private PlayerHandler handler;
|
||||||
private Config config;
|
private Config config;
|
||||||
private CommandMap commandMap = null;
|
|
||||||
|
|
||||||
public Map<UUID, PlayerConfig> getConfigMap() {
|
public Map<UUID, PlayerConfig> getConfigMap() {
|
||||||
return configMap;
|
return configMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoad() {
|
|
||||||
if (!PaperLib.isPaper()) PaperLib.suggestPaper(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
getLogger().info("Initializing metrics...");
|
getLogger().info("Initializing metrics...");
|
||||||
@ -50,9 +41,7 @@ public final class FeelingLucky extends JavaPlugin {
|
|||||||
loadPlayerConfigurations();
|
loadPlayerConfigurations();
|
||||||
getLogger().info("Attempting to load the main configuration...");
|
getLogger().info("Attempting to load the main configuration...");
|
||||||
config = new Config(this);
|
config = new Config(this);
|
||||||
getLogger().info("Main Config loaded successfully! Attempting to open the CommandMap...");
|
getLogger().info("Main Config loaded successfully! Loading commands...");
|
||||||
initCommandMap();
|
|
||||||
getLogger().info("Command Map successfully initialized! Attempting to register the commands...");
|
|
||||||
new LuckCMD(this);
|
new LuckCMD(this);
|
||||||
new RegenerateConfigCMD(this);
|
new RegenerateConfigCMD(this);
|
||||||
getLogger().info("Successfully loaded all commands!");
|
getLogger().info("Successfully loaded all commands!");
|
||||||
@ -69,16 +58,6 @@ public final class FeelingLucky extends JavaPlugin {
|
|||||||
getLogger().info("Complete! Goodbye! :)");
|
getLogger().info("Complete! Goodbye! :)");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initCommandMap() {
|
|
||||||
try {
|
|
||||||
Field f = getServer().getClass().getDeclaredField("commandMap");
|
|
||||||
f.setAccessible(true);
|
|
||||||
commandMap = (CommandMap) f.get(getServer());
|
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadPlayerConfigurations() {
|
private void loadPlayerConfigurations() {
|
||||||
if (!playerDirectory.exists()) {
|
if (!playerDirectory.exists()) {
|
||||||
getLogger().info("No directory exists. Creating...");
|
getLogger().info("No directory exists. Creating...");
|
||||||
@ -105,6 +84,7 @@ public final class FeelingLucky extends JavaPlugin {
|
|||||||
new BonemealFullCrop(this);
|
new BonemealFullCrop(this);
|
||||||
new CheatDeath(this);
|
new CheatDeath(this);
|
||||||
new EnchantmentBoost(this);
|
new EnchantmentBoost(this);
|
||||||
|
new ExpBoost(this);
|
||||||
new GiveDamage(this);
|
new GiveDamage(this);
|
||||||
new HideCheck(this);
|
new HideCheck(this);
|
||||||
new IllOmen(this);
|
new IllOmen(this);
|
||||||
@ -117,10 +97,6 @@ public final class FeelingLucky extends JavaPlugin {
|
|||||||
new TakeDamage(this);
|
new TakeDamage(this);
|
||||||
new UnbreakableTool(this);
|
new UnbreakableTool(this);
|
||||||
new VillagerInventory(this);
|
new VillagerInventory(this);
|
||||||
|
|
||||||
if (PaperLib.isPaper()) {
|
|
||||||
new ExpBoost(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerHandler getHandler() {
|
public PlayerHandler getHandler() {
|
||||||
@ -137,8 +113,7 @@ public final class FeelingLucky extends JavaPlugin {
|
|||||||
return specialFootItem;
|
return specialFootItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public CommandMap getCommandMap() {
|
public CommandMap getCommandMap() {
|
||||||
return commandMap;
|
return getServer().getCommandMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.github.simplex.luck.listener;
|
package io.github.simplex.luck.listener;
|
||||||
|
|
||||||
|
import io.github.simplex.luck.Config;
|
||||||
import io.github.simplex.luck.FeelingLucky;
|
import io.github.simplex.luck.FeelingLucky;
|
||||||
import io.github.simplex.luck.player.PlayerHandler;
|
import io.github.simplex.luck.player.PlayerHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package io.github.simplex.luck.listener;
|
package io.github.simplex.luck.listener;
|
||||||
|
|
||||||
import io.github.simplex.lib.ItemBuilder;
|
import io.github.simplex.lib.ItemBuilder;
|
||||||
|
import io.github.simplex.lib.MiniComponent;
|
||||||
import io.github.simplex.luck.FeelingLucky;
|
import io.github.simplex.luck.FeelingLucky;
|
||||||
import io.github.simplex.luck.player.Luck;
|
import io.github.simplex.luck.player.Luck;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -34,7 +35,7 @@ public final class BonemealFullCrop extends AbstractListener {
|
|||||||
|
|
||||||
BlockData data = block.getBlockData();
|
BlockData data = block.getBlockData();
|
||||||
|
|
||||||
if ((action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK))
|
if (action.isRightClick()
|
||||||
&& handItem.isSimilar(bonemeal)
|
&& handItem.isSimilar(bonemeal)
|
||||||
&& (data instanceof Ageable crop)
|
&& (data instanceof Ageable crop)
|
||||||
&& luck.quickRNG(luck.getValue())
|
&& luck.quickRNG(luck.getValue())
|
||||||
|
@ -2,10 +2,8 @@ package io.github.simplex.luck.listener;
|
|||||||
|
|
||||||
import io.github.simplex.lib.MiniComponent;
|
import io.github.simplex.lib.MiniComponent;
|
||||||
import io.github.simplex.luck.FeelingLucky;
|
import io.github.simplex.luck.FeelingLucky;
|
||||||
import io.github.simplex.luck.player.CancellablePlayerDeathEvent;
|
|
||||||
import io.github.simplex.luck.player.Luck;
|
import io.github.simplex.luck.player.Luck;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
|
||||||
@ -16,8 +14,8 @@ public final class CheatDeath extends AbstractListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void cheatDeath(CancellablePlayerDeathEvent event) {
|
public void cheatDeath(PlayerDeathEvent event) {
|
||||||
Player player = event.getEntity();
|
Player player = event.getPlayer();
|
||||||
Luck luck = getHandler().getLuckContainer(player);
|
Luck luck = getHandler().getLuckContainer(player);
|
||||||
double absorption = Math.round(Luck.RNG().nextDouble(5.0, 10.0));
|
double absorption = Math.round(Luck.RNG().nextDouble(5.0, 10.0));
|
||||||
if (luck.quickRNG(luck.getValue()) && doesQualify("cheat_death", luck.getValue())) {
|
if (luck.quickRNG(luck.getValue()) && doesQualify("cheat_death", luck.getValue())) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.github.simplex.luck.listener;
|
package io.github.simplex.luck.listener;
|
||||||
|
|
||||||
|
import io.github.simplex.lib.MiniComponent;
|
||||||
import io.github.simplex.luck.FeelingLucky;
|
import io.github.simplex.luck.FeelingLucky;
|
||||||
import io.github.simplex.luck.player.Luck;
|
import io.github.simplex.luck.player.Luck;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
@ -5,7 +5,6 @@ import io.github.simplex.luck.FeelingLucky;
|
|||||||
import io.github.simplex.luck.player.Luck;
|
import io.github.simplex.luck.player.Luck;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Mob;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||||
@ -16,7 +15,7 @@ import org.bukkit.event.player.PlayerToggleSneakEvent;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class HideCheck extends AbstractListener {
|
public class HideCheck extends AbstractListener {
|
||||||
public Map<Player, List<Mob>> entityMapList = new HashMap<>();
|
public Map<Player, List<Entity>> entityMapList = new HashMap<>();
|
||||||
|
|
||||||
public HideCheck(FeelingLucky plugin) {
|
public HideCheck(FeelingLucky plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
@ -31,8 +30,8 @@ public class HideCheck extends AbstractListener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void checkTargeting(EntityTargetLivingEntityEvent event) {
|
public void checkTargeting(EntityTargetLivingEntityEvent event) {
|
||||||
if (event.getTarget() instanceof Player player) {
|
if (event.getTarget() instanceof Player player) {
|
||||||
if (event.getEntity() instanceof Mob entity) {
|
if (event.getEntity() instanceof LivingEntity entity) {
|
||||||
List<Mob> buffer = entityMapList.get(player).isEmpty() ?
|
List<Entity> buffer = entityMapList.get(player).isEmpty() ?
|
||||||
new ArrayList<>() : entityMapList.get(player);
|
new ArrayList<>() : entityMapList.get(player);
|
||||||
buffer.add(entity);
|
buffer.add(entity);
|
||||||
entityMapList.replace(player, buffer);
|
entityMapList.replace(player, buffer);
|
||||||
@ -47,7 +46,9 @@ public class HideCheck extends AbstractListener {
|
|||||||
|
|
||||||
Luck luck = plugin.getHandler().getLuckContainer(player);
|
Luck luck = plugin.getHandler().getLuckContainer(player);
|
||||||
if (luck.quickRNG(luck.getValue()) && doesQualify("hide_check", luck.getValue())) {
|
if (luck.quickRNG(luck.getValue()) && doesQualify("hide_check", luck.getValue())) {
|
||||||
entityMapList.get(player).forEach(e -> e.getTarget().remove());
|
entityMapList.get(player).forEach(e -> {
|
||||||
|
e.getTrackedPlayers().remove(player);
|
||||||
|
});
|
||||||
player.sendMessage(MiniComponent.info("Your luck has hidden you from sight."));
|
player.sendMessage(MiniComponent.info("Your luck has hidden you from sight."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public class OreVein extends AbstractListener {
|
|||||||
public void playerMine(BlockBreakEvent event) {
|
public void playerMine(BlockBreakEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Luck luck = plugin.getHandler().getLuckContainer(player);
|
Luck luck = plugin.getHandler().getLuckContainer(player);
|
||||||
if (luck.quickRNG(luck.getValue()) && doesQualify("ore_vein", luck.getValue()) && event.getBlock().isPreferredTool(player.getInventory().getItemInMainHand())) {
|
if (luck.quickRNG(luck.getValue()) && doesQualify("ore_vein", luck.getValue()) && event.getBlock().isValidTool(player.getInventory().getItemInMainHand())) {
|
||||||
getOresInArea(event.getBlock()).forEach(Block::breakNaturally);
|
getOresInArea(event.getBlock()).forEach(Block::breakNaturally);
|
||||||
player.sendMessage(MiniComponent.info("Your luck has let you mine all the blocks with one swing."));
|
player.sendMessage(MiniComponent.info("Your luck has let you mine all the blocks with one swing."));
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,7 @@ public final class PlayerListener extends AbstractListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK))
|
if (action.isRightClick() && player.getInventory().getItemInMainHand().getType().equals(foot.getType())) {
|
||||||
&& player.getInventory().getItemInMainHand().getType().equals(foot.getType())) {
|
|
||||||
if (foot.getItemMeta().equals(special.meta()) || foot.equals(special.get())) {
|
if (foot.getItemMeta().equals(special.meta()) || foot.equals(special.get())) {
|
||||||
luck.setMultiplier(luck.multiplier() + 0.1);
|
luck.setMultiplier(luck.multiplier() + 0.1);
|
||||||
player.sendMessage(MiniComponent.info("Your luck multiplier has increased by 0.1!"));
|
player.sendMessage(MiniComponent.info("Your luck multiplier has increased by 0.1!"));
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
package io.github.simplex.luck.player;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CancellablePlayerDeathEvent extends PlayerDeathEvent implements Cancellable {
|
|
||||||
private boolean cancelled = false;
|
|
||||||
|
|
||||||
public CancellablePlayerDeathEvent(@NotNull Player player, @NotNull List<ItemStack> drops, int droppedExp, @Nullable String deathMessage) {
|
|
||||||
super(player, drops, droppedExp, deathMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CancellablePlayerDeathEvent(@NotNull Player player, @NotNull List<ItemStack> drops, int droppedExp, int newExp, @Nullable String deathMessage) {
|
|
||||||
super(player, drops, droppedExp, newExp, deathMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public CancellablePlayerDeathEvent(@NotNull Player player, @NotNull List<ItemStack> drops, int droppedExp, int newExp, int newTotalExp, int newLevel, @Nullable String deathMessage) {
|
|
||||||
super(player, drops, droppedExp, newExp, newTotalExp, newLevel, deathMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancel) {
|
|
||||||
cancelled = cancel;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user