Browse files

Added: Permission for free coloring

  • Loading branch information...
1 parent 03fb40f commit 04597531b092c63ce739ed8f72fd1eb6e6d8d560 @timbru31 committed May 22, 2012
View
46 src/de/xghostkillerx/colorme/Actions.java
@@ -179,31 +179,36 @@ static void updateName(String name, String color) {
boolean tabList = ColorMe.config.getBoolean("ColorMe.tabList");
boolean playerTitle = ColorMe.config.getBoolean("ColorMe.playerTitle");
// Name color
- if (ColorMe.config.getBoolean("ColorMe.displayName") == true) {
+ if (ColorMe.config.getBoolean("ColorMe.displayName")) {
// Random
if (color.equalsIgnoreCase("random")) {
player.setDisplayName(randomColor(cleanDisplayName) + ChatColor.WHITE);
}
// Rainbow
- if (color.equalsIgnoreCase("rainbow")) {
+ else if (color.equalsIgnoreCase("rainbow")) {
player.setDisplayName(rainbowColor(cleanDisplayName) + ChatColor.WHITE);
}
+ // Custom colors
+ else if (ColorMe.colors.contains(color) && (ColorMe.colors.getString(color).trim().length() > 1 ? true : false) == true) {
+ player.sendMessage("DEBUG");
+ }
// Normal
- else if (!color.equalsIgnoreCase("random") && !color.equalsIgnoreCase("rainbow")) {
+ else {
player.setDisplayName(ChatColor.valueOf(color.toUpperCase()) + cleanDisplayName + ChatColor.WHITE);
}
}
// Check for playerList
- if (tabList == true) {
+ if (tabList) {
if (color.equalsIgnoreCase("random")) {
newName = randomColor(cleanDisplayName);
}
- if (color.equalsIgnoreCase("rainbow")) {
+ else if (color.equalsIgnoreCase("rainbow")) {
newName = rainbowColor(cleanDisplayName);
}
- else if (!color.equalsIgnoreCase("random") && !color.equalsIgnoreCase("rainbow")) {
- newName = ChatColor.valueOf(color.toUpperCase()) + cleanDisplayName;
+ else if (ColorMe.colors.contains(color) && (ColorMe.colors.getString(color).trim().length() > 1 ? true : false) == true) {
+ player.sendMessage("DEBUG 2");
}
+ else newName = ChatColor.valueOf(color.toUpperCase()) + cleanDisplayName;
// Shorten it, if too long
if (newName != null || !newName.equals("")) {
if (newName.length() > 16) {
@@ -213,20 +218,21 @@ else if (!color.equalsIgnoreCase("random") && !color.equalsIgnoreCase("rainbow")
}
}
// Check for Spout
- if (ColorMe.spoutEnabled == true && playerTitle == true) {
+ if (ColorMe.spoutEnabled && playerTitle) {
SpoutPlayer spoutPlayer = (SpoutPlayer) player;
// Random color
if (color.equalsIgnoreCase("random")) {
spoutPlayer.setTitle(randomColor(cleanDisplayName));
}
// Rainbow
- if (color.equalsIgnoreCase("rainbow")) {
+ else if (color.equalsIgnoreCase("rainbow")) {
spoutPlayer.setTitle(rainbowColor(cleanDisplayName));
}
- // Normal color
- else if (!color.equalsIgnoreCase("random") && !color.equalsIgnoreCase("rainbow")) {
- spoutPlayer.setTitle(ChatColor.valueOf(color.toUpperCase()) + cleanDisplayName);
+ else if (ColorMe.colors.contains(color) && (ColorMe.colors.getString(color).trim().length() > 1 ? true : false) == true) {
+ player.sendMessage("DEBUG 3");
}
+ // Normal color
+ else spoutPlayer.setTitle(ChatColor.valueOf(color.toUpperCase()) + cleanDisplayName);
}
}
}
@@ -326,6 +332,8 @@ static boolean validColor(String color) {
if (color.equalsIgnoreCase("rainbow") || color.equalsIgnoreCase("random")) {
return true;
}
+ // Custom color? (Must contain something!!! NOT '' or null)
+ if (ColorMe.colors.contains(color) && (ColorMe.colors.getString(color).trim().length() > 1 ? true : false) == true) return true;
// Second place, cause random and rainbow aren't possible normally ;)
else {
for (ChatColor value : ChatColor.values()) {
@@ -343,6 +351,8 @@ static boolean isDisabled(String color) {
if (ColorMe.config.getBoolean("colors." + color.toLowerCase()) == true) {
return false;
}
+ // Custom color? (Must contain something!!! NOT '' or null)
+ if ((ColorMe.colors.getString(color).trim().length() > 1 ? true : false) == true) return false;
return true;
}
@@ -371,27 +381,21 @@ static void checkNames(String name, String world) {
color = Actions.get(name, world, "colors");
Actions.updateName(name, color);
}
- else {
- Actions.restoreName(name);
- }
+ else Actions.restoreName(name);
}
else if (Actions.has(name, "default", "colors")) {
if (Actions.validColor(ColorMe.players.getString(name + ".colors.default")) == true) {
color = Actions.get(name, "default", "colors");
Actions.updateName(name, color);
}
- else {
- Actions.restoreName(name);
- }
+ else Actions.restoreName(name);
}
else if (ColorMe.globalColor) {
if (Actions.validColor(ColorMe.config.getString("global_default.color")) == true) {
color = Actions.getGlobal("color");
Actions.updateName(name, color);
}
- else {
- Actions.restoreName(name);
- }
+ else Actions.restoreName(name);
}
else if (!Actions.has(name, world, "colors") || !Actions.has(name, "default", "colors") || !Actions.hasGlobal("color")) {
Actions.restoreName(name);
View
24 src/de/xghostkillerx/colorme/ColorMe.java
@@ -143,7 +143,7 @@ public void onEnable() {
log.warning("ColorMe failed to load the localization!");
}
- // Force to update the config (remove emtpy lines)
+ // Force to update the config (remove empty lines)
if (config.getBoolean("updateConfig")) {
try {
updateConfig(playersFile);
@@ -254,21 +254,13 @@ public void updateConfig(File config) throws Exception {
}
private void checkStatsStuff() {
- if (config.getBoolean("Prefixer") == true) {
- values.add("Prefixer");
- }
- if (config.getBoolean("Suffixer") == true) {
- values.add("Suffixer");
- }
- if (config.getBoolean("ColorMe.displayName") == true) {
- values.add("ColorMe - displayName");
- }
- if (config.getBoolean("ColorMe.tabList") == true) {
- values.add("ColorMe - tabList");
- }
- if (config.getBoolean("ColorMe.playerTitle") == true) {
- values.add("ColorMe - playerTitle");
- }
+ if (Prefixer) values.add("Prefixer");
+ if (Suffixer) values.add("Suffixer");
+ if (config.getBoolean("ColorMe.displayName")) values.add("ColorMe - displayName");
+ if (config.getBoolean("ColorMe.tabList")) values.add("ColorMe - tabList");
+ if (config.getBoolean("ColorMe.playerTitle")) values.add("ColorMe - playerTitle");
+ if (chatColors) values.add("ColorMe - chatColors");
+ if (signColors) values.add("ColorMe - signColors");
}
// Loads the config at the start
View
3 src/de/xghostkillerx/colorme/ColorMeCommands.java
@@ -304,7 +304,8 @@ else if (plugin.economy != null) {
}
// Charge costs :)
if (cost > 0 && plugin.economy.has(senderName, cost)) {
- plugin.economy.withdrawPlayer(senderName, cost);
+ // Charge player unless he has the free permissions
+ if (!sender.hasPermission("colorome.free")) plugin.economy.withdrawPlayer(senderName, cost);
// Set color an notify sender
Actions.set(senderName, color, world, pluginPart);
message = ColorMe.localization.getString("charged");
View
4 src/de/xghostkillerx/colorme/ColorMePlayerListener.java
@@ -101,7 +101,9 @@ else if (ColorMe.globalSuffix) {
event.setFormat(brackets);
}
// Color the message, too?
- if (ColorMe.chatColors) event.setMessage(Actions.replaceThings(event.getMessage()));
+ if (ColorMe.chatColors) {
+ event.setMessage(Actions.replaceThings(event.getMessage()));
+ }
prefix = null;
suffix = null;
View
3 src/de/xghostkillerx/colorme/PrefixCommands.java
@@ -259,7 +259,8 @@ public boolean onCommand (CommandSender sender, Command command, String commandL
else if (plugin.economy != null) {
// Charge costs :)
if (cost > 0 && plugin.economy.has(senderName, cost)) {
- plugin.economy.withdrawPlayer(senderName, cost);
+ // Charge player unless he has the free permissions
+ if (!sender.hasPermission("prefixer.free")) plugin.economy.withdrawPlayer(senderName, cost);
// Set prefix an notify sender
Actions.set(senderName, prefix, world, pluginPart);
message = ColorMe.localization.getString("charged");
View
3 src/de/xghostkillerx/colorme/SuffixCommands.java
@@ -259,7 +259,8 @@ public boolean onCommand (CommandSender sender, Command command, String commandL
else if (plugin.economy != null) {
// Charge costs :)
if (cost > 0 && plugin.economy.has(senderName, cost)) {
- plugin.economy.withdrawPlayer(senderName, cost);
+ // Charge player unless he has the free permissions
+ if (!sender.hasPermission("suffixer.free")) plugin.economy.withdrawPlayer(senderName, cost);
// Set suffix an notify sender
Actions.set(senderName, suffix, world, pluginPart);
message = ColorMe.localization.getString("charged");
View
12 src/plugin.yml
@@ -131,6 +131,9 @@ permissions:
colorme.global:
default: op
description: Sets the global color
+ colorme.free:
+ default: op
+ description: No costs for coloring
colorme.*:
children:
colorme.list: true
@@ -139,6 +142,7 @@ permissions:
colorme.remove: true
colorme.get: true
colorme.global: true
+ colorme.free: true
description: Allows all commands for ColorMe
prefixer.list:
default: true
@@ -158,6 +162,9 @@ permissions:
prefixer.global:
default: op
description: Sets the global prefix
+ prefixer.free:
+ default: op
+ description: No costs for prefixing
prefixer.*:
children:
prefixer.list: true
@@ -166,6 +173,7 @@ permissions:
prefixer.remove: true
prefixer.get: true
prefixer.global: true
+ prefixer.free: true
description: Allows all commands for Prefixer
suffixer.list:
default: true
@@ -185,6 +193,9 @@ permissions:
suffixer.global:
default: op
description: Sets the global suffix
+ suffixer.free:
+ default: op
+ description: No costs for suffixing
suffixer.*:
children:
suffixer.list: true
@@ -193,5 +204,6 @@ permissions:
suffixer.remove: true
suffixer.get: true
suffixer.global: true
+ suffixer.free: true
description: Allows all commands for Suffixer
softdepend: [Vault, Spout]

0 comments on commit 0459753

Please sign in to comment.