mirror of
https://github.com/taoneill/war.git
synced 2024-11-13 05:54:31 +01:00
Customizable warhub floor/gate/light materials
Just changeable through the war.yml file for now, since it's a pretty advanced option. Still missing warzone lobby materials.
This commit is contained in:
parent
4867b8cf03
commit
4bebb2d50e
@ -49,6 +49,7 @@ import com.tommytony.war.structure.ZoneLobby;
|
||||
import com.tommytony.war.utility.ChatFixUtil;
|
||||
import com.tommytony.war.utility.PlayerState;
|
||||
import com.tommytony.war.utility.WarLogFormatter;
|
||||
import com.tommytony.war.utility.WarhubMaterials;
|
||||
|
||||
/**
|
||||
* Main class of War
|
||||
@ -94,6 +95,8 @@ public class War extends JavaPlugin {
|
||||
|
||||
private Logger warLogger;
|
||||
|
||||
private WarhubMaterials warhubMaterials;
|
||||
|
||||
public War() {
|
||||
super();
|
||||
War.war = this;
|
||||
@ -970,4 +973,12 @@ public class War extends JavaPlugin {
|
||||
public SpoutDisplayer getSpoutDisplayer() {
|
||||
return this.spoutMessenger ;
|
||||
}
|
||||
|
||||
public void setWarhubMaterials(WarhubMaterials warhubMaterials) {
|
||||
this.warhubMaterials = warhubMaterials;
|
||||
}
|
||||
|
||||
public WarhubMaterials getWarhubMaterials() {
|
||||
return this.warhubMaterials;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.tommytony.war;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
@ -23,7 +22,6 @@ import org.bukkit.inventory.PlayerInventory;
|
||||
import org.getspout.spoutapi.SpoutManager;
|
||||
import org.getspout.spoutapi.player.SpoutPlayer;
|
||||
|
||||
|
||||
import com.tommytony.war.config.InventoryBag;
|
||||
import com.tommytony.war.config.TeamConfig;
|
||||
import com.tommytony.war.config.TeamConfigBag;
|
||||
|
@ -6,11 +6,11 @@ import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
|
||||
import com.tommytony.war.War;
|
||||
import com.tommytony.war.Warzone;
|
||||
import com.tommytony.war.mapper.VolumeMapper;
|
||||
import com.tommytony.war.structure.WarHub;
|
||||
import com.tommytony.war.utility.WarhubMaterials;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
|
||||
public class RestoreYmlWarhubJob implements Runnable {
|
||||
@ -28,6 +28,33 @@ public class RestoreYmlWarhubJob implements Runnable {
|
||||
|
||||
String worldName = warhubConfig.getString("world");
|
||||
String hubOrientation = warhubConfig.getString("orientation");
|
||||
|
||||
// materials
|
||||
int floorId = 20; // default glass
|
||||
int floorData = 0;
|
||||
ConfigurationSection floorMaterialSection = warhubConfig.getConfigurationSection("materials.floor");
|
||||
if (floorMaterialSection != null) {
|
||||
floorId = floorMaterialSection.getInt("id");
|
||||
floorData = floorMaterialSection.getInt("data");
|
||||
}
|
||||
|
||||
int gateId = 49; // default obsidian
|
||||
int gateData = 0;
|
||||
ConfigurationSection gateMaterialSection = warhubConfig.getConfigurationSection("materials.gate");
|
||||
if (gateMaterialSection != null) {
|
||||
gateId = gateMaterialSection.getInt("id");
|
||||
gateData = gateMaterialSection.getInt("data");
|
||||
}
|
||||
|
||||
int lightId = 89; // default glowstone
|
||||
int lightData = 0;
|
||||
ConfigurationSection lightMaterialSection = warhubConfig.getConfigurationSection("materials.light");
|
||||
if (lightMaterialSection != null) {
|
||||
lightId = lightMaterialSection.getInt("id");
|
||||
lightData = lightMaterialSection.getInt("data");
|
||||
}
|
||||
|
||||
War.war.setWarhubMaterials(new WarhubMaterials(floorId, (byte)floorData, gateId, (byte)gateData, lightId, (byte)lightData));
|
||||
|
||||
World world = War.war.getServer().getWorld(worldName);
|
||||
if (world != null) {
|
||||
|
@ -66,7 +66,7 @@ public class WarYmlMapper {
|
||||
War.war.getCommandWhitelist().add(command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// defaultLoadouts
|
||||
ConfigurationSection loadoutsSection = warRootSection.getConfigurationSection("team.default.loadout");
|
||||
LoadoutYmlMapper.fromConfigToLoadouts(loadoutsSection, War.war.getDefaultInventories().getLoadouts());
|
||||
@ -167,6 +167,16 @@ public class WarYmlMapper {
|
||||
hubConfigSection.set("z", hub.getLocation().getBlockZ());
|
||||
hubConfigSection.set("world", hub.getLocation().getWorld().getName());
|
||||
hubConfigSection.set("orientation", orientationStr);
|
||||
|
||||
ConfigurationSection floorSection = hubConfigSection.createSection("materials.floor");
|
||||
floorSection.set("id", War.war.getWarhubMaterials().getFloorId());
|
||||
floorSection.set("data", War.war.getWarhubMaterials().getFloorData());
|
||||
ConfigurationSection gateSection = hubConfigSection.createSection("materials.gate");
|
||||
gateSection.set("id", War.war.getWarhubMaterials().getGateId());
|
||||
gateSection.set("data", War.war.getWarhubMaterials().getGateData());
|
||||
ConfigurationSection lightSection = hubConfigSection.createSection("materials.light");
|
||||
lightSection.set("id", War.war.getWarhubMaterials().getLightId());
|
||||
lightSection.set("data", War.war.getWarhubMaterials().getLightData());
|
||||
|
||||
VolumeMapper.save(hub.getVolume(), "");
|
||||
}
|
||||
|
@ -153,11 +153,22 @@ public class WarHub {
|
||||
this.volume.setCornerOne(locationBlock.getRelative(back).getRelative(left, halfHubWidth).getRelative(BlockFace.DOWN));
|
||||
this.volume.setCornerTwo(locationBlock.getRelative(right, halfHubWidth).getRelative(front, hubDepth).getRelative(BlockFace.UP, hubHeigth));
|
||||
this.volume.saveBlocks();
|
||||
|
||||
// materials
|
||||
Material floor = Material.getMaterial(War.war.getWarhubMaterials().getFloorId());
|
||||
byte floorData = War.war.getWarhubMaterials().getFloorData();
|
||||
Material gate = Material.getMaterial(War.war.getWarhubMaterials().getGateId());
|
||||
byte gateData = War.war.getWarhubMaterials().getGateData();
|
||||
Material light = Material.getMaterial(War.war.getWarhubMaterials().getLightId());
|
||||
byte lightData = War.war.getWarhubMaterials().getLightData();
|
||||
|
||||
// glass floor
|
||||
this.volume.clearBlocksThatDontFloat();
|
||||
this.volume.setToMaterial(Material.AIR);
|
||||
this.volume.setFaceMaterial(BlockFace.DOWN, Material.GLASS);
|
||||
if (!floor.equals(Material.AIR)) {
|
||||
// If air, don't set floor to air, just leave original ground. Otherwise apply material.
|
||||
this.volume.setFaceMaterial(BlockFace.DOWN, floor, floorData);
|
||||
}
|
||||
|
||||
|
||||
// draw gates
|
||||
Block currentGateBlock = BlockInfo.getBlock(this.location.getWorld(), this.volume.getCornerOne()).getRelative(BlockFace.UP).getRelative(front, hubDepth).getRelative(right, 2);
|
||||
@ -165,14 +176,30 @@ public class WarHub {
|
||||
for (Warzone zone : War.war.getWarzones()) { // gonna use the index to find it again
|
||||
if (!zone.getWarzoneConfig().getBoolean(WarzoneConfig.DISABLED)) {
|
||||
this.zoneGateBlocks.put(zone.getName(), currentGateBlock);
|
||||
currentGateBlock.getRelative(BlockFace.DOWN).setType(Material.GLOWSTONE);
|
||||
currentGateBlock.getRelative(left).setType(Material.OBSIDIAN);
|
||||
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).setType(Material.OBSIDIAN);
|
||||
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(Material.OBSIDIAN);
|
||||
currentGateBlock.getRelative(right).setType(Material.OBSIDIAN);
|
||||
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).setType(Material.OBSIDIAN);
|
||||
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(Material.OBSIDIAN);
|
||||
currentGateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(Material.OBSIDIAN);
|
||||
currentGateBlock.getRelative(BlockFace.DOWN).setType(light);
|
||||
currentGateBlock.getRelative(BlockFace.DOWN).setData(lightData);
|
||||
|
||||
currentGateBlock.getRelative(left).setType(gate);
|
||||
currentGateBlock.getRelative(left).setData(gateData);
|
||||
|
||||
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).setType(gate);
|
||||
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).setData(gateData);
|
||||
|
||||
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(gate);
|
||||
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setData(gateData);
|
||||
|
||||
currentGateBlock.getRelative(right).setType(gate);
|
||||
currentGateBlock.getRelative(right).setData(gateData);
|
||||
|
||||
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).setType(gate);
|
||||
currentGateBlock.getRelative(left).getRelative(BlockFace.UP).setData(gateData);
|
||||
|
||||
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(gate);
|
||||
currentGateBlock.getRelative(right).getRelative(BlockFace.UP).getRelative(BlockFace.UP).setData(gateData);
|
||||
|
||||
currentGateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP).setType(gate);
|
||||
currentGateBlock.getRelative(BlockFace.UP).getRelative(BlockFace.UP).setData(gateData);
|
||||
|
||||
currentGateBlock = currentGateBlock.getRelative(right, 4);
|
||||
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ public class ZoneLobby {
|
||||
// flatten the area (set all but floor to air, then replace any floor air blocks with glass)
|
||||
this.volume.clearBlocksThatDontFloat();
|
||||
this.volume.setToMaterial(Material.AIR);
|
||||
this.volume.setFaceMaterial(BlockFace.DOWN, Material.GLASS); // beautiful
|
||||
this.volume.setFaceMaterial(BlockFace.DOWN, Material.GLASS, (byte)0); // beautiful
|
||||
|
||||
// add war hub link gate
|
||||
if (War.war.getWarHub() != null) {
|
||||
|
@ -0,0 +1,46 @@
|
||||
package com.tommytony.war.utility;
|
||||
|
||||
public class WarhubMaterials {
|
||||
private final int floorId;
|
||||
private final byte floorData;
|
||||
|
||||
private final int gateId;
|
||||
private final byte gateData;
|
||||
|
||||
private final int lightId;
|
||||
private final byte lightData;
|
||||
|
||||
public WarhubMaterials(int floorId, byte floorData, int gateId, byte gateData, int lightId, byte lightData) {
|
||||
this.floorId = floorId;
|
||||
this.floorData = floorData;
|
||||
this.gateId = gateId;
|
||||
this.gateData = gateData;
|
||||
this.lightId = lightId;
|
||||
this.lightData = lightData;
|
||||
}
|
||||
|
||||
public int getFloorId() {
|
||||
return floorId;
|
||||
}
|
||||
|
||||
public byte getFloorData() {
|
||||
return floorData;
|
||||
}
|
||||
|
||||
public int getGateId() {
|
||||
return gateId;
|
||||
}
|
||||
|
||||
public byte getGateData() {
|
||||
return gateData;
|
||||
}
|
||||
|
||||
public int getLightId() {
|
||||
return lightId;
|
||||
}
|
||||
|
||||
public byte getLightData() {
|
||||
return lightData;
|
||||
}
|
||||
|
||||
}
|
@ -448,7 +448,7 @@ public class Volume {
|
||||
}
|
||||
}
|
||||
|
||||
public void setFaceMaterial(BlockFace face, Material material) {
|
||||
public void setFaceMaterial(BlockFace face, Material material, byte data) {
|
||||
try {
|
||||
if (this.hasTwoCorners() && this.isSaved()) {
|
||||
int x = this.getMinX();
|
||||
@ -460,6 +460,7 @@ public class Volume {
|
||||
if ((face == BlockFace.DOWN && y == this.getMinY()) || (face == BlockFace.UP && y == this.getMaxY()) || (face == BlockFace.NORTH && x == this.getMinX()) || (face == BlockFace.EAST && z == this.getMinZ()) || (face == BlockFace.SOUTH && x == this.getMaxX()) || (face == BlockFace.WEST && z == this.getMaxZ())) {
|
||||
Block currentBlock = this.getWorld().getBlockAt(x, y, z);
|
||||
currentBlock.setType(material);
|
||||
currentBlock.setData(data);
|
||||
}
|
||||
z++;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user