Skip to content

Commit

Permalink
feat: upgrade shop prefab
Browse files Browse the repository at this point in the history
  • Loading branch information
Misat11 committed Aug 24, 2024
1 parent 6e1c5b2 commit aad855d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.screamingsandals.lib.sender.CommandSender;
import org.screamingsandals.lib.utils.annotations.Service;
import org.screamingsandals.lib.utils.annotations.ServiceDependencies;
import org.screamingsandals.lib.utils.annotations.methods.OnDisable;
import org.screamingsandals.lib.utils.annotations.methods.Provider;

import java.util.HashMap;
Expand Down Expand Up @@ -82,4 +83,9 @@ protected void construct(Command.Builder<CommandSender> commandSenderWrapperBuil
)
);
}

@OnDisable
public void onDisable() {
gc.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void construct(CommandManager<CommandSender> manager, Command.Builder<Com
return;
}

prefab.place(sender.as(Player.class));
prefab.place(game, sender.as(Player.class));
}))
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import org.jetbrains.annotations.NotNull;
import org.screamingsandals.bedwars.api.game.Game;
import org.screamingsandals.lib.player.Player;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.ConfigurationNode;
Expand All @@ -39,11 +40,12 @@ public class CommandPrefab implements Prefab {
private @NotNull List<@NotNull String> commands;

@Override
public void place(Player player) {
public void place(@NotNull Game game, @NotNull Player player) {
commands.forEach(s -> {
if (s.startsWith("/")) {
s = s.substring(1);
}
s = s.replace("%game%", game.getName());

player.tryToDispatchCommand(s);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
package org.screamingsandals.bedwars.variants.prefab;

import org.jetbrains.annotations.NotNull;
import org.screamingsandals.bedwars.api.game.Game;
import org.screamingsandals.lib.player.Player;
import org.spongepowered.configurate.ConfigurateException;
import org.spongepowered.configurate.ConfigurationNode;

public interface Prefab {
void place(Player player);
void place(@NotNull Game game, @NotNull Player player);

interface Loader<T extends Prefab> {
@NotNull Prefab load(@NotNull ConfigurationNode node) throws ConfigurateException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,11 @@ custom-spawner-types:
color: GOLD
name: Gold

# TODO: prefabs (already done shops with skin, shop file etc.)
# TODO: prefabs (already done shops with skin, shop file etc.)
prefabs:
# Usage: /bw admin <arena> prefab upgradeShop
upgradeShop:
type: command
commands:
- /bw admin %game% store add
- /bw admin %game% store file set certain-popular-server/upgradeShop.yml

0 comments on commit aad855d

Please sign in to comment.