use of org.bukkit.scheduler.BukkitRunnable in project MyPet by xXKeyleXx.
the class Sprint method finish.
@Override
public void finish() {
nav.getParameters().removeSpeedModifier("Sprint");
new BukkitRunnable() {
public void run() {
petEntity.setSprinting(false);
}
}.runTaskLater(MyPetApi.getPlugin(), 25L);
}
use of org.bukkit.scheduler.BukkitRunnable in project WildernessTp by AcmeProject.
the class TeleportGoneWild method WildTeleport.
public void WildTeleport(final Player p, final String world, final boolean bypass) {
this.bypass = bypass;
World world1 = Bukkit.getWorld(world);
if (!realTeleportt(p, world1, WildTP.maxXY, WildTP.minXY, WildTP.maxXY, WildTP.minXY)) {
new BukkitRunnable() {
@Override
public void run() {
WildTeleport(p, world, bypass);
}
}.runTaskLater(instace, 5L);
}
}
use of org.bukkit.scheduler.BukkitRunnable in project Sentinel by mcmonkey4eva.
the class SentinelTrait method onDeath.
public void onDeath() {
/*if (npc.hasTrait(Spawned.class)) {
npc.getTrait(Spawned.class).setSpawned(false);
}*/
greetedAlready.clear();
currentTargets.clear();
if (respawnTime < 0) {
BukkitRunnable removeMe = new BukkitRunnable() {
@Override
public void run() {
npc.destroy();
}
};
removeMe.runTaskLater(SentinelPlugin.instance, 1);
} else if (respawnTime > 0) {
final long rsT = respawnTime;
respawnMe = new BukkitRunnable() {
long timer = 0;
@Override
public void run() {
if (CitizensAPI.getNPCRegistry().getById(npc.getId()) != null) {
if (npc.isSpawned()) {
this.cancel();
respawnMe = null;
return;
}
if (timer >= rsT) {
if (spawnPoint == null && npc.getStoredLocation() == null) {
SentinelPlugin.instance.getLogger().warning("NPC " + npc.getId() + " has a null spawn point and can't be spawned. Perhaps the world was deleted?");
this.cancel();
return;
}
npc.spawn(spawnPoint == null ? npc.getStoredLocation() : spawnPoint);
this.cancel();
respawnMe = null;
return;
}
timer += 10;
} else {
respawnMe = null;
this.cancel();
return;
}
}
};
respawnMe.runTaskTimer(SentinelPlugin.instance, 10, 10);
}
}
use of org.bukkit.scheduler.BukkitRunnable in project QualityArmory by ZombieStriker.
the class GithubUpdater method autoUpdate.
/*
* public void update(Player p){ String version = Main.version; String
* parsedVersion = version.replace(".", "");
*
* try { URL api = new
* URL("https://api.github.com/repos/greeves12/COD/releases/latest");
* URLConnection con = api.openConnection(); con.setConnectTimeout(15000);
* con.setReadTimeout(15000);
*
* String tagName = null;
*
* try{ JsonObject json = new JsonParser().parse(new
* InputStreamReader(con.getInputStream())).getAsJsonObject(); tagName =
* json.get("tag_name").getAsString();
*
* String finalTagName = tagName.replace(".", ""); int latestVersion =
* Integer.parseInt(finalTagName.substring(1, finalTagName.length()));
*
* if(latestVersion > Integer.parseInt(parsedVersion)) {
*
* p.sendMessage("�8*** [COD] �bThere is a new version available �a" + tagName +
* "�8***"); p.sendMessage("�8*** �dDownload the new build from here �8***");
* p.sendMessage("�8*** �6�6https://github.com/greeves12/COD/releases �8***");
* p.sendMessage("�bOnly Admins can see this message!"); }
*
* }catch(JsonIOException e){ e.printStackTrace(); } } catch (IOException e) {
* e.printStackTrace(); } }
*/
public static boolean autoUpdate(final Plugin main, String author, String githubProject, String jarname) {
try {
String version = main.getDescription().getVersion();
String parseVersion = version.replace(".", "");
String tagname = null;
URL api = new URL("https://api.github.com/repos/" + author + "/" + githubProject + "/releases/latest");
URLConnection con = api.openConnection();
con.setConnectTimeout(15000);
con.setReadTimeout(15000);
JsonObject json = new JsonParser().parse(new InputStreamReader(con.getInputStream())).getAsJsonObject();
tagname = json.get("tag_name").getAsString();
String parsedTagName = tagname.replace(".", "");
int latestVersion = Integer.valueOf(parsedTagName.substring(1, parsedTagName.length()));
final URL download = new URL("https://github.com/" + author + "/" + githubProject + "/releases/download/" + tagname + "/" + jarname);
if (latestVersion > Integer.parseInt(parseVersion)) {
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "Found a new version of " + ChatColor.GOLD + main.getDescription().getName() + ": " + ChatColor.WHITE + tagname + ChatColor.LIGHT_PURPLE + " downloading now!!");
new BukkitRunnable() {
@Override
public void run() {
try {
InputStream in = download.openStream();
File pluginFile = null;
try {
pluginFile = new File(URLDecoder.decode(this.getClass().getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException("You don't have a good text codec on your system", e);
}
// File temp = new File("plugins/update");
// if (!temp.exists()) {
// temp.mkdir();
// }
File tempInCaseSomethingGoesWrong = new File(main.getName() + "-backup.jar");
copy(new FileInputStream(pluginFile), new FileOutputStream(tempInCaseSomethingGoesWrong));
// Path path = new File("plugins/update" + File.separator + "COD.jar").toPath();
pluginFile.setWritable(true, false);
pluginFile.delete();
// Files.copy(in, pluginFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
copy(in, new FileOutputStream(pluginFile));
if (pluginFile.length() < 1000) {
// Plugin is too small. Keep old version in case new one is incomplete/nonexistant
copy(new FileInputStream(tempInCaseSomethingGoesWrong), new FileOutputStream(pluginFile));
} else {
// Plugin is valid, and we can delete the temp
tempInCaseSomethingGoesWrong.delete();
}
} catch (IOException e) {
}
}
}.runTaskLaterAsynchronously(main, 0);
return true;
}
} catch (IOException e) {
}
return false;
}
use of org.bukkit.scheduler.BukkitRunnable in project QualityArmory by ZombieStriker.
the class Remmington method shoot.
@SuppressWarnings("deprecation")
@Override
public boolean shoot(final Player player) {
boolean offhand = player.getInventory().getItemInHand().getDurability() == IronSightsToggleItem.getData();
if ((!offhand && ItemFact.getAmount(player.getInventory().getItemInHand()) > 0) || (offhand && Update19OffhandChecker.hasAmountOFfhandGreaterthan(player, 0))) {
if (time.contains(player.getUniqueId()))
return false;
time.add(player.getUniqueId());
GunUtil.basicShoot(offhand, this, player, 0.1, 10);
new BukkitRunnable() {
@Override
public void run() {
try {
/*
* player.getWorld().playSound(player.getLocation(), Sound.BLOCK_LEVER_CLICK, 8,
* 1.4f); player.getWorld().playSound(player.getLocation(),
* Sound.BLOCK_SAND_BREAK, 8, 1.4f);
*/
player.getWorld().playSound(player.getLocation(), WeaponSounds.RELOAD_BULLET.getName(), 1, 1f);
} catch (Error e) {
player.getWorld().playSound(player.getLocation(), Sound.valueOf("CLICK"), 8, 1.4f);
player.getWorld().playSound(player.getLocation(), Sound.valueOf("DIG_SAND"), 8, 1.4f);
}
}
}.runTaskLater(Main.getInstance(), 12);
new BukkitRunnable() {
@Override
public void run() {
try {
player.getWorld().playSound(player.getLocation(), WeaponSounds.RELOAD_BOLT.getName(), 1, 1f);
/*
* player.getWorld().playSound(player.getLocation(), Sound.BLOCK_SAND_BREAK, 8,
* 1.4f); player.getWorld().playSound(player.getLocation(),
* Sound.BLOCK_LEVER_CLICK, 8, 1);
*/
} catch (Error e) {
player.getWorld().playSound(player.getLocation(), Sound.valueOf("DIG_SAND"), 8, 1.4f);
player.getWorld().playSound(player.getLocation(), Sound.valueOf("CLICK"), 8, 1);
}
time.remove(player.getUniqueId());
}
}.runTaskLater(Main.getInstance(), 16);
return true;
}
return false;
}
Aggregations