Skip to content

Commit

Permalink
Add disabled skill progress
Browse files Browse the repository at this point in the history
  • Loading branch information
games647 committed Dec 5, 2017
1 parent 61926c8 commit 29d40fd
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 7 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.github.games647</groupId>
Expand All @@ -8,7 +8,7 @@
<packaging>jar</packaging>

<name>mcMMOAction</name>
<version>2.1.2</version>
<version>2.2</version>

<url>https://dev.bukkit.org/bukkit-plugins/mcmmoaction/</url>
<description>
Expand Down
17 changes: 16 additions & 1 deletion src/main/java/com/github/games647/mcmmoaction/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class Configuration {

private final mcMMOAction plugin;
private final Set<String> messages = Sets.newHashSet();
private final Set<SkillType> disabledSkillProgress = Sets.newHashSet();

//notification sound
private Sound sound;
Expand All @@ -52,7 +53,17 @@ public void load() {
loadMessages(config);
loadNotificationSound(config.getConfigurationSection("notification-sound"));

progressEnabled = plugin.getConfig().getBoolean("progress");
progressEnabled = config.getBoolean("progress");

for (String disableSkill : config.getStringList("progress-disabled")) {
Optional<SkillType> skillType = Enums.getIfPresent(SkillType.class, disableSkill.toUpperCase());
if (skillType.isPresent()) {
disabledSkillProgress.add(skillType.get());
} else {
plugin.getLogger()
.log(Level.WARNING, "The skill type {0} for disabled progress is unknown", disableSkill);
}
}
}

private void loadNotificationSound(ConfigurationSection section) {
Expand Down Expand Up @@ -175,6 +186,10 @@ public Set<String> getMessages() {
return messages;
}

public Set<SkillType> getDisabledSkillProgress() {
return disabledSkillProgress;
}

public boolean isProgressEnabled() {
return progressEnabled;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void onPlayerQuit(PlayerQuitEvent quitEvent) {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onExperienceGain(McMMOPlayerXpGainEvent experienceEvent) {
Player player = experienceEvent.getPlayer();
if (plugin.isProgressEnabled(player)) {
if (plugin.isProgressEnabled(player) && !plugin.isDisabledProgress(experienceEvent.getSkill())) {
String message = plugin.getConfig().getString("progress-msg");
String coloredMessage = ChatColor.translateAlternateColorCodes('&', message);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.github.games647.mcmmoaction.listener.MessageListener;
import com.github.games647.mcmmoaction.listener.PlayerListener;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.google.common.collect.Sets;

import java.io.IOException;
Expand Down Expand Up @@ -92,11 +93,11 @@ private void saveDisabled(String fileName, Collection<UUID> disabledLst) {
}
}

public Set<UUID> getActionBarDisabled() {
public Collection<UUID> getActionBarDisabled() {
return actionBarDisabled;
}

public Set<UUID> getProgressBarDisabled() {
public Collection<UUID> getProgressBarDisabled() {
return progressBarDisabled;
}

Expand All @@ -105,6 +106,10 @@ public boolean isProgressEnabled(Player player) {
&& player.hasPermission(getName().toLowerCase() + ".display");
}

public boolean isDisabledProgress(SkillType skill) {
return configuration.getDisabledSkillProgress().contains(skill);
}

public Configuration getConfiguration() {
return configuration;
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ progress-enable: "&2Enabled displaying progress messages in your action-bar"
# If the user disables the progress bar
progress-disable: "&2Disabled displaying progress messages in your action-bar"

# Case insensitive list of skills that this plugin will ignore for progress messages
# You can see the number of skill types here:
# https://github.com/mcMMO-Dev/mcMMO/blob/master/src/main/java/com/gmail/nossr50/datatypes/skills/SkillType.java#L38
progress-disabled:
- SALVAGE

# if progress: is set to false above
progress-global-disabled: "&4The progress feature is globally disabled"

Expand Down

0 comments on commit 29d40fd

Please sign in to comment.