Fix broken stop command, added /kc tps command, better integration bukkit worlds with forge worlds
This commit is contained in:
parent
1bafa262d0
commit
1e51ceeb31
@ -468,15 +468,17 @@
|
||||
this.chunkProvider = this.createChunkProvider();
|
||||
|
||||
if (this instanceof WorldServer)
|
||||
@@ -294,6 +616,7 @@
|
||||
@@ -293,7 +615,9 @@
|
||||
|
||||
this.calculateInitialSkylight();
|
||||
this.calculateInitialWeather();
|
||||
+ this.getServer().addWorld(this.world); // CraftBukkit
|
||||
}
|
||||
+ // Cauldron end
|
||||
|
||||
private static MapStorage s_mapStorage;
|
||||
private static ISaveHandler s_savehandler;
|
||||
@@ -336,6 +659,18 @@
|
||||
@@ -336,6 +660,18 @@
|
||||
|
||||
public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_)
|
||||
{
|
||||
@ -495,7 +497,7 @@
|
||||
if (p_147439_1_ >= -30000000 && p_147439_3_ >= -30000000 && p_147439_1_ < 30000000 && p_147439_3_ < 30000000 && p_147439_2_ >= 0 && p_147439_2_ < 256)
|
||||
{
|
||||
Chunk chunk = null;
|
||||
@@ -404,7 +739,7 @@
|
||||
@@ -404,7 +740,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -504,7 +506,7 @@
|
||||
{
|
||||
return this.chunkProvider.chunkExists(p_72916_1_, p_72916_2_);
|
||||
}
|
||||
@@ -421,6 +756,27 @@
|
||||
@@ -421,6 +757,27 @@
|
||||
|
||||
public boolean setBlock(int p_147465_1_, int p_147465_2_, int p_147465_3_, Block p_147465_4_, int p_147465_5_, int p_147465_6_)
|
||||
{
|
||||
@ -532,7 +534,7 @@
|
||||
if (p_147465_1_ >= -30000000 && p_147465_3_ >= -30000000 && p_147465_1_ < 30000000 && p_147465_3_ < 30000000)
|
||||
{
|
||||
if (p_147465_2_ < 0)
|
||||
@@ -448,8 +804,22 @@
|
||||
@@ -448,8 +805,22 @@
|
||||
this.capturedBlockSnapshots.add(blockSnapshot);
|
||||
}
|
||||
|
||||
@ -555,7 +557,7 @@
|
||||
if (!flag && blockSnapshot != null)
|
||||
{
|
||||
this.capturedBlockSnapshots.remove(blockSnapshot);
|
||||
@@ -460,6 +830,7 @@
|
||||
@@ -460,6 +831,7 @@
|
||||
this.func_147451_t(p_147465_1_, p_147465_2_, p_147465_3_);
|
||||
this.theProfiler.endSection();
|
||||
|
||||
@ -563,7 +565,7 @@
|
||||
if (flag && blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates
|
||||
{
|
||||
// Modularize client and physic updates
|
||||
@@ -496,6 +867,19 @@
|
||||
@@ -496,6 +868,19 @@
|
||||
|
||||
public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_)
|
||||
{
|
||||
@ -583,7 +585,7 @@
|
||||
if (p_72805_1_ >= -30000000 && p_72805_3_ >= -30000000 && p_72805_1_ < 30000000 && p_72805_3_ < 30000000)
|
||||
{
|
||||
if (p_72805_2_ < 0)
|
||||
@@ -511,7 +895,7 @@
|
||||
@@ -511,7 +896,7 @@
|
||||
Chunk chunk = this.getChunkFromChunkCoords(p_72805_1_ >> 4, p_72805_3_ >> 4);
|
||||
p_72805_1_ &= 15;
|
||||
p_72805_3_ &= 15;
|
||||
@ -592,7 +594,7 @@
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -610,6 +994,12 @@
|
||||
@@ -610,6 +995,12 @@
|
||||
|
||||
public void notifyBlockChange(int p_147444_1_, int p_147444_2_, int p_147444_3_, Block p_147444_4_)
|
||||
{
|
||||
@ -605,7 +607,7 @@
|
||||
this.notifyBlocksOfNeighborChange(p_147444_1_, p_147444_2_, p_147444_3_, p_147444_4_);
|
||||
}
|
||||
|
||||
@@ -694,6 +1084,21 @@
|
||||
@@ -694,6 +1085,21 @@
|
||||
|
||||
try
|
||||
{
|
||||
@ -627,7 +629,7 @@
|
||||
block.onNeighborBlockChange(this, p_147460_1_, p_147460_2_, p_147460_3_, p_147460_4_);
|
||||
}
|
||||
catch (Throwable throwable1)
|
||||
@@ -1307,6 +1712,13 @@
|
||||
@@ -1307,6 +1713,13 @@
|
||||
|
||||
public boolean spawnEntityInWorld(Entity p_72838_1_)
|
||||
{
|
||||
@ -641,7 +643,7 @@
|
||||
// do not drop any items while restoring blocksnapshots. Prevents dupes
|
||||
if (!this.isRemote && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false;
|
||||
|
||||
@@ -1319,23 +1731,99 @@
|
||||
@@ -1319,23 +1732,99 @@
|
||||
flag = true;
|
||||
}
|
||||
|
||||
@ -744,7 +746,7 @@
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1346,6 +1834,8 @@
|
||||
@@ -1346,6 +1835,8 @@
|
||||
{
|
||||
((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_);
|
||||
}
|
||||
@ -753,7 +755,7 @@
|
||||
}
|
||||
|
||||
public void onEntityRemoved(Entity p_72847_1_)
|
||||
@@ -1354,6 +1844,8 @@
|
||||
@@ -1354,6 +1845,8 @@
|
||||
{
|
||||
((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_);
|
||||
}
|
||||
@ -762,7 +764,7 @@
|
||||
}
|
||||
|
||||
public void removeEntity(Entity p_72900_1_)
|
||||
@@ -1396,7 +1888,7 @@
|
||||
@@ -1396,7 +1889,7 @@
|
||||
this.getChunkFromChunkCoords(i, j).removeEntity(p_72973_1_);
|
||||
}
|
||||
|
||||
@ -771,7 +773,7 @@
|
||||
this.onEntityRemoved(p_72973_1_);
|
||||
}
|
||||
|
||||
@@ -1408,40 +1900,58 @@
|
||||
@@ -1408,40 +1901,58 @@
|
||||
public List getCollidingBoundingBoxes(Entity p_72945_1_, AxisAlignedBB p_72945_2_)
|
||||
{
|
||||
this.collidingBoundingBoxes.clear();
|
||||
@ -844,7 +846,7 @@
|
||||
|
||||
for (int j2 = 0; j2 < list.size(); ++j2)
|
||||
{
|
||||
@@ -1797,11 +2307,22 @@
|
||||
@@ -1797,11 +2308,22 @@
|
||||
Entity entity;
|
||||
CrashReport crashreport;
|
||||
CrashReportCategory crashreportcategory;
|
||||
@ -867,7 +869,7 @@
|
||||
try
|
||||
{
|
||||
++entity.ticksExisted;
|
||||
@@ -1838,35 +2359,26 @@
|
||||
@@ -1838,35 +2360,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -920,7 +922,7 @@
|
||||
if (entity.ridingEntity != null)
|
||||
{
|
||||
if (!entity.ridingEntity.isDead && entity.ridingEntity.riddenByEntity == entity)
|
||||
@@ -1884,7 +2396,9 @@
|
||||
@@ -1884,7 +2397,9 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -930,7 +932,7 @@
|
||||
}
|
||||
catch (Throwable throwable1)
|
||||
{
|
||||
@@ -1905,41 +2419,56 @@
|
||||
@@ -1905,41 +2420,56 @@
|
||||
}
|
||||
|
||||
this.theProfiler.endSection();
|
||||
@ -1009,7 +1011,7 @@
|
||||
crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity");
|
||||
crashreportcategory = crashreport.makeCategory("Block entity being ticked");
|
||||
tileentity.func_145828_a(crashreportcategory);
|
||||
@@ -1955,23 +2484,13 @@
|
||||
@@ -1955,23 +2485,13 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1038,7 +1040,7 @@
|
||||
if (!this.field_147483_b.isEmpty())
|
||||
{
|
||||
for (Object tile : field_147483_b)
|
||||
@@ -1981,6 +2500,7 @@
|
||||
@@ -1981,6 +2501,7 @@
|
||||
this.loadedTileEntityList.removeAll(this.field_147483_b);
|
||||
this.field_147483_b.clear();
|
||||
}
|
||||
@ -1046,7 +1048,7 @@
|
||||
|
||||
this.field_147481_N = false;
|
||||
|
||||
@@ -1994,9 +2514,9 @@
|
||||
@@ -1994,9 +2515,9 @@
|
||||
|
||||
if (!tileentity1.isInvalid())
|
||||
{
|
||||
@ -1058,7 +1060,7 @@
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2016,17 +2536,23 @@
|
||||
@@ -2016,17 +2537,23 @@
|
||||
this.addedTileEntityList.clear();
|
||||
}
|
||||
|
||||
@ -1085,7 +1087,7 @@
|
||||
}
|
||||
|
||||
public void updateEntity(Entity p_72870_1_)
|
||||
@@ -2036,21 +2562,33 @@
|
||||
@@ -2036,21 +2563,33 @@
|
||||
|
||||
public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_)
|
||||
{
|
||||
@ -1120,7 +1122,7 @@
|
||||
p_72866_1_.lastTickPosX = p_72866_1_.posX;
|
||||
p_72866_1_.lastTickPosY = p_72866_1_.posY;
|
||||
p_72866_1_.lastTickPosZ = p_72866_1_.posZ;
|
||||
@@ -2134,6 +2672,7 @@
|
||||
@@ -2134,6 +2673,7 @@
|
||||
p_72866_1_.riddenByEntity = null;
|
||||
}
|
||||
}
|
||||
@ -1128,7 +1130,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2500,7 +3039,7 @@
|
||||
@@ -2500,7 +3040,7 @@
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getDebugLoadedEntities()
|
||||
{
|
||||
@ -1137,7 +1139,7 @@
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -2570,7 +3109,7 @@
|
||||
@@ -2570,7 +3110,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1146,7 +1148,7 @@
|
||||
{
|
||||
if (this.field_147481_N)
|
||||
{
|
||||
@@ -2591,7 +3130,7 @@
|
||||
@@ -2591,7 +3131,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1155,7 +1157,7 @@
|
||||
}
|
||||
}
|
||||
Chunk chunk = this.getChunkFromChunkCoords(p_147455_1_ >> 4, p_147455_3_ >> 4);
|
||||
@@ -2612,7 +3151,7 @@
|
||||
@@ -2612,7 +3152,7 @@
|
||||
|
||||
public void func_147457_a(TileEntity p_147457_1_)
|
||||
{
|
||||
@ -1164,7 +1166,7 @@
|
||||
}
|
||||
|
||||
public boolean func_147469_q(int p_147469_1_, int p_147469_2_, int p_147469_3_)
|
||||
@@ -2718,7 +3257,15 @@
|
||||
@@ -2718,7 +3258,15 @@
|
||||
|
||||
if (i <= 0)
|
||||
{
|
||||
@ -1181,7 +1183,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2754,7 +3301,15 @@
|
||||
@@ -2754,7 +3302,15 @@
|
||||
|
||||
if (j <= 0)
|
||||
{
|
||||
@ -1198,7 +1200,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2777,8 +3332,41 @@
|
||||
@@ -2777,8 +3333,41 @@
|
||||
protected void setActivePlayerChunksAndCheckLight()
|
||||
{
|
||||
this.activeChunkSet.clear();
|
||||
@ -1241,7 +1243,7 @@
|
||||
int i;
|
||||
EntityPlayer entityplayer;
|
||||
int j;
|
||||
@@ -2788,17 +3376,28 @@
|
||||
@@ -2788,17 +3377,28 @@
|
||||
for (i = 0; i < this.playerEntities.size(); ++i)
|
||||
{
|
||||
entityplayer = (EntityPlayer)this.playerEntities.get(i);
|
||||
@ -1276,7 +1278,7 @@
|
||||
}
|
||||
|
||||
this.theProfiler.endSection();
|
||||
@@ -2810,7 +3409,7 @@
|
||||
@@ -2810,7 +3410,7 @@
|
||||
|
||||
this.theProfiler.startSection("playerCheckLight");
|
||||
|
||||
@ -1285,7 +1287,7 @@
|
||||
{
|
||||
i = this.rand.nextInt(this.playerEntities.size());
|
||||
entityplayer = (EntityPlayer)this.playerEntities.get(i);
|
||||
@@ -3280,12 +3879,23 @@
|
||||
@@ -3280,12 +3880,23 @@
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
@ -1312,7 +1314,7 @@
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -3298,9 +3908,10 @@
|
||||
@@ -3298,9 +3909,10 @@
|
||||
for (int i = 0; i < p_72868_1_.size(); ++i)
|
||||
{
|
||||
Entity entity = (Entity)p_72868_1_.get(i);
|
||||
@ -1324,7 +1326,7 @@
|
||||
this.onEntityAdded(entity);
|
||||
}
|
||||
}
|
||||
@@ -3308,14 +3919,25 @@
|
||||
@@ -3308,14 +3920,25 @@
|
||||
|
||||
public void unloadEntities(List p_72828_1_)
|
||||
{
|
||||
@ -1352,7 +1354,7 @@
|
||||
}
|
||||
|
||||
public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_)
|
||||
@@ -3464,6 +4086,12 @@
|
||||
@@ -3464,6 +4087,12 @@
|
||||
for (int i = 0; i < this.playerEntities.size(); ++i)
|
||||
{
|
||||
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
|
||||
@ -1365,7 +1367,7 @@
|
||||
double d5 = entityplayer1.getDistanceSq(p_72977_1_, p_72977_3_, p_72977_5_);
|
||||
|
||||
if ((p_72977_7_ < 0.0D || d5 < p_72977_7_ * p_72977_7_) && (d4 == -1.0D || d5 < d4))
|
||||
@@ -3489,7 +4117,12 @@
|
||||
@@ -3489,7 +4118,12 @@
|
||||
for (int i = 0; i < this.playerEntities.size(); ++i)
|
||||
{
|
||||
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
|
||||
@ -1379,7 +1381,7 @@
|
||||
if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive())
|
||||
{
|
||||
double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_);
|
||||
@@ -3612,11 +4245,11 @@
|
||||
@@ -3612,11 +4246,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
@ -1393,7 +1395,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3660,6 +4293,18 @@
|
||||
@@ -3660,6 +4294,18 @@
|
||||
|
||||
public void updateAllPlayersSleepingFlag() {}
|
||||
|
||||
@ -1412,7 +1414,7 @@
|
||||
public float getWeightedThunderStrength(float p_72819_1_)
|
||||
{
|
||||
return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_);
|
||||
@@ -3932,8 +4577,8 @@
|
||||
@@ -3932,8 +4578,8 @@
|
||||
*/
|
||||
public void addTileEntity(TileEntity entity)
|
||||
{
|
||||
@ -1423,7 +1425,7 @@
|
||||
{
|
||||
dest.add(entity);
|
||||
}
|
||||
@@ -4020,13 +4665,82 @@
|
||||
@@ -4020,13 +4666,82 @@
|
||||
public int countEntities(EnumCreatureType type, boolean forSpawnCount)
|
||||
{
|
||||
int count = 0;
|
||||
|
33
patches/org/bukkit/command/defaults/StopCommand.java.patch
Normal file
33
patches/org/bukkit/command/defaults/StopCommand.java.patch
Normal file
@ -0,0 +1,33 @@
|
||||
--- ../src-base/minecraft/org/bukkit/command/defaults/StopCommand.java
|
||||
+++ ../src-work/minecraft/org/bukkit/command/defaults/StopCommand.java
|
||||
@@ -12,6 +12,8 @@
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
+import net.minecraft.server.dedicated.DedicatedServer;
|
||||
+
|
||||
public class StopCommand extends VanillaCommand {
|
||||
public StopCommand() {
|
||||
super("stop");
|
||||
@@ -23,16 +25,19 @@
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
|
||||
if (!testPermission(sender)) return true;
|
||||
+
|
||||
+ DedicatedServer.allowPlayerLogins = false; // KCauldron - immediately disable logins
|
||||
|
||||
Command.broadcastCommandMessage(sender, "Stopping the server..");
|
||||
- Bukkit.shutdown();
|
||||
|
||||
String reason = this.createString(args, 0);
|
||||
if (StringUtils.isNotEmpty(reason)) {
|
||||
- for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
+ for (Player player : ImmutableList.copyOf(Bukkit.getOnlinePlayers())) {
|
||||
player.kickPlayer(reason);
|
||||
}
|
||||
}
|
||||
+
|
||||
+ Bukkit.shutdown(); // KCauldron - shutdown server after all players kicked
|
||||
|
||||
return true;
|
||||
}
|
@ -1,80 +1,120 @@
|
||||
package kcauldron;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
|
||||
import kcauldron.updater.CommandSenderUpdateCallback;
|
||||
import kcauldron.updater.KCauldronUpdater;
|
||||
import kcauldron.updater.KVersionRetriever;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.server.command.ForgeCommand;
|
||||
|
||||
public class KCauldronCommand extends Command {
|
||||
public static final String NAME = "kc";
|
||||
public static final String CHECK = NAME + ".check";
|
||||
public static final String UPDATE = NAME + ".update";
|
||||
public static final String RESTART = NAME + ".restart";
|
||||
public static final String NAME = "kc";
|
||||
public static final String CHECK = NAME + ".check";
|
||||
public static final String UPDATE = NAME + ".update";
|
||||
public static final String TPS = NAME + ".tps";
|
||||
public static final String RESTART = NAME + ".restart";
|
||||
|
||||
public KCauldronCommand() {
|
||||
super(NAME);
|
||||
public KCauldronCommand() {
|
||||
super(NAME);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(String.format("/%s check - Check to update\n", NAME));
|
||||
builder.append(String
|
||||
.format("/%s update [version] - Update to specified or latest version\n",
|
||||
NAME));
|
||||
builder.append(String.format("/%s restart - Restart server\n", NAME));
|
||||
setUsage(builder.toString());
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(String.format("/%s check - Check to update\n", NAME));
|
||||
builder.append(String.format("/%s update [version] - Update to specified or latest version\n", NAME));
|
||||
builder.append(String.format("/%s tps - Show tps statistics\n", NAME));
|
||||
builder.append(String.format("/%s restart - Restart server\n", NAME));
|
||||
setUsage(builder.toString());
|
||||
|
||||
setPermission("kcauldron");
|
||||
}
|
||||
setPermission("kcauldron");
|
||||
}
|
||||
|
||||
public boolean testPermission(CommandSender target, String permission) {
|
||||
if (testPermissionSilent(target, permission)) {
|
||||
return true;
|
||||
}
|
||||
target.sendMessage(ChatColor.RED
|
||||
+ "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.");
|
||||
return false;
|
||||
}
|
||||
public boolean testPermission(CommandSender target, String permission) {
|
||||
if (testPermissionSilent(target, permission)) {
|
||||
return true;
|
||||
}
|
||||
target.sendMessage(ChatColor.RED
|
||||
+ "I'm sorry, but you do not have permission to perform this command. Please contact the server administrators if you believe that this is in error.");
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean testPermissionSilent(CommandSender target, String permission) {
|
||||
if (!super.testPermissionSilent(target)) {
|
||||
return false;
|
||||
}
|
||||
for (String p : permission.split(";"))
|
||||
if (target.hasPermission(p))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
public boolean testPermissionSilent(CommandSender target, String permission) {
|
||||
if (!super.testPermissionSilent(target)) {
|
||||
return false;
|
||||
}
|
||||
for (String p : permission.split(";"))
|
||||
if (target.hasPermission(p))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String commandLabel,
|
||||
String[] args) {
|
||||
if (!testPermission(sender))
|
||||
return true;
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Please specify action");
|
||||
sender.sendMessage(ChatColor.AQUA + usageMessage);
|
||||
return true;
|
||||
}
|
||||
String action = args[0];
|
||||
if ("check".equals(action)) {
|
||||
if (!testPermission(sender, CHECK))
|
||||
return true;
|
||||
sender.sendMessage(ChatColor.GREEN + "Initiated version check...");
|
||||
KVersionRetriever.startServer(new CommandSenderUpdateCallback(
|
||||
sender), false);
|
||||
} else if ("update".equals(action)) {
|
||||
KCauldronUpdater.initUpdate(sender, args.length > 1 ? args[1]
|
||||
: null);
|
||||
} else if ("restart".equals(action)) {
|
||||
if (!testPermission(sender, RESTART))
|
||||
return true;
|
||||
KCauldron.restart();
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Unknown action");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||
if (!testPermission(sender))
|
||||
return true;
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "Please specify action");
|
||||
sender.sendMessage(ChatColor.AQUA + usageMessage);
|
||||
return true;
|
||||
}
|
||||
String action = args[0];
|
||||
if ("check".equals(action)) {
|
||||
if (!testPermission(sender, CHECK))
|
||||
return true;
|
||||
sender.sendMessage(ChatColor.GREEN + "Initiated version check...");
|
||||
KVersionRetriever.startServer(new CommandSenderUpdateCallback(sender), false);
|
||||
} else if ("update".equals(action)) {
|
||||
KCauldronUpdater.initUpdate(sender, args.length > 1 ? args[1] : null);
|
||||
} else if ("tps".equals(action)) {
|
||||
if (!testPermission(sender, TPS))
|
||||
return true;
|
||||
World currentWorld = null;
|
||||
if (sender instanceof CraftPlayer) {
|
||||
currentWorld = ((CraftPlayer) sender).getWorld();
|
||||
}
|
||||
sender.sendMessage(ChatColor.DARK_BLUE + "---------------------------------------");
|
||||
final MinecraftServer server = MinecraftServer.getServer();
|
||||
for (World world : server.server.getWorlds()) {
|
||||
if (world instanceof CraftWorld) {
|
||||
boolean current = currentWorld != null && currentWorld == world;
|
||||
net.minecraft.world.World mcWorld = ((CraftWorld) world).getHandle();
|
||||
String bukkitName = world.getName();
|
||||
int dimensionId = mcWorld.provider.dimensionId;
|
||||
String name = mcWorld.provider.getDimensionName();
|
||||
String displayName = name.equals(bukkitName) ? name : String.format("%s | %s", name, bukkitName);
|
||||
|
||||
double worldTickTime = mean(server.worldTickTimes.get(dimensionId)) * 1.0E-6D;
|
||||
double worldTPS = Math.min(1000.0 / worldTickTime, 20);
|
||||
|
||||
sender.sendMessage(String.format("%s[%d] %s%s %s- %s%.2fms / %.2ftps", ChatColor.GOLD, dimensionId,
|
||||
current ? ChatColor.GREEN : ChatColor.YELLOW, displayName, ChatColor.RESET, ChatColor.DARK_RED, worldTickTime,
|
||||
worldTPS));
|
||||
}
|
||||
}
|
||||
double meanTickTime = mean(server.tickTimeArray) * 1.0E-6D;
|
||||
double meanTPS = Math.min(1000.0 / meanTickTime, 20);
|
||||
sender.sendMessage(String.format("%sOverall - %s%s%.2fms / %.2ftps", ChatColor.BLUE, ChatColor.RESET,
|
||||
ChatColor.DARK_RED, meanTickTime, meanTPS));
|
||||
} else if ("restart".equals(action)) {
|
||||
if (!testPermission(sender, RESTART))
|
||||
return true;
|
||||
KCauldron.restart();
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "Unknown action");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static final long mean(long[] array) {
|
||||
long r = 0;
|
||||
for (long i : array)
|
||||
r += i;
|
||||
return r / array.length;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -670,7 +670,7 @@ public final class CraftServer implements Server {
|
||||
|
||||
@Override
|
||||
public List<World> getWorlds() {
|
||||
return new ArrayList<World>(worlds.values());
|
||||
return ImmutableList.copyOf(worlds.values());
|
||||
}
|
||||
|
||||
public DedicatedPlayerList getHandle() {
|
||||
|
Loading…
Reference in New Issue
Block a user