From 949bd6c9f5370e5ce344fc0ba5c67d224fa8ddeb Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Wed, 8 Oct 2014 16:06:06 +0200 Subject: [PATCH 1/5] Updated plugin info: New link, total downloads + newest version --- .../plot/commands/plugin.java | 66 ++++++++++++++----- 1 file changed, 51 insertions(+), 15 deletions(-) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/plugin.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/plugin.java index 7a58d17dd..00ca7ff68 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/plugin.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/plugin.java @@ -9,13 +9,17 @@ package com.intellectualcrafters.plot.commands; -import java.util.ArrayList; - -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.PlayerFunctions; import com.intellectualcrafters.plot.PlotMain; -import com.intellectualcrafters.plot.Settings; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; public class plugin extends SubCommand { @@ -24,18 +28,50 @@ public class plugin extends SubCommand { } @Override - public boolean execute(Player plr, String... args) { - ArrayList strings = new ArrayList() { - { - add(String.format("&c>> &6PlotSquared (Version: %s)", PlotMain.getMain().getDescription().getVersion())); - add(String.format("&c>> &6Made by Citymonstret and brandonrelph")); - add(String.format("&c>> &6Download at %s", Settings.URL)); + public boolean execute(final Player plr, String... args) { + Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() { + @Override + public void run() { + ArrayList strings = new ArrayList() { + { + String + downloads = getInfo("https://intellectualsites.com/spigot_api.php?method=downloads&url=http://www.spigotmc.org/resources/plotsquared.1177/"), + version = getInfo("https://intellectualsites.com/spigot_api.php?method=version&resource=1177"); + add(String.format("&c>> &6PlotSquared (Version: %s)", PlotMain.getMain().getDescription().getVersion())); + add(String.format("&c>> &6Made by Citymonstret and Empire92")); + add(String.format("&c>> &6Download at &lhttp://i-s.link/ps")); + add(String.format("&c>> &cNewest Version (Spigot): %s", version)); + add(String.format("&c>> &cTotal Downloads (Spigot): %s", downloads)); + } + }; + for (String s : strings) { + PlayerFunctions.sendMessage(plr, s); + } } - }; - for (String s : strings) { - PlayerFunctions.sendMessage(plr, s); - } + }); return true; } + /** + * + * @param link + * @return + */ + private String getInfo(String link) { + try { + URLConnection connection = new URL(link).openConnection(); + connection.addRequestProperty("User-Agent", "Mozilla/4.0"); + BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); + String document = "", line; + while ((line = reader.readLine()) != null) { + document += (line + "\n"); + } + reader.close(); + return document; + } catch(Exception e) { + e.printStackTrace(); + return ""; + } + } + } From 508b17a2a6ea7e64bd4e8bb27e72d290abbea811 Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Wed, 8 Oct 2014 16:15:25 +0200 Subject: [PATCH 2/5] 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: From 8315121d668fb1d2f83b2497de8c530a0e36c17b Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Wed, 8 Oct 2014 16:26:46 +0200 Subject: [PATCH 3/5] Yup. --- .idea/workspace.xml | 310 +++++++++++------- .../intellectualcrafters/plot/PlotMain.java | 4 +- .../plot/UUIDHandler.java | 25 +- .../plot/commands/Denied.java | 24 +- .../plot/commands/Helpers.java | 24 +- .../plot/commands/Info.java | 17 +- .../plot/commands/SetOwner.java | 17 +- .../plot/commands/Trusted.java | 23 +- .../plot/commands/list.java | 17 +- 9 files changed, 268 insertions(+), 193 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 8a4fd94f5..6624eb1ee 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -13,10 +13,14 @@
- - - - + + + + + + + + @@ -40,41 +44,66 @@ - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + - - + + - - + + - - + + @@ -83,34 +112,39 @@ - + - - + + - - - - - - + + + - - + + - - - - - + + + + + + + + + + + + + @@ -152,12 +186,9 @@ @@ -600,7 +639,7 @@ - + 1411382351159 @@ -694,11 +733,15 @@ 1412777166979 1412777166979 -