2016-03-02 19:28:01 +00:00
package me.totalfreedom.totalfreedommod.command ;
2011-10-19 00:37:00 +00:00
2016-03-06 15:56:15 +00:00
import me.totalfreedom.totalfreedommod.rank.Rank ;
2015-10-19 17:43:46 +00:00
import me.totalfreedom.totalfreedommod.util.FUtil ;
2011-10-19 00:37:00 +00:00
import org.bukkit.GameMode ;
import org.bukkit.command.Command ;
import org.bukkit.command.CommandSender ;
import org.bukkit.entity.Player ;
2016-03-06 15:56:15 +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 creative, define someone's username to change theirs, or change everyone's gamemode on the server. " , usage = " /<command> <-a | [partialname]> " , aliases = " gmc " )
2015-10-19 17:43:46 +00:00
public class Command_creative extends FreedomCommand
2011-10-19 00:37:00 +00:00
{
2015-11-22 18:26:47 +00:00
2011-10-19 00:37:00 +00:00
@Override
2015-11-22 18:26:47 +00:00
public boolean run ( CommandSender sender , Player playerSender , Command cmd , String commandLabel , String [ ] args , boolean senderIsConsole )
2011-10-19 00:37:00 +00:00
{
2016-05-12 19:40:39 +00:00
if ( args . length = = 0 )
2011-10-19 00:37:00 +00:00
{
2016-05-12 19:40:39 +00:00
if ( isConsole ( ) )
2011-10-19 00:37:00 +00:00
{
2016-05-12 19:40:39 +00:00
sender . sendMessage ( " When used from the console, you must define a target player. " ) ;
2011-10-19 00:37:00 +00:00
return true ;
}
2011-10-19 02:52:32 +00:00
2016-05-12 19:40:39 +00:00
playerSender . setGameMode ( GameMode . CREATIVE ) ;
2020-03-30 23:43:57 +00:00
msg ( " Your gamemode has been set to creative. " ) ;
2016-05-12 19:40:39 +00:00
return true ;
2011-10-19 00:37:00 +00:00
}
2013-06-10 06:24:53 +00:00
2020-09-28 03:17:01 +00:00
checkRank ( Rank . ADMIN ) ;
2013-06-10 06:24:53 +00:00
2016-05-12 19:40:39 +00:00
if ( args [ 0 ] . equals ( " -a " ) )
{
for ( Player targetPlayer : server . getOnlinePlayers ( ) )
2011-10-19 00:37:00 +00:00
{
2016-05-12 19:40:39 +00:00
targetPlayer . setGameMode ( GameMode . CREATIVE ) ;
2011-10-19 00:37:00 +00:00
}
2013-06-10 06:24:53 +00:00
2020-08-15 22:42:46 +00:00
FUtil . staffAction ( sender . getName ( ) , " Changing everyone's gamemode to creative " , false ) ;
2020-03-30 23:43:57 +00:00
msg ( " Your gamemode has been set to creative. " ) ;
2016-05-12 19:40:39 +00:00
return true ;
}
2014-04-26 11:55:24 +00:00
2016-05-12 19:40:39 +00:00
Player player = getPlayer ( args [ 0 ] ) ;
2013-07-02 18:31:22 +00:00
2016-05-12 19:40:39 +00:00
if ( player = = null )
{
sender . sendMessage ( FreedomCommand . PLAYER_NOT_FOUND ) ;
return true ;
2011-10-19 00:37:00 +00:00
}
2016-05-12 19:40:39 +00:00
msg ( " Setting " + player . getName ( ) + " to game mode creative " ) ;
msg ( player , sender . getName ( ) + " set your game mode to creative " ) ;
2013-08-14 14:01:42 +00:00
player . setGameMode ( GameMode . CREATIVE ) ;
2011-10-19 00:37:00 +00:00
return true ;
}
}