Merge pull request #1 from Driftay/trent

FGlobal Added
This commit is contained in:
Driftay 2019-06-29 17:45:17 -04:00 committed by GitHub
commit 3712424e1d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 104 additions and 2 deletions

View File

@ -330,8 +330,8 @@
</dependency>
<dependency>
<groupId>net.coreprotect</groupId>
<artifactId>CoreProtect</artifactId>
<version>2</version>
<artifactId>coreprotect</artifactId>
<version>2.15.0</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: com.massivecraft.factions.SaberFactions

View File

@ -0,0 +1,52 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
public class CmdFGlobal extends FCommand {
public CmdFGlobal() {
super();
this.aliases.add("gchat");
this.aliases.add("global");
this.aliases.add("globalchat");
this.disableOnLock = false;
this.disableOnSpam = false;
senderMustBePlayer = true;
senderMustBeMember = true;
senderMustBeModerator = false;
senderMustBeColeader = false;
senderMustBeAdmin = false;
}
public static List<UUID> toggled = new ArrayList<>();
@Override
public void perform() {
Player p = (Player)sender;
// /f global
if (toggled.contains(p.getUniqueId())){
toggled.remove(p.getUniqueId());
}else{
toggled.add(p.getUniqueId());
}
fme.msg(TL.COMMAND_F_GLOBAL_TOGGLE, toggled.contains(p.getUniqueId()) ? "enabled" : "disabled");
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_F_GLOBAL_DESCRIPTION;
}
}

View File

@ -8,6 +8,7 @@ import com.massivecraft.factions.zcore.util.TL;
public class CmdGrace extends FCommand {
public CmdGrace() {
super();
this.aliases.add("grace");

View File

@ -111,6 +111,7 @@ public class FCmdRoot extends FCommand {
public CmdSpam cmdSpam = new CmdSpam();
public CmdCorner cmdCorner = new CmdCorner();
public CmdInventorySee cmdInventorySee = new CmdInventorySee();
public CmdFGlobal cmdFGlobal = new CmdFGlobal();
@ -227,6 +228,7 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdStrikeSet);
this.addSubCommand(this.cmdSpam);
this.addSubCommand(this.cmdCorner);
this.addSubCommand(this.cmdFGlobal);
if (SaberFactions.plugin.getConfig().getBoolean("f-inventory-see.Enabled")) {

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.listeners;
import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.CmdFGlobal;
import com.massivecraft.factions.cmd.CmdFly;
import com.massivecraft.factions.cmd.CmdSeeChunk;
import com.massivecraft.factions.event.FPlayerEnteredFactionEvent;
@ -9,6 +10,7 @@ import com.massivecraft.factions.event.FPlayerLeaveEvent;
import com.massivecraft.factions.scoreboards.FScoreboard;
import com.massivecraft.factions.scoreboards.FTeamWrapper;
import com.massivecraft.factions.scoreboards.sidebar.FDefaultSidebar;
import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
@ -966,4 +968,41 @@ public class FactionsPlayerListener implements Listener {
}
}
}
@EventHandler
public void AsyncPlayerChatEvent(AsyncPlayerChatEvent e){
Player p = e.getPlayer();
if (CmdFGlobal.toggled.contains(p.getUniqueId())){
//they're muted, check status of Faction Chat
if (FPlayers.getInstance().getByPlayer(p).getFaction() == null) {
//they're muted, and not in a faction, cancel and return
e.setCancelled(true);
return;
} else {
//are in a faction that's not Wilderness, SafeZone, or Warzone, check their chat status
if (!FPlayers.getInstance().getByPlayer(p).getChatMode().isAtLeast(ChatMode.ALLIANCE)) {
//their Faction Chat Mode is not at-least a Alliance, cancel and return
e.setCancelled(true);
return;
}
}
}
//we made it this far, since we didn't return yet, we must have sent the chat event through
//iterate through all of recipients and check if they're muted, then remove them from the event list
List<Player> l = new ArrayList<>();
l.addAll(e.getRecipients());
for (int i = l.size() - 1; i >= 0; i--){ // going backwards in the list to prevent a ConcurrentModificationException
Player recipient = l.get(i);
if (recipient != null){
if (CmdFGlobal.toggled.contains(recipient.getUniqueId())){
e.getRecipients().remove(recipient);
}
}
}
}
}

View File

@ -818,6 +818,10 @@ public enum TL {
COMMAND_RULES_SET_SUCCESS("&cRule set successfully!"),
COMMAND_RULES_CLEAR_SUCCESS("&cRule cleared successfully!"),
// F Global \\
COMMAND_F_GLOBAL_TOGGLE("&c&l[!] &7You have &b%1$s &7Global Chat"),
COMMAND_F_GLOBAL_DESCRIPTION("Toggle global chat and only allow factions based chats"),
/**
* Leaving - This is accessed through a command, and so it MAY need a COMMAND_* slug :s
*/
@ -899,6 +903,7 @@ public enum TL {
GENERIC_PLACEHOLDER("<This is a placeholder for a message you should not see>"),
GENERIC_NOTENOUGHMONEY("&cYou dont have enough money!"),
GENERIC_MONEYTAKE("&c{amount} has been taken from your account."),
// F Global \\
PLAYER_NOT_FOUND("&c&l[!] &b%1$s &7is either not online or not in your faction!"),