Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added: SoftMode - don't edit the Chat if other plugin is present (so far

mChatSuite, bChatManager, ChatManager, EssentialsChat)
Changed: Write only the players.yml if player changes something
Changed: After tabList make it white again
  • Loading branch information...
commit 9c020b037b3cd0209c4818e32aaa51d6ffd69b4f 1 parent 5119b15
@timbru31 authored
View
2  src/de/dustplanet/colorme/Actions.java
@@ -278,7 +278,7 @@ else if (color.equalsIgnoreCase("rainbow")) {
else if (ColorMe.colors.contains(color) && (ColorMe.colors.getString(color).trim().length() > 1 ? true : false) == true) {
newName = updateCustomColor(color, cleanDisplayName);
}
- else newName = ChatColor.valueOf(color.toUpperCase()) + cleanDisplayName;
+ else newName = ChatColor.valueOf(color.toUpperCase()) + cleanDisplayName + ChatColor.WHITE;
// Shorten it, if too long
if (newName != null || !newName.equals("")) {
if (newName.length() > 16) {
View
44 src/de/dustplanet/colorme/ColorMe.java
@@ -56,7 +56,7 @@
public static FileConfiguration config, players, localization, colors;
public static File configFile, playersFile, localizationFile, colorsFile, bannedWordsFile, debugFile;
public static boolean tabList, playerTitle, playerTitleWithoutSpout, displayName, debug, spoutEnabled, Prefixer, Suffixer, globalSuffix, globalPrefix, globalColor, chatBrackets, chatColors, signColors, newColorOnJoin, displayAlwaysGlobalPrefix, displayAlwaysGlobalSuffix, blacklist;
- public static boolean groups, ownSystem, pex, bPermissions, groupManager;
+ public static boolean groups, ownSystem, pex, bPermissions, groupManager, softMode, otherChatPluginFound;
public static int prefixLength, suffixLength;
private ColorMeCommands colorExecutor;
private PrefixCommands prefixExecutor;
@@ -175,9 +175,9 @@ public void onEnable() {
suffixExecutor = new SuffixCommands(this);
getCommand("suffix").setExecutor(suffixExecutor);
- // Refer to GroupCommands
- groupExecutor = new GroupCommands(this);
- getCommand("group").setExecutor(groupExecutor);
+// // Refer to GroupCommands
+// groupExecutor = new GroupCommands(this);
+// getCommand("group").setExecutor(groupExecutor);
// Message
PluginDescriptionFile pdfFile = this.getDescription();
@@ -250,6 +250,40 @@ else if (groups) {
logDebug("Groups disabled");
this.getServer().getLogger().info("[ColorMe] Groups disabled.");
}
+
+ // SoftMode
+ if (softMode) {
+ logDebug("SoftMode enabled");
+ this.getServer().getLogger().info("[ColorMe] SoftMode enabled. If other chat plugins are found, the chat won't be affected by ColorMe.");
+ Plugin chatManager = this.getServer().getPluginManager().getPlugin("ChatManager");
+ Plugin bChatManager = this.getServer().getPluginManager().getPlugin("bChatManager");
+ Plugin EssentialsChat = this.getServer().getPluginManager().getPlugin("EssentialsChat");
+ Plugin mChatSuite = this.getServer().getPluginManager().getPlugin("mChatSuite");
+ if (chatManager != null) {
+ otherChatPluginFound = true;
+ this.getServer().getLogger().info("[ColorMe] Found ChatManager. Will use it for chat!");
+ logDebug("Found ChatManager");
+ }
+ else if (bChatManager != null) {
+ otherChatPluginFound = true;
+ this.getServer().getLogger().info("[ColorMe] Found bChatManager. Will use it for chat!");
+ logDebug("Found bChatManager");
+ }
+ else if (EssentialsChat != null) {
+ otherChatPluginFound = true;
+ this.getServer().getLogger().info("[ColorMe] Found EssentialsChat. Will use it for chat!");
+ logDebug("Found EssentialsChat");
+ }
+ else if (mChatSuite != null) {
+ otherChatPluginFound = true;
+ this.getServer().getLogger().info("[ColorMe] Found mChatSuite. Will use it for chat!");
+ logDebug("Found mChatSuite");
+ }
+ }
+ else {
+ logDebug("SoftMode disabled");
+ this.getServer().getLogger().info("[ColorMe] SoftMode disabled. Trying to override other chat plugins.");
+ }
// Stats
checkStatsStuff();
@@ -409,6 +443,7 @@ public void loadConfig() {
config.addDefault("useWordBlacklist", true);
config.addDefault("groups.enable", true);
config.addDefault("groups.ownSystem", true);
+ config.addDefault("softMode", true);
config.options().copyDefaults(true);
saveConfig();
}
@@ -558,6 +593,7 @@ private static void checkParts() {
blacklist = config.getBoolean("useWordBlacklist");
groups = config.getBoolean("groups.enable");
ownSystem = config.getBoolean("groups.ownSystem");
+ softMode = config.getBoolean("softMode");
if (debug) {
logDebug("Suffixer is " + Suffixer);
logDebug("Prefixer is " + Prefixer);
View
47 src/de/dustplanet/colorme/ColorMePlayerListener.java
@@ -1,6 +1,5 @@
package de.dustplanet.colorme;
-import java.io.IOException;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -8,9 +7,9 @@
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
-// PEX Import
-import ru.tehkode.permissions.PermissionUser;
+//PEX Import
import ru.tehkode.permissions.PermissionGroup;
+import ru.tehkode.permissions.PermissionUser;
import ru.tehkode.permissions.bukkit.PermissionsEx;
//bPermissions Import
import de.bananaco.bpermissions.api.ApiLayer;
@@ -59,13 +58,14 @@ public void onPlayerJoin(PlayerJoinEvent event) {
else if (color == ChatColor.values().length + 2) Actions.set(name, "random", world, pluginPart[0]);
else Actions.set(name, ChatColor.values()[color].name().toLowerCase(), world, pluginPart[0]);
}
- CheckRoutine(player, name, world);
+ Actions.checkNames(name, world);
}
// Loads the the values and set them to default one if not known
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerChat(PlayerChatEvent event) {
+ if (ColorMe.otherChatPluginFound) return;
ColorMe.logDebug("\t---PlayerChatEvent Begin---");
Player player = event.getPlayer();
String name = player.getName().toLowerCase(), nameExact = player.getName();
@@ -103,7 +103,6 @@ else if (ColorMe.groupManager) {
if (!groupPrefix.equals("")) groupPrefix += " ";
}
- CheckRoutine(player, name, world);
if (ColorMe.Prefixer) {
// Get world prefix if available
if (Actions.has(name, world, "prefix")) {
@@ -169,42 +168,4 @@ else if (ColorMe.globalSuffix) {
ColorMe.logDebug("\t---PlayerChatEvent End---");
ColorMe.logDebug("");
}
-
- // Check for the player and update the file is values are unknown
- private void CheckRoutine(Player player, String name, String world) {
- // If the player isn't in the players.yml add him
- if (!ColorMe.players.contains(name)) {
- ColorMe.players.set(name + ".colors.default", "");
- ColorMe.players.set(name + ".prefix.default", "");
- ColorMe.players.set(name + ".suffix.default", "");
- ColorMe.players.set(name + ".colors." + world, "");
- ColorMe.players.set(name + ".prefix." + world, "");
- ColorMe.players.set(name + ".suffix." + world, "");
- try {
- ColorMe.players.save(ColorMe.playersFile);
- } catch (IOException e) {
- plugin.getServer().getLogger().warning("Failed to save the players.yml! Please report this! IOException");
- }
- }
- for (int i = 0; i <= 2; i++) {
- String actualPart = pluginPart[i];
- if (!ColorMe.players.contains(name + "." + actualPart + "." + world)) {
- ColorMe.players.set(name + "." + actualPart + "." + world, "");
- try {
- ColorMe.players.save(ColorMe.playersFile);
- } catch (IOException e) {
- plugin.getServer().getLogger().warning("Failed to save the players.yml! Please report this! IOException");
- }
- }
- if (!ColorMe.players.contains(name + "." + actualPart + "." + "default")) {
- ColorMe.players.set(name + "." + actualPart + "." + "default", "");
- try {
- ColorMe.players.save(ColorMe.playersFile);
- } catch (IOException e) {
- plugin.getServer().getLogger().warning("Failed to save the players.yml! Please report this! IOException");
- }
- }
- }
- Actions.checkNames(name, world);
- }
}
View
2  src/plugin.yml
@@ -1,6 +1,6 @@
name: ColorMe
main: de.dustplanet.colorme.ColorMe
-version: 3.5 dev6
+version: 3.5 dev7
author: xGhOsTkiLLeRx
authors: [Valrix]
website: http://bit.ly/bukkitdevcolorme
Please sign in to comment.
Something went wrong with that request. Please try again.