Skip to content

Commit

Permalink
Refractored some old code
Browse files Browse the repository at this point in the history
  • Loading branch information
Geolykt committed Sep 7, 2020
1 parent 0e244e9 commit d044600
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions resources/patches.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,4 @@ compatibility: false # only has an effect if NBT is used above, if set to true,
getterDeny: # the list of materials can be found at https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Material.html. The plugin will not attempt to read enchantments from these items.
- "TRIPWIRE_HOOK"
- "LEVER"
pluginCompat: # Of course the compatibillities will be automatically disabled if the plugin was not found
combatLogX: true # setting it to true will fix an obscure bug with the plugin and the Bind enchantment
pluginCompat: # Of course the compatibillities will be automatically disabled if the plugin was not found
1 change: 0 additions & 1 deletion resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Enchantments_plus
main: de.geolykt.enchantments_plus.Enchantments_plus
api-version: 1.16
version: ${project.version}
softdepend: [CombatLogX]
commands:
ench:
description: Gives basic access; /ench help.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public List<String> onTabComplete(CommandSender sender, Command commandlabel, St

switch (label) {
case "lasercol":
List<String> resul = new ArrayList<>(Arrays.asList(new String[] {"AQUA","BLACK","BLUE","FUCHSIA",
List<String> resul = new ArrayList<>(Arrays.asList("AQUA","BLACK","BLUE","FUCHSIA",
((Player)sender).getLocale().toLowerCase(Locale.ROOT).contains("us") ? "GRAY" : "GREY",
"GREEN","LIME","MAROON","NAVY","OLIVE","ORANGE","PURPLE","RED","SILVER","TEAL","WHITE","YELLOW"}));
"GREEN","LIME","MAROON","NAVY","OLIVE","ORANGE","PURPLE","RED","SILVER","TEAL","WHITE","YELLOW"));
if (args.length != 1)
resul.removeIf(e -> !e.startsWith(args[1]));
return resul;
Expand Down Expand Up @@ -90,6 +90,8 @@ public List<String> onTabComplete(CommandSender sender, Command commandlabel, St
break;
default:
if (args.length == 1) {
results.addAll(Arrays.asList("version", "info", "list", "lasercol"));
results.removeIf(e -> !e.startsWith(args[0]));
for (Map.Entry<String, CustomEnchantment> ench : config.getSimpleMappings()) {
if (ench.getKey().startsWith(args[0].toLowerCase(Locale.ENGLISH)) && (stack.getType() == BOOK
|| stack.getType() == ENCHANTED_BOOK || ench.getValue().validMaterial(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.geolykt.enchantments_plus.compatibility;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.EnumSet;
Expand Down Expand Up @@ -40,7 +41,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import de.geolykt.enchantments_plus.Config;
import de.geolykt.enchantments_plus.Storage;

public class CompatibilityAdapter {
Expand Down Expand Up @@ -98,9 +98,13 @@ public void loadValues(FileConfiguration config) {
}
for (String s : config.getStringList("terraformerAllowlistTags")) {
try {
terraformerAllowlist.addAll(((Tag<Material>)Tag.class.getDeclaredField(s).get(null)).getValues()); // FIXME do this properly
Field f = Tag.class.getDeclaredField(s);
@SuppressWarnings("unchecked")
Tag<? extends Material> tag = (Tag<? extends Material>) f.get(null);
terraformerAllowlist.addAll(tag.getValues());
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
// TODO Auto-generated catch block
Bukkit.getLogger().warning("looks like an issue occoured with the Enchantments+ plugin. "
+ "This is likely the cause of an unsupported minecraft version.");
e.printStackTrace();
}
}
Expand Down Expand Up @@ -638,11 +642,6 @@ private void scanMethods() {
+ " for the EntityShootBowEvent. Handle with care and update to a newer Spigot (or Paper) version.");
legacyEntityShootBowEvent = true;
}

if (Config.PATCH_CONFIGURATION.getBoolean("pluginCompat.combatLogX", true) && Bukkit.getPluginManager().getPlugin("CombatLogX") != null) {
Bukkit.getLogger().warning(Storage.MINILOGO + " The Bind enchantments is known to be incompatible with the combatLogX plugin."
+ " This can easily be fixed by using the kill command instead and by setting the punish kill time to never.");
}
}

/**
Expand Down

0 comments on commit d044600

Please sign in to comment.