mirror of
https://github.com/TheDeus-Group/TFM-4.3-Reloaded.git
synced 2024-05-29 09:41:18 +00:00
Fix /premium command
This commit is contained in:
parent
63c1b71056
commit
8cd08fbb72
|
@ -1,12 +1,14 @@
|
||||||
package me.StevenLawson.TotalFreedomMod.commands;
|
package me.StevenLawson.TotalFreedomMod.commands;
|
||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.Log;
|
import me.StevenLawson.TotalFreedomMod.Log;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -33,37 +35,26 @@ public class Command_premium extends FreedomCommand {
|
||||||
name = args[0];
|
name = args[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
new BukkitRunnable()
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
{
|
try
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
{
|
||||||
try
|
final URL getUrl = new URL("https://api.mojang.com/users/profiles/minecraft/" + name);
|
||||||
{
|
final HttpsURLConnection urlConnection = (HttpsURLConnection) getUrl.openConnection();
|
||||||
final URL getUrl = new URL("https://minecraft.net/haspaid.jsp?user=" + name);
|
final String message = (urlConnection.getResponseCode() == 200 ? ChatColor.DARK_GREEN + "Yes" : ChatColor.RED + "No");
|
||||||
final URLConnection urlConnection = getUrl.openConnection();
|
urlConnection.disconnect();
|
||||||
// Read the response
|
|
||||||
final BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
|
|
||||||
final String message = ("false".equalsIgnoreCase(in.readLine()) ? ChatColor.RED + "No" : ChatColor.DARK_GREEN + "Yes");
|
|
||||||
in.close();
|
|
||||||
|
|
||||||
new BukkitRunnable()
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
{
|
playerMsg("Player " + name + " is premium: " + message);
|
||||||
@Override
|
});
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
playerMsg("Player " + name + " is premium: " + message);
|
|
||||||
}
|
|
||||||
}.runTask(plugin);
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Log.severe(ex);
|
|
||||||
playerMsg("There was an error querying the mojang server.", ChatColor.RED);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(plugin);
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.severe(ex);
|
||||||
|
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||||
|
playerMsg("There was an error querying the mojang server.", ChatColor.RED);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue