-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
0 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
40 changes: 40 additions & 0 deletions
40
src/main/java/dev/csutter/race/commands/RenameCommand.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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package dev.csutter.race.commands; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
import dev.csutter.race.models.Course; | ||
import dev.csutter.race.utils.CourseUtils; | ||
|
||
public class RenameCommand implements CommandExecutor { | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
|
||
if (!(sender instanceof Player)) { | ||
sender.sendMessage("You must be a player to use this command"); | ||
return true; | ||
} | ||
|
||
if (args.length != 2) return false; | ||
|
||
Course course = CourseUtils.getCourse(args[0]); | ||
if (course == null) { | ||
sender.sendMessage("Couldn't find the course you were looking for"); | ||
return false; | ||
} | ||
|
||
if (!CourseUtils.checkIfOwner(course, (Player) sender)) { | ||
sender.sendMessage("You must be the player who created the track"); | ||
return false; | ||
} | ||
|
||
CourseUtils.renameCourse(course, args[1]); | ||
sender.sendMessage("Course has been successfully renamed"); | ||
|
||
|
||
return true; | ||
} | ||
} |
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