Proper Distribution to Vankka For Proper Discord Code & Fixed F Leader Leaving Faction Disband Message

This commit is contained in:
Driftay 2020-04-02 08:33:33 -04:00
parent 4359a8b584
commit 663bd96d26
13 changed files with 100 additions and 39 deletions

View File

@ -38,6 +38,7 @@ public class Aliases {
public static ArrayList<String> money_withdraw = new ArrayList<>(Arrays.asList("w", "withdraw")); public static ArrayList<String> money_withdraw = new ArrayList<>(Arrays.asList("w", "withdraw"));
public static ArrayList<String> grace = new ArrayList<>(Collections.singletonList("grace")); public static ArrayList<String> grace = new ArrayList<>(Collections.singletonList("grace"));
public static ArrayList<String> logout = new ArrayList<>(Collections.singletonList("logout")); public static ArrayList<String> logout = new ArrayList<>(Collections.singletonList("logout"));
public static ArrayList<String> points_balance = new ArrayList<>(Arrays.asList("balance", "bal"));
public static ArrayList<String> points_points = new ArrayList<>(Collections.singletonList("points")); public static ArrayList<String> points_points = new ArrayList<>(Collections.singletonList("points"));
public static ArrayList<String> points_add = new ArrayList<>(Collections.singletonList("add")); public static ArrayList<String> points_add = new ArrayList<>(Collections.singletonList("add"));
public static ArrayList<String> points_remove = new ArrayList<>(Collections.singletonList("remove")); public static ArrayList<String> points_remove = new ArrayList<>(Collections.singletonList("remove"));

View File

@ -6,6 +6,10 @@ import com.massivecraft.factions.zcore.util.TL;
import java.util.Random; import java.util.Random;
/**
* @author SaberTeam
*/
public class CmdDiscord extends FCommand { public class CmdDiscord extends FCommand {
public CmdDiscord() { public CmdDiscord() {
super(); super();

View File

@ -11,7 +11,7 @@ import net.dv8tion.jda.core.Permission;
public class CmdInviteBot extends FCommand { public class CmdInviteBot extends FCommand {
/** /**
* @author Driftay * @author Vankka
*/ */
public CmdInviteBot() { public CmdInviteBot() {

View File

@ -19,7 +19,7 @@ import java.util.concurrent.TimeUnit;
public class CmdSetGuild extends FCommand { public class CmdSetGuild extends FCommand {
/** /**
* @author Driftay * @author Vankka
*/ */
private EventWaiter eventWaiter; private EventWaiter eventWaiter;

View File

@ -18,6 +18,10 @@ import java.util.HashSet;
import java.util.Objects; import java.util.Objects;
import java.util.logging.Level; import java.util.logging.Level;
/**
* @author SaberTeam
*/
public class Discord { public class Discord {
//We dont want waitingLink to reset during reload so we are going to set it here //We dont want waitingLink to reset during reload so we are going to set it here
public static HashMap<Integer, FPlayer> waitingLink; public static HashMap<Integer, FPlayer> waitingLink;

View File

@ -25,7 +25,7 @@ import java.util.stream.Collectors;
public class DiscordListener extends ListenerAdapter { public class DiscordListener extends ListenerAdapter {
/** /**
* @author Driftay * @author Vankka
*/ */
private static File file = new File(FactionsPlugin.getInstance().getDataFolder(), "discord_guilds.json"); private static File file = new File(FactionsPlugin.getInstance().getDataFolder(), "discord_guilds.json");

View File

@ -1,5 +1,10 @@
package com.massivecraft.factions.discord; package com.massivecraft.factions.discord;
/**
* @author SaberTeam
*/
public class DiscordSetupAttempt { public class DiscordSetupAttempt {
private Boolean success; private Boolean success;
private String reason; private String reason;

View File

@ -22,6 +22,11 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
/**
* @author Vankka & SaberTeam
*/
public class FactionChatHandler extends ListenerAdapter { public class FactionChatHandler extends ListenerAdapter {
private FactionsPlugin plugin; private FactionsPlugin plugin;

View File

@ -8,6 +8,7 @@ import com.sk89q.worldguard.domains.Association;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.association.Associables; import com.sk89q.worldguard.protection.association.Associables;
import com.sk89q.worldguard.protection.association.RegionAssociable; import com.sk89q.worldguard.protection.association.RegionAssociable;
import com.sk89q.worldguard.protection.flags.DefaultFlag;
import com.sk89q.worldguard.protection.flags.StateFlag; import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
@ -21,9 +22,7 @@ import org.bukkit.plugin.Plugin;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.List;
/* /*
* WorldGuard Permission Checking. * WorldGuard Permission Checking.
@ -96,6 +95,42 @@ public class Worldguard {
return associable; return associable;
} }
public static boolean isPvPDisabled(Location l) {
try {
ApplicableRegionSet regionSet = Objects.requireNonNull(instance.getRegionManager(l.getWorld())).getApplicableRegions(l);
if (regionSet.size() < 1) {
try {
return Objects.requireNonNull(Objects.requireNonNull(instance.getRegionManager(l.getWorld())).getRegion("__global__")).getFlags().get(DefaultFlag.PVP) == StateFlag.State.DENY;
} catch (Exception e) {
if (!(e instanceof NullPointerException)) {
e.printStackTrace();
}
return false;
}
} else {
boolean return_flag = false;
int return_priority = -1;
for (ProtectedRegion region : regionSet) {
if (region.getFlags().containsKey(DefaultFlag.PVP)) {
StateFlag.State pvp_flag = (StateFlag.State) region.getFlags().get(DefaultFlag.PVP);
int region_priority = region.getPriority();
if (return_priority == -1) {
return_flag = pvp_flag == StateFlag.State.DENY;
return_priority = region_priority;
} else if (region_priority > return_priority) {
return_flag = pvp_flag == StateFlag.State.DENY;
return_priority = region_priority;
}
}
}
return return_flag;
}
} catch (Exception e) {
return false;
}
}
/** /**
* Credits to the people listed above for using reflections to load WorldGuard 6.0 & 7.0 in 1 class! * Credits to the people listed above for using reflections to load WorldGuard 6.0 & 7.0 in 1 class!
*/ */

View File

@ -96,23 +96,26 @@ public class FactionsBlockListener implements Listener {
boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty()); boolean landOwned = (myFaction.doesLocationHaveOwnersSet(loc) && !myFaction.getOwnerList(loc).isEmpty());
if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId()))) if ((landOwned && myFaction.getOwnerListString(loc).contains(player.getName())) || (me.getRole() == Role.LEADER && me.getFactionId().equals(myFaction.getId())))
return true; return true;
else if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) { else {
String replace = TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString());
if (landOwned && !myFaction.getOwnerListString(loc).contains(player.getName())) {
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc))); me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
if (shouldHurt) { if (shouldHurt) {
player.damage(Conf.actionDeniedPainAmount); player.damage(Conf.actionDeniedPainAmount);
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction))); me.msg(replace.replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
} }
return false; return false;
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway } else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway
if (shouldHurt) { if (shouldHurt) {
player.damage(Conf.actionDeniedPainAmount); player.damage(Conf.actionDeniedPainAmount);
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null) if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction))); me.msg(replace.replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
} }
if (myFaction.getTag(me.getFaction()) != null && action != null) if (myFaction.getTag(me.getFaction()) != null && action != null)
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString())); me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
return false; return false;
} else if (access == Access.ALLOW) return true; } else if (access == Access.ALLOW) return true;
}
me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString())); me.msg(TL.ACTIONS_NOPERMISSION.toString().replace("{faction}", myFaction.getTag(me.getFaction())).replace("{action}", action.toString()));
return false; return false;
} }
@ -417,8 +420,9 @@ public class FactionsBlockListener implements Listener {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true) @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onFrostWalker(EntityBlockFormEvent event) { public void onFrostWalker(EntityBlockFormEvent event) {
if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null) if (event.getEntity() == null || event.getEntity().getType() != EntityType.PLAYER || event.getBlock() == null) {
return; return;
}
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
Location location = event.getBlock().getLocation(); Location location = event.getBlock().getLocation();
@ -426,10 +430,14 @@ public class FactionsBlockListener implements Listener {
// only notify every 10 seconds // only notify every 10 seconds
FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player); FPlayer fPlayer = FPlayers.getInstance().getByPlayer(player);
boolean justCheck = fPlayer.getLastFrostwalkerMessage() + 10000 > System.currentTimeMillis(); boolean justCheck = fPlayer.getLastFrostwalkerMessage() + 10000 > System.currentTimeMillis();
if (!justCheck) fPlayer.setLastFrostwalkerMessage(); if (!justCheck) {
fPlayer.setLastFrostwalkerMessage();
}
// Check if they have build permissions here. If not, block this from happening. // Check if they have build permissions here. If not, block this from happening.
if (!playerCanBuildDestroyBlock(player, location, "frostwalk", justCheck)) event.setCancelled(true); if (!playerCanBuildDestroyBlock(player, location, PermissableAction.FROST_WALK.toString(), justCheck)) {
event.setCancelled(true);
}
} }
@EventHandler @EventHandler
@ -452,16 +460,6 @@ public class FactionsBlockListener implements Listener {
e.setCancelled(true); e.setCancelled(true);
} }
@EventHandler
public void entityDamage(EntityDamageEvent e) {
if (!Conf.gracePeriod) return;
if (e.getEntity() instanceof Player) {
if (e.getCause() == EntityDamageEvent.DamageCause.PROJECTILE) {
e.setCancelled(true);
}
}
}
@EventHandler @EventHandler
public void onTNTPlace(BlockPlaceEvent e1) { public void onTNTPlace(BlockPlaceEvent e1) {

View File

@ -21,6 +21,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class ShopGUIFrame { public class ShopGUIFrame {
@ -47,7 +48,7 @@ public class ShopGUIFrame {
for (int a = 1; a <= items; a++) { for (int a = 1; a <= items; a++) {
String s = a + ""; String s = a + "";
int slot = ShopConfig.getShop().getInt("items." + s + ".slot"); int slot = ShopConfig.getShop().getInt("items." + s + ".slot");
Material material = XMaterial.matchXMaterial(ShopConfig.getShop().getString("items." + s + ".block")).get().parseMaterial(); Material material = XMaterial.matchXMaterial(Objects.requireNonNull(ShopConfig.getShop().getString("items." + s + ".block"))).get().parseMaterial();
int cost = ShopConfig.getShop().getInt("items." + s + ".cost"); int cost = ShopConfig.getShop().getInt("items." + s + ".cost");
String name = ShopConfig.getShop().getString("items." + s + ".name"); String name = ShopConfig.getShop().getString("items." + s + ".name");
boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing"); boolean glowing = ShopConfig.getShop().getBoolean("items." + s + ".glowing");

View File

@ -814,8 +814,11 @@ public abstract class MemoryFPlayer implements FPlayer {
setFlying(false); setFlying(false);
if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty()) { if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty()) {
// Remove this faction // Remove this faction
if(FactionsPlugin.getInstance().getConfig().getBoolean("faction-disband-broadcast")) {
for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers()) for (FPlayer fplayer : FPlayers.getInstance().getOnlinePlayers())
fplayer.msg(TL.LEAVE_DISBANDED, myFaction.describeTo(fplayer, true)); fplayer.msg(TL.LEAVE_DISBANDED, myFaction.describeTo(fplayer, true));
}
FactionDisbandEvent disbandEvent = new FactionDisbandEvent(getPlayer(), myFaction.getId(), PlayerDisbandReason.LEAVE); FactionDisbandEvent disbandEvent = new FactionDisbandEvent(getPlayer(), myFaction.getId(), PlayerDisbandReason.LEAVE);

View File

@ -674,6 +674,11 @@ public enum TL {
COMMAND_PERM_TOP("RCT MEM OFF ALLY TRUCE NEUT ENEMY"), COMMAND_PERM_TOP("RCT MEM OFF ALLY TRUCE NEUT ENEMY"),
COMMAND_PERM_LOCKED("&cThis permission has been locked by the server"), COMMAND_PERM_LOCKED("&cThis permission has been locked by the server"),
COMMAND_POINTS_SHOW_DESCRIPTION("See the point balance of factions"),
COMMAND_POINTS_SHOW_WILDERNESS("&c&l[!] &7You may not check the point balance of wilderness!"),
COMMAND_POINTS_SHOW_OWN("&c&l[!] &7Your faction has &e%1$s &7points."),
COMMAND_POINTS_SHOW("&c&l[!] &e%1$s &7has a point balance of &b%2$s&7."),
COMMAND_POINTS_FAILURE("&c&l[!] &c{faction} does not exist."), COMMAND_POINTS_FAILURE("&c&l[!] &c{faction} does not exist."),
COMMAND_POINTS_SUCCESSFUL("&c&l[!] &7You have added &e%1$s &7points to &b%2$s&7. &b%2$s's &7New Point Balance: &e%3$s"), COMMAND_POINTS_SUCCESSFUL("&c&l[!] &7You have added &e%1$s &7points to &b%2$s&7. &b%2$s's &7New Point Balance: &e%3$s"),
COMMAND_POINTS_INSUFFICIENT("&c&l[!] &7You may not add/set/remove a negative number of points to a faction!"), COMMAND_POINTS_INSUFFICIENT("&c&l[!] &7You may not add/set/remove a negative number of points to a faction!"),