Skip to content

Commit d1ac60a

Browse files
committed
Updated: Made item aliases an optional feature, item aliases can now be set in item_aliases.csv when required. Also makes the default kit valid now (excluding an issue with damage values).
1 parent b8958b3 commit d1ac60a

File tree

15 files changed

+40
-53
lines changed

15 files changed

+40
-53
lines changed

modules/RoyalCommands/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<includes>
2424
<include>*.yml</include>
2525
<include>*.txt</include>
26-
<include>items.csv</include>
26+
<include>item_aliases.csv</include>
2727
</includes>
2828
</resource>
2929
</resources>

modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/Config.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -366,15 +366,15 @@ public void reloadConfiguration() {
366366

367367
Reader in = null;
368368
try {
369-
in = new FileReader(new File(this.plugin.getDataFolder() + File.separator + "items.csv"));
369+
in = new FileReader(new File(this.plugin.getDataFolder() + File.separator + "item_aliases.csv"));
370370
CSVReader reader = new CSVReader(in);
371371
RoyalCommands.inm = new ItemNameManager(reader.readAll());
372372
reader.close();
373373
} catch (FileNotFoundException e) {
374-
this.plugin.getLogger().warning("items.csv was not found! Item aliases will not be used.");
374+
this.plugin.getLogger().warning("item_aliases.csv was not found! Item aliases will not be used.");
375375
RoyalCommands.inm = null;
376376
} catch (final IOException e) {
377-
this.plugin.getLogger().warning("Internal input/output error loading items.csv. Item aliases will not be used.");
377+
this.plugin.getLogger().warning("Internal input/output error loading item_aliases.csv. Item aliases will not be used.");
378378
RoyalCommands.inm = null;
379379
} finally {
380380
try {

modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/ItemNameManager.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,30 @@ public class ItemNameManager {
2626
public ItemNameManager(Iterable<String[]> values) {
2727
for (String[] s : values) {
2828
if (s.length < 1) continue;
29+
if (s[0].startsWith("#")) continue;
2930
String[] aliases;
3031
try {
31-
aliases = s[2].split(",");
32+
aliases = s[1].split(",");
3233
} catch (IndexOutOfBoundsException e) {
3334
Logger l = Logger.getLogger("Minecraft");
3435
l.warning("[RoyalCommands] Values passed in ItemNameManager invalid: ");
3536
for (String ss : s) l.warning("[RoyalCommands] - " + ss);
3637
continue;
3738
}
3839
Material m;
39-
short data;
40+
short data = 0;
4041
try {
4142
m = Material.valueOf(s[0]);
4243
} catch (IllegalArgumentException ex) {
43-
RoyalCommands.getInstance().getLogger().warning("Material in items.csv is invalid: " + s[0]);
44-
continue;
45-
}
46-
try {
47-
data = Short.valueOf(s[1]);
48-
} catch (NumberFormatException e) {
49-
RoyalCommands.getInstance().getLogger().warning("Data in items.csv file is invalid: " + s[1]);
44+
RoyalCommands.getInstance().getLogger().warning("Material in item_aliases.csv is invalid: " + s[0]);
5045
continue;
5146
}
47+
// try {
48+
// data = Short.valueOf(s[1]);
49+
// } catch (NumberFormatException e) {
50+
// RoyalCommands.getInstance().getLogger().warning("Data in item_aliases.csv file is invalid: " + s[1]);
51+
// continue;
52+
// }
5253
synchronized (items) {
5354
items.put(aliases, new Pair<>(m, data));
5455
}

modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/RUtils.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
package org.royaldev.royalcommands;
77

8+
import org.apache.commons.lang3.ArrayUtils;
89
import org.mvplugins.multiverse.core.world.LoadedMultiverseWorld;
910
import org.mvplugins.multiverse.core.world.MultiverseWorld;
1011

@@ -86,6 +87,7 @@
8687
import org.royaldev.royalcommands.rcommands.CmdBack;
8788
import org.royaldev.royalcommands.spawninfo.SpawnInfo;
8889
import org.royaldev.royalcommands.tools.NameFetcher;
90+
import org.royaldev.royalcommands.tools.Pair;
8991
import org.royaldev.royalcommands.tools.UUIDFetcher;
9092

9193
@SuppressWarnings("unused")

modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/RoyalCommands.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ public boolean isVanished(Player p, CommandSender cs) {
392392

393393
public void loadConfiguration() {
394394
if (!new File(getDataFolder(), "config.yml").exists()) saveDefaultConfig();
395-
if (!new File(getDataFolder(), "items.csv").exists()) saveResource("items.csv", false);
395+
if (!new File(getDataFolder(), "item_aliases.csv").exists()) saveResource("item_aliases.csv", false);
396396
if (!new File(getDataFolder(), "rules.txt").exists()) saveResource("rules.txt", false);
397397
if (!new File(getDataFolder(), "help.txt").exists()) saveResource("help.txt", false);
398398
if (!new File(getDataFolder(), "warps.yml").exists()) saveResource("warps.yml", false);

modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/rcommands/CmdGive.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
public class CmdGive extends TabCommand {
2626

2727
public CmdGive(final RoyalCommands instance, final String name) {
28-
super(instance, name, true, new Short[]{CompletionType.ONLINE_PLAYER.getShort(), CompletionType.ITEM_ALIAS.getShort()});
28+
super(instance, name, true, new Short[]{CompletionType.ONLINE_PLAYER.getShort(), CompletionType.ITEM.getShort()});
2929
}
3030

3131
public static boolean giveItemStandalone(CommandSender cs, Player target, String itemname, int amount) {

modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/rcommands/CmdHelmet.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
public class CmdHelmet extends TabCommand {
2222

2323
public CmdHelmet(final RoyalCommands instance, final String name) {
24-
super(instance, name, true, new Short[]{CompletionType.ITEM_ALIAS.getShort()});
24+
super(instance, name, true, new Short[]{CompletionType.ITEM.getShort()});
2525
}
2626
/**
2727
* TODO: Add support to add a helmet to another player

modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/rcommands/CmdItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class CmdItem extends TabCommand {
3030
private static final Flag<String> loreFlag = new Flag<>(String.class, "description", "lore", "l");
3131

3232
public CmdItem(final RoyalCommands instance, final String name) {
33-
super(instance, name, true, new Short[]{CompletionType.ITEM_ALIAS.getShort()});
33+
super(instance, name, true, new Short[]{CompletionType.ITEM.getShort()});
3434
this.addExpectedFlag(CmdItem.nameFlag);
3535
this.addExpectedFlag(CmdItem.loreFlag);
3636
}

modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/rcommands/CmdRecipe.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@
3636
import org.royaldev.royalcommands.MessageColor;
3737
import org.royaldev.royalcommands.RUtils;
3838
import org.royaldev.royalcommands.RoyalCommands;
39-
import org.royaldev.royalcommands.exceptions.InvalidItemNameException;
39+
4040

4141
@ReflectCommand
4242
public class CmdRecipe extends TabCommand {
4343

4444
private final Map<String, Integer> tasks = new HashMap<>();
4545

4646
public CmdRecipe(final RoyalCommands instance, final String name) {
47-
super(instance, name, true, new Short[]{CompletionType.ITEM_ALIAS.getShort()});
47+
super(instance, name, true, new Short[]{CompletionType.ITEM.getShort()});
4848
this.plugin.getServer().getPluginManager().registerEvents(new WorkbenchCloseListener(), this.plugin);
4949
}
5050

modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/rcommands/CmdUses.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class CmdUses extends TabCommand {
4747
private final Map<String, Integer> tasks = new HashMap<>();
4848

4949
public CmdUses(final RoyalCommands instance, final String name) {
50-
super(instance, name, true, new Short[]{CompletionType.ITEM_ALIAS.getShort()});
50+
super(instance, name, true, new Short[]{CompletionType.ITEM.getShort()});
5151
this.plugin.getServer().getPluginManager().registerEvents(new WorkbenchCloseListener(), this.plugin);
5252
}
5353

0 commit comments

Comments
 (0)