Cleaned out some debug messages and added some java-docs.
This commit is contained in:
parent
65e05b9d8c
commit
a69101bef3
@ -16,7 +16,9 @@ import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
|
||||
/**
|
||||
* Represents a display slot to display Mavericks Master Builders builds.
|
||||
*/
|
||||
public class DisplaySlot
|
||||
{
|
||||
|
||||
@ -25,6 +27,9 @@ public class DisplaySlot
|
||||
private ArrayList<Entity> _pastedEntities = new ArrayList<>();
|
||||
private Map<Vector, ParticleType> _particles = null;
|
||||
|
||||
/**
|
||||
* @param loc The minimum corner of where the build will be pasted in.
|
||||
*/
|
||||
public DisplaySlot(Location loc)
|
||||
{
|
||||
_loc = loc.clone();
|
||||
@ -77,6 +82,9 @@ public class DisplaySlot
|
||||
_data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send all the entities to nearby players. Should be called every 10 ticks.
|
||||
*/
|
||||
public void updateParticles()
|
||||
{
|
||||
if(_particles == null) return;
|
||||
@ -107,6 +115,10 @@ public class DisplaySlot
|
||||
_pastedEntities.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param e The entity you want to check.
|
||||
* @return Returns true if this entity is spawned in by this display slot.
|
||||
*/
|
||||
public boolean isDisplaySlotEntity(Entity e)
|
||||
{
|
||||
return _pastedEntities.contains(e);
|
||||
|
@ -15,8 +15,10 @@ import mineplex.serverdata.database.DBPool;
|
||||
/**
|
||||
* Repository for Mavericks-MasterBuilders SQL game data
|
||||
* -
|
||||
* Table to back this repository may be created with
|
||||
* CREATE TABLE mavericksMasterBuildersApproved (
|
||||
* Table to back this repository may be created with:
|
||||
*
|
||||
*
|
||||
CREATE TABLE mavericksMasterBuildersApproved (
|
||||
buildId INT NOT NULL AUTO_INCREMENT,
|
||||
ApproveDate INT NOT NULL,
|
||||
ApprovedBy VARCHAR(36) NOT NULL DEFAULT '',
|
||||
@ -24,7 +26,7 @@ import mineplex.serverdata.database.DBPool;
|
||||
PRIMARY KEY (buildId),
|
||||
CONSTRAINT account_id FOREIGN KEY (ApprovedBy) REFERENCES accounts (id) ON DELETE NO ACTION ON UPDATE NO ACTION,
|
||||
CONSTRAINT build_id FOREIGN KEY (BuildId) REFERENCES mavericksMasterBuildersBuilds (BuildId) ON DELETE NO ACTION ON UPDATE NO ACTION
|
||||
)
|
||||
)
|
||||
*/
|
||||
public class MavericksApprovedRepository
|
||||
{
|
||||
@ -65,11 +67,6 @@ public class MavericksApprovedRepository
|
||||
try (Connection conn = DBPool.getAccount().getConnection())
|
||||
{
|
||||
String filter = onlyDisplay ? " WHERE Display=1 " : " ";
|
||||
// PreparedStatement stmt3 = conn.prepareStatement("SELECT BuildId," +
|
||||
// "(SELECT uuid from accounts WHERE accounts.id=" + TABLE_APPROVED + ".accountId)," +
|
||||
// "(SELECT name from accounts WHERE accounts.id=" + TABLE_APPROVED + ".accountId)," +
|
||||
// ",BuildTheme,Points,Place,Date,Schematic,Reviewed FROM " + TABLE_APPROVED + " " + filter +
|
||||
// " LIMIT " + limit + " OFFSET " + offset);
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement(
|
||||
"SELECT " +
|
||||
|
@ -5,7 +5,6 @@ import java.util.UUID;
|
||||
/**
|
||||
* A wrapper class to SQL data in the mavericksMasterBuildersApproved SQL table
|
||||
*/
|
||||
|
||||
public class MavericksApprovedWrapper
|
||||
{
|
||||
|
||||
|
@ -15,7 +15,8 @@ import mineplex.serverdata.database.DBPool;
|
||||
* Repository for Mavericks-MasterBuilders SQL game data
|
||||
* -
|
||||
* Table to back this repository may be created with
|
||||
* CREATE TABLE IF NOT EXISTS mavericksMasterBuildersBuilds (
|
||||
*
|
||||
CREATE TABLE IF NOT EXISTS mavericksMasterBuildersBuilds (
|
||||
accountId INT NOT NULL,
|
||||
BuildTheme VARCHAR(255) NOT NULL,
|
||||
Points DOUBLE NOT NULL,
|
||||
|
@ -19,7 +19,10 @@ import mineplex.core.mavericks.MavericksApprovedWrapper;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.hub.modules.mavericks.MavericksPortalManager;
|
||||
|
||||
/**
|
||||
* A manager to handle all mavericks related content in the hub. Holds the mavericks portal manager in addition to handle
|
||||
* the rotation of the "best of" builds from Mavericks Master Builders.
|
||||
*/
|
||||
public class MavericksManager extends MiniPlugin
|
||||
{
|
||||
|
||||
@ -41,6 +44,9 @@ public class MavericksManager extends MiniPlugin
|
||||
_displaySlots.add(new DisplaySlot(new Location(Bukkit.getWorld("world"), -19, 63, -145)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Main task to handle the rotation. Pulls data from the SQL DB and displays it in-game.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onUpdate(UpdateEvent event)
|
||||
{
|
||||
@ -130,6 +136,12 @@ public class MavericksManager extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if an entity is spawned in and managed by the mavericks "best of" builds.
|
||||
* @param e The entity you want to check.
|
||||
* @return Returns true if the entity is spawned and managed by this mavericks manager.
|
||||
*/
|
||||
public boolean isStatueEntity(Entity e)
|
||||
{
|
||||
for(DisplaySlot d : _displaySlots)
|
||||
|
@ -16,10 +16,15 @@ import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
/**
|
||||
* A small teleportation manager to manage the portal from the hub to the mavericks world and back.
|
||||
*/
|
||||
public class MavericksPortalManager extends MiniPlugin
|
||||
{
|
||||
|
||||
/**
|
||||
* A list of players who are on "cooldown". Players are removed from this list when they walk outside a portal.
|
||||
*/
|
||||
private Set<Player> _cooldown = new HashSet<>();
|
||||
|
||||
private Box _portalHubMavericks;
|
||||
@ -82,6 +87,9 @@ public class MavericksPortalManager extends MiniPlugin
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A small AABB box util class.
|
||||
*/
|
||||
private static class Box
|
||||
{
|
||||
private Vector _min;
|
||||
|
@ -7,7 +7,6 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
@ -407,9 +406,11 @@ public class BuildData
|
||||
return UtilSchematic.createSchematic(min, max);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns a map of the particles with their relative vector paths to the build.
|
||||
*/
|
||||
public Map<Vector, ParticleType> getParticles()
|
||||
{
|
||||
Bukkit.broadcastMessage("Getting particles [" + Player.getName() + "]");
|
||||
Vector min = getMin().toVector();
|
||||
|
||||
Map<Vector, ParticleType> map = new HashMap<>();
|
||||
@ -418,12 +419,13 @@ public class BuildData
|
||||
Vector v = e.getKey().toVector().subtract(min);
|
||||
map.put(v, e.getValue());
|
||||
}
|
||||
|
||||
Bukkit.broadcastMessage("Returning map [" + map.size() + "]:\n" + map);
|
||||
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the byte map from {@link #getParticles()} in byte form converted to NBT data and compressed with Gzip
|
||||
*/
|
||||
public byte[] getParticlesBytes()
|
||||
{
|
||||
Map<String, Tag> map = new HashMap<String, Tag>();
|
||||
@ -441,23 +443,10 @@ public class BuildData
|
||||
|
||||
CompoundTag entry = new CompoundTag(entryMap);
|
||||
map.put("particle" + i++, entry);
|
||||
|
||||
Bukkit.broadcastMessage("Adding entry: 'particle" + i + "'\n" + entry);
|
||||
}
|
||||
|
||||
CompoundTag parent = new CompoundTag(map);
|
||||
|
||||
Bukkit.broadcastMessage("Compressing main: " + parent);
|
||||
|
||||
byte[] bytes = NBTUtils.toBytesCompressed("particles", parent);
|
||||
if(bytes == null)
|
||||
{
|
||||
Bukkit.broadcastMessage("Returning bytes = null!");
|
||||
}
|
||||
else
|
||||
{
|
||||
Bukkit.broadcastMessage("Returning bytes: " + bytes.length + "\n" + new String(bytes));
|
||||
}
|
||||
return bytes;
|
||||
return NBTUtils.toBytesCompressed("particles", parent);
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,9 @@ import mineplex.core.common.util.UtilItem;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import nautilus.game.arcade.game.games.build.BuildData;
|
||||
import nautilus.game.arcade.game.games.build.GroundData;
|
||||
|
||||
/**
|
||||
* Represents the cylinder build area where the player can build. Holds particles and blocks.
|
||||
*/
|
||||
public class BuildDataCylinder extends BuildData
|
||||
{
|
||||
|
||||
|
@ -72,17 +72,6 @@ public class BuildMavericks extends Build
|
||||
};
|
||||
|
||||
_reposetory = new MavericksBuildRepository();
|
||||
|
||||
//TODO: REMOVE AFTER DEBUG!
|
||||
/*
|
||||
_buildTime = 20000;
|
||||
_voteTime = 4000;
|
||||
_viewTime = 7000;
|
||||
Bukkit.broadcastMessage("Time updated!");
|
||||
*/
|
||||
|
||||
// Bukkit.getPluginManager().registerEvents(new SchematicTester(), UtilServer.getPlugin());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -111,8 +100,6 @@ public class BuildMavericks extends Build
|
||||
{
|
||||
BuildData data = e.getValue();
|
||||
|
||||
Bukkit.broadcastMessage("Trying to upload " + e.getKey().getName() + "'s build data...");
|
||||
Bukkit.broadcastMessage("--> Points: " + data.getPoints());
|
||||
//TODO: Insert some real value here
|
||||
// if(data.getPoints() <= 0) continue;
|
||||
|
||||
@ -124,16 +111,12 @@ public class BuildMavericks extends Build
|
||||
|
||||
|
||||
int place = _places.indexOf(e.getKey());
|
||||
Bukkit.broadcastMessage("--> Place: " + place);
|
||||
if(place == -1) continue;
|
||||
|
||||
MavericksBuildWrapper wrapper = new MavericksBuildWrapper(-1, uuid, name, _word, data.getPoints(), place,
|
||||
System.currentTimeMillis(), UtilSchematic.getBytes(schematic), data.getParticlesBytes(), false);
|
||||
|
||||
Bukkit.broadcastMessage("--> Uploading...");
|
||||
|
||||
_reposetory.add(wrapper).thenCompose(BukkitFuture.accept(sucess -> {
|
||||
Bukkit.broadcastMessage("Success: " + sucess);
|
||||
if(!sucess)
|
||||
new RuntimeException("Unable to save build data and schematic for player '" + e.getKey().getName() + "': " + wrapper).printStackTrace();
|
||||
}));
|
||||
@ -141,6 +124,44 @@ public class BuildMavericks extends Build
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void prepare(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() == GameState.Prepare)
|
||||
{
|
||||
if (GetPlayers(true).size() > GetTeamList().get(0).GetSpawns().size())
|
||||
{
|
||||
SetState(GameState.End);
|
||||
Announce(C.Bold + "Too Many Players...");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else if (event.GetState() == GameState.Live)
|
||||
{
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
Location spawn = UtilAlg.findClosest(player.getLocation(), this.GetTeamList().get(0).GetSpawns());
|
||||
|
||||
Location center = UtilAlg.findClosest(player.getLocation(), WorldData.GetDataLocs("YELLOW"));
|
||||
|
||||
_data.put(player, new BuildDataCylinder(player, spawn, center));
|
||||
|
||||
player.setFlySpeed(0.1f);
|
||||
}
|
||||
|
||||
if (!_useHolidayWords || Math.random() >= 0.5)
|
||||
_word = _words[UtilMath.r(_words.length)];
|
||||
else
|
||||
_word = _holidayWords[UtilMath.r(_holidayWords.length)];
|
||||
|
||||
UtilTextMiddle.display(null, C.cYellow + "Build " + C.cWhite + _word, 0, 80, 5);
|
||||
|
||||
this.WorldTimeSet = -1;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: REMOVE INNER CLASS AFTER TESTING!
|
||||
public static class SchematicTester implements Listener
|
||||
{
|
||||
|
||||
@ -257,43 +278,8 @@ public class BuildMavericks extends Build
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void prepare(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() == GameState.Prepare)
|
||||
{
|
||||
if (GetPlayers(true).size() > GetTeamList().get(0).GetSpawns().size())
|
||||
{
|
||||
SetState(GameState.End);
|
||||
Announce(C.Bold + "Too Many Players...");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else if (event.GetState() == GameState.Live)
|
||||
{
|
||||
for (Player player : GetPlayers(true))
|
||||
{
|
||||
Location spawn = UtilAlg.findClosest(player.getLocation(), this.GetTeamList().get(0).GetSpawns());
|
||||
|
||||
Location center = UtilAlg.findClosest(player.getLocation(), WorldData.GetDataLocs("YELLOW"));
|
||||
|
||||
_data.put(player, new BuildDataCylinder(player, spawn, center));
|
||||
|
||||
player.setFlySpeed(0.1f);
|
||||
}
|
||||
|
||||
if (!_useHolidayWords || Math.random() >= 0.5)
|
||||
_word = _words[UtilMath.r(_words.length)];
|
||||
else
|
||||
_word = _holidayWords[UtilMath.r(_holidayWords.length)];
|
||||
|
||||
UtilTextMiddle.display(null, C.cYellow + "Build " + C.cWhite + _word, 0, 80, 5);
|
||||
|
||||
this.WorldTimeSet = -1;
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: REMOVE AFTER QA FINISH TESTING!
|
||||
// DO NOT GO LIVE!
|
||||
@EventHandler
|
||||
public void onCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
|
@ -46,7 +46,9 @@ import mineplex.core.updater.Updater;
|
||||
import mineplex.core.velocity.VelocityFix;
|
||||
import mineplex.core.visibility.VisibilityManager;
|
||||
import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
/**
|
||||
* Main JavaPlugin class for this plugin. Initializes the rest of this plugin.
|
||||
*/
|
||||
public class Hub extends JavaPlugin
|
||||
{
|
||||
|
||||
|
@ -62,7 +62,9 @@ import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import nautilus.game.arcade.ArcadeFormat;
|
||||
|
||||
/**
|
||||
* The Mavericks Review Manager. Handles the review process.
|
||||
*/
|
||||
public class MavericksReviewManager extends MiniPlugin
|
||||
{
|
||||
private MavericksBuildRepository _repoBuilds;
|
||||
|
@ -8,7 +8,9 @@ import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.mavericks.MavericksBuildWrapper;
|
||||
|
||||
/**
|
||||
* A simple wrapper class used to hold build data related to a location and player.
|
||||
*/
|
||||
public class ReviewData
|
||||
{
|
||||
private Player _player;
|
||||
|
@ -1,7 +1,9 @@
|
||||
package nautilus.game.arcade;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
|
||||
/**
|
||||
* Copy from {@link nautilus.game.arcade.ArcadeFormat}
|
||||
*/
|
||||
public class ArcadeFormat
|
||||
{
|
||||
public static String Line = C.cDGreen + C.Strike + "=============================================";
|
||||
|
Loading…
Reference in New Issue
Block a user