From 508b17a2a6ea7e64bd4e8bb27e72d290abbea811 Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Wed, 8 Oct 2014 16:15:25 +0200 Subject: [PATCH] Improved economy (multiplies price * plots) :D Added you to plugin.yml --- .idea/workspace.xml | 278 +++++++++++------- .../intellectualcrafters/plot/PlotHelper.java | 38 ++- .../plot/commands/Auto.java | 9 +- .../plot/commands/Merge.java | 16 +- PlotSquared/src/plugin.yml | 2 +- 5 files changed, 203 insertions(+), 140 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a077bf067..8a4fd94f5 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -14,8 +14,9 @@ - - + + + @@ -38,38 +39,83 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -92,7 +138,6 @@ @@ -157,6 +206,8 @@ + + @@ -335,8 +386,6 @@ - - @@ -550,7 +599,8 @@ - + + 1411382351159 @@ -636,11 +686,19 @@ 1412599888665 1412599888665 - - @@ -678,6 +736,7 @@ + @@ -689,7 +748,6 @@ - @@ -727,7 +785,9 @@ - @@ -739,28 +799,6 @@ - - - - - - - - - - - - - - - - - - - - - - @@ -803,13 +841,6 @@ - - - - - - - @@ -936,13 +967,6 @@ - - - - - - - @@ -998,7 +1022,6 @@ - @@ -1006,7 +1029,6 @@ - @@ -1017,19 +1039,10 @@ - - - - - - - - - @@ -1045,7 +1058,6 @@ - @@ -1065,19 +1077,10 @@ - - - - - - - - - @@ -1097,21 +1100,80 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java index 2f1cdaf18..29250b4a1 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotHelper.java @@ -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 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
* (There are no checks to make sure you supply the correct diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java index ab55f1426..7943ae1ec 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Auto.java @@ -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)) { diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java index 63b231e28..2fb53e1eb 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Merge.java @@ -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) { diff --git a/PlotSquared/src/plugin.yml b/PlotSquared/src/plugin.yml index c4ba2f754..671cdba1b 100644 --- a/PlotSquared/src/plugin.yml +++ b/PlotSquared/src/plugin.yml @@ -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: