Skip to content

Instantly share code, notes, and snippets.

@TheMasteredPanda
Created June 17, 2017 21:49
Show Gist options
  • Save TheMasteredPanda/9fb59b161c15ed21564b13af38343626 to your computer and use it in GitHub Desktop.
Save TheMasteredPanda/9fb59b161c15ed21564b13af38343626 to your computer and use it in GitHub Desktop.
package com.hcsurvival.hcbooster.config;
import com.themasteredpanda.library.config.yaml.BaseConfig;
import com.themasteredpanda.library.plugin.MPlugin;
import com.themasteredpanda.library.utils.Players;
import com.themasteredpanda.library.utils.TryUtils;
import java.util.List;
import java.util.UUID;
public class MuteConfig extends BaseConfig
{
public MuteConfig(MPlugin instance)
{
super(instance, "muted");
}
public boolean hasNotificationsMuted(UUID uuid)
{
return this.config.getStringList("Players").contains(uuid.toString());
}
public void add(UUID uuid)
{
if (hasNotificationsMuted(uuid)) {
System.out.println(Players.get(uuid).getName() + " is not in muted.yml.");
return;
}
List<String> list = this.config.getStringList("Players");
list.add(uuid.toString());
this.config.set("Players", list);
TryUtils.sneaky(() -> this.config.save(this.configFile));
}
public void remove(UUID uuid)
{
if (!hasNotificationsMuted(uuid)) {
return;
}
this.config.set("Players." + uuid.toString(), null);
TryUtils.sneaky(() -> this.config.save(this.configFile));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment