UHC world loading

This commit is contained in:
Mini-Chiss 2015-05-11 14:10:51 -05:00
parent 123af16bd2
commit 5e73441b9a
4 changed files with 47 additions and 13 deletions

View File

@ -12,7 +12,11 @@ public class FileUtil
public static void DeleteFolder(File folder)
{
if (!folder.exists())
{
System.out.println("Delete target does not exist: " + folder);
return;
}
File[] files = folder.listFiles();

View File

@ -201,7 +201,10 @@ public class UHC extends TeamGame
if (_mapLoaded)
return;
int chunksPerTick = 4;
if (WorldData.World == null)
return;
int chunksPerTick = 20;
//Print Debug
if (event.getType() == UpdateType.SLOW)
@ -211,7 +214,7 @@ public class UHC extends TeamGame
int chunksToGo = chunkTotal - _chunksLoaded;
Announce(C.cGreen + C.Bold + "Generating Map: " + ChatColor.RESET +
UtilTime.MakeStr((long)((double)chunksToGo / (double)(20 * chunksPerTick) * 1000d), 1));
UtilTime.MakeStr((long)((double)chunksToGo / (double)(20 * chunksPerTick) * 1000d), 1) + " Remaining...");
TimingManager.endTotal("UHC Generation", true);
return;
@ -245,9 +248,12 @@ public class UHC extends TeamGame
}
else
{
Announce(C.cGreen + C.Bold + "Generating Map: " + ChatColor.RESET + "Complete!");
_mapLoaded = true;
System.out.println("Map Loading Finished!");
generateSpawns();
break;
}
_chunksLoaded++;

View File

@ -44,7 +44,7 @@ public class ExperienceStatTracker extends StatTracker<Game>
for (Player player : event.GetGame().GetPlayers(false))
{
//Tally Gems
double gems = 0;
double gemExp = 0;
for (String reason : event.GetGame().GetGems(player).keySet())
{
if (reason.toLowerCase().contains("participation"))
@ -52,21 +52,20 @@ public class ExperienceStatTracker extends StatTracker<Game>
GemData gem = event.GetGame().GetGems(player).get(reason);
gems += (int)gem.Gems;
gemExp += (int)gem.Gems;
}
gems = Math.min(gems, 250);
gemExp = Math.min(gemExp, 250) * 3;
//Game Time
double time = (System.currentTimeMillis() - _startTime)/60000d;
//Game Time = 1 Exp per 3 Seconds
double timeExp = (System.currentTimeMillis() - _startTime)/2000d;
//Mult
double mult = 1;
if (!winners.contains(player))
mult = 0.25;
if (winners.contains(player))
mult = 1.5;
//Exp
int expGained = (int)(time*gems*mult);
//Exp
int expGained = (int)((timeExp + gemExp)*mult);
//Record Global and per Game
addStat(player, "ExpEarned", expGained, false, true);

View File

@ -17,11 +17,13 @@ import mineplex.core.common.util.WorldUtil;
import mineplex.core.common.util.ZipUtil;
import mineplex.core.timing.TimingManager;
import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.uhc.UHC;
import net.minecraft.server.v1_7_R4.ChunkPreLoadEvent;
import org.bukkit.Difficulty;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.WorldCreator;
import org.bukkit.event.world.ChunkUnloadEvent;
@ -80,7 +82,30 @@ public class WorldData
{
TimingManager.start("WorldData loading world.");
//Start World
World = WorldUtil.LoadWorld(new WorldCreator(GetFolder()));
if (Host instanceof UHC)
{
//Delete Old World
File dir = new File(GetFolder() + "/data");
FileUtil.DeleteFolder(dir);
dir = new File(GetFolder() + "/region");
FileUtil.DeleteFolder(dir);
dir = new File(GetFolder() + "/level.dat");
dir.delete();
//Create Fresh World with Random Seed
WorldCreator creator = new WorldCreator(GetFolder());
creator.seed(UtilMath.r(999999999));
creator.environment(Environment.NORMAL);
creator.generateStructures(true);
World = creator.createWorld();
}
else
{
World = WorldUtil.LoadWorld(new WorldCreator(GetFolder()));
}
TimingManager.stop("WorldData loading world.");
World.setDifficulty(Difficulty.HARD);