2017-05-22 18:13:59 +00:00
package me.totalfreedom.totalfreedommod.command ;
import me.totalfreedom.totalfreedommod.rank.Rank ;
import me.totalfreedom.totalfreedommod.util.FUtil ;
import org.bukkit.GameMode ;
import org.bukkit.command.Command ;
import org.bukkit.command.CommandSender ;
import org.bukkit.entity.Player ;
2019-01-12 03:05:12 +00:00
@CommandPermissions ( level = Rank . OP , source = SourceType . BOTH )
2020-03-30 23:43:57 +00:00
@CommandParameters ( description = " Quickly change your own gamemode to adventure, define someone's username to change theirs, or change everyone's gamemode on the server. " , usage = " /<command> <[partialname] | -a> " , aliases = " gma " )
2017-05-22 18:13:59 +00:00
public class Command_adventure extends FreedomCommand
{
@Override
public boolean run ( CommandSender sender , Player playerSender , Command cmd , String commandLabel , String [ ] args , boolean senderIsConsole )
{
if ( args . length = = 0 )
{
if ( isConsole ( ) )
{
sender . sendMessage ( " When used from the console, you must define a target player. " ) ;
return true ;
}
playerSender . setGameMode ( GameMode . ADVENTURE ) ;
2020-03-30 23:43:57 +00:00
msg ( " Your gamemode has been set to adventure. " ) ;
2017-05-22 18:13:59 +00:00
return true ;
}
2020-08-15 22:42:46 +00:00
checkRank ( Rank . TRIAL_MOD ) ;
2019-01-12 03:05:12 +00:00
2017-05-22 18:13:59 +00:00
if ( args [ 0 ] . equals ( " -a " ) )
{
for ( Player targetPlayer : server . getOnlinePlayers ( ) )
{
targetPlayer . setGameMode ( GameMode . ADVENTURE ) ;
}
2020-08-15 22:42:46 +00:00
FUtil . staffAction ( sender . getName ( ) , " Changing everyone's gamemode to adventure " , false ) ;
2020-03-30 23:43:57 +00:00
msg ( " Your gamemode has been set to adventure. " ) ;
2017-05-22 18:13:59 +00:00
return true ;
}
Player player = getPlayer ( args [ 0 ] ) ;
if ( player = = null )
{
sender . sendMessage ( FreedomCommand . PLAYER_NOT_FOUND ) ;
return true ;
}
2019-01-12 03:05:12 +00:00
msg ( " Setting " + player . getName ( ) + " to game mode adventure. " ) ;
msg ( player , sender . getName ( ) + " set your game mode to adventure. " ) ;
2017-05-22 18:13:59 +00:00
player . setGameMode ( GameMode . ADVENTURE ) ;
return true ;
}
}