2018-06-07 00:23:26 +02:00
/ *
2020-02-07 01:02:15 +01:00
* Copyright ( C ) 2020 GeorgH93
2018-06-07 00:23:26 +02:00
*
* This program is free software : you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation , either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
2023-06-15 20:07:38 +02:00
* along with this program . If not , see < https : //www.gnu.org/licenses/>.
2018-06-07 00:23:26 +02:00
* /
package at.pcgamingfreaks.Minepacks.Bukkit.Command ;
2020-07-27 17:45:18 +02:00
import at.pcgamingfreaks.Bukkit.MCVersion ;
2018-06-07 00:23:26 +02:00
import at.pcgamingfreaks.Bukkit.Message.Message ;
import at.pcgamingfreaks.Minepacks.Bukkit.API.MinepacksCommand ;
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks ;
2020-02-07 01:02:15 +01:00
import at.pcgamingfreaks.Minepacks.Bukkit.Permissions ;
2023-01-26 19:35:21 +01:00
import at.pcgamingfreaks.Minepacks.MagicValues ;
2020-07-27 17:45:18 +02:00
import org.bukkit.ChatColor ;
2018-06-07 00:23:26 +02:00
import org.bukkit.command.CommandSender ;
import org.jetbrains.annotations.NotNull ;
import java.util.List ;
public class UpdateCommand extends MinepacksCommand
{
private final Message messageCheckingForUpdates , messageUpdated , messageNoUpdate , messageUpdateFail , messageUpdateAvailable ;
public UpdateCommand ( Minepacks plugin )
{
2020-02-07 01:02:15 +01:00
super ( plugin , " update " , plugin . getLanguage ( ) . getTranslated ( " Commands.Description.Update " ) , Permissions . UPDATE , plugin . getLanguage ( ) . getCommandAliases ( " Update " ) ) ;
2018-06-07 00:23:26 +02:00
messageCheckingForUpdates = plugin . getLanguage ( ) . getMessage ( " Ingame.Update.CheckingForUpdates " ) ;
messageUpdated = plugin . getLanguage ( ) . getMessage ( " Ingame.Update.Updated " ) ;
messageNoUpdate = plugin . getLanguage ( ) . getMessage ( " Ingame.Update.NoUpdate " ) ;
messageUpdateFail = plugin . getLanguage ( ) . getMessage ( " Ingame.Update.UpdateFail " ) ;
messageUpdateAvailable = plugin . getLanguage ( ) . getMessage ( " Ingame.Update.UpdateAvailable " ) ;
}
@Override
2020-07-27 17:45:18 +02:00
public void execute ( @NotNull final CommandSender sender , final @NotNull String mainCommandAlias , final @NotNull String alias , final @NotNull String [ ] args )
2018-06-07 00:23:26 +02:00
{
2023-01-26 19:35:21 +01:00
if ( MCVersion . isNewerOrEqualThan ( MCVersion . getFromVersionName ( MagicValues . MIN_MC_VERSION_FOR_UPDATES ) ) )
2020-07-27 17:45:18 +02:00
{
messageCheckingForUpdates . send ( sender ) ;
/*if_not[STANDALONE]*/
2020-07-27 18:22:04 +02:00
( ( at . pcgamingfreaks . PluginLib . Bukkit . PluginLib ) at . pcgamingfreaks . PluginLib . Bukkit . PluginLib . getInstance ( ) ) . getUpdater ( ) . update ( ) ; // Make the PluginLib check for updates too
2020-07-27 17:45:18 +02:00
/*end[STANDALONE]*/
( ( Minepacks ) plugin ) . update ( result - > {
switch ( result )
{
case SUCCESS : messageUpdated . send ( sender ) ; break ;
case NO_UPDATE : messageNoUpdate . send ( sender ) ; break ;
case UPDATE_AVAILABLE : messageUpdateAvailable . send ( sender ) ; break ;
default : messageUpdateFail . send ( sender ) ; break ;
}
} ) ;
}
else
{
sender . sendMessage ( ChatColor . RED + " There are no more updates for Minecraft 1.7. If you would like to use new features please update your Minecraft version. " ) ;
}
2018-06-07 00:23:26 +02:00
}
@Override
public List < String > tabComplete ( @NotNull CommandSender sender , @NotNull String mainCommandAlias , @NotNull String alias , @NotNull String [ ] args )
{
return null ;
}
}