Skip to content

Commit

Permalink
Merge pull request #16 from Chickenpowerrr/develop
Browse files Browse the repository at this point in the history
1.4.0 Update
  • Loading branch information
Chickenpowerrr authored Jan 2, 2020
2 parents 51d39dd + a7dc3e0 commit e627d55
Show file tree
Hide file tree
Showing 41 changed files with 1,222 additions and 346 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ranksync</artifactId>
<groupId>com.gmail.chickenpowerrr</groupId>
<version>1.3.3</version>
<version>1.4.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.gmail.chickenpowerrr.ranksync.api.bot;

import com.gmail.chickenpowerrr.languagehelper.LanguageHelper;
import com.gmail.chickenpowerrr.ranksync.api.name.NameResource;
import com.gmail.chickenpowerrr.ranksync.api.player.PlayerFactory;
import com.gmail.chickenpowerrr.ranksync.api.command.CommandFactory;
import com.gmail.chickenpowerrr.ranksync.api.data.Database;
import com.gmail.chickenpowerrr.ranksync.api.data.DatabaseFactory;
import com.gmail.chickenpowerrr.ranksync.api.name.NameResource;
import com.gmail.chickenpowerrr.ranksync.api.player.PlayerFactory;
import com.gmail.chickenpowerrr.ranksync.api.rank.RankFactory;
import java.util.Collection;

Expand Down Expand Up @@ -99,4 +99,25 @@ public interface Bot<P, R> {
* Returns if the program should synchronize the usernames
*/
boolean doesUpdateNames();

/**
* Returns the format for in which an username should be updated
* if name sync has been enabled
*
* @return the format for in which an username should be updated
* if name sync has been enabled
*/
String getNameSyncFormat();

/**
* Returns the time in seconds a message sent to a public channel should stay there before
* it needs to be deleted, -1 will make sure the message doesn't get deleted
*/
int getDeleteTimer();

/**
* Returns the interval between times in which all users should be checked if their rank
* is still correct, should be greater than 0 if you want to use this feature
*/
int getUpdateInterval();
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.gmail.chickenpowerrr.ranksync.api.data;

import com.gmail.chickenpowerrr.ranksync.api.player.Player;
import com.gmail.chickenpowerrr.ranksync.api.rank.Rank;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

Expand All @@ -15,13 +17,13 @@
public interface Database {

/**
* Returns the id that represents a player on the other service by their id on this service
* Returns the Player that represents the link between the two platforms
*
* @param playerId the id that represents the player on this service
* @return a CompletableFuture that will be completed whenever the id of the other service has
* been found
* @param constructor the player constructor based on the retrieved data
* @return a CompletableFuture that will be completed whenever the link has been found
*/
CompletableFuture<UUID> getUuid(String playerId);
CompletableFuture<Player> getPlayer(String playerId, PlayerConstructor<Player> constructor);

/**
* Sets the id that represents a player on the other service by their id on this service
Expand All @@ -34,13 +36,13 @@ public interface Database {
CompletableFuture<Void> setUuid(String playerId, UUID uuid);

/**
* Returns the id that represents a player on this service by their id on the other service
* Returns the Player that represents the link between the two platforms
*
* @param uuid the id that represents the player on the other service
* @return a CompletableFuture that will be completed whenever the id of this service has been
* found
* @param constructor the player constructor based on the retrieved data
* @return a CompletableFuture that will be completed whenever the link has been found
*/
CompletableFuture<String> getPlayerId(UUID uuid);
CompletableFuture<Player> getPlayer(UUID uuid, PlayerConstructor<Player> constructor);

/**
* Returns the ranks based on the id that represents the player on the other service
Expand All @@ -49,7 +51,7 @@ public interface Database {
* @return a CompletableFuture that will be completed whenever the ranks of this service has been
* found
*/
CompletableFuture<Collection<Rank>> getRanks(UUID uuid);
CompletableFuture<List<Rank>> getRanks(UUID uuid);

/**
* Returns the if a rank with the given name exists
Expand All @@ -69,4 +71,14 @@ public interface Database {
* Returns if the ranks are case sensitive when they are requested by their name
*/
boolean hasCaseSensitiveRanks();

/**
* This functional interface makes sure a database can turn data into a player
*
* @param <P> the player type that should be returned
*/
@FunctionalInterface
interface PlayerConstructor<P extends Player> {
P apply(UUID uuid, String identifier, int timesSynced, int timesUnsynced);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.gmail.chickenpowerrr.ranksync.api.link;

import com.gmail.chickenpowerrr.ranksync.api.bot.Bot;
import java.util.List;

/**
* This interface contains all the requirements for a link
*
* @author Chickenpowerrr
* @since 1.4.0
*/
public interface Link {

/**
* Returns all Minecraft ranks involved in this link
*/
List<String> getMinecraftRanks();

/**
* Returns all platform ranks involved in this link
*/
List<String> getPlatformRanks();

/**
* Returns the format used for this link
*/
String getNameFormat();

/**
* Returns the bot which has to sync the rank
*/
Bot<?, ?> getBot();
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.gmail.chickenpowerrr.ranksync.api.bot.Bot;
import com.gmail.chickenpowerrr.ranksync.api.rank.Rank;
import java.util.Collection;
import java.util.List;
import java.util.UUID;

/**
Expand All @@ -24,7 +25,7 @@ public interface Player {
*
* @param ranks the ranks the Player should have
*/
void setRanks(Collection<Rank> ranks);
void setRanks(List<Rank> ranks);

/**
* Returns the id that represents the Player on the other service
Expand All @@ -45,8 +46,9 @@ public interface Player {
* Sends a private message to the Player on this service
*
* @param message the message the Player should receive
* @return true if the message has been send successfully, otherwise false
*/
void sendPrivateMessage(String message);
boolean sendPrivateMessage(String message);

/**
* Returns the name the Player wants to hear when you're talking to it
Expand Down Expand Up @@ -76,4 +78,16 @@ public interface Player {
* @param username the new username
*/
void setUsername(String username);

/**
* Returns how many times an user synced their account
*/
int getTimesSynced();

/**
* Returns how many times an user unsynced their account
*/
default int getTimesUnsynced() {
return getTimesSynced() - (getUuid() != null ? 1 : 0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.gmail.chickenpowerrr.ranksync.api.bot.Bot;
import java.util.Collection;
import java.util.List;

/**
* This interface manages all of the data that a Developer will probably need to synchronize the
Expand All @@ -27,7 +28,7 @@ public interface RankFactory<R> {
* @param internalRoles the Rank objects used by the platform API, not the RankSync API
* @return the RankSync representations of the Roles
*/
Collection<Rank> getRanksFromRoles(Collection<R> internalRoles);
List<Rank> getRanksFromRoles(Collection<R> internalRoles);

/**
* Returns the internally used role by its name
Expand All @@ -43,7 +44,7 @@ public interface RankFactory<R> {
* @param strings the names of the roles
* @return the Rank objects used by the platform API, not the RankSync API
*/
Collection<R> getRolesFromNames(Collection<String> strings);
List<R> getRolesFromNames(Collection<String> strings);

/**
* Turns the role supported by the RankSync API back into the role that is internally used by the
Expand All @@ -61,7 +62,7 @@ public interface RankFactory<R> {
* @param ranks the ranks that can by used by the RankSync API
* @return the internally used roles
*/
Collection<R> getRolesFromRanks(Collection<Rank> ranks);
List<R> getRolesFromRanks(Collection<Rank> ranks);

/**
* Returns the Bot that uses this factory
Expand Down Expand Up @@ -95,4 +96,14 @@ public interface RankFactory<R> {
* Returns if the helper should give warnings when the bot doesn't have high enough permissions
*/
boolean shouldThrowPermissionWarnings();

/**
* Returns the format for the Rank in which an username should be updated
* if name sync has been enabled
*
* @param rank the rank which format should be returned
* @return the format for the Rank in which an username should be updated
* if name sync has been enabled
*/
String getNameSyncFormat(Rank rank);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gmail.chickenpowerrr.ranksync.api.rank;

import com.gmail.chickenpowerrr.ranksync.api.bot.Bot;
import com.gmail.chickenpowerrr.ranksync.api.link.Link;
import java.util.Collection;

/**
Expand Down Expand Up @@ -43,4 +44,9 @@ public interface RankHelper {
* be send to the console
*/
void validateRanks();

/**
* Returns all links
*/
Collection<Link> getLinks();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.gmail.chickenpowerrr.ranksync.api.bot.Bot;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

Expand All @@ -19,7 +20,7 @@ public interface RankResource {
* @param uuid the UUID that represents the Player
* @return a {@code CompletableFuture} that will be completed whenever the ranks have been found
*/
CompletableFuture<Collection<Rank>> getRanks(UUID uuid);
CompletableFuture<List<Rank>> getRanks(UUID uuid);

/**
* Sets the {@code Bot} that uses this Resource
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.gmail.chickenpowerrr.ranksync.api.reward;

import com.gmail.chickenpowerrr.ranksync.api.player.Player;

/**
* This interface contains the settings for a reward system
*
* @author Chickenpowerrr
* @since 1.4.0
*/
public interface RewardSettings {

/**
* Returns the settings for what should happen on a sync
*/
RewardAction getSyncAction();

/**
* Returns the settings for what should happen on an unsync
*/
RewardAction getUnsyncAction();

/**
* This interface contains all settings for a reward action
*
* @author Chickenpowerrr
* @since 1.4.0
*/
interface RewardAction {

/**
* Returns the maximum times a user can receive the action commands can be executed for the
* given player, -1 if it should be executed every time
*/
int getMax();

/**
* Returns if the action commands should be executed
*/
boolean isEnabled();

/**
* Returns the commands that should be executed when someone syncs their account, %player%
* is the placeholder for the player who synced their account
*/
void executeCommands(Player player);
}
}
9 changes: 1 addition & 8 deletions bungee/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<artifactId>ranksync</artifactId>
<groupId>com.gmail.chickenpowerrr</groupId>
<version>1.3.3</version>
<version>1.4.0</version>
</parent>

<groupId>com.gmail.chickenpowerrr.ranksync</groupId>
Expand Down Expand Up @@ -82,13 +82,6 @@
<version>1.5</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>me.lucko.luckperms</groupId>
<artifactId>luckperms-api</artifactId>
<version>4.4</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Loading

0 comments on commit e627d55

Please sign in to comment.