Skip to content

Commit

Permalink
Merge from Driftay/1.6.x
Browse files Browse the repository at this point in the history
Merge from Driftay 1.6.x
  • Loading branch information
DroppingAnvil authored Oct 4, 2019
2 parents 666d6ab + fac351d commit 7973d80
Show file tree
Hide file tree
Showing 13 changed files with 229 additions and 215 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# SaberFactions

![Downloads](https://img.shields.io/github/downloads/driftay/saber-factions/total.svg) [![CodeFactor](https://www.codefactor.io/repository/github/driftay/saber-factions/badge)](https://www.codefactor.io/repository/github/driftay/saber-factions)

SaberFactions is a fork of both FactionsUUID and SavageFactions. Creators of those plugins include DtrShock and ProSavage. Credits to them.
SaberFactions is the newest, latest and greatest factions plugin designed for the best and most functional factions experience minecraft has seen!

Expand Down
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId>
<version>1.6.9.5-U0.2.1-1.9.7-BETA</version>
<version>1.6.9.5-U0.2.1-2.0.2-BETA</version>
<packaging>jar</packaging>

<name>SaberFactions</name>
Expand Down Expand Up @@ -383,10 +383,9 @@
</dependency>
<dependency>
<groupId>com.jagrosh</groupId>
<artifactId>jda-utilities</artifactId>
<artifactId>jda-utilities-commons</artifactId>
<version>2.1</version>
<scope>compile</scope>
<type>pom</type>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/massivecraft/factions/Conf.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class Conf {
public static boolean worldGuardChecking = false;
public static boolean worldGuardBuildPriority = false;
//DISCORD
public static boolean useDiscordSystem = true;
public static boolean useDiscordSystem = false;
public static String discordBotToken = "<token here>";
public static String fromDiscordFactionChatPrefix = "&f[&dDiscord&f] ";
public static String avatarUrl = "http://cravatar.eu/helmavatar/%uuid%.png";
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/massivecraft/factions/FactionsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,8 @@ public void onEnable() {
}
if(Conf.useDiscordSystem) {
new FactionChatHandler(this);
} else {
System.out.println("\n\n\n SABER-FACTIONS-DISCORD-INTEGRATION - You are not using Discord integration features, set conf.json option useDiscordSystem to true and put a valid token in before using!\n\n\n");
}

ShopConfig.setup();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/massivecraft/factions/cmd/CmdUnban.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void perform(CommandContext context) {
context.faction.unban(target);

context.msg(TL.COMMAND_UNBAN_UNBANNED, context.fPlayer.getName(), target.getName());
target.msg(TL.COMMAND_UNBAN_TARGET, context.faction.getTag(target));
target.msg(TL.COMMAND_UNBAN_TARGET.toString(), context.faction.getTag(target));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public void run() {
}
faction.msg(TL.CHECK_WALLS_CHECK);

if (!Conf.useDiscordSystem) return;


String channelId = faction.getWallNotifyChannelId();
if (channelId == null) {
continue;
Expand Down Expand Up @@ -122,6 +125,10 @@ public void run() {
CheckTask.bufferChecks.add(faction.getId());
}
faction.msg(TL.CHECK_BUFFERS_CHECK);

if (!Conf.useDiscordSystem) return;


String channelId = faction.getBufferNotifyChannelId();
if (channelId == null) {
continue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.massivecraft.factions.cmd.check;

import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.FactionsPlugin;
Expand All @@ -24,9 +25,9 @@ public void run() {
continue;
}
faction.msg(TL.WEE_WOO_MESSAGE);
if (!FactionChatHandler.jda.getStatus().equals(JDA.Status.CONNECTED)) {
continue;
}

if (!Conf.useDiscordSystem) return;

String discordChannelId = faction.getWeeWooChannelId();
if (discordChannelId == null || discordChannelId.isEmpty()) {
continue;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/massivecraft/factions/cmd/tnt/CmdTnt.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,16 @@ public void perform(CommandContext context) {
context.msg(TL.GENERIC_ARGS_TOOFEW);
context.msg(context.args.get(0).equalsIgnoreCase("take") || context.args.get(0).equalsIgnoreCase("t") ? TL.COMMAND_TNT_TAKE_DESCRIPTION : TL.COMMAND_TNT_ADD_DESCRIPTION);
}
context.sendMessage(TL.COMMAND_TNT_AMOUNT.toString().replace("{amount}", context.faction.getTnt() + "").replace("{bankSize}", context.faction.getTntBankLimit() + ""));
context.msg(TL.COMMAND_TNT_AMOUNT, context.faction.getTnt(), context.faction.getTntBankLimit());
}


public boolean inventoryContains(Inventory inventory, ItemStack item) {
int count = 0;
ItemStack[] items = inventory.getContents();
for (int i = 0; i < items.length; i++) {
if (items[i] != null && items[i].getType() == item.getType() && items[i].getDurability() == item.getDurability()) {
count += items[i].getAmount();
for (ItemStack item1 : items) {
if (item1 != null && item1.getType() == item.getType() && item1.getDurability() == item.getDurability()) {
count += item1.getAmount();
}
if (count >= item.getAmount()) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import mkremins.fanciful.FancyMessage;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.Permission;
import org.bukkit.ChatColor;

public class CmdInviteBot extends FCommand {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.attribute.FileAttribute;
import java.text.DecimalFormat;
import java.util.List;
import java.util.*;
Expand All @@ -37,27 +36,30 @@ public DiscordListener(FactionsPlugin plugin) {

private static JSONGuilds loadGuilds() {
try {
if (!DiscordListener.file.exists()) {
Files.createFile(DiscordListener.file.toPath(), (FileAttribute<?>[]) new FileAttribute[0]);
Files.write(DiscordListener.file.toPath(), "{}".getBytes());
}
return FactionsPlugin.getInstance().gson.fromJson(String.join("\n", Files.readAllLines(DiscordListener.file.toPath())), JSONGuilds.class);
if (file.exists())
return FactionsPlugin.getInstance().gson.fromJson(String.join("\n", Files.readAllLines(file.toPath())), JSONGuilds.class);
Files.createFile(file.toPath());
Files.write(file.toPath(), "{}".getBytes());
return FactionsPlugin.getInstance().gson.fromJson(String.join("\n", Files.readAllLines(file.toPath())), JSONGuilds.class);
} catch (IOException e) {
e.printStackTrace();
throw new NullPointerException();
}
}


public static void saveGuilds() {
try {
String content = FactionsPlugin.getInstance().gson.toJson(DiscordListener.guilds);
Files.write(DiscordListener.file.toPath(), content.getBytes());
} catch (IOException e) {
String content = FactionsPlugin.getInstance().gson.toJson(guilds);
Files.write(file.toPath(), content.getBytes());
}
catch (IOException e) {
e.printStackTrace();
throw new NullPointerException();
}
}


public void onGuildMessageReceived(GuildMessageReceivedEvent event) {
try {
if (event.getMessage().isWebhookMessage() || event.getAuthor().isBot()) {
Expand Down Expand Up @@ -208,7 +210,7 @@ private void fstats(GuildMessageReceivedEvent event, String content, String pref
EmbedBuilder embedBuilder = new EmbedBuilder().setColor(Color.MAGENTA).setTitle("Faction Stats").setAuthor(ChatColor.stripColor(faction.getTag())).addField("Description", faction.getDescription(), false).addField("Players Online", String.valueOf(faction.getOnlinePlayers().size()), true).addField("Total players", String.valueOf(faction.getFPlayers().size()), true).addField("Alts", String.valueOf(faction.getAltPlayers().size()), true).addField("Land", String.valueOf(faction.getLandRounded()), true).addField("Power", faction.getPowerRounded() + "/" + faction.getPowerMaxRounded(), true);
Faction guildFaction = this.getFaction(event.getGuild());
if (guildFaction != null && guildFaction.getId().equals(faction.getId()) && this.canAccessRole(guildFaction, event.getMember())) {
embedBuilder.addField("Kills", String.valueOf(faction.getKills()), true).addField("Deaths", String.valueOf(faction.getDeaths()), true);
embedBuilder.addField("Kills", String.valueOf(faction.getKills()), true).addField("Points", String.valueOf(faction.getPoints()), true).addField("Deaths", String.valueOf(faction.getDeaths()), true);
}
event.getChannel().sendMessage(embedBuilder.build()).queue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ public boolean canClaimForFactionAtLocation(Faction forFaction, FLocation flocat
int factionBuffer = FactionsPlugin.getInstance().getConfig().getInt("hcf.buffer-zone", 0);
int worldBuffer = FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0);

if (Conf.worldGuardChecking && Worldguard.checkForRegionsInChunk(flocation)) {
if (Conf.worldGuardChecking && Worldguard.checkForRegionsInChunk(flocation) && !this.isAdminBypassing()) {
// Checks for WorldGuard regions in the chunk attempting to be claimed
error = FactionsPlugin.getInstance().txt.parse(TL.CLAIM_PROTECTED.toString());
} else if (flocation.isOutsideWorldBorder(FactionsPlugin.getInstance().getConfig().getInt("world-border.buffer", 0))) {
Expand Down Expand Up @@ -1226,7 +1226,7 @@ public boolean attemptClaim(Faction forFaction, FLocation flocation, boolean not
}

LandClaimEvent claimEvent = new LandClaimEvent(flocation, forFaction, this);
Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> Bukkit.getPluginManager().callEvent(claimEvent));
Bukkit.getPluginManager().callEvent(claimEvent);
if (claimEvent.isCancelled()) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/massivecraft/factions/zcore/util/TL.java
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,7 @@ public enum TL {
COMMAND_TNT_WIDTHDRAW_SUCCESS("&cSuccessfully withdrew tnt."),
COMMAND_TNT_WIDTHDRAW_NOTENOUGH("&cNot enough tnt in bank."),
COMMAND_TNT_DEPOSIT_NOTENOUGH("&cNot enough tnt in tnt inventory."),
COMMAND_TNT_AMOUNT("&cYour faction has {amount} tnt out of {bankSize} in the tnt bank."),
COMMAND_TNT_AMOUNT("&cYour faction has %1$s tnt out of %2$s in the tnt bank."),
COMMAND_TNT_POSITIVE("&cPlease use positive numbers!"),
COMMAND_TNT_DESCRIPTION("add/widthraw from faction's tnt bank"),
COMMAND_TNT_WIDTHDRAW_NOTENOUGH_SPACE("&cNot enough space in your inventory."),
Expand Down
Loading

0 comments on commit 7973d80

Please sign in to comment.