Improved economy (multiplies price * plots) :D

Added you to plugin.yml
This commit is contained in:
Sauilitired
2014-10-08 16:15:25 +02:00
parent 949bd6c9f5
commit 508b17a2a6
5 changed files with 203 additions and 140 deletions

View File

@ -9,19 +9,9 @@
package com.intellectualcrafters.plot;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import com.intellectualcrafters.plot.database.DBFunc;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
@ -29,7 +19,8 @@ import org.bukkit.block.Sign;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.database.DBFunc;
import java.io.File;
import java.util.*;
/**
* plot functions
@ -48,7 +39,7 @@ public class PlotHelper {
/**
* direction 0 = north, 1 = south, etc:
*
* @param plot
* @param id
* @param direction
* @return
*/
@ -66,6 +57,23 @@ public class PlotHelper {
return id;
}
public static boolean mergePlots(Player plr, World world, ArrayList<PlotId> plotIds) {
PlotWorld plotworld = PlotMain.getWorldSettings(world);
if(PlotMain.useEconomy && plotworld.USE_ECONOMY) {
double cost = plotIds.size() * plotworld.MERGE_PRICE;
if (cost > 0d) {
Economy economy = PlotMain.economy;
if (economy.getBalance(plr) < cost) {
PlayerFunctions.sendMessage(plr, C.CANNOT_AFFORD_MERGE, "" + cost);
return false;
}
economy.withdrawPlayer(plr, cost);
PlayerFunctions.sendMessage(plr, C.REMOVED_BALANCE, cost + "");
}
}
return mergePlots(world, plotIds);
}
/**
* Completely merges a set of plots<br>
* <b>(There are no checks to make sure you supply the correct

View File

@ -70,6 +70,7 @@ public class Auto extends SubCommand {
PlotWorld pWorld = PlotMain.getWorldSettings(world);
if(PlotMain.useEconomy && pWorld.USE_ECONOMY) {
double cost = pWorld.PLOT_PRICE;
cost = (size_x * size_z) * cost;
if (cost > 0d) {
Economy economy = PlotMain.economy;
if (economy.getBalance(plr) < cost) {
@ -119,16 +120,16 @@ public class Auto extends SubCommand {
PlotId start = new PlotId(x, z);
PlotId end = new PlotId((x + size_x) - 1, (z + size_z) - 1);
if (isUnowned(world, start, end)) {
// TODO claim event
// Claim.claimPlot calls that event...
for (int i = start.x; i <= end.x; i++) {
for (int j = start.y; j <= end.y; j++) {
Plot plot = PlotHelper.getPlot(world, new PlotId(i, j));
boolean teleport = ((i == end.x) && (j == end.y)) ? true : false;
boolean teleport = ((i == end.x) && (j == end.y));
Claim.claimPlot(plr, plot, teleport);
}
}
PlotHelper.mergePlots(world, PlayerFunctions.getPlotSelectionIds(world, start, end));
if(!PlotHelper.mergePlots(plr, world, PlayerFunctions.getPlotSelectionIds(world, start, end))) {
return false;
}
br = true;
}
if ((z < q) && ((z - x) < q)) {

View File

@ -9,24 +9,15 @@
package com.intellectualcrafters.plot.commands;
import java.util.ArrayList;
import com.intellectualcrafters.plot.*;
import com.intellectualcrafters.plot.events.PlotMergeEvent;
import net.milkbowl.vault.economy.Economy;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot;
import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld;
import com.intellectualcrafters.plot.SetBlockFast;
import com.intellectualcrafters.plot.events.PlotMergeEvent;
import java.util.ArrayList;
/**
*
@ -127,6 +118,7 @@ public class Merge extends SubCommand {
PlotWorld plotWorld = PlotMain.getWorldSettings(world);
if (PlotMain.useEconomy && plotWorld.USE_ECONOMY) {
double cost = plotWorld.MERGE_PRICE;
cost = plots.size() * cost;
if (cost > 0d) {
Economy economy = PlotMain.economy;
if (economy.getBalance(plr) < cost) {

View File

@ -4,7 +4,7 @@ version: 2.0.5
load: STARTUP
description: >
Easy, yet powerful Plot World generation and management.
authors: [Citymonstret, brandonrelph]
authors: [Citymonstret, Empire92]
softdepend: [WorldEdit, BarAPI, PlotMe, CameraAPI]
database: false
commands: