use of org.bukkit.scheduler.BukkitRunnable in project TotalFreedomMod by TotalFreedom.
the class FreezeData method setFrozen.
public void setFrozen(boolean freeze) {
final Player player = fPlayer.getPlayer();
if (player == null) {
FLog.info("Could not freeze " + fPlayer.getName() + ". Player not online!");
return;
}
FUtil.cancel(unfreeze);
unfreeze = null;
location = null;
if (!freeze) {
if (fPlayer.getPlayer().getGameMode() != GameMode.CREATIVE) {
FUtil.setFlying(player, false);
}
return;
}
// Blockify location
location = player.getLocation();
// Avoid infinite falling
FUtil.setFlying(player, true);
if (fPlayer.getPlugin().al.isAdminImpostor(player)) {
// Don't run unfreeze task for impostors
return;
}
unfreeze = new BukkitRunnable() {
@Override
public void run() {
FUtil.adminAction("TotalFreedom", "Unfreezing " + player.getName(), false);
setFrozen(false);
}
}.runTaskLater(fPlayer.getPlugin(), AUTO_PURGE_TICKS);
}
use of org.bukkit.scheduler.BukkitRunnable in project TotalFreedomMod by TotalFreedom.
the class Command_premium method run.
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length != 1) {
return false;
}
final Player player = getPlayer(args[0]);
final String name;
if (player != null) {
name = player.getName();
} else {
name = args[0];
}
new BukkitRunnable() {
@Override
public void run() {
try {
final URL getUrl = new URL("http://axis.iaero.me/accstatus?username=" + name + "&format=plain");
final URLConnection urlConnection = getUrl.openConnection();
final String message;
try (// Read the response
BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()))) {
message = (!"PREMIUM".equalsIgnoreCase(in.readLine()) ? ChatColor.RED + "No" : ChatColor.DARK_GREEN + "Yes");
}
if (!plugin.isEnabled()) {
return;
}
new BukkitRunnable() {
@Override
public void run() {
msg("Player " + name + " is premium: " + message);
}
}.runTask(plugin);
} catch (Exception ex) {
FLog.severe(ex);
msg("There was an error querying the mojang server.", ChatColor.RED);
}
}
}.runTaskAsynchronously(plugin);
return true;
}
use of org.bukkit.scheduler.BukkitRunnable in project TotalFreedomMod by TotalFreedom.
the class LoginProcess method onPlayerJoin.
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
final Player player = event.getPlayer();
new BukkitRunnable() {
@Override
public void run() {
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean()) {
player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
}
if (lockdownEnabled) {
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
}
}
}.runTaskLater(plugin, 20L * 1L);
}
use of org.bukkit.scheduler.BukkitRunnable in project TotalFreedomMod by TotalFreedom.
the class Command_doom method run.
@Override
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length != 1) {
return false;
}
final Player player = getPlayer(args[0]);
if (player == null) {
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
return true;
}
FUtil.adminAction(sender.getName(), "Casting oblivion over " + player.getName(), true);
FUtil.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED);
final String ip = player.getAddress().getAddress().getHostAddress().trim();
// Remove from superadmin
Admin admin = getAdmin(player);
if (admin != null) {
FUtil.adminAction(sender.getName(), "Removing " + player.getName() + " from the superadmin list", true);
plugin.al.removeAdmin(admin);
}
// Remove from whitelist
player.setWhitelisted(false);
// Deop
player.setOp(false);
// Ban player
Ban ban = Ban.forPlayer(player, sender);
ban.setReason("&cFUCKOFF");
for (String playerIp : plugin.pl.getData(player).getIps()) {
ban.addIp(playerIp);
}
plugin.bm.addBan(ban);
// Set gamemode to survival
player.setGameMode(GameMode.SURVIVAL);
// Clear inventory
player.closeInventory();
player.getInventory().clear();
// Ignite player
player.setFireTicks(10000);
// Generate explosion
player.getWorld().createExplosion(player.getLocation(), 0F, false);
// Shoot the player in the sky
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 20, 0)));
new BukkitRunnable() {
@Override
public void run() {
// strike lightning
player.getWorld().strikeLightning(player.getLocation());
// kill (if not done already)
player.setHealth(0.0);
}
}.runTaskLater(plugin, 2L * 20L);
new BukkitRunnable() {
@Override
public void run() {
// message
FUtil.adminAction(sender.getName(), "Banning " + player.getName() + ", IP: " + ip, true);
// generate explosion
player.getWorld().createExplosion(player.getLocation(), 0F, false);
// kick player
player.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
}
}.runTaskLater(plugin, 3L * 20L);
return true;
}
use of org.bukkit.scheduler.BukkitRunnable in project TotalFreedomMod by TotalFreedom.
the class Command_health method run.
@Override
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
Runtime runtime = Runtime.getRuntime();
long usedMem = runtime.totalMemory() - runtime.freeMemory();
msg("Reserved Memory: " + (double) runtime.totalMemory() / (double) BYTES_PER_MB + "mb");
msg("Used Memory: " + new DecimalFormat("#").format((double) usedMem / (double) BYTES_PER_MB) + "mb (" + new DecimalFormat("#").format(((double) usedMem / (double) runtime.totalMemory()) * 100.0) + "%)");
msg("Max Memory: " + (double) runtime.maxMemory() / (double) BYTES_PER_MB + "mb");
msg("Calculating ticks per second, please wait...");
new BukkitRunnable() {
@Override
public void run() {
try {
TFM_TickMeter tickMeter = new TFM_TickMeter(plugin);
tickMeter.startTicking();
Thread.sleep(2500);
final double ticksPerSecond = tickMeter.stopTicking();
// Plugin was disabled during async task
if (!plugin.isEnabled()) {
return;
}
new BukkitRunnable() {
@Override
public void run() {
msg("Ticks per second: " + (TPS_RANGE.containsDouble(ticksPerSecond) ? ChatColor.GREEN : ChatColor.RED) + ticksPerSecond);
}
}.runTask(plugin);
} catch (Exception ex) {
FLog.severe(ex);
}
}
}.runTaskAsynchronously(plugin);
return true;
}
Aggregations