Skip to content

Commit

Permalink
* Added the "getMaxStock" method to the Manager interface. This new m…
Browse files Browse the repository at this point in the history
…ethod takes a shop object and uses admin bypasses alongside owner permissions to determine the shop's maximum stock.

* Added the "isPrismaInstalled" method to the DisplayShopsAPI interface to allow a simple way for developers to check if needed.
* Added some new clean-up task id methods to the DisplayShopsAPI interface.
* The DataPack interface has had its ChatInteractionId methods swapped to ChatInteractionType and returns an enumeration value instead of a String. In addition to this, all references to these methods were changed as well. Based on timings and micro-optimization, this increases performance by 7% in terms of chat interaction due to loops that were used to evaluate each string.

Signed-off-by: BuildTools <[email protected]>
  • Loading branch information
BuildTools committed Jul 12, 2020
1 parent c8115ec commit 529785b
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 20 deletions.
2 changes: 1 addition & 1 deletion API Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
## API-VERSION 1.0.7 ##
## API-VERSION 1.0.9 ##
6 changes: 2 additions & 4 deletions DisplayShopsAPI.iml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@
<orderEntry type="module-library" scope="PROVIDED">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../../Dependencies/Server Jars/1.16.1.jar!/" />
<root url="jar://$MODULE_DIR$/../../../Dependencies/Server Jars/1.16.1 - Paper.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../../Dependencies/Server Jars/1.16.1.jar!/" />
</SOURCES>
<SOURCES />
</library>
</orderEntry>
</component>
Expand Down
10 changes: 10 additions & 0 deletions src/xzot1k/plugins/ds/DisplayShops.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ public void setInSightTask(int inSightTask) {

}

@Override
public int getCleanupTask() {
return 0;
}

@Override
public void setCleanupTask(int cleanupTask) {

}

@Override
public List<UUID> getTeleportingPlayers() {
return null;
Expand Down
4 changes: 4 additions & 0 deletions src/xzot1k/plugins/ds/DisplayShopsAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ interface DisplayShopsAPI {

void setInSightTask(int inSightTask);

int getCleanupTask();

void setCleanupTask(int cleanupTask);

List<UUID> getTeleportingPlayers();

HashMap<UUID, UUID> getShopMemory();
Expand Down
8 changes: 8 additions & 0 deletions src/xzot1k/plugins/ds/api/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ public interface Manager {
*/
boolean exceededShopLimit(Player player);

/**
* Obtains the passed shop's max stock based on owner permissions or administrator bypasses.
*
* @param shop The shop to get the max stock for (obtains owner for permissions, returns max possible integer if the shop is admin or the owner has the "displayshops.stock.max").
* @return The obtained max stock (defaults to configuration value or max possible integer, if the shop is admin).
*/
int getMaxStock(Shop shop);

/**
* Gets the player specific shop promotion item modifier.
*
Expand Down
21 changes: 12 additions & 9 deletions src/xzot1k/plugins/ds/api/enums/ChatInteractionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@
package xzot1k.plugins.ds.api.enums;

public enum ChatInteractionType {
SHOP_ITEM_AMOUNT("change-item-amount"), BUY_LIMIT("buy-limit"), SELL_LIMIT("sell-limit"), BUY_PRICE("change-buy-price"),
SELL_PRICE("change-sell-price"), WITHDRAW_STOCK("withdraw-stock"), DEPOSIT_STOCK("deposit-stock"), EDIT_DESCRIPTION("edit-description"),
DEPOSIT_BALANCE("deposit-balance"), WITHDRAW_BALANCE("withdraw-balance"), ASSISTANTS_ADD("assistants-add"), ASSISTANTS_REMOVE("assistants-add");
SHOP_ITEM_AMOUNT(true), BUY_LIMIT(true), SELL_LIMIT(true), BUY_PRICE(true),
SELL_PRICE(true), WITHDRAW_STOCK(true), DEPOSIT_STOCK(true), EDIT_DESCRIPTION(false),
DEPOSIT_BALANCE(true), WITHDRAW_BALANCE(true), ASSISTANTS_ADD(false), ASSISTANTS_REMOVE(false);

String interactionId;
boolean numericalEntry;

ChatInteractionType(String interactionId) {
this.interactionId = interactionId;
ChatInteractionType(boolean numericalEntry) {
this.numericalEntry = numericalEntry;
}

public String getInteractionId() {
return interactionId;
}
/**
* Checks if the chat interaction type requires a numerical entry or not.
*
* @return whether a numerical entry is required.
*/
public boolean isNumericalEntry() { return numericalEntry; }
}
13 changes: 7 additions & 6 deletions src/xzot1k/plugins/ds/api/objects/DataPack.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import xzot1k.plugins.ds.api.enums.ChatInteractionType;

import java.util.HashMap;

Expand Down Expand Up @@ -85,19 +86,19 @@ public interface DataPack {
void setSelectedShop(Shop selectedShop);

/**
* Gets the current chat interaction identification key in-progress. This is what is used to define what
* Gets the current chat interaction type in-progress. This is what is used to define what
* the player's entry is being used for.
*
* @return The chat interaction identification key. (Returns NULL if no chat interaction is active)
* @return The chat interaction type. (Returns NULL if no chat interaction is active)
*/
String getChatInteractionKey();
ChatInteractionType getChatInteractionType();

/**
* Sets the chat interaction identification key.
* Sets the chat interaction identification type.
*
* @param chatInteractionKey The key to set as. (Use names 'getInteractionId()' from the 'ChatInteractionType' enumeration)
* @param chatInteractionType The type to set as.
*/
void setChatInteractionKey(String chatInteractionKey);
void setChatInteractionType(ChatInteractionType chatInteractionType);

/**
* Obtains the selected region of a player, if there is one.
Expand Down

0 comments on commit 529785b

Please sign in to comment.