mirror of
https://github.com/bloodmc/GriefDefender.git
synced 2024-11-12 10:44:42 +01:00
Fix schematics.
This commit is contained in:
parent
13361eeada
commit
ef3659b33e
@ -37,6 +37,7 @@
|
||||
import com.griefdefender.api.Tristate;
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.ClaimBlockSystem;
|
||||
import com.griefdefender.api.claim.ClaimSchematic;
|
||||
import com.griefdefender.api.claim.ClaimType;
|
||||
import com.griefdefender.api.claim.TrustType;
|
||||
import com.griefdefender.api.economy.BankTransaction;
|
||||
@ -50,6 +51,7 @@
|
||||
import com.griefdefender.claim.ClaimContextCalculator;
|
||||
import com.griefdefender.claim.GDClaim;
|
||||
import com.griefdefender.claim.GDClaimManager;
|
||||
import com.griefdefender.claim.GDClaimSchematic.ClaimSchematicBuilder;
|
||||
import com.griefdefender.command.CommandAdjustBonusClaimBlocks;
|
||||
import com.griefdefender.command.CommandCallback;
|
||||
import com.griefdefender.command.CommandClaimAbandon;
|
||||
@ -463,7 +465,7 @@ public void onPreInit(GamePreInitializationEvent event, Logger logger, Path path
|
||||
this.permissionProvider = new LuckPermsProvider();
|
||||
|
||||
instance = this;
|
||||
this.getLogger().info("Grief Prevention boot start.");
|
||||
this.getLogger().info("GriefDefender boot start.");
|
||||
this.getLogger().info("Finished loading configuration.");
|
||||
DEFAULT_HOLDER = new GDPermissionHolder("default");
|
||||
PUBLIC_USER = new GDPermissionUser(PUBLIC_UUID, PUBLIC_NAME);
|
||||
@ -485,6 +487,7 @@ public void onPreInit(GamePreInitializationEvent event, Logger logger, Path path
|
||||
WeatherTypeRegistryModule.getInstance().registerDefaults();
|
||||
OptionRegistryModule.getInstance().registerDefaults();
|
||||
GriefDefender.getRegistry().registerBuilderSupplier(Claim.Builder.class, GDClaim.ClaimBuilder::new);
|
||||
GriefDefender.getRegistry().registerBuilderSupplier(ClaimSchematic.Builder.class, ClaimSchematicBuilder::new);
|
||||
GriefDefender.getRegistry().registerBuilderSupplier(BankTransaction.Builder.class, GDBankTransaction.BankTransactionBuilder::new);
|
||||
Sponge.getEventManager().registerListeners(GDBootstrap.getInstance(), GriefDefenderPlugin.getInstance());
|
||||
}
|
||||
|
@ -29,7 +29,6 @@
|
||||
import com.griefdefender.api.claim.Claim;
|
||||
import com.griefdefender.api.claim.ClaimSchematic;
|
||||
import com.griefdefender.internal.util.VecHelper;
|
||||
import com.griefdefender.storage.FileStorage;
|
||||
import org.spongepowered.api.data.DataContainer;
|
||||
import org.spongepowered.api.data.persistence.DataFormats;
|
||||
import org.spongepowered.api.data.persistence.DataTranslators;
|
||||
@ -107,11 +106,11 @@ public Schematic getSchematic() {
|
||||
* @return If schematic apply was successful, false if not
|
||||
*/
|
||||
public boolean apply() {
|
||||
if (!this.schematic.containsBlock(this.claim.getLesserBoundaryCorner()) && !schematic.containsBlock(this.claim.getGreaterBoundaryCorner())) {
|
||||
if (!this.schematic.containsBlock(this.claim.getLesserBoundaryCorner()) && !this.schematic.containsBlock(this.claim.getGreaterBoundaryCorner())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.schematic.apply(VecHelper.toLocation(((GDClaim)(this.claim)).getWorld(), this.claim.getLesserBoundaryCorner()), BlockChangeFlags.ALL);
|
||||
this.schematic.apply(VecHelper.toLocation(((GDClaim)(this.claim)).getWorld(), this.origin), BlockChangeFlags.ALL);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -124,16 +123,7 @@ public static class ClaimSchematicBuilder implements Builder {
|
||||
|
||||
@Override
|
||||
public Builder claim(Claim claim) {
|
||||
final World world = ((GDClaim) claim).getWorld();
|
||||
final ArchetypeVolume volume = world.createArchetypeVolume(this.claim.getLesserBoundaryCorner(), this.claim.getGreaterBoundaryCorner(), new Vector3i(0, 0, 0));
|
||||
final Schematic schematic = Schematic.builder()
|
||||
.metaValue(Schematic.METADATA_NAME, name)
|
||||
.metaValue(Schematic.METADATA_DATE, Instant.now().toString())
|
||||
.metaValue("UUID", this.claim.getUniqueId().toString())
|
||||
.volume(volume)
|
||||
.build();
|
||||
this.claim = claim;
|
||||
this.schematic = schematic;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -160,10 +150,18 @@ public Builder reset() {
|
||||
@Override
|
||||
public Optional<ClaimSchematic> build() {
|
||||
if (this.origin == null) {
|
||||
//this.origin = new Vector3i(0, 0, 0);
|
||||
this.origin = this.claim.getLesserBoundaryCorner();
|
||||
this.origin = new Vector3i(0, 0, 0);
|
||||
}
|
||||
|
||||
final World world = ((GDClaim) this.claim).getWorld();
|
||||
final ArchetypeVolume volume = world.createArchetypeVolume(this.claim.getLesserBoundaryCorner(), this.claim.getGreaterBoundaryCorner(), this.origin);
|
||||
final Schematic schematic = Schematic.builder()
|
||||
.metaValue(Schematic.METADATA_NAME, this.name)
|
||||
.metaValue(Schematic.METADATA_DATE, Instant.now().toString())
|
||||
.metaValue("UUID", this.claim.getUniqueId().toString())
|
||||
.volume(volume)
|
||||
.build();
|
||||
this.schematic = schematic;
|
||||
DataContainer schematicData = DataTranslators.SCHEMATIC.translate(schematic);
|
||||
final Path schematicPath = GriefDefenderPlugin.getInstance().getWorldEditProvider().getSchematicWorldMap().get(world.getUniqueId()).resolve(this.claim.getUniqueId().toString());
|
||||
try {
|
||||
@ -179,9 +177,9 @@ public Optional<ClaimSchematic> build() {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
final GDClaimSchematic schematic = new GDClaimSchematic(this.claim, this.schematic, this.name, this.origin);
|
||||
((GDClaim) this.claim).schematics.put(this.name, schematic);
|
||||
return Optional.of(schematic);
|
||||
final GDClaimSchematic claimSchematic = new GDClaimSchematic(this.claim, this.schematic, this.name, this.origin);
|
||||
((GDClaim) this.claim).schematics.put(this.name, claimSchematic);
|
||||
return Optional.of(claimSchematic);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user