mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2025-01-24 00:41:23 +01:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
a93e71724e
@ -8,6 +8,7 @@ import com.willfp.eco.core.integrations.IntegrationLoader;
|
||||
import com.willfp.eco.util.TelekinesisUtils;
|
||||
import com.willfp.ecoenchants.command.CommandEcoEnchants;
|
||||
import com.willfp.ecoenchants.command.CommandEnchantinfo;
|
||||
import com.willfp.ecoenchants.config.DataYml;
|
||||
import com.willfp.ecoenchants.config.RarityYml;
|
||||
import com.willfp.ecoenchants.config.TargetYml;
|
||||
import com.willfp.ecoenchants.config.VanillaEnchantsYml;
|
||||
@ -34,6 +35,7 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@ -57,6 +59,12 @@ public class EcoEnchantsPlugin extends EcoPlugin {
|
||||
@Getter
|
||||
private final TargetYml targetYml;
|
||||
|
||||
/**
|
||||
* Data.yml.
|
||||
*/
|
||||
@Getter
|
||||
private final DataYml dataYml;
|
||||
|
||||
/**
|
||||
* VanillaEnchants.yml.
|
||||
*/
|
||||
@ -78,6 +86,7 @@ public class EcoEnchantsPlugin extends EcoPlugin {
|
||||
|
||||
rarityYml = new RarityYml(this);
|
||||
targetYml = new TargetYml(this);
|
||||
dataYml = new DataYml(this);
|
||||
vanillaEnchantsYml = new VanillaEnchantsYml(this);
|
||||
dataHandler = this.getConfigYml().getBool("mysql.enabled")
|
||||
? new MySQLDataHandler(this) : new YamlDataHandler(this);
|
||||
@ -92,6 +101,11 @@ public class EcoEnchantsPlugin extends EcoPlugin {
|
||||
|
||||
@Override
|
||||
protected void handleDisable() {
|
||||
try {
|
||||
this.dataYml.save();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
for (World world : Bukkit.getServer().getWorlds()) {
|
||||
world.getPopulators().removeIf(blockPopulator -> blockPopulator instanceof LootPopulator);
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ public class CommandEcoEnchants extends PluginCommand {
|
||||
.addSubcommand(new CommandReload(plugin))
|
||||
.addSubcommand(new CommandGiverandombook(plugin))
|
||||
.addSubcommand(new CommandRandomenchant(plugin))
|
||||
.addSubcommand(new CommandLocale(plugin));
|
||||
.addSubcommand(new CommandLocale(plugin))
|
||||
.addSubcommand(new CommandToggleDescriptions(plugin));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,6 +5,8 @@ import com.willfp.eco.core.command.impl.Subcommand;
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class CommandReload extends Subcommand {
|
||||
/**
|
||||
* Instantiate a new command handler.
|
||||
@ -18,6 +20,11 @@ public class CommandReload extends Subcommand {
|
||||
@Override
|
||||
public CommandHandler getHandler() {
|
||||
return (sender, args) -> {
|
||||
try {
|
||||
((EcoEnchantsPlugin) this.getPlugin()).getDataYml().save();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
this.getPlugin().reload();
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("reloaded"));
|
||||
};
|
||||
|
@ -0,0 +1,31 @@
|
||||
package com.willfp.ecoenchants.command;
|
||||
|
||||
import com.willfp.eco.core.command.CommandHandler;
|
||||
import com.willfp.eco.core.command.impl.Subcommand;
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class CommandToggleDescriptions extends Subcommand {
|
||||
/**
|
||||
* Instantiate a new command handler.
|
||||
*
|
||||
* @param plugin The plugin for the commands to listen for.
|
||||
*/
|
||||
public CommandToggleDescriptions(@NotNull final EcoEnchantsPlugin plugin) {
|
||||
super(plugin, "toggledescriptions", "ecoenchants.command.toggledescriptions", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandHandler getHandler() {
|
||||
return (sender, args) -> {
|
||||
if (!((EcoEnchantsPlugin) this.getPlugin()).getDisplayModule().getOptions().getDescriptionOptions().isEnabled()){
|
||||
sender.sendMessage(this.getPlugin().getLangYml().getMessage("descriptions-disabled"));
|
||||
return;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
((EcoEnchantsPlugin) this.getPlugin()).getDataYml().toggleDescriptions(player);
|
||||
player.sendMessage(this.getPlugin().getLangYml().getMessage("descriptions-enabled."+((EcoEnchantsPlugin) this.getPlugin()).getDataYml().isDescriptionEnabled(player)));
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.willfp.ecoenchants.config;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.config.yaml.YamlBaseConfig;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class DataYml extends YamlBaseConfig {
|
||||
|
||||
/**
|
||||
* Instantiate data.yml.
|
||||
*
|
||||
* @param plugin Instance of EcoEnchants.
|
||||
*/
|
||||
public DataYml(@NotNull final EcoPlugin plugin) {
|
||||
super("data", false, plugin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get descriptions state (enabled/disabled) for the given player.
|
||||
*
|
||||
* @param player A player to get the descriptions state of.
|
||||
* @return Descriptions state for the given player.
|
||||
*/
|
||||
public boolean isDescriptionEnabled(@NotNull final Player player) {
|
||||
if (this.getBoolOrNull(player.getUniqueId() + ".describe") == null) return true;
|
||||
return this.getBool(player.getUniqueId() + ".describe");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set descriptions state (enabled/disabled) for the given player.
|
||||
*
|
||||
* @param player A player to set the given state for.
|
||||
* @param enabled The state to set for the given player.
|
||||
*/
|
||||
public void setDescriptionEnabled(@NotNull final Player player, final boolean enabled) {
|
||||
this.set(player.getUniqueId() + ".describe", enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle descriptions state (enabled->disabled | disabled->enabled) for the given player.
|
||||
*
|
||||
* @param player A player to toggle the state for.
|
||||
*/
|
||||
public void toggleDescriptions(@NotNull final Player player) {
|
||||
setDescriptionEnabled(player, !isDescriptionEnabled(player));
|
||||
}
|
||||
|
||||
}
|
@ -129,7 +129,10 @@ public class EnchantDisplay extends DisplayModule {
|
||||
|
||||
lore.add(Display.PREFIX + name);
|
||||
if (!options.getDescriptionOptions().isShowingAtBottom()) {
|
||||
if (enchantments.size() <= options.getDescriptionOptions().getThreshold() && options.getDescriptionOptions().isEnabled()) {
|
||||
if (enchantments.size() <= options.getDescriptionOptions().getThreshold()
|
||||
&& options.getDescriptionOptions().isEnabled()
|
||||
&& options.getDescriptionOptions().playerEnabled(player)
|
||||
) {
|
||||
lore.addAll(EnchantmentCache.getEntry(enchantment).getDescription(level));
|
||||
}
|
||||
}
|
||||
@ -159,7 +162,10 @@ public class EnchantDisplay extends DisplayModule {
|
||||
}
|
||||
|
||||
if (options.getDescriptionOptions().isShowingAtBottom()) {
|
||||
if (enchantments.size() <= options.getDescriptionOptions().getThreshold() && options.getDescriptionOptions().isEnabled()) {
|
||||
if (enchantments.size() <= options.getDescriptionOptions().getThreshold()
|
||||
&& options.getDescriptionOptions().isEnabled()
|
||||
&& options.getDescriptionOptions().playerEnabled(player)
|
||||
) {
|
||||
for (Map.Entry<Enchantment, Integer> entry : enchantments.entrySet()) {
|
||||
lore.addAll(EnchantmentCache.getEntry(entry.getKey()).getDescription(entry.getValue()));
|
||||
}
|
||||
|
@ -2,8 +2,11 @@ package com.willfp.ecoenchants.display.options;
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin;
|
||||
import com.willfp.eco.core.PluginDependent;
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class DescriptionOptions extends PluginDependent<EcoPlugin> {
|
||||
/**
|
||||
@ -48,4 +51,15 @@ public class DescriptionOptions extends PluginDependent<EcoPlugin> {
|
||||
color = this.getPlugin().getLangYml().getString("description-color");
|
||||
showingAtBottom = this.getPlugin().getConfigYml().getBool("lore.describe.at-bottom");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get description state for a player
|
||||
*
|
||||
* @param player - a player to get the state for.
|
||||
*/
|
||||
public boolean playerEnabled(@Nullable final Player player) {
|
||||
if (player == null) return true;
|
||||
return ((EcoEnchantsPlugin) this.getPlugin()).getDataYml().isDescriptionEnabled(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -34,4 +34,4 @@ public class Diurnal extends EcoEnchant {
|
||||
|
||||
event.setDamage(event.getDamage() * (1 + (level * multiplier)));
|
||||
}
|
||||
}
|
||||
}
|
@ -41,4 +41,4 @@ public class Tornado extends EcoEnchant {
|
||||
|
||||
this.getPlugin().getScheduler().runLater(() -> victim.setVelocity(victim.getVelocity().clone().add(toAdd)), 1);
|
||||
}
|
||||
}
|
||||
}
|
@ -29,4 +29,5 @@ general-config:
|
||||
maximum-level: 2
|
||||
|
||||
config:
|
||||
velocity-per-level: 0.25
|
||||
velocity-per-level: 0.25
|
||||
time-to-exempt: 60 #In ticks. Time to exempt hit player from being detected by your Anti-Cheat for flying (The higher max velocity is - the higher should be this value)
|
@ -31,6 +31,10 @@ messages:
|
||||
downloaded-locale: "Locale downloaded! Reload config to enact changes."
|
||||
invalid-locale: "&cYou must supply a valid locale! Check the wiki for more information."
|
||||
specify-locale-subcommand: "&cYou must specify whether to export or download a locale!"
|
||||
descriptions-enabled:
|
||||
true: "&fYou have successfully &aenabled &fenchantment descriptions!"
|
||||
false: "&fYou have successfully &cdisabled &fenchantment descriptions!"
|
||||
descriptions-disabled: "&cEnchantment descriptions are disabled on this server."
|
||||
|
||||
no-targets: "&cCannot be applied"
|
||||
no-conflicts: "&cNo conflicts"
|
||||
|
Loading…
Reference in New Issue
Block a user