Skip to content

Commit

Permalink
Fixed prefixes and inputs
Browse files Browse the repository at this point in the history
Fixed annoying bugs with prefixes and war inputs.
  • Loading branch information
ShermansWorld committed Dec 23, 2022
1 parent d8ede6d commit 732b3a8
Show file tree
Hide file tree
Showing 10 changed files with 281 additions and 418 deletions.
2 changes: 1 addition & 1 deletion AlathraWar2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>me.ShermansWorld</groupId>
<artifactId>AlathraWar</artifactId>
<version>1.2.2</version>
<version>1.3</version>
<packaging>jar</packaging>

<name>AlathraWar</name>
Expand Down
6 changes: 3 additions & 3 deletions AlathraWar2/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: AlathraWar
version: 1.2.2
version: 1.3
api-version: 1.19
author: ShermansWorld
main: me.ShermansWorld.AlathraWar.Main
depend: [Vault, Towny, LuckPerms]
depend: [Vault, Towny, TAB]

commands:
war:
description: used to create, delete, join and leave wars
softdepend: [Vault, Towny, LuckPerms]
softdepend: [Vault, Towny, TAB]
siege:
description: used to start, end, and view sieges
softdepend: [Vault, Towny]
Expand Down
1 change: 0 additions & 1 deletion AlathraWar2/resources/prefixes.yml

This file was deleted.

48 changes: 9 additions & 39 deletions AlathraWar2/src/main/java/me/ShermansWorld/AlathraWar/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@
import me.ShermansWorld.AlathraWar.commands.SiegeTabCompletion;
import me.ShermansWorld.AlathraWar.commands.WarCommands;
import me.ShermansWorld.AlathraWar.commands.WarTabCompletion;
import me.ShermansWorld.AlathraWar.data.PrefixData;
import me.ShermansWorld.AlathraWar.data.RolesData;
import me.ShermansWorld.AlathraWar.data.SiegeData;
import me.ShermansWorld.AlathraWar.data.WarData;
import me.ShermansWorld.AlathraWar.hooks.LuckPermsHook;
import me.ShermansWorld.AlathraWar.hooks.TABHook;
import me.ShermansWorld.AlathraWar.listeners.BlockBreakListener;
import me.ShermansWorld.AlathraWar.listeners.JoinListener;
Expand All @@ -38,7 +36,6 @@ public class Main extends JavaPlugin {

public static WarData warData;
public static SiegeData siegeData;
public static PrefixData prefixData;
public static RolesData rolesData;
public static Main instance;
public static Economy econ;
Expand All @@ -61,39 +58,29 @@ private static void initData() {
Iterator<String> it = warsSet.iterator();
ArrayList<String> warsTempList = new ArrayList<String>();
while (it.hasNext()) {
warsTempList.add(it.next().toLowerCase());
warsTempList.add(it.next());
}
for (int i = 0; i < warsTempList.size(); ++i) {
final War war = new War(warsTempList.get(i).toLowerCase(),
warData.getConfig().getString("Wars." + warsTempList.get(i) + ".side1"),
warData.getConfig().getString("Wars." + warsTempList.get(i) + ".side2"));
ArrayList<String> side1Players = new ArrayList<String>();
ArrayList<String> side2Players = new ArrayList<String>();
ArrayList<String> side1Mercs = new ArrayList<String>();
ArrayList<String> side2Mercs = new ArrayList<String>();
side1Players = (ArrayList<String>) warData.getConfig()
.getList("Wars." + war.getName() + ".side1players");
side2Players = (ArrayList<String>) warData.getConfig()
.getList("Wars." + war.getName() + ".side2players");
side1Mercs = (ArrayList<String>) warData.getConfig()
.getList("Wars." + war.getName() + ".side1mercs");
side2Mercs = (ArrayList<String>) warData.getConfig()
.getList("Wars." + war.getName() + ".side2mercs");
war.setSide1Players(side1Players);
war.setSide2Players(side2Players);
war.setSide1Mercs(side1Mercs);
war.setSide2Mercs(side2Mercs);
WarCommands.wars.add(war);
for (final String playerName : war.getSide1Players()) {
try {
Bukkit.getServer().getPlayer(playerName)
.setPlayerListName(String.valueOf(Helper.color(
new StringBuilder("&c[").append(war.getSide1()).append("]&r").toString()))
+ playerName);
} catch (NullPointerException ex) {
}
}
for (final String playerName : war.getSide2Players()) {
try {
Bukkit.getServer().getPlayer(playerName)
.setPlayerListName(String.valueOf(Helper.color(
new StringBuilder("&9[").append(war.getSide2()).append("]&r").toString()))
+ playerName);
} catch (NullPointerException ex2) {
}
}
}
} catch (NullPointerException e) {
Bukkit.getLogger().info("NULL when initializing wars");
Expand Down Expand Up @@ -137,21 +124,6 @@ private static void initData() {
} catch (NullPointerException e) {
Bukkit.getLogger().info("NULL when initializing sieges");
}
try {
Set<String> prefixSet = (Set<String>) prefixData.getConfig().getConfigurationSection("Prefixes")
.getKeys(false);
Iterator<String> it3 = prefixSet.iterator();
ArrayList<String> prefixesTempList = new ArrayList<String>();
while (it3.hasNext()) {
prefixesTempList.add(it3.next());
}
for (int i = 0; i < prefixesTempList.size(); ++i) {
LuckPermsHook.prefixMap.put(prefixesTempList.get(i),
prefixData.getConfig().getString("Prefixes." + prefixesTempList.get(i)));
}
} catch (NullPointerException e) {
Bukkit.getLogger().info("NULL when initializing prefixes");
}
}

@SuppressWarnings("rawtypes")
Expand Down Expand Up @@ -191,15 +163,13 @@ public static void initLogs() {
}

private static void initAPIs() {
LuckPermsHook.init();
TABHook.init();
}

public void onEnable() {
instance = this;
warData = new WarData(this);
siegeData = new SiegeData(this);
prefixData = new PrefixData(this);
new WarCommands(this);
new SiegeCommands(this);
new MercCommand(this);
Expand Down
Loading

0 comments on commit 732b3a8

Please sign in to comment.