mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-03 22:21:20 +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
+76
-97
No files matched your search
@@ -7,7 +7,7 @@
|
|||||||
<groupId>com.palmergames.bukkit</groupId>
|
<groupId>com.palmergames.bukkit</groupId>
|
||||||
<artifactId>TownyChat</artifactId>
|
<artifactId>TownyChat</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>0.88</version>
|
<version>0.89</version>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.TownyAdvanced</groupId>
|
<groupId>com.github.TownyAdvanced</groupId>
|
||||||
<artifactId>Towny</artifactId>
|
<artifactId>Towny</artifactId>
|
||||||
<version>0.96.7.0</version>
|
<version>0.97.0.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@@ -374,4 +374,6 @@ v0.87:
|
|||||||
v0.88:
|
v0.88:
|
||||||
- Fix players who've just recently joined a town/nation/alliance not being included in the town/nation/alliance chats.
|
- 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 spam_time settings not working.
|
||||||
- Fix hex color codes not being parsed in TownyChat spy messages.
|
- 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 Towny towny = null;
|
||||||
private DynmapAPI dynMap = 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;
|
public static boolean usingPlaceholderAPI = false;
|
||||||
boolean chatConfigError = false;
|
boolean chatConfigError = false;
|
||||||
boolean channelsConfigError = 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.listener.LocalTownyChatEvent;
|
||||||
import com.palmergames.bukkit.TownyChat.util.StringReplaceManager;
|
import com.palmergames.bukkit.TownyChat.util.StringReplaceManager;
|
||||||
import com.palmergames.bukkit.towny.Towny;
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
import com.palmergames.bukkit.towny.TownySettings;
|
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.Government;
|
||||||
import com.palmergames.bukkit.towny.object.Nation;
|
import com.palmergames.bukkit.towny.object.Nation;
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
@@ -237,89 +237,82 @@ public class TownyChatFormatter {
|
|||||||
* @return string containing the correctly formatted nation/town data
|
* @return string containing the correctly formatted nation/town data
|
||||||
*/
|
*/
|
||||||
public static String formatTownyTag(Resident resident, Boolean override, Boolean full) {
|
public static String formatTownyTag(Resident resident, Boolean override, Boolean full) {
|
||||||
try {
|
if (resident.hasTown()) {
|
||||||
if (resident.hasTown()) {
|
Town town = TownyAPI.getInstance().getResidentTownOrNull(resident);
|
||||||
Town town = resident.getTown();
|
String townTag = getTag(town);
|
||||||
String townTag = getTag(town);
|
Nation nation = null;
|
||||||
Nation nation = null;
|
String nationTag = null;
|
||||||
String nationTag = null;
|
if (resident.hasNation()) {
|
||||||
if (resident.hasNation()) {
|
nation = TownyAPI.getInstance().getResidentNationOrNull(resident);
|
||||||
nation = town.getNation();
|
nationTag = getTag(nation);
|
||||||
nationTag = getTag(nation);
|
|
||||||
}
|
|
||||||
|
|
||||||
String nTag = "", tTag = "";
|
|
||||||
|
|
||||||
//Force use of full names only
|
|
||||||
if (full) {
|
|
||||||
nationTag = "";
|
|
||||||
townTag = "";
|
|
||||||
}
|
|
||||||
// Load town tags/names
|
|
||||||
if (townTag != null && !townTag.isEmpty())
|
|
||||||
tTag = townTag;
|
|
||||||
else if (override || full)
|
|
||||||
tTag = getName(town);
|
|
||||||
|
|
||||||
// Load the nation tags/names
|
|
||||||
if ((nationTag != null) && !nationTag.isEmpty())
|
|
||||||
nTag = nationTag;
|
|
||||||
else if (resident.hasNation() && (override || full))
|
|
||||||
nTag = getName(nation);
|
|
||||||
|
|
||||||
// Output depending on what tags are present
|
|
||||||
if ((!tTag.isEmpty()) && (!nTag.isEmpty())) {
|
|
||||||
if (ChatSettings.getBothTags().contains("%t") || ChatSettings.getBothTags().contains("%n")) {
|
|
||||||
// Then it contains %s & %s
|
|
||||||
// Small suttle change so that an issue is solved, it is documented in the config.
|
|
||||||
// But only after addition of this. (v0.50)
|
|
||||||
return ChatSettings.getBothTags().replace("%t", tTag).replace("%n", nTag);
|
|
||||||
} else {
|
|
||||||
return String.format(ChatSettings.getBothTags(), nTag, tTag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!nTag.isEmpty()) {
|
|
||||||
return String.format(ChatSettings.getNationTag(), nTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tTag.isEmpty()) {
|
|
||||||
return String.format(ChatSettings.getTownTag(), tTag);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
// no town or nation
|
String nTag = "", tTag = "";
|
||||||
|
|
||||||
|
//Force use of full names only
|
||||||
|
if (full) {
|
||||||
|
nationTag = "";
|
||||||
|
townTag = "";
|
||||||
|
}
|
||||||
|
// Load town tags/names
|
||||||
|
if (townTag != null && !townTag.isEmpty())
|
||||||
|
tTag = townTag;
|
||||||
|
else if (override || full)
|
||||||
|
tTag = getName(town);
|
||||||
|
|
||||||
|
// Load the nation tags/names
|
||||||
|
if ((nationTag != null) && !nationTag.isEmpty())
|
||||||
|
nTag = nationTag;
|
||||||
|
else if (resident.hasNation() && (override || full))
|
||||||
|
nTag = getName(nation);
|
||||||
|
|
||||||
|
// Output depending on what tags are present
|
||||||
|
if ((!tTag.isEmpty()) && (!nTag.isEmpty())) {
|
||||||
|
if (ChatSettings.getBothTags().contains("%t") || ChatSettings.getBothTags().contains("%n")) {
|
||||||
|
// Then it contains %s & %s
|
||||||
|
// Small suttle change so that an issue is solved, it is documented in the config.
|
||||||
|
// But only after addition of this. (v0.50)
|
||||||
|
return ChatSettings.getBothTags().replace("%t", tTag).replace("%n", nTag);
|
||||||
|
} else {
|
||||||
|
return String.format(ChatSettings.getBothTags(), nTag, tTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nTag.isEmpty()) {
|
||||||
|
return String.format(ChatSettings.getNationTag(), nTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!tTag.isEmpty()) {
|
||||||
|
return String.format(ChatSettings.getTownTag(), tTag);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatTownTag(Resident resident, Boolean override, Boolean full) {
|
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)
|
if (full)
|
||||||
return hexIfCompatible(String.format(ChatSettings.getTownTag(), getName(resident.getTown())));
|
return hexIfCompatible(String.format(ChatSettings.getTownTag(), getName(town)));
|
||||||
else if (resident.getTown().hasTag())
|
else if (town.hasTag())
|
||||||
return hexIfCompatible(String.format(ChatSettings.getTownTag(), getTag(resident.getTown())));
|
return hexIfCompatible(String.format(ChatSettings.getTownTag(), getTag(town)));
|
||||||
else if (override)
|
else if (override)
|
||||||
return hexIfCompatible(String.format(ChatSettings.getTownTag(), getName(resident.getTown())));
|
return hexIfCompatible(String.format(ChatSettings.getTownTag(), getName(town)));
|
||||||
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatNationTag(Resident resident, Boolean override, Boolean full) {
|
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)
|
if (full)
|
||||||
return hexIfCompatible(String.format(ChatSettings.getNationTag(), getName(resident.getTown().getNation())));
|
return hexIfCompatible(String.format(ChatSettings.getNationTag(), getName(nation)));
|
||||||
else if (resident.getTown().getNation().hasTag())
|
else if (nation.hasTag())
|
||||||
return hexIfCompatible(String.format(ChatSettings.getNationTag(), getTag(resident.getTown().getNation())));
|
return hexIfCompatible(String.format(ChatSettings.getNationTag(), getTag(nation)));
|
||||||
else if (override)
|
else if (override)
|
||||||
return hexIfCompatible(String.format(ChatSettings.getNationTag(), getName(resident.getTown().getNation())));
|
return hexIfCompatible(String.format(ChatSettings.getNationTag(), getName(nation)));
|
||||||
|
|
||||||
} catch (NotRegisteredException e) {
|
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.palmergames.bukkit.TownyChat.listener.LocalTownyChatEvent;
|
|||||||
import com.palmergames.bukkit.towny.Towny;
|
import com.palmergames.bukkit.towny.Towny;
|
||||||
import com.palmergames.bukkit.towny.TownyAPI;
|
import com.palmergames.bukkit.towny.TownyAPI;
|
||||||
import com.palmergames.bukkit.towny.TownyMessaging;
|
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.exceptions.TownyException;
|
||||||
import com.palmergames.bukkit.towny.object.Nation;
|
import com.palmergames.bukkit.towny.object.Nation;
|
||||||
import com.palmergames.bukkit.towny.object.Resident;
|
import com.palmergames.bukkit.towny.object.Resident;
|
||||||
@@ -54,18 +53,8 @@ public class StandardChannel extends Channel {
|
|||||||
Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
|
Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
|
||||||
if (resident == null)
|
if (resident == null)
|
||||||
return;
|
return;
|
||||||
// TODO: When 0.97.0.0 is released, replace 61-68 with:
|
Town town = TownyAPI.getInstance().getResidentTownOrNull(resident);
|
||||||
// Town town = TownyAPI.getInstance().getResidentTownOrNull(resident);
|
Nation nation = TownyAPI.getInstance().getResidentNationOrNull(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)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If player sends a message to a channel it had left
|
// If player sends a message to a channel it had left
|
||||||
// tell the channel to add the player back
|
// tell the channel to add the player back
|
||||||
@@ -345,14 +334,9 @@ public class StandardChannel extends Channel {
|
|||||||
Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
|
Resident resident = TownyUniverse.getInstance().getResident(player.getUniqueId());
|
||||||
if (resident == null)
|
if (resident == null)
|
||||||
return null;
|
return null;
|
||||||
Town town = null;
|
Town town = TownyAPI.getInstance().getResidentTownOrNull(resident);
|
||||||
Nation nation = null;
|
Nation nation = TownyAPI.getInstance().getResidentNationOrNull(resident);
|
||||||
try {
|
|
||||||
town = resident.getTown();
|
|
||||||
nation = resident.getTown().getNation();
|
|
||||||
} catch (NotRegisteredException e1) {
|
|
||||||
// Not in a town/nation (doesn't matter which)
|
|
||||||
}
|
|
||||||
String format = ChatColor.translateAlternateColorCodes('&', getChannelTag());
|
String format = ChatColor.translateAlternateColorCodes('&', getChannelTag());
|
||||||
if (Towny.is116Plus())
|
if (Towny.is116Plus())
|
||||||
format = HexFormatter.translateHexColors(format);
|
format = HexFormatter.translateHexColors(format);
|
||||||
|
|||||||
Reference in new issue
Block a user