mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2024-12-22 04:37:42 +01:00
- merge
This commit is contained in:
commit
9d4347ee28
BIN
lib/Iridescent.jar
Normal file
BIN
lib/Iridescent.jar
Normal file
Binary file not shown.
9
pom.xml
9
pom.xml
@ -79,10 +79,17 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MMOCore.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.klyser8.iridescent</groupId>
|
||||
<artifactId>Iridescent</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/Iridescent.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.Indyuce</groupId>
|
||||
<artifactId>MMOLib</artifactId>
|
||||
<version>1.0.7</version>
|
||||
<version>1.2.5</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/MMOLib.jar</systemPath>
|
||||
</dependency>
|
||||
|
@ -1,6 +1,8 @@
|
||||
package net.Indyuce.mmoitems;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
@ -41,9 +43,11 @@ import net.Indyuce.mmoitems.comp.inventory.RPGInventoryHook;
|
||||
import net.Indyuce.mmoitems.comp.itemglow.ItemGlowListener;
|
||||
import net.Indyuce.mmoitems.comp.itemglow.NoGlowListener;
|
||||
import net.Indyuce.mmoitems.comp.mmocore.MMOCoreMMOLoader;
|
||||
import net.Indyuce.mmoitems.comp.placeholderapi.DefaultParser;
|
||||
import net.Indyuce.mmoitems.comp.placeholderapi.PlaceholderAPIParser;
|
||||
import net.Indyuce.mmoitems.comp.placeholderapi.PlaceholderParser;
|
||||
import net.Indyuce.mmoitems.comp.parse.IridescentParser;
|
||||
import net.Indyuce.mmoitems.comp.parse.StringInputParser;
|
||||
import net.Indyuce.mmoitems.comp.parse.placeholders.DefaultPlaceholderParser;
|
||||
import net.Indyuce.mmoitems.comp.parse.placeholders.PlaceholderAPIParser;
|
||||
import net.Indyuce.mmoitems.comp.parse.placeholders.PlaceholderParser;
|
||||
import net.Indyuce.mmoitems.comp.rpg.DefaultHook;
|
||||
import net.Indyuce.mmoitems.comp.rpg.RPGHandler;
|
||||
import net.Indyuce.mmoitems.gui.PluginInventory;
|
||||
@ -102,9 +106,10 @@ public class MMOItems extends JavaPlugin {
|
||||
private ItemManager itemManager;
|
||||
private SetManager setManager;
|
||||
|
||||
private PlaceholderParser placeholderParser = new DefaultParser();
|
||||
private PlaceholderParser placeholderParser = new DefaultPlaceholderParser();
|
||||
private PlayerInventory inventory = new DefaultPlayerInventory();
|
||||
private FlagPlugin flagPlugin = new DefaultFlags();
|
||||
private final List<StringInputParser> stringInputParsers = new ArrayList<>();
|
||||
private HologramSupport hologramSupport;
|
||||
private RPGHandler rpgPlugin;
|
||||
|
||||
@ -202,6 +207,11 @@ public class MMOItems extends JavaPlugin {
|
||||
getLogger().log(Level.INFO, "Hooked onto AdvancedEnchantments");
|
||||
}
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("Iridescent") != null) {
|
||||
stringInputParsers.add(new IridescentParser());
|
||||
getLogger().log(Level.INFO, "Hooked onto Iridescent");
|
||||
}
|
||||
|
||||
if (Bukkit.getPluginManager().getPlugin("HolographicDisplays") != null) {
|
||||
hologramSupport = new HolographicDisplaysPlugin();
|
||||
getLogger().log(Level.INFO, "Hooked onto HolographicDisplays");
|
||||
@ -396,6 +406,10 @@ public class MMOItems extends JavaPlugin {
|
||||
return itemManager;
|
||||
}
|
||||
|
||||
public List<StringInputParser> getStringInputParsers() {
|
||||
return stringInputParsers;
|
||||
}
|
||||
|
||||
public void findRpgPlugin() {
|
||||
if (rpgPlugin != null)
|
||||
return;
|
||||
@ -415,44 +429,44 @@ public class MMOItems extends JavaPlugin {
|
||||
}
|
||||
|
||||
/***
|
||||
* Parses an ItemStack from a string.
|
||||
* Can be used to both get a vanilla material or
|
||||
* an MMOItem. Used by the recipe manager.
|
||||
* Parses an ItemStack from a string. Can be used to both get a vanilla
|
||||
* material or an MMOItem. Used by the recipe manager.
|
||||
*/
|
||||
public ItemStack parseStack(String parse) {
|
||||
ItemStack stack = null;
|
||||
String[] split = parse.split("\\:");
|
||||
String input = split[0];
|
||||
|
||||
|
||||
if (input.contains(".")) {
|
||||
String[] typeId = input.split("\\.");
|
||||
String typeFormat = typeId[0].toUpperCase().replace("-", "_").replace(" ", "_");
|
||||
Validate.isTrue(getTypes().has(typeFormat), "Could not find type " + typeFormat);
|
||||
|
||||
MMOItem mmo = getItems().getMMOItem(MMOItems.plugin.getTypes().get(typeFormat), typeId[1]);
|
||||
if(mmo != null) stack = mmo.newBuilder().build();
|
||||
}
|
||||
else {
|
||||
if (mmo != null)
|
||||
stack = mmo.newBuilder().build();
|
||||
} else {
|
||||
Material mat = Material.AIR;
|
||||
try {
|
||||
mat = Material.valueOf(input.toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
} catch (IllegalArgumentException e) {
|
||||
getLogger().warning("Couldn't parse material from '" + parse + "'!");
|
||||
}
|
||||
|
||||
if(mat != Material.AIR) stack = new ItemStack(mat);
|
||||
|
||||
if (mat != Material.AIR)
|
||||
stack = new ItemStack(mat);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
if(stack != null && split.length > 1)
|
||||
if (stack != null && split.length > 1)
|
||||
stack.setAmount(Integer.parseInt(split[1]));
|
||||
} catch (NumberFormatException e) {
|
||||
getLogger().warning("Couldn't parse amount from '" + parse + "'!");
|
||||
}
|
||||
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
public void debug(Object... message) {
|
||||
if (!getConfig().getBoolean("debug"))
|
||||
return;
|
||||
|
@ -1,9 +1,18 @@
|
||||
package net.Indyuce.mmoitems.api.edition;
|
||||
|
||||
public interface Edition {
|
||||
|
||||
/*
|
||||
* processes the player input; returns true if edition should be closed or
|
||||
* false if it should continue
|
||||
*/
|
||||
public boolean output(String input);
|
||||
|
||||
|
||||
public void enable(String... message);
|
||||
|
||||
|
||||
/*
|
||||
* true if after successful edition, the GUI should go back to the
|
||||
* previously opened GUI or if it should just be ignored
|
||||
*/
|
||||
public boolean shouldGoBack();
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.ChatColor;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.edition.process.AnvilGUI;
|
||||
import net.Indyuce.mmoitems.api.edition.process.ChatEdition;
|
||||
import net.Indyuce.mmoitems.comp.parse.StringInputParser;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.asangarin.hexcolors.ColorParse;
|
||||
@ -61,7 +62,13 @@ public class StatEdition implements Edition {
|
||||
|
||||
@Override
|
||||
public boolean output(String input) {
|
||||
return input.equals("cancel") || stat.whenInput((EditionInventory) inv, ((EditionInventory) inv).getEdited().getType().getConfigFile(), input, info);
|
||||
|
||||
// apply string input parsers
|
||||
for (StringInputParser parser : MMOItems.plugin.getStringInputParsers())
|
||||
input = parser.parseInput(inv.getPlayer(), input);
|
||||
|
||||
return input.equals("cancel")
|
||||
|| stat.whenInput((EditionInventory) inv, ((EditionInventory) inv).getEdited().getType().getConfigFile(), input, info);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,7 +21,8 @@ public abstract class EditionProcess {
|
||||
|
||||
public void input(String input) {
|
||||
if (edition.output(input)) {
|
||||
if(edition.shouldGoBack()) inv.open();
|
||||
if (edition.shouldGoBack())
|
||||
inv.open();
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package net.Indyuce.mmoitems.comp.parse;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.klyser8.iridescent.util.ColorUtil;
|
||||
|
||||
public class IridescentParser implements StringInputParser {
|
||||
|
||||
@Override
|
||||
public String parseInput(Player player, String input) {
|
||||
return ColorUtil.colorMessage(player, input, false);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package net.Indyuce.mmoitems.comp.parse;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface StringInputParser {
|
||||
|
||||
/*
|
||||
* this interface is used to apply changes to string inputs when editing
|
||||
* stats, for instance Iridescent applies weird ass color codes to strings
|
||||
* and therefore all strings must be updated before being processed by stat
|
||||
* edition methods
|
||||
*/
|
||||
public String parseInput(Player player, String input);
|
||||
}
|
@ -1,8 +1,8 @@
|
||||
package net.Indyuce.mmoitems.comp.placeholderapi;
|
||||
package net.Indyuce.mmoitems.comp.parse.placeholders;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
public class DefaultParser implements PlaceholderParser {
|
||||
public class DefaultPlaceholderParser implements PlaceholderParser {
|
||||
@Override
|
||||
public String parse(OfflinePlayer player, String string) {
|
||||
return string.replace("%player%", player.getName());
|
@ -1,4 +1,4 @@
|
||||
package net.Indyuce.mmoitems.comp.placeholderapi;
|
||||
package net.Indyuce.mmoitems.comp.parse.placeholders;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.Indyuce.mmoitems.comp.placeholderapi;
|
||||
package net.Indyuce.mmoitems.comp.parse.placeholders;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.Indyuce.mmoitems.comp.placeholderapi;
|
||||
package net.Indyuce.mmoitems.comp.parse.placeholders;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
@ -57,7 +57,7 @@ public class StringStat extends ItemStat {
|
||||
config.getConfig().set(inv.getEdited().getId() + "." + getPath(), message);
|
||||
inv.registerItemEdition(config);
|
||||
inv.open();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + getName() + " successfully changed to " + message + ".");
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + getName() + " successfully changed to " + message + ChatColor.GRAY + ".");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user