mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-04 22:21:52 +00:00
- Update min. Towny to 0.97.0.0 and remove NotRegisteredException
catches.
This commit is contained in:
1 parent
cb2f8da9c3
commit
ce03d1dd5c
5 files changed
+25
-46
No files matched your search
@@ -7,7 +7,7 @@
|
||||
<groupId>com.palmergames.bukkit</groupId>
|
||||
<artifactId>TownyChat</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>0.88</version>
|
||||
<version>0.89</version>
|
||||
|
||||
<licenses>
|
||||
<license>
|
||||
@@ -74,7 +74,7 @@
|
||||
<dependency>
|
||||
<groupId>com.github.TownyAdvanced</groupId>
|
||||
<artifactId>Towny</artifactId>
|
||||
<version>0.96.7.0</version>
|
||||
<version>0.97.0.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -375,3 +375,5 @@ v0.88:
|
||||
- Fix players who've just recently joined a town/nation/alliance not being included in the town/nation/alliance chats.
|
||||
- Fix spam_time settings not working.
|
||||
- Fix hex color codes not being parsed in TownyChat spy messages.
|
||||
v0.89:
|
||||
- Update min. Towny to 0.97.0.0 and remove NotRegisteredException catches.
|
||||
@@ -45,7 +45,7 @@ public class Chat extends JavaPlugin {
|
||||
private Towny towny = null;
|
||||
private DynmapAPI dynMap = null;
|
||||
|
||||
private static Version requiredTownyVersion = Version.fromString("0.96.5.5");
|
||||
private static Version requiredTownyVersion = Version.fromString("0.97.0.0");
|
||||
public static boolean usingPlaceholderAPI = false;
|
||||
boolean chatConfigError = false;
|
||||
boolean channelsConfigError = false;
|
||||
|
||||
@@ -4,8 +4,8 @@ import com.palmergames.bukkit.TownyChat.config.ChatSettings;
|
||||
import com.palmergames.bukkit.TownyChat.listener.LocalTownyChatEvent;
|
||||
import com.palmergames.bukkit.TownyChat.util.StringReplaceManager;
|
||||
import com.palmergames.bukkit.towny.Towny;
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
import com.palmergames.bukkit.towny.TownySettings;
|
||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||
import com.palmergames.bukkit.towny.object.Government;
|
||||
import com.palmergames.bukkit.towny.object.Nation;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
@@ -237,14 +237,13 @@ public class TownyChatFormatter {
|
||||
* @return string containing the correctly formatted nation/town data
|
||||
*/
|
||||
public static String formatTownyTag(Resident resident, Boolean override, Boolean full) {
|
||||
try {
|
||||
if (resident.hasTown()) {
|
||||
Town town = resident.getTown();
|
||||
Town town = TownyAPI.getInstance().getResidentTownOrNull(resident);
|
||||
String townTag = getTag(town);
|
||||
Nation nation = null;
|
||||
String nationTag = null;
|
||||
if (resident.hasNation()) {
|
||||
nation = town.getNation();
|
||||
nation = TownyAPI.getInstance().getResidentNationOrNull(resident);
|
||||
nationTag = getTag(nation);
|
||||
}
|
||||
|
||||
@@ -288,38 +287,32 @@ public class TownyChatFormatter {
|
||||
}
|
||||
|
||||
}
|
||||
} catch (NotRegisteredException e) {
|
||||
// no town or nation
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String formatTownTag(Resident resident, Boolean override, Boolean full) {
|
||||
try {
|
||||
if (resident.hasTown())
|
||||
if (resident.hasTown()) {
|
||||
Town town = TownyAPI.getInstance().getResidentTownOrNull(resident);
|
||||
if (full)
|
||||
return hexIfCompatible(String.format(ChatSettings.getTownTag(), getName(resident.getTown())));
|
||||
else if (resident.getTown().hasTag())
|
||||
return hexIfCompatible(String.format(ChatSettings.getTownTag(), getTag(resident.getTown())));
|
||||
return hexIfCompatible(String.format(ChatSettings.getTownTag(), getName(town)));
|
||||
else if (town.hasTag())
|
||||
return hexIfCompatible(String.format(ChatSettings.getTownTag(), getTag(town)));
|
||||
else if (override)
|
||||
return hexIfCompatible(String.format(ChatSettings.getTownTag(), getName(resident.getTown())));
|
||||
return hexIfCompatible(String.format(ChatSettings.getTownTag(), getName(town)));
|
||||
|
||||
} catch (NotRegisteredException e) {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public static String formatNationTag(Resident resident, Boolean override, Boolean full) {
|
||||
try {
|
||||
if (resident.hasNation())
|
||||
if (resident.hasNation()) {
|
||||
Nation nation = TownyAPI.getInstance().getResidentNationOrNull(resident);
|
||||
if (full)
|
||||
return hexIfCompatible(String.format(ChatSettings.getNationTag(), getName(resident.getTown().getNation())));
|
||||
else if (resident.getTown().getNation().hasTag())
|
||||
return hexIfCompatible(String.format(ChatSettings.getNationTag(), getTag(resident.getTown().getNation())));
|
||||
return hexIfCompatible(String.format(ChatSettings.getNationTag(), getName(nation)));
|
||||
else if (nation.hasTag())
|
||||
return hexIfCompatible(String.format(ChatSettings.getNationTag(), getTag(nation)));
|
||||
else if (override)
|
||||
return hexIfCompatible(String.format(ChatSettings.getNationTag(), getName(resident.getTown().getNation())));
|
||||
|
||||
} catch (NotRegisteredException e) {
|
||||
return hexIfCompatible(String.format(ChatSettings.getNationTag(), getName(nation)));
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.palmergames.bukkit.TownyChat.listener.LocalTownyChatEvent;
|
||||
import com.palmergames.bukkit.towny.Towny;
|
||||
import com.palmergames.bukkit.towny.TownyAPI;
|
||||
import com.palmergames.bukkit.towny.TownyMessaging;
|
||||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
|
||||
import com.palmergames.bukkit.towny.exceptions.TownyException;
|
||||
import com.palmergames.bukkit.towny.object.Nation;
|
||||
import com.palmergames.bukkit.towny.object.Resident;
|
||||
@@ -54,18 +53,8 @@ public class StandardChannel extends Channel {
|
||||
Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
|
||||
if (resident == null)
|
||||
return;
|
||||
// TODO: When 0.97.0.0 is released, replace 61-68 with:
|
||||
// Town town = TownyAPI.getInstance().getResidentTownOrNull(resident);
|
||||
// Nation nation = TownyAPI.getInstance().getResidentNationOrNull(resident);
|
||||
|
||||
Town town = null;
|
||||
Nation nation = null;
|
||||
try {
|
||||
town = resident.getTown();
|
||||
nation = resident.getTown().getNation();
|
||||
} catch (NotRegisteredException e1) {
|
||||
// Not in a town/nation (doesn't matter which)
|
||||
}
|
||||
Town town = TownyAPI.getInstance().getResidentTownOrNull(resident);
|
||||
Nation nation = TownyAPI.getInstance().getResidentNationOrNull(resident);
|
||||
|
||||
// If player sends a message to a channel it had left
|
||||
// tell the channel to add the player back
|
||||
@@ -345,14 +334,9 @@ public class StandardChannel extends Channel {
|
||||
Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
|
||||
if (resident == null)
|
||||
return null;
|
||||
Town town = null;
|
||||
Nation nation = null;
|
||||
try {
|
||||
town = resident.getTown();
|
||||
nation = resident.getTown().getNation();
|
||||
} catch (NotRegisteredException e1) {
|
||||
// Not in a town/nation (doesn't matter which)
|
||||
}
|
||||
Town town = TownyAPI.getInstance().getResidentTownOrNull(resident);
|
||||
Nation nation = TownyAPI.getInstance().getResidentNationOrNull(resident);
|
||||
|
||||
String format = ChatColor.translateAlternateColorCodes('&', getChannelTag());
|
||||
if (Towny.is116Plus())
|
||||
format = HexFormatter.translateHexColors(format);
|
||||
|
||||
Reference in new issue
Block a user