Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Essentials/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>com.earth2me.essentialss</groupId>
<artifactId>essentials-parent</artifactId>
<version>2.6.9</version>
<version>2.7.0</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -76,6 +76,12 @@
<version>1.1.3</version>
</dependency>

<dependency>
<groupId>com.johnymuffin.beta</groupId>
<artifactId>discordauth</artifactId>
<version>1.1.3</version>
</dependency>

<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import static org.bukkit.Bukkit.getPlayer;


public class EssentialsPlayerListener extends PlayerListener {
private static final Logger LOGGER = Logger.getLogger("Minecraft");
Expand All @@ -41,6 +43,24 @@ public void onPlayerRespawn(final PlayerRespawnEvent event) {
@Override
public void onPlayerChat(final PlayerChatEvent event) {
final User user = ess.getUser(event.getPlayer());

// If the user has ignore exempt permission, unignore them for all players
if (user.hasPermission("essentials.ignore.exempt") || user.isOp()) {
for (Player p : ess.getServer().getOnlinePlayers()) {
// Skip self
if(p.getName().equalsIgnoreCase(user.getName())) {
continue;
}

User u = ess.getUser(p);

// If the viewer is ignoring the poster, unignore them
if (u.isIgnoredPlayer(user.getName())) {
u.setIgnoredPlayer(user.getName(), false);
}
}
}

if (user.isMuted()) {
event.setCancelled(true);
user.sendMessage(Util.i18n("playerMuted"));
Expand Down Expand Up @@ -208,6 +228,8 @@ public void onPlayerJoin(final PlayerJoinEvent event) {
ess.getBackup().onPlayerJoin();
final User user = ess.getUser(event.getPlayer());

user.setUUID(event.getPlayer().getUniqueId()); // Set the UUID of the player

//we do not know the ip address on playerlogin so we need to do this here.
if (user.isIpBanned()) {
final String banReason = user.getBanReason();
Expand Down
55 changes: 51 additions & 4 deletions Essentials/src/main/java/com/earth2me/essentials/UserData.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import javax.annotation.Nullable;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.logging.Logger;


Expand Down Expand Up @@ -41,6 +39,9 @@ public abstract class UserData extends PlayerExtension implements IConf {
private boolean isSocialSpyEnabled;
private boolean isNPC;

private UUID uuid;
private boolean receiveMailOnDiscord;

protected UserData(Player base, IEssentials ess) {
super(base, ess);
File folder = new File(ess.getDataFolder(), "userdata");
Expand Down Expand Up @@ -77,6 +78,8 @@ public final void reloadConfig() {
geolocation = _getGeoLocation();
isSocialSpyEnabled = _isSocialSpyEnabled();
isNPC = _isNPC();
uuid = _getUUID();
receiveMailOnDiscord = _getReceiveMailOnDiscord();
}

private double _getMoney() {
Expand Down Expand Up @@ -617,4 +620,48 @@ public void setNPC(boolean set) {
config.setProperty("npc", set);
config.save();
}

public void setUUID(UUID uuid) {
this.uuid = uuid;
config.setProperty("uuid", uuid.toString());
config.save();
}

@Nullable
private UUID _getUUID() {
String uuid = config.getString("uuid");
if (uuid == null) {
return null;
}

try {
return UUID.fromString(uuid);
} catch (IllegalArgumentException e) {
logger.warning("Invalid UUID in user data for " + getName() + ": " + uuid + ". UUID will be removed.");
config.removeProperty("uuid");
config.save();
}

return null;
}

@Nullable
public UUID getUUID() {
return uuid;
}

private boolean _getReceiveMailOnDiscord() {
return config.getBoolean("receiveMailOnDiscord", true); // Default to true
}

public boolean getReceiveMailOnDiscord() {
return receiveMailOnDiscord;
}

public void setReceiveMailOnDiscord(boolean receiveMailOnDiscord) {
this.receiveMailOnDiscord = receiveMailOnDiscord;
config.setProperty("receiveMailOnDiscord", receiveMailOnDiscord);
config.save();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,44 @@

import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.ChatColor;
import org.bukkit.Server;

import com.johnymuffin.jperms.beta.JohnyPerms;
import com.johnymuffin.jperms.beta.JohnyPermsAPI;
import com.johnymuffin.jperms.core.models.PermissionsUser;

import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;

import java.io.FileReader;
import java.util.UUID;

public class Commandignore extends EssentialsCommand {

public Commandignore() {
super("ignore");
}

private UUID getUUIDFromCache(String playerName) {
try {
JSONParser parser = new JSONParser();
JSONArray arr = (JSONArray) parser.parse(new FileReader("uuidcache.json"));
for (Object obj : arr) {
JSONObject entry = (JSONObject) obj;
String name = (String) entry.get("name");
if (name != null && name.equalsIgnoreCase(playerName)) {
String uuidStr = (String) entry.get("uuid");
return UUID.fromString(uuidStr);
}
}
} catch (Exception e) {
// Sil
}
return null;
}

@Override
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception {
if (args.length < 1) {
Expand All @@ -26,6 +55,13 @@ protected void run(Server server, User user, String commandLabel, String[] args)
throw new Exception(Util.i18n("playerNotFound"));
}
String name = u.getName();

if(u.hasPermission("essentials.ignore.exempt") || u.isOp()) {
user.setIgnoredPlayer(name, false); // Ensure they are not ignored. This is useful if an op/exempt player was ignored before gaining exempt status.
user.sendMessage(Util.format("ignoreExempt", u.getName()));
return;
}

if (user.isIgnoredPlayer(name)) {
user.setIgnoredPlayer(name, false);
user.sendMessage(Util.format("unignorePlayer", u.getName()));
Expand All @@ -34,6 +70,4 @@ protected void run(Server server, User user, String commandLabel, String[] args)
user.sendMessage(Util.format("ignorePlayer", u.getName()));
}
}


}
Loading