Fixed player time / music / expire keep / Economy / remove unused messages

This commit is contained in:
boy0001 2015-06-10 04:54:00 +10:00
parent 66a15d8d59
commit 5f3fab5e42
10 changed files with 57 additions and 24 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>2.11.15</version> <version>2.11.17</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>

View File

@ -374,7 +374,11 @@ public class PlotSquared {
config.createSection(path); config.createSection(path);
} }
plotWorld.TYPE = 2; System.out.print("GENERATOR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
System.out.print(generator != null);
System.out.print(generator instanceof PlotGenerator);
plotWorld.TYPE = generator instanceof PlotGenerator ? 0 : 2;
plotWorld.TERRAIN = 0; plotWorld.TERRAIN = 0;
plotWorld.saveConfiguration(config.getConfigurationSection(path)); plotWorld.saveConfiguration(config.getConfigurationSection(path));
plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path)); plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path));

View File

@ -194,10 +194,6 @@ public enum C {
TITLE_ENTERED_PLOT_COLOR("GOLD", "Titles"), TITLE_ENTERED_PLOT_COLOR("GOLD", "Titles"),
TITLE_ENTERED_PLOT_SUB("Owned by %s", "Titles"), TITLE_ENTERED_PLOT_SUB("Owned by %s", "Titles"),
TITLE_ENTERED_PLOT_SUB_COLOR("RED", "Titles"), TITLE_ENTERED_PLOT_SUB_COLOR("RED", "Titles"),
TITLE_LEFT_PLOT("You left plot %s", "Titles"),
TITLE_LEFT_PLOT_COLOR("GOLD", "Titles"),
TITLE_LEFT_PLOT_SUB("Owned by %s", "Titles"),
TITLE_LEFT_PLOT_SUB_COLOR("RED", "Titles"),
PREFIX_GREETING("$1%id%$2> ", "Titles"), PREFIX_GREETING("$1%id%$2> ", "Titles"),
PREFIX_FAREWELL("$1%id%$2> ", "Titles"), PREFIX_FAREWELL("$1%id%$2> ", "Titles"),
/* /*

View File

@ -39,10 +39,13 @@ import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.BukkitPlayer;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.comment.CommentManager; import com.intellectualcrafters.plot.object.comment.CommentManager;
import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.titles.AbstractTitle;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
/** /**
@ -108,7 +111,7 @@ public class PlotListener extends APlotListener {
if (timeFlag != null) { if (timeFlag != null) {
try { try {
final long time = (long) timeFlag.getValue(); final long time = (long) timeFlag.getValue();
player.setPlayerTime(time, true); player.setPlayerTime(time, false);
} catch (final Exception e) { } catch (final Exception e) {
FlagManager.removePlotFlag(plot, "time"); FlagManager.removePlotFlag(plot, "time");
} }
@ -126,8 +129,12 @@ public class PlotListener extends APlotListener {
else { else {
greeting = ""; greeting = "";
} }
final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "").replaceAll("%greeting%", greeting).replaceFirst("%s", getName(plot.owner)); String alias = plot.settings.getAlias();
final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "").replaceAll("%greeting%", greeting).replaceFirst("%s", getName(plot.owner)); if (alias.length() == 0) {
alias = plot.toString();
}
final String sTitleMain = C.TITLE_ENTERED_PLOT.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "").replaceAll("%greeting%", greeting).replaceAll("%s", getName(plot.owner)).replaceAll("%alias%", alias);
final String sTitleSub = C.TITLE_ENTERED_PLOT_SUB.s().replaceAll("%x%", plot.id.x + "").replaceAll("%z%", plot.id.y + "").replaceAll("%world%", plot.world + "").replaceAll("%greeting%", greeting).replaceAll("%s", getName(plot.owner)).replaceAll("%alias%", alias);
AbstractTitle.sendTitle(pp, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s())); AbstractTitle.sendTitle(pp, sTitleMain, sTitleSub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()));
} }
{ {
@ -139,7 +146,10 @@ public class PlotListener extends APlotListener {
player.playEffect(player.getLocation(), Effect.RECORD_PLAY, 0); player.playEffect(player.getLocation(), Effect.RECORD_PLAY, 0);
Integer id = (Integer) musicFlag.getValue(); Integer id = (Integer) musicFlag.getValue();
if (id != 0) { if (id != 0) {
player.playEffect(player.getLocation(), Effect.RECORD_PLAY, Material.getMaterial(id)); Location center = MainUtil.getPlotCenter(plot);
org.bukkit.Location newLoc = BukkitUtil.getLocation(center);
newLoc.setY(Math.min((((int) player.getLocation().getBlockY())/16) * 16, 240));
player.playEffect(newLoc, Effect.RECORD_PLAY, Material.getMaterial(id));
} }
} }
CommentManager.sendTitle(pp, plot); CommentManager.sendTitle(pp, plot);
@ -163,7 +173,12 @@ public class PlotListener extends APlotListener {
player.resetPlayerWeather(); player.resetPlayerWeather();
} }
if (FlagManager.getPlotFlag(plot, "music") != null) { if (FlagManager.getPlotFlag(plot, "music") != null) {
player.playEffect(player.getLocation(), Effect.RECORD_PLAY, 0); Location center = MainUtil.getPlotCenter(plot);
for (int i = 0; i < 256; i+= 16) {
org.bukkit.Location newLoc = BukkitUtil.getLocation(center);
newLoc.setY(i);
player.playEffect(newLoc, Effect.RECORD_PLAY, 0);
}
} }
} }

View File

@ -7,9 +7,9 @@ public abstract class EconHandler {
public static EconHandler manager; public static EconHandler manager;
public abstract double getMoney(PlotPlayer player); public abstract double getMoney(PlotPlayer player);
public abstract double withdrawMoney(PlotPlayer player, double amount); public abstract void withdrawMoney(PlotPlayer player, double amount);
public abstract double depositMoney(PlotPlayer player, double amount); public abstract void depositMoney(PlotPlayer player, double amount);
public abstract double depositMoney(OfflinePlotPlayer player, double amount); public abstract void depositMoney(OfflinePlotPlayer player, double amount);
public abstract void setPermission(PlotPlayer player, String perm, boolean value); public abstract void setPermission(PlotPlayer player, String perm, boolean value);
public abstract boolean getPermission(PlotPlayer player, String perm); public abstract boolean getPermission(PlotPlayer player, String perm);
} }

View File

@ -126,7 +126,7 @@ public class ExpireManager {
@Override @Override
public void run() { public void run() {
int changed = (int) this.value; int changed = (int) this.value;
if (changed >= Settings.MIN_BLOCKS_CHANGED) { if (changed >= Settings.MIN_BLOCKS_CHANGED && Settings.MIN_BLOCKS_CHANGED > 0) {
PlotSquared.log("&aKeep flag added to: " + plot.id + (changed != -1 ? " (changed " + value + ")" : "")); PlotSquared.log("&aKeep flag added to: " + plot.id + (changed != -1 ? " (changed " + value + ")" : ""));
FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("keep"), true)); FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("keep"), true));
expiredPlots.get(world).remove(plot); expiredPlots.get(world).remove(plot);

View File

@ -67,6 +67,12 @@ public class MainUtil {
return true; return true;
} }
public static Location getPlotCenter(Plot plot) {
Location bot = getPlotBottomLoc(plot.world, plot.id);
Location top = getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
return new Location(plot.world, bot.getX() + (top.getX() - bot.getX()) / 2, 0, bot.getZ() + (top.getZ() - bot.getZ()) / 2);
}
/** /**
* Merges all plots in the arraylist (with cost) * Merges all plots in the arraylist (with cost)
* *

View File

@ -6,6 +6,7 @@ import java.util.Map.Entry;
import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.generator.AugmentedPopulator;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
public class SetBlockQueue { public class SetBlockQueue {
@ -130,6 +131,16 @@ public class SetBlockQueue {
running = true; running = true;
} }
} }
public static void setChunk(final String world, ChunkLoc loc, PlotBlock[][] result) {
locked = true;
if (!running) {
init();
}
ChunkWrapper wrap = new ChunkWrapper(world, loc.x, loc.z);
blocks.put(wrap, result);
locked = false;
}
public static void setBlock(final String world, int x, final int y, int z, final PlotBlock block) { public static void setBlock(final String world, int x, final int y, int z, final PlotBlock block) {
locked = true; locked = true;

View File

@ -46,26 +46,22 @@ public class BukkitEconHandler extends EconHandler {
@Override @Override
public double getMoney(PlotPlayer player) { public double getMoney(PlotPlayer player) {
econ.getBalance(player.getName()); return econ.getBalance(player.getName());
return 0;
} }
@Override @Override
public double withdrawMoney(PlotPlayer player, double amount) { public void withdrawMoney(PlotPlayer player, double amount) {
econ.withdrawPlayer(player.getName(), amount); econ.withdrawPlayer(player.getName(), amount);
return 0;
} }
@Override @Override
public double depositMoney(PlotPlayer player, double amount) { public void depositMoney(PlotPlayer player, double amount) {
econ.depositPlayer(player.getName(), amount); econ.depositPlayer(player.getName(), amount);
return 0;
} }
@Override @Override
public double depositMoney(OfflinePlotPlayer player, double amount) { public void depositMoney(OfflinePlotPlayer player, double amount) {
econ.depositPlayer(((BukkitOfflinePlayer) player).player, amount); econ.depositPlayer(((BukkitOfflinePlayer) player).player, amount);
return 0;
} }
@Override @Override

View File

@ -26,12 +26,17 @@ public class BukkitSetupUtils extends SetupUtils {
} }
final String testWorld = "CheckingPlotSquaredGenerator"; final String testWorld = "CheckingPlotSquaredGenerator";
for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) { for (final Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
System.out.print(plugin.getName());
if (plugin.isEnabled()) { if (plugin.isEnabled()) {
System.out.print(" - enabled");
final ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, ""); final ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
if (generator != null) { if (generator != null) {
System.out.print(" - non null");
PlotSquared.removePlotWorld(testWorld); PlotSquared.removePlotWorld(testWorld);
final String name = plugin.getDescription().getName(); final String name = plugin.getDescription().getName();
// if (generator instanceof PlotGenerator) { if (generator instanceof PlotGenerator) {
System.out.print(" - ps gen");
}
// final PlotGenerator pgen = (PlotGenerator) generator; // final PlotGenerator pgen = (PlotGenerator) generator;
// if (pgen.getPlotManager() instanceof SquarePlotManager) { // if (pgen.getPlotManager() instanceof SquarePlotManager) {
SetupUtils.generators.put(name, generator); SetupUtils.generators.put(name, generator);