-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from teakivy/Transition-To-Adventure-API
Transition to adventure api
- Loading branch information
Showing
88 changed files
with
2,557 additions
and
3,271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 12 additions & 25 deletions
37
src/main/java/me/teakivy/teakstweaks/commands/BackCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,34 @@ | ||
package me.teakivy.teakstweaks.commands; | ||
|
||
import me.teakivy.teakstweaks.TeaksTweaks; | ||
import me.teakivy.teakstweaks.packs.teleportation.back.Back; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import me.teakivy.teakstweaks.utils.command.AbstractCommand; | ||
import me.teakivy.teakstweaks.utils.command.CommandType; | ||
import me.teakivy.teakstweaks.utils.command.PlayerCommandEvent; | ||
import org.bukkit.entity.Player; | ||
|
||
public class BackCommand extends AbstractCommand { | ||
|
||
public BackCommand() { | ||
super("back", "back", "/back", CommandType.PLAYER_ONLY); | ||
super(CommandType.PLAYER_ONLY, "back", "back"); | ||
|
||
setCooldownTime(getConfig().getInt("packs.back.teleport-cooldown")); | ||
setCooldownTime(getPackConfig().getInt("teleport-cooldown")); | ||
} | ||
|
||
@Override | ||
public void playerCommand(Player player, String[] args) { | ||
if (isOnCooldown(player)) { | ||
player.sendMessage(getError("on_cooldown").replace("%cooldown_seconds%", getCooldownTime() + "")); | ||
public void playerCommand(PlayerCommandEvent event) { | ||
Player player = event.getPlayer(); | ||
if (isOnCooldown()) { | ||
sendError("on_cooldown", insert("cooldown_seconds", getCooldownTime())); | ||
return; | ||
} | ||
|
||
if (!Back.backLoc.containsKey(player.getUniqueId())) { | ||
player.sendMessage(getError("no_back_location")); | ||
return; | ||
} | ||
|
||
setCooldown(player); | ||
player.sendMessage(getString("teleporting")); | ||
|
||
if (getConfig().getInt("packs.back.teleport-delay") > 0) { | ||
Location loc = player.getLocation(); | ||
Bukkit.getScheduler().scheduleSyncDelayedTask(TeaksTweaks.getInstance(), () -> { | ||
if (!player.getLocation().equals(loc)) { | ||
player.sendMessage(getError("moved")); | ||
return; | ||
} | ||
Back.tpBack(player); | ||
}, getConfig().getInt("packs.back.teleport-delay") * 20L); | ||
|
||
sendError("no_back_location"); | ||
return; | ||
} | ||
|
||
setCooldown(); | ||
Back.tpBack(player); | ||
sendMessage("teleporting"); | ||
} | ||
} |
Oops, something went wrong.