Fixes a bunch of grammatical errors, and some warnings

This commit is contained in:
Kristian Knarvik 2023-06-23 21:35:02 +02:00
parent fd8cce63ee
commit 645d59d06e
41 changed files with 135 additions and 174 deletions

1
.gitignore vendored
View File

@ -167,7 +167,6 @@ GitHub.sublime-settings
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags

View File

@ -2,7 +2,7 @@
<!-- In order to help you we need to know which plugin this issue is about. -->
<!-- The plugin always has the same version as MassiveCore. -->
<!-- All our plugins depend on MassiveCore, you did not forget to install it did you? -->
<!-- All our plugins depend on MassiveCore, you did not forget to install it, did you? -->
<!-- Run the command "/massivecore version" to see the version you are running. -->
- **Affected Plugin Name:** Factions
@ -17,11 +17,11 @@
## Steps to Reproduce this Bug
<!-- Write a step by step description of how we can reproduce this bug. -->
<!-- As developers we need to know how to trigger the bug before we can fix it. -->
<!-- As developers, we need to know how to trigger the bug before we can fix it. -->
1. First I did this.
2. Next I did that.
3. Finally this happened.
3. Finally, this happened.
## Observed Results

View File

@ -95,7 +95,7 @@ public class TerritoryAccess {
// -------------------------------------------- //
// This method intentionally returns null if the Faction no longer exists.
// In Board we don't even return this TerritoryAccess if that is the case.
// In Board, we don't even return this TerritoryAccess if that is the case.
public Faction getHostFaction() {
return Faction.get(this.getHostFactionId());
}

View File

@ -25,7 +25,6 @@ public class BoardAdapter implements JsonDeserializer<Board>, JsonSerializer<Boa
// OVERRIDE
// -------------------------------------------- //
@SuppressWarnings("unchecked")
@Override
public Board deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
return new Board(context.deserialize(json, Board.MAP_TYPE));

View File

@ -35,7 +35,7 @@ public class ChatFormatter {
public static String format(String msg, CommandSender sender, CommandSender recipient) {
// We build the return value in this string buffer
StringBuffer ret = new StringBuffer();
StringBuilder ret = new StringBuilder();
// A matcher to match all the tags in the msg
Matcher matcher = pattern.matcher(msg);

View File

@ -58,7 +58,7 @@ public class CmdFactionsCreate extends FactionsCommand {
EventFactionsMembershipChange joinEvent = new EventFactionsMembershipChange(sender, msender, faction, MembershipChangeReason.CREATE);
joinEvent.run();
// NOTE: join event cannot be cancelled or you'll have an empty faction
// NOTE: join event cannot be cancelled, or you'll have an empty faction
// Inform
msg("<i>You created the faction %s", faction.getName(msender));

View File

@ -32,7 +32,7 @@ public class CmdFactionsFlagSet extends FactionsCommand {
boolean value = this.readArg();
Faction faction = this.readArg(msenderFaction);
// Do the sender have the right to change flags for this faction?
// Does the sender have the right to change flags for this faction?
if (!MPerm.getPermFlags().has(msender, faction, true)) {
return;
}

View File

@ -37,7 +37,7 @@ public class CmdFactionsPermSet extends FactionsCommand {
MPerm.MPermable permable = TypeMPermable.get(faction).read(this.argAt(1), sender);
// Do the sender have the right to change perms for this faction?
// Does the sender have the right to change perms for this faction?
if (!MPerm.getPermPerms().has(msender, faction, true)) {
return;
}

View File

@ -60,8 +60,7 @@ public class CmdFactionsPermView extends FactionsCommand {
String permissionSingularPlural = permNames.size() == 1 ? "permission" : "permissions";
msg("<i>In <reset>%s <reset>%s <i>specifically has the %s: <reset>%s<i>.", faction.describeTo(msender), permable.getDisplayName(sender), permissionSingularPlural, names);
}
if (permable instanceof MPlayer) {
MPlayer mplayer = (MPlayer) permable;
if (permable instanceof MPlayer mplayer) {
msg("<i>They may have other permissions through their faction membership, rank or relation to <reset>%s<i>.", faction.describeTo(msender));
List<Mson> msons = new MassiveList<>();
@ -76,15 +75,13 @@ public class CmdFactionsPermView extends FactionsCommand {
Mson msons2 = Mson.implode(msons, Mson.SPACE);
message(mson(mson("Commands: ").color(ChatColor.YELLOW), msons2));
}
if (permable instanceof Faction) {
Faction faction1 = (Faction) permable;
if (permable instanceof Faction faction1) {
msg("<i>They may have other permissions through their relation to <reset>%s<i>.", faction.describeTo(msender));
Mson msonRelation = Mson.parse("<command>[relation]").command(this, faction.getRelationTo(faction1).toString(), faction.getName());
Mson msons = Mson.implode(MUtil.list(msonRelation), Mson.SPACE);
message(mson(mson("Commands: ").color(ChatColor.YELLOW), msons));
}
if (permable instanceof Rank && !faction.hasRank((Rank) permable)) {
Rank rank = (Rank) permable;
if (permable instanceof Rank rank && !faction.hasRank((Rank) permable)) {
msg("<i>They may have other permissions thorugh their faction membership or relation to <reset>%s<i>.", faction.describeTo(msender));
Mson msonFaction = Mson.parse("<command>[faction]").command(this, rank.getFaction().getName(), faction.getName());
Mson msonRelation = Mson.parse("<command>[relation]").command(this, faction.getRelationTo(rank.getFaction()).toString(), faction.getName());

View File

@ -45,18 +45,15 @@ public class CmdFactionsPermViewall extends FactionsCommand {
List<MPermable> permables = new MassiveList<>();
permables.add(permable);
if (permable instanceof MPlayer) {
MPlayer mplayer = (MPlayer) permable;
if (permable instanceof MPlayer mplayer) {
permables.add(mplayer.getFaction());
permables.add(mplayer.getRank());
permables.add(faction.getRelationTo(mplayer));
}
if (permable instanceof Faction) {
Faction faction1 = (Faction) permable;
if (permable instanceof Faction faction1) {
permables.add(faction.getRelationTo(faction1));
}
if (permable instanceof Rank && !faction.hasRank((Rank) permable)) {
Rank rank = (Rank) permable;
if (permable instanceof Rank rank && !faction.hasRank((Rank) permable)) {
Faction faction1 = rank.getFaction();
permables.add(faction1);
permables.add(faction.getRelationTo(faction1));

View File

@ -59,7 +59,7 @@ public class CmdFactionsPlayer extends FactionsCommand {
}
// INFO: Power per Hour
// If the player is not at maximum we wan't to display how much time left.
// If the player is not at maximum we want to display how much time left.
String stringTillMax = "";
double powerTillMax = mplayer.getPowerMax() - mplayer.getPower();

View File

@ -163,12 +163,12 @@ public class CmdFactionsRankSet extends FactionsCommand {
// The following two if statements could be merged.
// But isn't for the sake of nicer error messages.
if (senderRank == targetRank) {
// You can't change someones rank if it is equal to yours.
// You can't change someone's rank if it is equal to yours.
throw new MassiveException().addMsg("<h>%s <b>can't manage eachother.", senderRank.getName() + "s");
}
if (senderRank.isLessThan(targetRank)) {
// You can't change someones rank if it is higher than yours.
// You can't change someone's rank if it is higher than yours.
throw new MassiveException().addMsg("<b>You can't manage people of higher rank.");
}
@ -259,7 +259,7 @@ public class CmdFactionsRankSet extends FactionsCommand {
// Inform & demote the old leader.
targetFactionCurrentLeader.setRank(rank.getRankBelow());
if (targetFactionCurrentLeader != msender) {
// They kinda know if they fired the command themself.
// They kinda know if they fired the command themselves.
targetFactionCurrentLeader.msg("<i>You have been demoted from the position of faction leader by %s<i>.", msender.describeTo(targetFactionCurrentLeader, true));
}
}

View File

@ -41,7 +41,7 @@ public class CmdFactionsTitle extends FactionsCommand {
return;
}
// Rank Check
// Check Rank
if (!msender.isOverriding() && you.getRank().isMoreThan(msender.getRank())) {
throw new MassiveException().addMsg("<b>You can not edit titles for higher ranks.");
}

View File

@ -80,20 +80,14 @@ public class CmdFactionsTop extends FactionsCommand {
private static String getValue(TopCategory category, Faction faction, MPlayer mplayer) {
String ret = Txt.parse("%s<i>: ", faction.getName(mplayer));
switch (category) {
case MONEY:
ret += Money.format(Econ.getMoney(faction), true);
break;
case MEMBERS:
ret += faction.getMPlayers().size() + " members";
break;
case TERRITORY:
ret += faction.getLandCount() + " chunks";
break;
case AGE:
case MONEY -> ret += Money.format(Econ.getMoney(faction), true);
case MEMBERS -> ret += faction.getMPlayers().size() + " members";
case TERRITORY -> ret += faction.getLandCount() + " chunks";
case AGE -> {
long ageMillis = faction.getAge();
LinkedHashMap<TimeUnit, Long> ageUnitcounts = TimeDiffUtil.limit(TimeDiffUtil.unitcounts(ageMillis, TimeUnit.getAllButMillis()), 3);
ret += TimeDiffUtil.formatedVerboose(ageUnitcounts);
break;
}
}
return ret;
}

View File

@ -54,7 +54,7 @@ public class TypeFaction extends TypeAbstract<Faction> {
return FactionColl.get().getNone();
}
// Faction Id Exact
// Faction id Exact
if (FactionColl.get().containsId(str)) {
ret = FactionColl.get().get(str);
if (ret != null) {

View File

@ -60,7 +60,7 @@ public class ComparatorFactionList extends ComparatorAbstract<Faction> {
return ret;
}
// Tie by Id
// Tie by id
return ComparatorComparable.get().compare(f1.getId(), f2.getId());
}

View File

@ -75,12 +75,10 @@ public class EngineCanCombatHappen extends Engine {
}
ProjectileSource projectileSource = event.getPotion().getShooter();
if (!(projectileSource instanceof Entity)) {
if (!(projectileSource instanceof Entity thrower)) {
return;
}
Entity thrower = (Entity) projectileSource;
// ... scan through affected entities to make sure they're all valid targets.
for (LivingEntity affectedEntity : event.getAffectedEntities()) {
EntityDamageByEntityEvent sub = new EntityDamageByEntityEvent(thrower, affectedEntity, EntityDamageEvent.DamageCause.CUSTOM, 0D);
@ -101,12 +99,10 @@ public class EngineCanCombatHappen extends Engine {
}
ProjectileSource projectileSource = event.getEntity().getSource();
if (!(projectileSource instanceof Entity)) {
if (!(projectileSource instanceof Entity thrower)) {
return;
}
Entity thrower = (Entity) projectileSource;
// ... create a dummy list to avoid ConcurrentModificationException ...
List<LivingEntity> affectedList = new ArrayList<>();
@ -201,7 +197,7 @@ public class EngineCanCombatHappen extends Engine {
// ... PVP flag may cause a damage block ...
// (just checking the defender as above isn't enough. What about the attacker? It could be in a no-pvp area)
// NOTE: This check is probably not that important but we could keep it anyways.
// NOTE: This check is probably not that important, but we could keep it anyway.
if (attackerPsFaction.getFlag(MFlag.getFlagPvp()) == false) {
ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, DisallowCause.PEACEFUL_LAND, event);
if (!ret && notify) {

View File

@ -64,7 +64,7 @@ public class EngineChat extends Engine {
// SET FORMAT
// -------------------------------------------- //
private class SetFormatEventExecutor implements EventExecutor {
private static class SetFormatEventExecutor implements EventExecutor {
@Override
public void execute(Listener listener, Event event) throws EventException {
try {
@ -86,7 +86,7 @@ public class EngineChat extends Engine {
// PARSE TAGS
// -------------------------------------------- //
private class ParseTagsEventExecutor implements EventExecutor {
private static class ParseTagsEventExecutor implements EventExecutor {
@Override
public void execute(Listener listener, Event event) throws EventException {
try {
@ -115,7 +115,7 @@ public class EngineChat extends Engine {
// PARSE RELCOLOR
// -------------------------------------------- //
private class ParseRelcolorEventExecutor implements EventExecutor {
private static class ParseRelcolorEventExecutor implements EventExecutor {
@Override
public void execute(Listener listener, Event event) throws EventException {
try {

View File

@ -40,7 +40,7 @@ public class EngineCleanInactivity extends Engine {
public void applyPlayerAgeBonus(EventMassiveCorePlayerCleanInactivityToleranceMillis event) {
// Calculate First Played
Long firstPlayed = event.getEntity().getFirstPlayed();
Long age = 0L;
long age = 0L;
if (firstPlayed != null) {
age = System.currentTimeMillis() - firstPlayed;
}
@ -78,7 +78,7 @@ public class EngineCleanInactivity extends Engine {
return null;
}
Long bonus = 0L;
long bonus = 0L;
for (Entry<Long, Long> entry : ageToBonus.entrySet()) {
Long key = entry.getKey();
if (key == null) {

View File

@ -51,7 +51,7 @@ public class EngineFlagSpawn extends Engine {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void blockMonstersAndAnimals(CreatureSpawnEvent event) {
// If this is a natural spawn ..
// If this is a natural spawn
if (!NATURAL_SPAWN_REASONS.contains(event.getSpawnReason())) {
return;
}

View File

@ -137,10 +137,9 @@ public class EngineFly extends Engine {
// ... and the attacker is a player ...
Entity eattacker = MUtil.getLiableDamager(event);
if (!(eattacker instanceof Player)) {
if (!(eattacker instanceof Player attacker)) {
return;
}
Player attacker = (Player) eattacker;
MPlayer mattacker = MPlayer.get(attacker);
// ... disable flying for both
@ -195,7 +194,7 @@ public class EngineFly extends Engine {
}
// ... otherwise ...
else {
// .. tell them to have someone else edit it ...
// ... tell them to have someone else edit it ...
ex.addMsg("<i>You can ask a faction admin to change the flag.");
}
}

View File

@ -49,7 +49,8 @@ public class EngineLastActivity extends Engine {
@EventHandler(priority = EventPriority.LOWEST)
public void updateLastActivity(PlayerJoinEvent event) {
// During the join event itself we want to be able to reach the old data.
// That is also the way the underlying fallback Mixin system does it and we do it that way for the sake of symmetry.
// That is also the way the underlying fallback Mixin system does it, and we do it that way for the sake of
// symmetry.
// For that reason we wait till the next tick with updating the value.
updateLastActivitySoon(event.getPlayer());
}

View File

@ -238,7 +238,7 @@ public class EnginePermBuild extends Engine {
return;
}
// ... or are allowed to right click with the item, this event is safe to perform.
// ... or are allowed to right-click with the item, this event is safe to perform.
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
@ -266,7 +266,7 @@ public class EnginePermBuild extends Engine {
// Armor stands are handled in EngineSpigot instead.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void useEntity(PlayerInteractEntityEvent event) {
// Ignore Off Hand
// Ignore Off-Hand
if (isOffHand(event)) {
return;
}
@ -276,10 +276,10 @@ public class EnginePermBuild extends Engine {
// This is a special Spigot event that fires for Minecraft 1.8 armor stands.
// It also fires for other entity types but for those the event is buggy.
// It seems we can only cancel interaction with armor stands from here.
// Thus we only handle armor stands from here and handle everything else in EngineMain.
// Thus, we only handle armor stands from here and handle everything else in EngineMain.
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void handleArmorStand(PlayerInteractAtEntityEvent event) {
// Ignore Off Hand
// Ignore Off-Hand
if (isOffHand(event)) {
return;
}
@ -328,10 +328,9 @@ public class EnginePermBuild extends Engine {
public void combustEntity(EntityCombustByEntityEvent event) {
// If a burning projectile ...
if (!(event.getCombuster() instanceof Projectile)) {
if (!(event.getCombuster() instanceof Projectile entityProjectile)) {
return;
}
Projectile entityProjectile = (Projectile) event.getCombuster();
// ... fired by a player ...
ProjectileSource projectileSource = entityProjectile.getShooter();

View File

@ -42,10 +42,9 @@ public enum ProtectCase {
return MPerm.getPermBuild();
case USE_ENTITY:
if (!(object instanceof Entity)) {
if (!(object instanceof Entity entity)) {
return null;
}
Entity entity = (Entity) object;
EntityType type = entity.getType();
if (EnumerationUtil.isEntityTypeContainer(type)) {
return MPerm.getPermContainer();
@ -55,10 +54,9 @@ public enum ProtectCase {
}
case USE_BLOCK:
if (!(object instanceof Material)) {
if (!(object instanceof Material material)) {
return null;
}
Material material = (Material) object;
if (material == Material.LECTERN) {
return MPerm.getPermLectern();
}

View File

@ -109,10 +109,11 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// FIELDS: RAW
// -------------------------------------------- //
// In this section of the source code we place the field declarations only.
// Each field has it's own section further down since just the getter and setter logic takes up quite some place.
// Each field has its own section further down since just the getter and setter logic takes up quite some place.
// The actual faction id looks something like "54947df8-0e9e-4471-a2f9-9af509fb5889" and that is not too easy to remember for humans.
// Thus we make use of a name. Since the id is used in all foreign key situations changing the name is fine.
// The actual faction id looks something like "54947df8-0e9e-4471-a2f9-9af509fb5889" and that is not too easy to
// remember for humans.
// Thus, we make use of a name. Since the id is used in all foreign key situations changing the name is fine.
// Null should never happen. The name must not be null.
private String name = null;
@ -861,7 +862,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
Set<String> permables = this.perms.get(permId);
if (permables == null) {
// No perms was found, but likely this is just a new MPerm.
// No perms were found, but likely this is just a new MPerm.
// So if this does not exist in the database, throw an error.
if (!doesPermExist(permId)) {
throw new NullPointerException(permId + " caused null");
@ -897,7 +898,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
// TODO: Isn't this section redundant and just a copy of that from getPermitted?
Set<String> permables = this.perms.get(permId);
if (permables == null) {
// No perms was found, but likely this is just a new MPerm.
// No perms were found, but likely this is just a new MPerm.
// So if this does not exist in the database, throw an error.
if (!doesPermExist(permId)) {
throw new NullPointerException(permId + " caused null");
@ -917,7 +918,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
Set<String> perms = this.perms.get(permId);
if (perms == null) {
// No perms was found, but likely this is just a new MPerm.
// No perms were found, but likely this is just a new MPerm.
// So if this does not exist in the database, throw an error.
if (!doesPermExist(permId)) {
throw new NullPointerException(permId + " caused null");

View File

@ -93,7 +93,7 @@ public class FactionColl extends Coll<Faction> {
faction.setPermittedRelations(MPerm.getPermLectern(), MPerm.getPermables(faction));
faction.setPermittedRelations(MPerm.getPermButton(), MPerm.getPermables(faction));
faction.setPermittedRelations(MPerm.getPermLever(), MPerm.getPermables(faction));
faction.setPermittedRelations(MPerm.getPermDeposit(), Collections.singleton(faction.getLeaderRank())); // Wilderness deposit should be limited as an anti spam meassure.
faction.setPermittedRelations(MPerm.getPermDeposit(), Collections.singleton(faction.getLeaderRank())); // Wilderness deposit should be limited as an anti-spam measure.
return faction;
}

View File

@ -76,8 +76,8 @@ public class MConf extends Entity<MConf> {
// -------------------------------------------- //
// Use this blacklist/whitelist system to toggle features on a per world basis.
// Do you only want claiming enabled on the one map called "Hurr"?
// In such case set standard to false and add "Hurr" as an exeption to worldsClaimingEnabled.
// Do you only want the ability to claim enabled on the one map called "Hurr"?
// In such case set standard to false and add "Hurr" as an exception to worldsClaimingEnabled.
public WorldExceptionSet worldsClaimingEnabled = new WorldExceptionSet();
public WorldExceptionSet worldsPowerLossEnabled = new WorldExceptionSet();
public WorldExceptionSet worldsPowerGainEnabled = new WorldExceptionSet();
@ -175,7 +175,7 @@ public class MConf extends Entity<MConf> {
public int factionMemberLimit = 0;
// Is there a maximum faction power cap?
// 0 means there is not. Set it to a positive value in case you wan't to use this feature.
// 0 means there is not. Set it to a positive value in case you want to use this feature.
public double factionPowerMax = 0.0;
// Limit the length of faction names here.
@ -198,26 +198,26 @@ public class MConf extends Entity<MConf> {
// Must claims be connected to each other?
// If you set this to false you will allow factions to claim more than one base per world map.
// That would makes outposts possible but also potentially ugly weird claims messing up your Dynmap and ingame experiance.
// That would make outposts possible but also potentially ugly weird claims messing up your Dynmap and in-game experience.
public boolean claimsMustBeConnected = true;
// Must claims be connected to each other enforced strictly?
// If this is enabled there is also done a check on
// unclaim which makes sure you can't make two different bases by unclaiming land.
// un-claim which makes sure you can't make two different bases by un-claiming land.
public boolean claimsMustBeConnectedStrict = false;
// Would you like to allow unconnected claims when conquering land from another faction?
// Setting this to true would allow taking over someone elses base even if claims normally have to be connected.
// Note that even without this you can pillage/unclaim another factions territory in war.
// Setting this to true would allow taking over someone else's base even if claims normally have to be connected.
// Note that even without this you can pillage/un-claim another factions territory in war.
// You just won't be able to take the land as your own.
public boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = false;
// Is claiming from other factions even allowed?
// Set this to false to disable territorial warfare altogether.
// Set this to false in order to disable territorial warfare altogether.
public boolean claimingFromOthersAllowed = true;
// Is it required for factions to have an inflated land/power ratio in order to have their land conquered by another faction?
// Set this to false to allow factions to invade each other without requiring them to have an inflated land/power ratio..
// Set this to false in order to allow factions to invade each other without requiring them to have an inflated land/power ratio..
public boolean claimingFromOthersMustBeInflated = true;
// Is a minimum distance (measured in chunks) to other factions required?
@ -260,7 +260,7 @@ public class MConf extends Entity<MConf> {
// Must warps be located inside the faction's territory?
// It's usually a wise idea keeping this true.
// Otherwise players can set their warps inside enemy territory.
// Otherwise, players can set their warps inside enemy territory.
public boolean warpsMustBeInClaimedTerritory = true;
// And what faction warp should be used when a player types /f home
@ -303,7 +303,7 @@ public class MConf extends Entity<MConf> {
// ASSORTED
// -------------------------------------------- //
// Set this to true if want to block the promotion of new leaders for permanent factions.
// Set this to true if you want to block the promotion of new leaders for permanent factions.
// I don't really understand the user case for this option.
public boolean permanentFactionsDisableLeaderPromotion = false;
@ -458,7 +458,7 @@ public class MConf extends Entity<MConf> {
// -------------------------------------------- //
// Here you can alter the colors tied to certain faction relations and settings.
// You probably don't want to edit these to much.
// You probably don't want to edit these too much.
// Doing so might confuse players that are used to Factions.
public ChatColor colorMember = ChatColor.GREEN;
public ChatColor colorAlly = ChatColor.DARK_PURPLE;
@ -604,7 +604,7 @@ public class MConf extends Entity<MConf> {
// Interacting with these materials when they are already placed in the terrain results in an edit.
public BackstringSet<Material> materialsEditOnInteract = new BackstringSet<>(Material.class);
// Interacting with the the terrain holding this item in hand results in an edit.
// Interacting with the terrain holding this item in hand results in an edit.
// There's no need to add all block materials here. Only special items other than blocks.
public BackstringSet<Material> materialsEditTools = new BackstringSet<>(Material.class);
@ -756,19 +756,20 @@ public class MConf extends Entity<MConf> {
// Format for popup - substitute values for macros
//public String dynmapInfowindowFormat = "<div class=\"infowindow\"><span style=\"font-size:120%;\">%regionname%</span><br />Flags<br /><span style=\"font-weight:bold;\">%flags%</span></div>";
public String dynmapFactionDescription =
"<div class=\"infowindow\">\n" +
"<span style=\"font-weight: bold; font-size: 150%;\">%name%</span></br>\n" +
"<span style=\"font-style: italic; font-size: 110%;\">%description%</span></br>\n" +
"</br>\n" +
"<span style=\"font-weight: bold;\">Leader:</span> %players.leader%</br>\n" +
"<span style=\"font-weight: bold;\">Members:</span> %players%</br>\n" +
"</br>\n" +
"<span style=\"font-weight: bold;\">Age:</span> %age%</br>\n" +
"<span style=\"font-weight: bold;\">Bank:</span> %money%</br>\n" +
"</br>\n" +
"<span style=\"font-weight: bold;\">Flags:</span></br>\n" +
"%flags.table3%\n" +
"</div>";
"""
<div class="infowindow">
<span style="font-weight: bold; font-size: 150%;">%name%</span></br>
<span style="font-style: italic; font-size: 110%;">%description%</span></br>
</br>
<span style="font-weight: bold;">Leader:</span> %players.leader%</br>
<span style="font-weight: bold;">Members:</span> %players%</br>
</br>
<span style="font-weight: bold;">Age:</span> %age%</br>
<span style="font-weight: bold;">Bank:</span> %money%</br>
</br>
<span style="font-weight: bold;">Flags:</span></br>
%flags.table3%
</div>""";
// Enable the %money% macro. Only do this if you know your economy manager is thread safe.
public boolean dynmapShowMoneyInDescription = false;

View File

@ -214,8 +214,9 @@ public class MFlag extends Entity<MFlag> implements Prioritized, Registerable, N
// The sort priority. Low values appear first in sorted lists.
// 1 is high up, 99999 is far down.
// Standard Faction flags use "thousand values" like 1000, 2000, 3000 etc to allow adding new flags inbetween.
// So 1000 might sound like a lot but it's actually the priority for the first flag.
// Standard Faction flags use "a thousand interval values" like 1000, 2000, 3000 etc. to allow adding new flags
// in between.
// So 1000 might sound like a lot, but it's actually the priority for the first flag.
private int priority = 0;
@Override

View File

@ -315,8 +315,9 @@ public class MPerm extends Entity<MPerm> implements Prioritized, Registerable, N
// The sort priority. Low values appear first in sorted lists.
// 1 is high up, 99999 is far down.
// Standard Faction perms use "thousand values" like 1000, 2000, 3000 etc to allow adding new perms inbetween.
// So 1000 might sound like a lot but it's actually the priority for the first perm.
// Standard Faction perms use "a thousand interval values" like 1000, 2000, 3000 etc. to allow adding new perms
// in between.
// So 1000 might sound like a lot, but it's actually the priority for the first perm.
private int priority = 0;
@Override

View File

@ -31,6 +31,7 @@ import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipator, MPerm.MPermable {
@ -130,7 +131,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
// FIELDS: RAW
// -------------------------------------------- //
// In this section of the source code we place the field declarations only.
// Each field has it's own section further down since just the getter and setter logic takes up quite some place.
// Each field has its own section further down since just the getter and setter logic takes up quite some place.
// The last known time of explicit player activity, such as login or logout.
// This value is most importantly used for removing cleanable players.
@ -292,7 +293,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
return !this.getFaction().isNone();
}
// This setter is so long because it search for default/null case and takes
// This setter is so long because it searches for default/null case and takes
// care of updating the faction member index
public void setFactionId(String factionId) {
// Before
@ -591,10 +592,7 @@ public class MPlayer extends SenderEntity<MPlayer> implements FactionsParticipat
if (!MixinTitle.get().isAvailable()) {
return false;
}
if (this.territoryInfoTitles == null) {
return MConf.get().territoryInfoTitlesDefault;
}
return this.territoryInfoTitles;
return Objects.requireNonNullElseGet(this.territoryInfoTitles, () -> MConf.get().territoryInfoTitlesDefault);
}
public void setTerritoryInfoTitles(Boolean territoryInfoTitles) {

View File

@ -24,7 +24,7 @@ public class MigratorFaction001Invitations extends MigratorRoot {
this.addInnerMigrator(new MigratorFaction001InvitationsField());
}
public class MigratorFaction001InvitationsField extends MigratorFieldConvert {
public static class MigratorFaction001InvitationsField extends MigratorFieldConvert {
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //

View File

@ -49,17 +49,15 @@ public class MigratorMConf001EnumerationUtil extends MigratorRoot {
private void removeFromStringsField(JsonObject entity, String fieldName, Collection<String> removals) {
JsonElement stringsElement = entity.get(fieldName);
if (!(stringsElement instanceof JsonArray)) {
if (!(stringsElement instanceof JsonArray strings)) {
return;
}
JsonArray strings = (JsonArray) stringsElement;
for (Iterator<JsonElement> iterator = strings.iterator(); iterator.hasNext(); ) {
JsonElement stringElement = iterator.next();
if (!(stringElement instanceof JsonPrimitive)) {
if (!(stringElement instanceof JsonPrimitive string)) {
continue;
}
JsonPrimitive string = (JsonPrimitive) stringElement;
if (!removals.contains(string.getAsString())) {
continue;

View File

@ -42,7 +42,7 @@ public class MigratorMPerm002MoveStandard extends MigratorRoot {
String id = entity.get("name").getAsString();
// This is hacky but we utilise that names and ids are the same
// This is hacky, but we utilise that names and ids are the same
MConf.get().perm2default.put(id, result);
MConf.get().changed();
}

View File

@ -91,7 +91,7 @@ public class Econ {
Faction fMe = RelationUtil.getFaction(me);
Faction fYou = RelationUtil.getFaction(you);
// A faction can always transfer away the money of it's members and its own money...
// A faction can always transfer away the money of its members and its own money...
// This will however probably never happen as a faction does not have free will.
// Ohh by the way... Yes it could. For daily rent to the faction.
if (me == fMe && fMe == fYou) {
@ -279,7 +279,7 @@ public class Econ {
return Money.move(from, to, by, amount, category);
}
// Or if neither to or from is a faction
// Or if neither to nor from is a faction
if (!fromFaction && !toFaction) {
return Money.move(from, to, by, amount, category);
}

View File

@ -58,7 +58,8 @@ public class DynmapStyle {
}
// NOTE: We just return the string here. We do not return the resolved Dynmap MarkerIcon object.
// The reason is we use this class in the MConf. For serialization to work Dynmap would have to be loaded and we can't require that.
// The reason is we use this class in the MConf. For serialization to work Dynmap would have to be loaded, and we
// can't require that.
// Using dynmap is optional.
public final String homeMarker;

View File

@ -84,7 +84,7 @@ public class EngineDynmap extends Engine {
long before = System.currentTimeMillis();
// We do what we can here.
// You /can/ run this method from the main server thread but it's not recommended at all.
// You /can/ run this method from the main server thread, but it's not recommended at all.
// This method is supposed to be run async to avoid locking the main server thread.
//final Map<String, TempMarker> homes = createHomes();
final Map<String, AreaMarkerValues> areas = createAreas();
@ -106,7 +106,7 @@ public class EngineDynmap extends Engine {
return;
}
// createLayer() is thread safe but it makes use of fields set in fetchDynmapAPI() so we must have it after.
// createLayer() is thread safe, but it makes use of fields set in fetchDynmapAPI() so we must have it after.
if (!updateLayer(createLayer())) {
return;
}
@ -268,9 +268,9 @@ public class EngineDynmap extends Engine {
Map<PS, PS> edges_v = new MassiveMap<>();
List<PS> sorted_x = new MassiveList<>(points);
Collections.sort(sorted_x, this::xThenZ);
sorted_x.sort(this::xThenZ);
List<PS> sorted_z = new MassiveList<>(points);
Collections.sort(sorted_z, this::zThenX);
sorted_z.sort(this::zThenX);
// Create horizontal edges
for (int i = 0; i < points.size(); ) {
@ -292,6 +292,7 @@ public class EngineDynmap extends Engine {
}
}
//TODO: Why has this been commented out?
//List<PS> linelist = getLineList(polygonChunks);
@ -432,7 +433,7 @@ public class EngineDynmap extends Engine {
// Calc current partial
String partial = IntegrationDynmap.FACTIONS_AREA_ + world + "__" + faction.getId() + "__";
// If different than last time, then reset the counter
// If different from last time, then reset the counter
if (!partial.equals(lastPartialMarkerId)) {
markerIdx = 0;
}
@ -657,31 +658,21 @@ public class EngineDynmap extends Engine {
XPLUS, ZPLUS, XMINUS, ZMINUS;
public PS adjacent(PS ps) {
switch (this) {
case XPLUS:
return PS.valueOf(ps.getChunkX() + 1, ps.getChunkZ());
case ZPLUS:
return PS.valueOf(ps.getChunkX(), ps.getChunkZ() + 1);
case XMINUS:
return PS.valueOf(ps.getChunkX() - 1, ps.getChunkZ());
case ZMINUS:
return PS.valueOf(ps.getChunkX(), ps.getChunkZ() - 1);
}
throw new RuntimeException("say what");
return switch (this) {
case XPLUS -> PS.valueOf(ps.getChunkX() + 1, ps.getChunkZ());
case ZPLUS -> PS.valueOf(ps.getChunkX(), ps.getChunkZ() + 1);
case XMINUS -> PS.valueOf(ps.getChunkX() - 1, ps.getChunkZ());
case ZMINUS -> PS.valueOf(ps.getChunkX(), ps.getChunkZ() - 1);
};
}
public PS getCorner(PS ps) {
switch (this) {
case XPLUS:
return PS.valueOf(ps.getChunkX() + 1, ps.getChunkZ());
case ZPLUS:
return PS.valueOf(ps.getChunkX() + 1, ps.getChunkZ() + 1);
case XMINUS:
return PS.valueOf(ps.getChunkX(), ps.getChunkZ() + 1);
case ZMINUS:
return PS.valueOf(ps.getChunkX(), ps.getChunkZ());
}
throw new RuntimeException("say what");
return switch (this) {
case XPLUS -> PS.valueOf(ps.getChunkX() + 1, ps.getChunkZ());
case ZPLUS -> PS.valueOf(ps.getChunkX() + 1, ps.getChunkZ() + 1);
case XMINUS -> PS.valueOf(ps.getChunkX(), ps.getChunkZ() + 1);
case ZMINUS -> PS.valueOf(ps.getChunkX(), ps.getChunkZ());
};
}
public Direction turnRight() {

View File

@ -9,7 +9,7 @@ public class IntegrationDynmap extends Integration {
// -------------------------------------------- //
// Constants must be here rather than in EngineDynmap.
// MConf relies on DynmapStyle which relies on these constants
// MConf relies on DynmapStyle which relies on these constants,
// and we must be able to load MConf without EngineDynmap.
public final static int BLOCKS_PER_CHUNK = 16;

View File

@ -64,7 +64,7 @@ public class EngineLwc extends Engine {
// ... then remove for all other factions than the new one.
// First we wait one tick to make sure the chunk ownership changes have been applied.
// Then we remove the protections but we do it asynchronously to not lock the main thread.
// Then we remove the protections, but we do it asynchronously to not lock the main thread.
for (PS chunk : chunks) {
removeAlienProtectionsAsyncNextTick(chunk, newFaction);
}

View File

@ -90,7 +90,7 @@ public class FactionsLwcModule extends JavaModule {
protection.remove();
// ... cancel the event ...
// NOTE: The first time you click nothing but the unlock should happen.
// NOTE: The first time you click nothing but the unlocking should happen.
// NOTE: This way it's more obvious the auto unlock system kicked in.
// NOTE: No inventory will get opened.
event.setResult(Result.CANCEL);

View File

@ -50,29 +50,20 @@ public class PlaceholderFactions extends PlaceholderExpansion {
}
DecimalFormat df = new DecimalFormat("#.##");
switch (params) {
case "faction":
return mplayer.getFaction().getName();
case "power":
return df.format(mplayer.getPower());
case "powermax":
return df.format(mplayer.getPowerMax());
case "factionpower":
return df.format(mplayer.getFaction().getPower());
case "factionpowermax":
return df.format(mplayer.getFaction().getPowerMax());
case "title":
return mplayer.getTitle();
case "rank":
return mplayer.getRank().getName();
case "claims":
return Long.toString(BoardColl.get().getAll().stream().mapToInt(board -> board.getCount(mplayer.getFaction())).sum());
case "onlinemembers":
return Integer.toString(mplayer.getFaction().getMPlayersWhereOnlineTo(mplayer).size());
case "allmembers":
return Integer.toString(mplayer.getFaction().getMPlayers().size());
}
return null;
return switch (params) {
case "faction" -> mplayer.getFaction().getName();
case "power" -> df.format(mplayer.getPower());
case "powermax" -> df.format(mplayer.getPowerMax());
case "factionpower" -> df.format(mplayer.getFaction().getPower());
case "factionpowermax" -> df.format(mplayer.getFaction().getPowerMax());
case "title" -> mplayer.getTitle();
case "rank" -> mplayer.getRank().getName();
case "claims" ->
Long.toString(BoardColl.get().getAll().stream().mapToInt(board -> board.getCount(mplayer.getFaction())).sum());
case "onlinemembers" -> Integer.toString(mplayer.getFaction().getMPlayersWhereOnlineTo(mplayer).size());
case "allmembers" -> Integer.toString(mplayer.getFaction().getMPlayers().size());
default -> null;
};
}
}

View File

@ -48,8 +48,7 @@ public class RelationUtil {
} else {
ret = thatFactionName;
}
} else if (that instanceof MPlayer) {
MPlayer mplayerthat = (MPlayer) that;
} else if (that instanceof MPlayer mplayerthat) {
if (that == me) {
ret = SELF;
} else if (isSameFaction) {