Search in sources :

Example 1 with CommandHook

use of redempt.redlib.commandmanager.CommandHook in project PrivateMinesOOP by UntouchedOdin0.

the class PrivateMinesCommand method expand.

// Add 1 to whatever args you put so if you want to expand by one do /pmine expand 2
@CommandHook("expand")
public void expand(CommandSender commandSender, Player target, int amount) {
    Player player = (Player) commandSender;
    String targetDoesNotOwnMine = Messages.msg("targetDoesNotOwnMine");
    if (!mineStorage.hasMine(target.getUniqueId())) {
        utils.sendMessage(commandSender, targetDoesNotOwnMine);
        return;
    }
    Mine mine = mineStorage.getMine(target.getUniqueId());
    mine.expand(amount);
    mineStorage.replaceMine(player.getUniqueId(), mine);
}
Also used : Player(org.bukkit.entity.Player) Mine(me.untouchedodin0.plugin.mines.Mine) CommandHook(redempt.redlib.commandmanager.CommandHook)

Example 2 with CommandHook

use of redempt.redlib.commandmanager.CommandHook in project PrivateMinesOOP by UntouchedOdin0.

the class PrivateMinesCommand method unban.

@CommandHook("unban")
public void unban(Player player, Player target) {
    Mine mine;
    MineData mineData;
    UUID uuid = player.getUniqueId();
    UUID targetUUID = target.getUniqueId();
    String doNotOwnMine = Messages.msg("doNotOwnMine");
    String youHaveBeenUnbanned = Messages.msg("youHaveBeenUnbanned");
    String youHaveUnbannedPlayer = Messages.msg("youHaveUnbanned");
    String replacedYouHaveBeenUnbanned = youHaveBeenUnbanned.replace("%name%", player.getName());
    String replacedYouHaveUnbannedPlayer = youHaveUnbannedPlayer.replace("%name%", target.getName());
    if (!privateMines.getMineStorage().hasMine(uuid)) {
        player.sendMessage(doNotOwnMine);
    }
    mine = privateMines.getMineStorage().getMine(uuid);
    mineData = mine.getMineData();
    mineData.addBannedPlayer(targetUUID);
    mine.setMineData(mineData);
    privateMines.getMineStorage().replaceMine(uuid, mine);
    player.sendMessage(replacedYouHaveBeenUnbanned);
    target.sendMessage(replacedYouHaveUnbannedPlayer);
}
Also used : MineData(me.untouchedodin0.plugin.mines.data.MineData) Mine(me.untouchedodin0.plugin.mines.Mine) CommandHook(redempt.redlib.commandmanager.CommandHook)

Example 3 with CommandHook

use of redempt.redlib.commandmanager.CommandHook in project PrivateMinesOOP by UntouchedOdin0.

the class PrivateMinesCommand method upgrade.

@CommandHook("upgrade")
public void upgrade(CommandSender commandSender, Player target) {
    String targetDoesNotOwnMine = Messages.msg("targetDoesNotOwnMine");
    if (!mineStorage.hasMine(target.getUniqueId())) {
        utils.sendMessage(commandSender, targetDoesNotOwnMine);
        return;
    }
    Mine mine = mineStorage.getMine(target.getUniqueId());
    try {
        mine.upgrade();
    } catch (MineAlreadyMaxedException e) {
        e.printStackTrace();
    }
}
Also used : MineAlreadyMaxedException(me.untouchedodin0.plugin.util.exceptions.MineAlreadyMaxedException) Mine(me.untouchedodin0.plugin.mines.Mine) CommandHook(redempt.redlib.commandmanager.CommandHook)

Example 4 with CommandHook

use of redempt.redlib.commandmanager.CommandHook in project PrivateMinesOOP by UntouchedOdin0.

the class PrivateMinesCommand method close.

@CommandHook("close")
public void close(Player player) {
    Mine mine;
    MineData mineData;
    UUID uuid = player.getUniqueId();
    String doNotOwnMine = Messages.msg("doNotOwnMine");
    String mineAlreadyClosed = Messages.msg("mineAlreadyClosed");
    String mineClosed = Messages.msg("mineClosed");
    if (!mineStorage.hasMine(uuid)) {
        utils.sendMessage(player, doNotOwnMine);
        return;
    }
    mine = mineStorage.getMine(player.getUniqueId());
    mineData = mine.getMineData();
    boolean isOpen = mineData.isOpen();
    if (!isOpen) {
        player.sendMessage(mineAlreadyClosed);
    } else {
        mineData.setOpen(false);
        mine.setMineData(mineData);
        privateMines.getMineStorage().replaceMine(uuid, mine);
        player.sendMessage(mineClosed);
    }
}
Also used : MineData(me.untouchedodin0.plugin.mines.data.MineData) Mine(me.untouchedodin0.plugin.mines.Mine) CommandHook(redempt.redlib.commandmanager.CommandHook)

Example 5 with CommandHook

use of redempt.redlib.commandmanager.CommandHook in project PrivateMinesOOP by UntouchedOdin0.

the class PrivateMinesCommand method setType.

@CommandHook("settype")
public void setType(CommandSender commandSender, Player target, String type) {
    String invalidMineType = Messages.msg("invalidMineType");
    if (!mineStorage.hasMine(target.getUniqueId())) {
        utils.sendMessage(commandSender, Utils.sendColorMessage(invalidMineType));
        return;
    }
    UUID uuid = target.getUniqueId();
    Mine mine = mineStorage.getMine(target.getUniqueId());
    MineData mineData = mine.getMineData();
    MineType newType = privateMines.getMineTypeManager().getMineType(type);
    if (newType == null) {
        commandSender.sendMessage(Utils.colorStatic(invalidMineType));
        return;
    }
    mine.cancelResetTask();
    mineData.setMineType(type);
    mine.setMineType(newType);
    mine.setMineData(mineData);
    utils.saveMineData(uuid, mineData);
    mine.reset();
    mine.startResetTask();
    mineStorage.replaceMine(target.getUniqueId(), mine);
    mine.teleport(target);
}
Also used : MineData(me.untouchedodin0.plugin.mines.data.MineData) Mine(me.untouchedodin0.plugin.mines.Mine) MineType(me.untouchedodin0.plugin.mines.MineType) CommandHook(redempt.redlib.commandmanager.CommandHook)

Aggregations

CommandHook (redempt.redlib.commandmanager.CommandHook)30 Mine (me.untouchedodin0.plugin.mines.Mine)19 MineData (me.untouchedodin0.plugin.mines.data.MineData)13 MineType (me.untouchedodin0.plugin.mines.MineType)4 SampleMethod (redempt.redlib.dev.profiler.SampleSummary.SampleMethod)4 Player (org.bukkit.entity.Player)3 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Location (org.bukkit.Location)2 InventoryGUI (redempt.redlib.inventorygui.InventoryGUI)2 ItemButton (redempt.redlib.inventorygui.ItemButton)2 ItemBuilder (redempt.redlib.itemutils.ItemBuilder)2 MultiBlockStructure (redempt.redlib.multiblock.MultiBlockStructure)2 PrivateMineCreationEvent (me.untouchedodin0.plugin.events.PrivateMineCreationEvent)1 PlayerBorder (me.untouchedodin0.plugin.util.border.PlayerBorder)1 MineAlreadyMaxedException (me.untouchedodin0.plugin.util.exceptions.MineAlreadyMaxedException)1 PublicMinesGUI (me.untouchedodin0.plugin.util.inventory.PublicMinesGUI)1 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)1 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)1