Skip to content

Commit

Permalink
Added ActionUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
QuickGlare committed Mar 20, 2020
1 parent 637f4d1 commit 67e71e8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
<id>placeholderapi</id>
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>

<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -77,6 +82,13 @@
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>com.github.GiansCode</groupId>
<artifactId>ActionUtil</artifactId>
<version>a1266cbbc7</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/io/alerium/itemshops/ItemShopsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import io.alerium.itemshops.shops.ShopManager;
import io.alerium.itemshops.utils.commands.Command;
import io.alerium.itemshops.utils.configuration.YAMLConfiguration;
import io.samdev.actionutil.ActionUtil;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
Expand All @@ -27,6 +28,8 @@ public class ItemShopsPlugin extends JavaPlugin {
@Getter private CoinsManager coinsManager;
@Getter private ShopManager shopManager;

@Getter private ActionUtil actionUtil;

@Override
public void onEnable() {
long time = System.currentTimeMillis();
Expand Down Expand Up @@ -59,6 +62,8 @@ private void registerInstances() {

shopManager = new ShopManager();
shopManager.enable();

actionUtil = ActionUtil.init(this);
}

private void registerCommands() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ public BiConsumer<GUIInfo, InventoryClickEvent> getOnClick() {
}

for (String command : buyCommands) {
String commandExec = command.substring(command.indexOf("]")).replaceAll("%player%", player.getName()).replaceAll("%cost%", Integer.toString(cost));
String commandExec = command.replaceAll("%cost%", Integer.toString(cost));

if (command.startsWith("[CONSOLE]"))
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), commandExec);
else if (command.startsWith("[PLAYER]"))
Bukkit.dispatchCommand(player, commandExec);
ItemShopsPlugin.getInstance().getActionUtil().executeActions(player, commandExec);
}

if (info instanceof ShopGUI && ((ShopGUI) info).isCloseOnBuy())
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/shops/armor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ items:
column: 1
cost: 10
buy-commands:
- '[CONSOLE] kit diamond_armor %player%'
- '[PLAYER] me bought the Diamond Armor set in the /itemshop for %cost% Gold'
- '[CONSOLECOMMAND] kit diamond_armor %player_name%'
- '[PLAYERCOMMAND] me bought the Diamond Armor set in the /itemshop for %cost% Gold'

0 comments on commit 67e71e8

Please sign in to comment.