Skip to content

Commit

Permalink
Added Configurable Option allFactionsPeaceful
Browse files Browse the repository at this point in the history
  • Loading branch information
Driftay committed Oct 31, 2021
1 parent ffb4384 commit 28964c1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 32 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/massivecraft/factions/Conf.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ public class Conf {
public static boolean disablePVPForFactionlessPlayers = false;
public static boolean enablePVPAgainstFactionlessInAttackersLand = false;
public static int noPVPDamageToOthersForXSecondsAfterLogin = 3;
public static boolean allFactionsPeaceful = false;
public static boolean peacefulTerritoryDisablePVP = true;
public static boolean peacefulTerritoryDisableMonsters = false;
public static boolean peacefulTerritoryDisableBoom = false;
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/massivecraft/factions/cmd/CmdCreate.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ public void perform(CommandContext context) {
Logger.print(context.fPlayer.getName() + TL.COMMAND_CREATE_CREATEDLOG + tag, Logger.PrefixType.DEFAULT);
if (FactionsPlugin.getInstance().getConfig().getBoolean("fpaypal.Enabled"))
context.msg(TL.COMMAND_PAYPALSET_CREATED);
if(Conf.allFactionsPeaceful) {
faction.setPeaceful(true);
faction.setPeacefulExplosionsEnabled(false);
}
if (Conf.useCustomDefaultPermissions) faction.setDefaultPerms();
if (Conf.usePermissionHints) context.msg(TL.COMMAND_HINT_PERMISSION);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,6 @@ public void handleSpawnerUpdate(Faction at, Player player, ItemStack spawnerItem
}
}

@EventHandler(
priority = EventPriority.HIGH,
ignoreCancelled = true
)
public void onPlayerPlace(BlockPlaceEvent event) {
ItemStack item = event.getItemInHand();
if (item != null && item.getType() == XMaterial.SPAWNER.parseMaterial()) {
Faction at = Board.getInstance().getFactionAt(new FLocation(event.getBlockPlaced()));
if (at != null && at.isNormal()) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
if (fplayer != null && at.getRelationTo(fplayer.getFaction()).isAtLeast(Relation.TRUCE)) {
this.handleSpawnerUpdate(at, event.getPlayer(), item, LogTimer.TimerSubType.SPAWNER_PLACE);
}
}
}
}

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
Expand Down Expand Up @@ -482,7 +466,7 @@ public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();

Faction at = Board.getInstance().getFactionAt(new FLocation(block));
boolean isSpawner = event.getBlock().getType().equals(XMaterial.SPAWNER.parseMaterial());
boolean isSpawner = event.getBlock().getType().equals(XMaterial.matchXMaterial("MOB_SPAWNER").get().parseMaterial());
if (!playerCanBuildDestroyBlock(event.getPlayer(), event.getBlock().getLocation(), "destroy", false)) {
event.setCancelled(true);
return;
Expand All @@ -497,21 +481,6 @@ public void onBlockBreak(BlockBreakEvent event) {
fme.msg(TL.GENERIC_FPERM_NOPERMISSION, "mine spawners");
}
}

if (isSpawner && !fme.isAdminBypassing()) {
ItemStack item = new ItemStack(block.getType(), 1, block.getData());
if (at != null && at.isNormal()) {
FPlayer fplayer = FPlayers.getInstance().getByPlayer(event.getPlayer());
if (fplayer != null) {
BlockState state = block.getState();
if (state instanceof CreatureSpawner) {
CreatureSpawner spawner = (CreatureSpawner) state;
item.setDurability(spawner.getSpawnedType().getTypeId());
}
handleSpawnerUpdate(at, event.getPlayer(), item, LogTimer.TimerSubType.SPAWNER_BREAK);
}
}
}
} catch (Exception e) {
event.setCancelled(true);
e.printStackTrace();
Expand Down

0 comments on commit 28964c1

Please sign in to comment.