Auto claim the end island
This commit is contained in:
parent
3757b00fbf
commit
8cdccefdc7
|
|
@ -990,7 +990,7 @@ public abstract class DataStore
|
||||||
assignClaimID(newClaim); // assign a claim ID before calling event, in case a plugin wants to know the ID.
|
assignClaimID(newClaim); // assign a claim ID before calling event, in case a plugin wants to know the ID.
|
||||||
ClaimCreatedEvent event = new ClaimCreatedEvent(newClaim, creatingPlayer);
|
ClaimCreatedEvent event = new ClaimCreatedEvent(newClaim, creatingPlayer);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
if (event.isCancelled())
|
if (event.isCancelled() && creatingPlayer != null)
|
||||||
{
|
{
|
||||||
result.succeeded = false;
|
result.succeeded = false;
|
||||||
result.claim = null;
|
result.claim = null;
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import me.ryanhamshire.GriefPrevention.DataStore.NoTransferException;
|
||||||
import me.ryanhamshire.GriefPrevention.events.PreventBlockBreakEvent;
|
import me.ryanhamshire.GriefPrevention.events.PreventBlockBreakEvent;
|
||||||
import me.ryanhamshire.GriefPrevention.events.SaveTrappedPlayerEvent;
|
import me.ryanhamshire.GriefPrevention.events.SaveTrappedPlayerEvent;
|
||||||
import me.ryanhamshire.GriefPrevention.events.TrustChangedEvent;
|
import me.ryanhamshire.GriefPrevention.events.TrustChangedEvent;
|
||||||
|
import me.ryanhamshire.GriefPrevention.listeners.AltitudeListener;
|
||||||
import me.ryanhamshire.GriefPrevention.metrics.MetricsHandler;
|
import me.ryanhamshire.GriefPrevention.metrics.MetricsHandler;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.bukkit.BanList;
|
import org.bukkit.BanList;
|
||||||
|
|
@ -387,6 +388,7 @@ public class GriefPrevention extends JavaPlugin
|
||||||
new IgnoreLoaderThread(player.getUniqueId(), this.dataStore.getPlayerData(player.getUniqueId()).ignoredPlayers).start();
|
new IgnoreLoaderThread(player.getUniqueId(), this.dataStore.getPlayerData(player.getUniqueId()).ignoredPlayers).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new AltitudeListener(this.dataStore, this);
|
||||||
AddLogEntry("Boot finished.");
|
AddLogEntry("Boot finished.");
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
class WordFinder
|
public class WordFinder // make public
|
||||||
{
|
{
|
||||||
private Pattern pattern;
|
private Pattern pattern;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package me.ryanhamshire.GriefPrevention.listeners;
|
||||||
|
|
||||||
|
import me.ryanhamshire.GriefPrevention.CreateClaimResult;
|
||||||
|
import me.ryanhamshire.GriefPrevention.DataStore;
|
||||||
|
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||||
|
import me.ryanhamshire.GriefPrevention.Messages;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public class AltitudeListener implements Listener {
|
||||||
|
|
||||||
|
private final GriefPrevention plugin;
|
||||||
|
|
||||||
|
public AltitudeListener(DataStore dataStore, GriefPrevention plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.worldInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void info(String s) {
|
||||||
|
plugin.getLogger().info(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void worldInit() {
|
||||||
|
for(World world : Bukkit.getWorlds()) {
|
||||||
|
// info("Scanning world " + world.getName());
|
||||||
|
if (world.getEnvironment() == World.Environment.THE_END) {
|
||||||
|
CreateClaimResult result = plugin.dataStore.createClaim(world,
|
||||||
|
-250, 250,
|
||||||
|
0, 256,
|
||||||
|
250, -250,
|
||||||
|
null, null, null, null);
|
||||||
|
if (!result.succeeded) {
|
||||||
|
if (result.claim != null) {
|
||||||
|
// info(Messages.CreateClaimFailOverlapShort.toString());
|
||||||
|
} else {
|
||||||
|
// info(Messages.CreateClaimFailOverlapRegion.toString());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// info(Messages.CreateClaimSuccess.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user