mirror of
https://github.com/kaboomserver/extras.git
synced 2024-11-27 09:55:36 -05:00
Tweak TPS check
This commit is contained in:
parent
f984ac411a
commit
3a0946054d
3 changed files with 24 additions and 35 deletions
|
@ -29,6 +29,8 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import org.bukkit.util.BlockIterator;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
@ -267,7 +269,7 @@ class CommandSkin implements CommandExecutor {
|
|||
if (args.length == 0) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <username>");
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(main, new Runnable() {
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
try {
|
||||
final String name = args[0];
|
||||
|
@ -295,35 +297,35 @@ class CommandSkin implements CommandExecutor {
|
|||
textureProfile.clearProperties();
|
||||
textureProfile.setProperty(new ProfileProperty("textures", texture, signature));
|
||||
|
||||
Bukkit.getScheduler().runTask(main, new Runnable() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.setPlayerProfile(textureProfile);
|
||||
player.sendMessage("Successfully set your skin to " + name + "'s");
|
||||
}
|
||||
});
|
||||
}.runTask(main);
|
||||
} else {
|
||||
uuidConnection.disconnect();
|
||||
Bukkit.getScheduler().runTask(main, new Runnable() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.sendMessage("Failed to change skin. Try again later");
|
||||
}
|
||||
});
|
||||
}.runTask(main);
|
||||
}
|
||||
} else {
|
||||
nameConnection.disconnect();
|
||||
Bukkit.getScheduler().runTask(main, new Runnable() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.sendMessage("A player with that username doesn't exist");
|
||||
}
|
||||
});
|
||||
}.runTask(main);
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}.runTaskAsynchronously(main);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -414,7 +416,7 @@ class CommandUsername implements CommandExecutor {
|
|||
if (args.length == 0) {
|
||||
player.sendMessage(ChatColor.RED + "Usage: /" + label + " <username>");
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(main, new Runnable() {
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
try {
|
||||
String texture = "";
|
||||
|
@ -457,17 +459,17 @@ class CommandUsername implements CommandExecutor {
|
|||
profile.setProperty(new ProfileProperty("textures", texture, signature));
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTask(main, new Runnable() {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.setPlayerProfile(profile);
|
||||
player.sendMessage("Successfully set your username to \"" + name + "\"");
|
||||
}
|
||||
});
|
||||
}.runTask(main);
|
||||
} catch (Exception exception) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}.runTaskAsynchronously(main);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import javax.net.ssl.HttpsURLConnection;
|
|||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
@ -36,7 +37,6 @@ import org.bukkit.event.block.BlockFromToEvent;
|
|||
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
|
@ -87,9 +87,9 @@ class AutosaveCheck extends BukkitRunnable {
|
|||
}
|
||||
}
|
||||
|
||||
/*class TileEntityCheckAsync extends BukkitRunnable {
|
||||
class TileEntityCheck extends BukkitRunnable {
|
||||
Main main;
|
||||
TileEntityCheckAsync(Main main) {
|
||||
TileEntityCheck(Main main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
|
@ -99,16 +99,16 @@ class AutosaveCheck extends BukkitRunnable {
|
|||
try {
|
||||
chunk.getTileEntities();
|
||||
} catch (Exception e) {
|
||||
Bukkit.getScheduler().runTask(main, new Runnable() {
|
||||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
world.regenerateChunk(chunk.getX(), chunk.getZ());
|
||||
}
|
||||
});
|
||||
}.runTask(main);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
class Events implements Listener {
|
||||
Main main;
|
||||
|
@ -291,20 +291,11 @@ class Events implements Listener {
|
|||
void onBlockRedstone(BlockRedstoneEvent event) {
|
||||
final double tps = Bukkit.getServer().getTPS()[0];
|
||||
|
||||
if (tps < 14) {
|
||||
if (tps < 10) {
|
||||
event.setNewCurrent(0);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onBlockSpread(BlockSpreadEvent event) {
|
||||
final double tps = Bukkit.getServer().getTPS()[0];
|
||||
|
||||
if (tps < 14) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if (event.getSpawnReason() == SpawnReason.CUSTOM ||
|
||||
|
@ -425,11 +416,7 @@ class Events implements Listener {
|
|||
|
||||
@EventHandler
|
||||
void onExplosionPrime(ExplosionPrimeEvent event) {
|
||||
final double tps = Bukkit.getServer().getTPS()[0];
|
||||
|
||||
if (tps < 14) {
|
||||
event.setCancelled(true);
|
||||
} else if (event.getRadius() > 20) {
|
||||
if (event.getRadius() > 20) {
|
||||
event.setRadius(20);
|
||||
}
|
||||
}
|
||||
|
@ -709,7 +696,7 @@ class Events implements Listener {
|
|||
void onTNTPrime(TNTPrimeEvent event) {
|
||||
final double tps = Bukkit.getServer().getTPS()[0];
|
||||
|
||||
if (tps < 14) {
|
||||
if (tps < 10) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -580,7 +580,7 @@ public class Main extends JavaPlugin {
|
|||
this.getCommand("username").setExecutor(new CommandUsername(this));
|
||||
|
||||
new AutosaveCheck().runTaskTimerAsynchronously(this, 0, 20);
|
||||
/*new TileEntityCheckAsync(this).runTaskTimerAsynchronously(this, 0, 400);*/
|
||||
new TileEntityCheck(this).runTaskTimerAsynchronously(this, 0, 400);
|
||||
this.getServer().getPluginManager().registerEvents(new Events(this), this);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue