Messages had a small error where someone accepting the offer to exit a
contract early would *say* the land lord paid, when the tennant was paying Removed CoreProtect as a soft-depend as it does not appear to actually do what I need. Updated the "Self cleaning" rentals so that broken blocks do not restore themselves upon breaking the rental agreement. The plugin will restore *only* air, so new structures will be destroyed, unless they occupy a block that was already present (replacing a dirt block with a chest will result in the chest remaining when the agreement breaks).
This commit is contained in:
parent
051eef009f
commit
a18a88616c
@ -3,7 +3,7 @@ main: me.EtienneDx.RealEstate.RealEstate
|
||||
version: ${project.version}
|
||||
authors: [EtienneDx, DmitryRendov, FamousLongwing]
|
||||
depend: [Vault, GriefPrevention]
|
||||
softdepend: [WorldEdit, CoreProtect]
|
||||
softdepend: [WorldEdit]
|
||||
api-version: "1.20"
|
||||
|
||||
commands:
|
||||
|
||||
2
pom.xml
2
pom.xml
@ -96,6 +96,7 @@
|
||||
</plugins>
|
||||
</build>
|
||||
<repositories>
|
||||
|
||||
<repository>
|
||||
<id>enginehub-maven</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
@ -180,6 +181,7 @@
|
||||
<version>7.2.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
||||
@ -283,7 +283,7 @@ public class Messages extends AnnotationConfig
|
||||
public String msgInfoExitOfferCreatedByOther = "$a{0} $bhas created an offer to exit the transaction for the {1} at $a{3} $bfor $a{2}";
|
||||
|
||||
@ConfigField(name="RealEstate.Info.ExitOffer.AcceptedBySelf", comment = "0: claim type, 1:formatted price")
|
||||
public String msgInfoExitOfferAcceptedBySelf = "$bThe {0} is no longer rented or leased, you have been charged $a{1}";
|
||||
public String msgInfoExitOfferAcceptedBySelf = "$bThe {0} is no longer rented or leased, you have been paid $a{1}";
|
||||
|
||||
@ConfigField(name="RealEstate.Info.ExitOffer.AcceptedByOther", comment = "0: player name, 1: claim type, 2: formatted price, 3: claim location")
|
||||
public String msgInfoExitOfferAcceptedByOther = "$a{0} $bhas accepted the offer to exit the transaction for the {1} at $a{3} $bfor $a{2}. It is no longer leased or rented.";
|
||||
|
||||
@ -309,6 +309,7 @@ public class RECommand extends BaseCommand
|
||||
claim.dropPermission(bt.buyer.toString());
|
||||
claim.managers.remove(bt.buyer.toString());
|
||||
GriefPrevention.instance.dataStore.saveClaim(claim);
|
||||
ClaimRent.restore_rental(claim);
|
||||
bt.buyer = null;
|
||||
bt.update();// eventual cancel is contained in here
|
||||
}
|
||||
|
||||
@ -88,13 +88,19 @@ public class RealEstate extends JavaPlugin
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (checkWorldEdit())
|
||||
{
|
||||
org.bukkit.plugin.Plugin WorldEditPlugin=getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
this.log.info("Found WorldEdit, using version "+WorldEditPlugin.getDescription().getVersion());
|
||||
if (checkWorldEdit())
|
||||
{
|
||||
org.bukkit.plugin.Plugin WorldEditPlugin=getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
this.log.info("Found WorldEdit, using version "+WorldEditPlugin.getDescription().getVersion());
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
if(getServer().getPluginManager().getPlugin("CoreProtect")!=null)
|
||||
{
|
||||
org.bukkit.plugin.Plugin cp=getServer().getPluginManager().getPlugin("CoreProtect");
|
||||
this.log.info("Found CoreProtect, using version"+cp.getDescription().getVersion());
|
||||
|
||||
}
|
||||
if(getServer().getPluginManager().getPlugin("Essentials") != null)
|
||||
{
|
||||
org.bukkit.plugin.Plugin ess=getServer().getPluginManager().getPlugin("Essentials");
|
||||
|
||||
@ -9,10 +9,13 @@ import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.Period;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -30,12 +33,18 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
|
||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.mask.Masks;
|
||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.session.ClipboardHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import me.EtienneDx.RealEstate.Messages;
|
||||
import me.EtienneDx.RealEstate.RealEstate;
|
||||
@ -92,6 +101,10 @@ public class ClaimRent extends BoughtTransaction
|
||||
com.sk89q.worldedit.world.World adaptedworld= BukkitAdapter.adapt(lesser.getWorld());
|
||||
EditSession editSession=WorldEdit.getInstance().newEditSession(adaptedworld);
|
||||
ForwardExtentCopy CopyArea=new ForwardExtentCopy(editSession,region,clipboard,region.getMinimumPoint());
|
||||
CopyArea.setCopyingEntities(false);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
Operations.complete(CopyArea);
|
||||
} catch (WorldEditException e) {
|
||||
@ -99,7 +112,6 @@ public class ClaimRent extends BoughtTransaction
|
||||
RealEstate.instance.log.info("Failed to copy rental area, WorldEdit gives error: "+e.getMessage());
|
||||
}
|
||||
|
||||
|
||||
String schempath = RealEstate.pluginDirPath + "/schematics/"+claim.getID().toString()+".schem";
|
||||
File file = new File(schempath);
|
||||
try (ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(new FileOutputStream(file))) {
|
||||
@ -215,6 +227,60 @@ public class ClaimRent extends BoughtTransaction
|
||||
|
||||
}
|
||||
|
||||
public static void restore_rental(Claim claim)
|
||||
{
|
||||
|
||||
//if worldedit saving is requested, here's where I load the saved area
|
||||
if((claim.isAdminClaim()&&RealEstate.instance.config.RestoreAdminOnly)|| !RealEstate.instance.config.RestoreAdminOnly) //if we are in an admin claim *and* admin only is selected, or if admin only is false
|
||||
{
|
||||
if(RealEstate.instance.getServer().getPluginManager().getPlugin("WorldEdit")!=null) //is world edit installed?
|
||||
{
|
||||
if(RealEstate.instance.config.RestoreRentalState)//are we configured to use it?
|
||||
{
|
||||
//load schematic, paste where we got it.
|
||||
String schempath = RealEstate.pluginDirPath + "/schematics/"+claim.getID().toString()+".schem";
|
||||
File file = new File(schempath);
|
||||
Clipboard clipboard =null;
|
||||
ClipboardFormat format= ClipboardFormats.findByFile(file);
|
||||
try (ClipboardReader reader = format.getReader(new FileInputStream(file))) {
|
||||
clipboard = reader.read();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
RealEstate.instance.log.info("Failed to import previously saved schematic: "+e.getMessage());
|
||||
|
||||
return;
|
||||
}
|
||||
Location lesser=claim.getLesserBoundaryCorner();
|
||||
|
||||
|
||||
com.sk89q.worldedit.world.World world = BukkitAdapter.adapt(lesser.getWorld());
|
||||
|
||||
try (EditSession editSession = WorldEdit.getInstance().newEditSession(world)) {
|
||||
|
||||
|
||||
|
||||
BlockType air=new BlockType("minecraft:air");//we want to capture all the air from the saved schematic, to empty out the space that used to be empty
|
||||
BlockTypeMask mask= new BlockTypeMask(clipboard,air);//create a mask, specifying we want to keep just the air from the schematic
|
||||
Operation operation = new ClipboardHolder(clipboard)
|
||||
.createPaste(editSession)
|
||||
.to(BlockVector3.at(lesser.getX(), lesser.getWorld().getMinHeight(), lesser.getZ()))
|
||||
.maskSource(mask)//ignore non-air blocks from the schematic.
|
||||
.ignoreAirBlocks(false) //well that would be silly, we want the air
|
||||
.build();
|
||||
Operations.complete(operation);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
RealEstate.instance.log.info("Failed to paste initial schematic: "+e.getMessage());
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
private void unRent(boolean msgBuyer)
|
||||
{
|
||||
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(sign, false, null);
|
||||
@ -236,48 +302,7 @@ public class ClaimRent extends BoughtTransaction
|
||||
}
|
||||
buyer = null;
|
||||
RealEstate.transactionsStore.saveData();
|
||||
//if worldedit saving is requested, here's where i load the saved area
|
||||
if((claim.isAdminClaim()&&RealEstate.instance.config.RestoreAdminOnly)|| !RealEstate.instance.config.RestoreAdminOnly) //if we are in an admin claim *and* admin only is selected, or if admin only is false
|
||||
{
|
||||
if(RealEstate.instance.getServer().getPluginManager().getPlugin("WorldEdit")!=null) //is world edit installed?
|
||||
{
|
||||
if(RealEstate.instance.config.RestoreRentalState)//are we configured to use it?
|
||||
{
|
||||
//load schematic, paste where we got it.
|
||||
String schempath = RealEstate.pluginDirPath + "/schematics/"+claim.getID().toString()+".schem";
|
||||
File file = new File(schempath);
|
||||
Clipboard clipboard =null;
|
||||
ClipboardFormat format= ClipboardFormats.findByFile(file);
|
||||
try (ClipboardReader reader = format.getReader(new FileInputStream(file))) {
|
||||
clipboard = reader.read();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
RealEstate.instance.log.info("Failed to import previously saved schematic: "+e.getMessage());
|
||||
update();
|
||||
return;
|
||||
}
|
||||
Location lesser=claim.getLesserBoundaryCorner();
|
||||
|
||||
com.sk89q.worldedit.world.World world = BukkitAdapter.adapt(lesser.getWorld());
|
||||
try (EditSession editSession = WorldEdit.getInstance().newEditSession(world)) {
|
||||
Operation operation = new ClipboardHolder(clipboard)
|
||||
.createPaste(editSession)
|
||||
.to(BlockVector3.at(lesser.getX(), lesser.getWorld().getMinHeight(), lesser.getZ()))
|
||||
// configure here
|
||||
.build();
|
||||
Operations.complete(operation);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
RealEstate.instance.log.info("Failed to paste initial schematic: "+e.getMessage());
|
||||
update();
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ClaimRent.restore_rental(claim);
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user