mirror of
https://github.com/RoinujNosde/SimpleClans.git
synced 2026-11-05 01:10:04 -05:00
Compare commits
16
Commits
v2.18.0
...
chat-perms
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
776acbebbe | ||
|
|
aa70a7653e | ||
|
|
046aa1d96d | ||
|
|
e44775e994 | ||
|
|
43da5bd1f1 | ||
|
|
8fa465da38 | ||
|
|
56c7908c33 | ||
|
|
fc81e76521 | ||
|
|
f7fe5c4ad4 | ||
|
|
8f4f763c37 | ||
|
|
7a37382264 | ||
|
|
7f9d133051 | ||
|
|
26ba9f7329 | ||
|
|
d8cb61b0fc | ||
|
|
3f1b06dcf9 | ||
|
|
b043eb0742 |
No files matched your search
@@ -1,5 +1,19 @@
|
||||
# Changelog
|
||||
|
||||
## [2.18.1](https://github.com/RoinujNosde/SimpleClans/compare/v2.18.0...v2.18.1) (2022-11-29)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* added check for clan_member on land commands ([fc81e76](https://github.com/RoinujNosde/SimpleClans/commit/fc81e765211bebe22a7a6aa5d5158754580bbdc5))
|
||||
* attempt at fixing NPE on getAllClanPlayers ([26ba9f7](https://github.com/RoinujNosde/SimpleClans/commit/26ba9f73296a772eaa698d2ede6fbc3831da850c))
|
||||
* **bungee:** error deserializing clan banners ([56c7908](https://github.com/RoinujNosde/SimpleClans/commit/56c7908c332167cec9cca6a4ea054977d0d68b9f))
|
||||
* channel auto creation setting not respected on join/link ([7f9d133](https://github.com/RoinujNosde/SimpleClans/commit/7f9d133051b9011837d0a5114abc6c3637a3f02c))
|
||||
* default ranks were getting re-added on config load ([7a37382](https://github.com/RoinujNosde/SimpleClans/commit/7a37382264ff4dd5456f6930045b5102bf491897))
|
||||
* missing getHandlerList on HomeRegroupEvent ([#338](https://github.com/RoinujNosde/SimpleClans/issues/338)) ([8fa465d](https://github.com/RoinujNosde/SimpleClans/commit/8fa465da385f36b1fb075031c375ef94df78ea52))
|
||||
* money was not given back when channel creation failed ([#336](https://github.com/RoinujNosde/SimpleClans/issues/336)) ([d8cb61b](https://github.com/RoinujNosde/SimpleClans/commit/d8cb61b0fc9584bb58f421faf98596816621053f))
|
||||
* wrong path of discord economy section ([#334](https://github.com/RoinujNosde/SimpleClans/issues/334)) ([3f1b06d](https://github.com/RoinujNosde/SimpleClans/commit/3f1b06dcf996e51a878b7fc281069e236ebcbfce))
|
||||
|
||||
## [2.18.0](https://github.com/RoinujNosde/SimpleClans/compare/v2.17.0...v2.18.0) (2022-10-14)
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<name>SimpleClans</name>
|
||||
<version>2.17.1-SNAPSHOT</version>
|
||||
<version>2.18.1-SNAPSHOT</version>
|
||||
<url>https://www.spigotmc.org/resources/simpleclans.71242/</url>
|
||||
<build>
|
||||
<resources>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<version>2.18.0</version>
|
||||
<version>2.18.2-SNAPSHOT</version>
|
||||
<name>SimpleClans</name>
|
||||
<url>https://www.spigotmc.org/resources/simpleclans.71242/</url>
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@ package net.sacredlabyrinth.phaed.simpleclans.chat;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.ChatManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
|
||||
public interface ChatHandler {
|
||||
|
||||
SimpleClans plugin = SimpleClans.getInstance();
|
||||
|
||||
SettingsManager settingsManager = plugin.getSettingsManager();
|
||||
|
||||
ChatManager chatManager = plugin.getChatManager();
|
||||
PermissionsManager permissionsManager = plugin.getPermissionsManager();
|
||||
|
||||
void sendMessage(SCMessage message);
|
||||
|
||||
|
||||
+20
-1
@@ -13,6 +13,7 @@ import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.Con
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.ConfigField.PERFORMANCE_USE_BUNGEECORD;
|
||||
import static org.bukkit.Bukkit.getPluginManager;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class SpigotChatHandler implements ChatHandler {
|
||||
|
||||
@Override
|
||||
@@ -30,7 +31,7 @@ public class SpigotChatHandler implements ChatHandler {
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
message.setContent(event.getMessage());
|
||||
message.setContent(stripColorsAndFormatsPerPermission(message.getSender(),event.getMessage()));
|
||||
|
||||
ConfigField configField = ConfigField.valueOf(String.format("%sCHAT_FORMAT",
|
||||
message.getSource() == DISCORD ? "DISCORD" : message.getChannel()));
|
||||
@@ -47,6 +48,24 @@ public class SpigotChatHandler implements ChatHandler {
|
||||
}.runTask(plugin);
|
||||
}
|
||||
|
||||
private String stripColorsAndFormatsPerPermission(ClanPlayer sender, String message) {
|
||||
if (!permissionsManager.has(sender.toPlayer(), "simpleclans.member.chat.color")) {
|
||||
message = stripColors(message);
|
||||
}
|
||||
if (!permissionsManager.has(sender.toPlayer(), "simpleclans.member.chat.format")) {
|
||||
message = stripFormats(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private String stripColors(String message) {
|
||||
return message.replaceAll("[§&][0-9a-fA-FxX]", "");
|
||||
}
|
||||
|
||||
private String stripFormats(String message) {
|
||||
return message.replaceAll("[§&][k-orK-OR]", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canHandle(SCMessage.Source source) {
|
||||
return source == SPIGOT || (source == PROXY && settingsManager.is(PERFORMANCE_USE_BUNGEECORD))
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ public class SpyChatHandler implements ChatHandler {
|
||||
private List<ClanPlayer> getOnlineSpies() {
|
||||
return Bukkit.getOnlinePlayers().stream().
|
||||
filter(Objects::nonNull).
|
||||
filter(player -> plugin.getPermissionsManager().has(player, "simpleclans.admin.all-seeing-eye")).
|
||||
filter(player -> permissionsManager.has(player, "simpleclans.admin.all-seeing-eye")).
|
||||
map(player -> plugin.getClanManager().getCreateClanPlayer(player.getUniqueId())).
|
||||
filter(Objects::nonNull).
|
||||
filter(clanPlayer -> !clanPlayer.isMuted()).
|
||||
|
||||
@@ -18,7 +18,7 @@ import static net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager.Con
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Subcommand("%land")
|
||||
@Conditions("%basic_conditions|land_sharing|own_land")
|
||||
@Conditions("%basic_conditions|clan_member|land_sharing|own_land")
|
||||
@CommandPermission("simpleclans.member.land")
|
||||
public class LandCommand extends BaseCommand {
|
||||
|
||||
|
||||
+5
-1
@@ -198,8 +198,8 @@ public class LeaderCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
double amount = settings.getDouble(ECONOMY_DISCORD_CREATION_PRICE);
|
||||
if (settings.is(ECONOMY_PURCHASE_DISCORD_CREATE)) {
|
||||
double amount = settings.getDouble(ECONOMY_DISCORD_CREATION_PRICE);
|
||||
if (!permissions.playerHasMoney(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player, amount));
|
||||
return;
|
||||
@@ -214,6 +214,10 @@ public class LeaderCommands extends BaseCommand {
|
||||
discordHook.createChannel(clan.getTag());
|
||||
ChatBlock.sendMessageKey(player, "discord.created.successfully");
|
||||
} catch (DiscordHookException ex) {
|
||||
// Return player's money if clan creation went wrong
|
||||
if (settings.is(ECONOMY_PURCHASE_DISCORD_CREATE)) {
|
||||
permissions.playerGrantMoney(player, amount);
|
||||
}
|
||||
String messageKey = ex.getMessageKey();
|
||||
if (messageKey != null) {
|
||||
ChatBlock.sendMessage(player, RED + lang(messageKey));
|
||||
|
||||
@@ -50,12 +50,16 @@ public class HomeRegroupEvent extends Event implements Cancellable {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
|
||||
@@ -639,7 +639,7 @@ public class DiscordHook implements Listener {
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
private boolean createChannelSilently(ClanPlayer clanPlayer) {
|
||||
Clan clan = clanPlayer.getClan();
|
||||
if (clan == null) {
|
||||
if (clan == null || !settingsManager.is(DISCORDCHAT_AUTO_CREATION)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ public class SCPlayerListener extends SCListener {
|
||||
if (duplicate != null) {
|
||||
plugin.getLogger().warning(String.format("Found duplicate for %s, UUIDs: %s, %s", player.getName(),
|
||||
player.getUniqueId(), duplicate.getUniqueId()));
|
||||
duplicate.setName(duplicate.getName() + "_duplicate");
|
||||
duplicate.setName(duplicate.getUniqueId().toString());
|
||||
plugin.getStorageManager().updatePlayerName(duplicate);
|
||||
}
|
||||
if (cp != null) {
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
@@ -36,8 +37,8 @@ import static org.bukkit.ChatColor.RED;
|
||||
public final class ClanManager {
|
||||
|
||||
private final SimpleClans plugin;
|
||||
private final HashMap<String, Clan> clans = new HashMap<>();
|
||||
private final HashMap<UUID, ClanPlayer> clanPlayers = new HashMap<>();
|
||||
private final ConcurrentHashMap<String, Clan> clans = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<UUID, ClanPlayer> clanPlayers = new ConcurrentHashMap<>();
|
||||
private final HashMap<ClanPlayer, List<Kill>> kills = new HashMap<>();
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,6 @@ import net.sacredlabyrinth.phaed.simpleclans.Rank;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -252,13 +251,16 @@ public final class SettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public @NotNull Collection<Rank> getStarterRanks() {
|
||||
List<Rank> ranks = new ArrayList<>();
|
||||
ConfigurationSection section = config.getConfigurationSection("clan.starter-ranks");
|
||||
if (section != null) {
|
||||
for (String name : section.getKeys(false)) {
|
||||
String displayName = section.getString(name + ".display-name");
|
||||
List<String> permissions = section.getStringList(name + ".permissions");
|
||||
List<Map<?, ?>> mapList = config.getMapList("clan.starter-ranks");
|
||||
for (Map<?, ?> rankMap : mapList) {
|
||||
Set<String> names = (Set<String>) rankMap.keySet();
|
||||
for (String name : names) {
|
||||
Map<String, Object> rank = (Map<String, Object>) rankMap.get(name);
|
||||
String displayName = (String) rank.get("display-name");
|
||||
List<String> permissions = (List<String>) rank.get("permissions");
|
||||
ranks.add(new Rank(name, displayName, new HashSet<>(permissions)));
|
||||
}
|
||||
}
|
||||
@@ -398,8 +400,8 @@ public final class SettingsManager {
|
||||
ECONOMY_PURCHASE_HOME_TELEPORT_SET("economy.purchase-home-teleport-set", false),
|
||||
ECONOMY_REGROUP_PRICE("economy.home-regroup-price", 5.0),
|
||||
ECONOMY_PURCHASE_HOME_REGROUP("economy.purchase-home-regroup", false),
|
||||
ECONOMY_PURCHASE_DISCORD_CREATE("purchase-discord-create", false),
|
||||
ECONOMY_DISCORD_CREATION_PRICE("discord-creation-price", 1000.0),
|
||||
ECONOMY_PURCHASE_DISCORD_CREATE("economy.purchase-discord-create", false),
|
||||
ECONOMY_DISCORD_CREATION_PRICE("economy.discord-creation-price", 1000.0),
|
||||
ECONOMY_UNIQUE_TAX_ON_REGROUP("economy.unique-tax-on-regroup", true),
|
||||
ECONOMY_ISSUER_PAYS_REGROUP("economy.issuer-pays-regroup", true),
|
||||
ECONOMY_MONEY_PER_KILL("economy.money-per-kill", false),
|
||||
|
||||
@@ -23,9 +23,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public final class BungeeManager implements ProxyManager, PluginMessageListener {
|
||||
@@ -40,6 +38,7 @@ public final class BungeeManager implements ProxyManager, PluginMessageListener
|
||||
private final Gson gson;
|
||||
private final List<String> onlinePlayers = new ArrayList<>();
|
||||
private String serverName = "";
|
||||
private final Set<String> unknownChannels = new HashSet<>();
|
||||
|
||||
public BungeeManager(SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -61,13 +60,18 @@ public final class BungeeManager implements ProxyManager, PluginMessageListener
|
||||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, byte[] data) {
|
||||
ByteArrayDataInput input = ByteStreams.newDataInput(data);
|
||||
String subChannel = input.readUTF();
|
||||
|
||||
if (unknownChannels.contains(subChannel)) {
|
||||
return;
|
||||
}
|
||||
SimpleClans.debug("Message received, sub-channel: " + subChannel);
|
||||
try {
|
||||
Class<?> clazz = Class.forName("net.sacredlabyrinth.phaed.simpleclans.proxy.listeners." + subChannel);
|
||||
MessageListener listener = (MessageListener) clazz.getConstructor(BungeeManager.class).newInstance(this);
|
||||
listener.accept(input);
|
||||
SimpleClans.debug("Message processed");
|
||||
} catch (ClassNotFoundException e) {
|
||||
SimpleClans.debug(String.format("Unknown channel: %s", subChannel));
|
||||
unknownChannels.add(subChannel);
|
||||
} catch (ReflectiveOperationException ex) {
|
||||
plugin.getLogger().log(Level.SEVERE, String.format("Error processing channel %s", subChannel), ex);
|
||||
}
|
||||
@@ -182,7 +186,9 @@ public final class BungeeManager implements ProxyManager, PluginMessageListener
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
private void forwardPluginMessage(final String subChannel, final String message, final boolean all) {
|
||||
SimpleClans.debug(String.format("Forwarding message, channel %s, message %s, all %s", subChannel, message, all));
|
||||
if (!isChannelRegistered()) {
|
||||
SimpleClans.debug("Not registered");
|
||||
return;
|
||||
}
|
||||
String target = all ? "ALL" : "ONLINE";
|
||||
|
||||
+2
-1
@@ -39,7 +39,8 @@ public class ConfigurationSerializableAdapter implements TypeAdapterFactory {
|
||||
return null;
|
||||
}
|
||||
Map map = adapter.read(in);
|
||||
return ConfigurationSerialization.deserializeObject(map);
|
||||
return ConfigurationSerialization.deserializeObject(map,
|
||||
(Class<? extends ConfigurationSerializable>) type.getRawType());
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ public abstract class Update<T> extends MessageListener {
|
||||
T current = getCurrent(t);
|
||||
if (current == null) {
|
||||
insert(t);
|
||||
debug(String.format("Inserted %s", t));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
@@ -156,13 +156,13 @@ clan:
|
||||
min-size-to-set-ally: 3
|
||||
min-to-verify: 1
|
||||
starter-ranks:
|
||||
recruit:
|
||||
- recruit:
|
||||
display-name: "&7Recruit"
|
||||
permissions: [ stats, kills, mostkilled, rank.list ]
|
||||
ambassador:
|
||||
- ambassador:
|
||||
display-name: "&bAmbassador"
|
||||
permissions: [ ally.chat, ally.add, ally.remove, rival.add, rival.remove, war.end, war.start ]
|
||||
treasurer:
|
||||
- treasurer:
|
||||
display-name: "&6Treasurer"
|
||||
permissions: [ bank.balance, bank.deposit, bank.withdraw ]
|
||||
|
||||
|
||||
@@ -103,6 +103,11 @@ permissions:
|
||||
description: Can use ally chat
|
||||
simpleclans.member.chat:
|
||||
description: Can use clan chat
|
||||
simpleclans.member.chat.color:
|
||||
description: Can use colors in chat
|
||||
simpleclans.member.chat.format:
|
||||
description: Can use formats in chat
|
||||
default: false
|
||||
simpleclans.member.can-join:
|
||||
description: Can join clans
|
||||
simpleclans.member.home:
|
||||
@@ -298,6 +303,7 @@ permissions:
|
||||
simpleclans.member.kills: true
|
||||
simpleclans.member.bank: true
|
||||
simpleclans.member.fee-check: true
|
||||
simpleclans.member.chat.color: true
|
||||
simpleclans.leader.*:
|
||||
description: Permissions for those who can be clan leaders
|
||||
default: true
|
||||
|
||||
Reference in new issue
Block a user