Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
dmccoystephenson committed Sep 24, 2022
2 parents 83ac83c + 88ee7eb commit e551c8d
Show file tree
Hide file tree
Showing 84 changed files with 2,530 additions and 1,535 deletions.
1 change: 0 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
Thank you so much for being willing to contribute to this project! It wouldn't be where it is today without the help of others. Please feel free to fork the repository and contact me on my [support discord server](https://discord.gg/xXtuAQ2).

## Some Things To Know
- I use ZenHub to manage repository issues. This is optional for contributors.
- Our highest priority issues will given the "priority" label. [Check them out here](https://github.com/dmccoystephenson/Medieval-Factions/issues?q=is%3Aissue+is%3Aopen+label%3Apriority)

## Process
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ GoodLucky777 | Fixed a bug and a few typos in the code
Elafir | Made it possible to control gates with redstone
[Deej](https://github.com/Mr-Deej) | Added checks to several commands
VoChiDanh | Refactored parts the PersistentData class in an attempt to resolve java compatibility issues
alyphen | Transitioned the project from using maven to gradle.
[JackAttack924](https://github.com/jackcayc924) | Created Tab-Completion functionality for commands

### Translators
Name | Language(s)
Expand Down
3 changes: 0 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ repositories {
}

dependencies {
implementation 'com.github.dmccoystephenson:Fiefs:v0.8'
implementation 'com.github.Preponderous-Software:Ponder:1.1'
implementation 'me.clip:placeholderapi:2.11.1'
implementation 'org.spigotmc:spigot-api:1.14.1-R0.1-SNAPSHOT'
Expand All @@ -46,7 +45,6 @@ shadowJar {
include(dependency('com.github.Preponderous-Software:Ponder'))
include(dependency('org.bstats:bstats-bukkit'))
include(dependency('org.bstats:bstats-base'))
include(dependency('com.github.dmccoystephenson:Fiefs'))
}
relocate 'preponderous.ponder', 'dansplugins.factionsystem.shadow.preponderous.ponder'
relocate 'org.intellij', 'dansplugins.factionsystem.shadow.org.intellij'
Expand All @@ -55,7 +53,6 @@ shadowJar {
relocate 'junit', 'dansplugins.factionsystem.shadow.junit'
relocate 'org.hamcrest', 'dansplugins.factionsystem.shadow.org.hamcrest'
relocate 'org.junit', 'dansplugins.factionsystem.shadow.org.junit'
relocate 'dansplugins.fiefs', 'dansplugins.factionsystem.shadow.dansplugins.fiefs'
}

artifacts {
Expand Down
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@
<version>2.2</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.dmccoystephenson</groupId>
<artifactId>Fiefs</artifactId>
<version>v0.8</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.Preponderous-Software</groupId>
<artifactId>Ponder</artifactId>
Expand Down
43 changes: 19 additions & 24 deletions src/main/java/dansplugins/factionsystem/MedievalFactions.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
*/
package dansplugins.factionsystem;

import dansplugins.factionsystem.commands.abs.TabCompleterBase;
import dansplugins.factionsystem.data.EphemeralData;
import dansplugins.factionsystem.data.PersistentData;
import dansplugins.factionsystem.eventhandlers.*;
import dansplugins.factionsystem.externalapi.MedievalFactionsAPI;
import dansplugins.factionsystem.factories.WarFactory;
import dansplugins.factionsystem.integrators.CurrenciesIntegrator;
import dansplugins.factionsystem.integrators.DynmapIntegrator;
import dansplugins.factionsystem.integrators.FiefsIntegrator;
import dansplugins.factionsystem.placeholders.PlaceholderAPI;
import dansplugins.factionsystem.services.*;
import dansplugins.factionsystem.utils.Logger;
Expand Down Expand Up @@ -39,49 +38,45 @@
*/
public class MedievalFactions extends PonderBukkitPlugin {

private MedievalFactions medievalFactions;
private final String pluginVersion = "v" + getDescription().getVersion();
private final ActionBarService actionBarService = new ActionBarService();
private final ConfigService configService = new ConfigService(this);
public boolean USE_NEW_LANGUAGE_FILE = configService.getBoolean("useNewLanguageFile");
private final EphemeralData ephemeralData = new EphemeralData();
private final Logger logger = new Logger(this);
private final FiefsIntegrator fiefsIntegrator = new FiefsIntegrator(this);
private final Messenger messenger = new Messenger(configService.getLocaleService(), fiefsIntegrator);
private final CurrenciesIntegrator currenciesIntegrator = new CurrenciesIntegrator();
private final PersistentData persistentData = new PersistentData(configService.getLocaleService(), configService, this, messenger, ephemeralData, logger, fiefsIntegrator, currenciesIntegrator);
private final WarFactory warFactory = new WarFactory(persistentData);
private final MessageService messageService = new MessageService();
private final RelationChecker relationChecker = new RelationChecker(persistentData);
private final GateService gateService = new GateService(persistentData, configService.getLocaleService(), ephemeralData);
private final LockService lockService = new LockService(persistentData, configService.getLocaleService(), persistentData.getBlockChecker(), ephemeralData);
private final PlayerTeleporter playerTeleporter = new PlayerTeleporter(logger);
private final Scheduler scheduler = new Scheduler(logger, configService.getLocaleService(), this, persistentData, configService, playerTeleporter);
private final CommandService commandService = new CommandService(configService.getLocaleService(), this, configService, persistentData, ephemeralData, persistentData.getChunkDataAccessor(), persistentData.getDynmapIntegrator(), warFactory, logger, scheduler, messenger, relationChecker, fiefsIntegrator, currenciesIntegrator);
private final TerritoryOwnerNotifier territoryOwnerNotifier = new TerritoryOwnerNotifier(configService.getLocaleService(), configService, actionBarService);

public MedievalFactions getMedievalFactions() {
return medievalFactions;
}
private final MessageService messageService = new MessageService(this);
private final PlayerService playerService = new PlayerService(configService, messageService);
private final Messenger messenger = new Messenger(configService.getLocaleService(), playerService, messageService, this, configService);
private final PersistentData persistentData = new PersistentData(configService.getLocaleService(), configService, this, messenger, ephemeralData, logger, playerService, messageService);
private final WarFactory warFactory = new WarFactory(persistentData);
private final RelationChecker relationChecker = new RelationChecker(persistentData);
private final GateService gateService = new GateService(persistentData, configService.getLocaleService(), ephemeralData, playerService, messageService);
private final LockService lockService = new LockService(persistentData, configService.getLocaleService(), persistentData.getBlockChecker(), playerService, messageService, ephemeralData);
private final Scheduler scheduler = new Scheduler(logger, configService.getLocaleService(), this, persistentData, configService, playerTeleporter, playerService, messageService);
private final CommandService commandService = new CommandService(configService.getLocaleService(), this, configService, persistentData, ephemeralData, persistentData.getChunkDataAccessor(), persistentData.getDynmapIntegrator(), warFactory, logger, scheduler, messenger, relationChecker, playerService, messageService);

public ConfigService getConfigService() {
return configService;
}


/**
* This runs when the server starts.
*/
@Override
public void onEnable() {
medievalFactions = this;
initializeConfig();
messageService.createLanguageFile();
load();
scheduleRecurringTasks();
registerEventHandlers();
handleIntegrations();
makeSureEveryPlayerExperiencesPowerDecay();

getCommand("mf").setTabCompleter(new TabCompleterBase(persistentData, configService));
getCommand("f").setTabCompleter(new TabCompleterBase(persistentData, configService));
getCommand("medievalfactions").setTabCompleter(new TabCompleterBase(persistentData, configService));
getCommand("factions").setTabCompleter(new TabCompleterBase(persistentData, configService));
}

/**
Expand Down Expand Up @@ -207,9 +202,9 @@ private ArrayList<Listener> initializeListeners() {
new DamageHandler(logger, persistentData, ephemeralData, configService.getLocaleService(), configService, relationChecker),
new DeathHandler(configService, persistentData, configService.getLocaleService()),
new EffectHandler(ephemeralData, this, relationChecker),
new InteractionHandler(persistentData, persistentData.getInteractionAccessChecker(), configService.getLocaleService(), persistentData.getBlockChecker(), this, lockService, ephemeralData, gateService),
new InteractionHandler(persistentData, persistentData.getInteractionAccessChecker(), configService.getLocaleService(), persistentData.getBlockChecker(), this, lockService, ephemeralData, gateService, playerService, messageService),
new JoinHandler(persistentData, configService.getLocaleService(), configService, logger, messenger, territoryOwnerNotifier),
new MoveHandler(persistentData, territoryOwnerNotifier, configService.getLocaleService(), this, persistentData.getDynmapIntegrator()),
new MoveHandler(persistentData, territoryOwnerNotifier, configService.getLocaleService(), this, persistentData.getDynmapIntegrator(), playerService),
new QuitHandler(ephemeralData, persistentData, actionBarService),
new SpawnHandler(configService, persistentData)
));
Expand Down Expand Up @@ -238,7 +233,7 @@ private void handleDynmapIntegration() {

private void handlePlaceholdersIntegration() {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new PlaceholderAPI(this, persistentData).register();
new PlaceholderAPI(this, persistentData, configService).register();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ public class AddLawCommand extends SubCommand {
/**
* Constructor to initialise a Command.
*/
public AddLawCommand(LocaleService localeService, PersistentData persistentData, EphemeralData ephemeralData, PersistentData.ChunkDataAccessor chunkDataAccessor, DynmapIntegrator dynmapIntegrator, ConfigService configService) {
public AddLawCommand(LocaleService localeService, PersistentData persistentData, EphemeralData ephemeralData, PersistentData.ChunkDataAccessor chunkDataAccessor, DynmapIntegrator dynmapIntegrator, ConfigService configService, PlayerService playerService, MessageService messageService) {
super(new String[]{
LOCALE_PREFIX + "CMDAddLaw", "AL", "addlaw"
}, true, true, false, true, localeService, persistentData, ephemeralData, chunkDataAccessor, dynmapIntegrator, configService);
}, true, true, false, true, localeService, persistentData, ephemeralData, chunkDataAccessor, dynmapIntegrator, configService, playerService, messageService);
}

/**
Expand All @@ -47,14 +47,14 @@ public void execute(Player player, String[] args, String key) {

// check if they have provided any strings beyond "addlaw"
if (args.length == 0) {
new PlayerService().sendMessageType(player, translate("&c" + getText("UsageAddLaw")), "UsageAddLaw", false);
playerService.sendMessage(player, translate("&c" + getText("UsageAddLaw")), "UsageAddLaw", false);
return;
}

// add the law and send a success message.
faction.addLaw(String.join(" ", args));
new PlayerService().sendMessageType(player, "&a" + getText("LawAdded"), Objects.requireNonNull(new MessageService().getLanguage().getString("LawAdded"))
.replaceAll("#law#", String.join(" ", args)), true);
playerService.sendMessage(player, "&a" + getText("LawAdded"), Objects.requireNonNull(messageService.getLanguage().getString("LawAdded"))
.replace("#law#", String.join(" ", args)), true);
}

/**
Expand Down
34 changes: 17 additions & 17 deletions src/main/java/dansplugins/factionsystem/commands/AllyCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ public class AllyCommand extends SubCommand {
/**
* Constructor to initialise a Command.
*/
public AllyCommand(LocaleService localeService, PersistentData persistentData, EphemeralData ephemeralData, PersistentData.ChunkDataAccessor chunkDataAccessor, DynmapIntegrator dynmapIntegrator, ConfigService configService) {
public AllyCommand(LocaleService localeService, PersistentData persistentData, EphemeralData ephemeralData, PersistentData.ChunkDataAccessor chunkDataAccessor, DynmapIntegrator dynmapIntegrator, ConfigService configService, PlayerService playerService, MessageService messageService) {
super(new String[]{
"ally", LOCALE_PREFIX + "CmdAlly"
}, true, true, true, false, localeService, persistentData, ephemeralData, chunkDataAccessor, dynmapIntegrator, configService);
}, true, true, true, false, localeService, persistentData, ephemeralData, chunkDataAccessor, dynmapIntegrator, configService, playerService, messageService);
}

/**
Expand All @@ -48,7 +48,7 @@ public void execute(Player player, String[] args, String key) {
}

if (args.length == 0) {
new PlayerService().sendMessageType(player, "&c" + getText("UsageAlly"), "UsageAlly", false);
playerService.sendMessage(player, "&c" + getText("UsageAlly"), "UsageAlly", false);
return;
}

Expand All @@ -57,30 +57,30 @@ public void execute(Player player, String[] args, String key) {

// the faction needs to exist to ally
if (otherFaction == null) {
new PlayerService().sendMessageType(player, "&c" + getText("FactionNotFound"), Objects.requireNonNull(new MessageService().getLanguage().getString("FactionNotFound"))
.replaceAll("#faction#", String.join(" ", args)), true);
playerService.sendMessage(player, "&c" + getText("FactionNotFound"), Objects.requireNonNull(messageService.getLanguage().getString("FactionNotFound"))
.replace("#faction#", String.join(" ", args)), true);
return;
}

// the faction can't be itself
if (otherFaction == faction) {
new PlayerService().sendMessageType(player, "&c" + getText("CannotAllyWithSelf"), "CannotAllyWithSelf", false);
playerService.sendMessage(player, "&c" + getText("CannotAllyWithSelf"), "CannotAllyWithSelf", false);
return;
}

// no need to allow them to ally if they're already allies
if (faction.isAlly(otherFaction.getName())) {
new PlayerService().sendMessageType(player, "&c" + getText("FactionAlreadyAlly"), "FactionAlreadyAlly", false);
playerService.sendMessage(player, "&c" + getText("FactionAlreadyAlly"), "FactionAlreadyAlly", false);
return;
}

if (faction.isEnemy(otherFaction.getName())) {
new PlayerService().sendMessageType(player, "&cThat faction is currently at war with your faction.", "FactionIsEnemy", false);
playerService.sendMessage(player, "&cThat faction is currently at war with your faction.", "FactionIsEnemy", false);
return;
}

if (faction.isRequestedAlly(otherFaction.getName())) {
new PlayerService().sendMessageType(player, "&c" + getText("AlertAlreadyRequestedAlliance"), "AlertAlreadyRequestedAlliance", false);
playerService.sendMessage(player, "&c" + getText("AlertAlreadyRequestedAlliance"), "AlertAlreadyRequestedAlliance", false);
return;
}

Expand All @@ -90,17 +90,17 @@ public void execute(Player player, String[] args, String key) {
messageFaction(
faction,
translate("&a" + getText("AlertAttemptedAlliance", faction.getName(), otherFaction.getName())),
Objects.requireNonNull(new MessageService().getLanguage().getString("AlertAttemptedAlliance"))
.replaceAll("#faction_a#", faction.getName())
.replaceAll("#faction_b#", otherFaction.getName())
Objects.requireNonNull(messageService.getLanguage().getString("AlertAttemptedAlliance"))
.replace("#faction_a#", faction.getName())
.replace("#faction_b#", otherFaction.getName())
);

messageFaction(
otherFaction,
translate("&a" + getText("AlertAttemptedAlliance", faction.getName(), otherFaction.getName())),
Objects.requireNonNull(new MessageService().getLanguage().getString("AlertAttemptedAlliance"))
.replaceAll("#faction_a#", faction.getName())
.replaceAll("#faction_b#", otherFaction.getName())
Objects.requireNonNull(messageService.getLanguage().getString("AlertAttemptedAlliance"))
.replace("#faction_a#", faction.getName())
.replace("#faction_b#", otherFaction.getName())
);

// check if both factions are have requested an alliance
Expand All @@ -109,10 +109,10 @@ public void execute(Player player, String[] args, String key) {
faction.addAlly(otherFaction.getName());
otherFaction.addAlly(faction.getName());
// message player's faction
messageFaction(faction, translate("&a" + getText("AlertNowAlliedWith", otherFaction.getName())), Objects.requireNonNull(new MessageService().getLanguage().getString("AlertNowAlliedWith")).replaceAll("#faction#", otherFaction.getName()));
messageFaction(faction, translate("&a" + getText("AlertNowAlliedWith", otherFaction.getName())), Objects.requireNonNull(messageService.getLanguage().getString("AlertNowAlliedWith")).replace("#faction#", otherFaction.getName()));

// message target faction
messageFaction(otherFaction, translate("&a" + getText("AlertNowAlliedWith", faction.getName())), Objects.requireNonNull(new MessageService().getLanguage().getString("AlertNowAlliedWith")).replaceAll("#faction#", faction.getName()));
messageFaction(otherFaction, translate("&a" + getText("AlertNowAlliedWith", faction.getName())), Objects.requireNonNull(messageService.getLanguage().getString("AlertNowAlliedWith")).replace("#faction#", faction.getName()));

// remove alliance requests
faction.removeAllianceRequest(otherFaction.getName());
Expand Down
Loading

0 comments on commit e551c8d

Please sign in to comment.