SteamWar/BauSystem
Archiviert
13
0

Fixing Reset & Testblock reset

Dieser Commit ist enthalten in:
Travis CI 2019-06-13 15:23:02 +02:00
Ursprung 59ab68ad6b
Commit 2f5d577edb
4 geänderte Dateien mit 13 neuen und 36 gelöschten Zeilen

Datei anzeigen

@ -25,6 +25,7 @@ public class CommandReset implements CommandExecutor {
for(ArenaSection section : BauSystem.getSections()){ for(ArenaSection section : BauSystem.getSections()){
if(section.inRegion(player.getLocation())){ if(section.inRegion(player.getLocation())){
section.reset(); section.reset();
player.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
return false; return false;
} }
} }

Datei anzeigen

@ -25,6 +25,7 @@ public class CommandTestblock implements CommandExecutor {
for(ArenaSection section : BauSystem.getSections()){ for(ArenaSection section : BauSystem.getSections()){
if(section.inRegion(player.getLocation())){ if(section.inRegion(player.getLocation())){
section.getTestblock().reset(); section.getTestblock().reset();
player.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
return false; return false;
} }
} }

Datei anzeigen

@ -8,7 +8,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map;
public class ArenaSection extends Region { public class ArenaSection extends Region {
@ -23,14 +22,6 @@ public class ArenaSection extends Region {
return testblock; return testblock;
} }
@Override
public Map<String, Object> serialize() {
Map<String, Object> section = super.serialize();
for(Map.Entry<String, Object> subsection : testblock.serialize().entrySet())
section.put("testblock." + subsection.getKey(), subsection.getValue());
return section;
}
public static List<ArenaSection> loadFromFile(File file) throws IOException, InvalidConfigurationException { public static List<ArenaSection> loadFromFile(File file) throws IOException, InvalidConfigurationException {
YamlConfiguration config = new YamlConfiguration(); YamlConfiguration config = new YamlConfiguration();
config.load(file); config.load(file);

Datei anzeigen

@ -1,6 +1,7 @@
package de.steamwar.bausystem.world; package de.steamwar.bausystem.world;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.object.schematic.Schematic;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.AffineTransform;
@ -9,14 +10,11 @@ import de.steamwar.bausystem.BauSystem;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class Region implements ConfigurationSerializable { public class Region {
private final int sizeX; private final int sizeX;
private final int sizeY; private final int sizeY;
private final int sizeZ; private final int sizeZ;
@ -29,15 +27,14 @@ public class Region implements ConfigurationSerializable {
private final boolean rotate; private final boolean rotate;
Region(ConfigurationSection config){ Region(ConfigurationSection config){
Region rg = config.getSerializable("region", this.getClass()); sizeX = config.getInt("sizeX");
sizeX = rg.sizeX; sizeY = config.getInt("sizeY");
sizeY = rg.sizeY; sizeZ = config.getInt("sizeZ");
sizeZ = rg.sizeZ; minX = config.getInt("minX");
minX = rg.minX; minY = config.getInt("minY");
minY = rg.minY; minZ = config.getInt("minZ");
minZ = rg.minZ; schematic = config.getString("schematic");
schematic = rg.schematic; rotate = config.getBoolean("rotate");
rotate = rg.rotate;
} }
public boolean inRegion(Location l){ public boolean inRegion(Location l){
@ -50,7 +47,7 @@ public class Region implements ConfigurationSerializable {
public void reset(){ public void reset(){
File file = new File(BauSystem.SECTION_PATH + schematic); File file = new File(BauSystem.SECTION_PATH + schematic);
com.boydti.fawe.object.schematic.Schematic schem; Schematic schem;
try { try {
schem = FaweAPI.load(file); schem = FaweAPI.load(file);
}catch(IOException e){ }catch(IOException e){
@ -70,17 +67,4 @@ public class Region implements ConfigurationSerializable {
} }
schem.paste(w, v, false, true, aT).flushQueue(); schem.paste(w, v, false, true, aT).flushQueue();
} }
public Map<String, Object> serialize() {
Map<String, Object> map = new HashMap<>();
map.put("sizeX", sizeX);
map.put("sizeY", sizeY);
map.put("sizeZ", sizeZ);
map.put("minX", minX);
map.put("minY", minY);
map.put("minZ", minZ);
map.put("schematic", schematic);
map.put("rotate", rotate);
return map;
}
} }