Adding WorldBorder Events

This commit is contained in:
timafh 2015-09-04 20:20:27 +02:00
parent a349063a74
commit e42c5be1dc
4 changed files with 94 additions and 11 deletions

View File

@ -0,0 +1,37 @@
package com.wimbli.WorldBorder.Events;
import org.bukkit.World;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Created by timafh on 04.09.2015.
*/
public class WorldBorderFillFinishedEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private World world;
private long totalChunks;
public WorldBorderFillFinishedEvent(World world, long totalChunks) {
this.world = world;
this.totalChunks = totalChunks;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public World getWorld() {
return world;
}
public long getTotalChunks() {
return totalChunks;
}
}

View File

@ -0,0 +1,37 @@
package com.wimbli.WorldBorder.Events;
import org.bukkit.World;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Created by timafh on 04.09.2015.
*/
public class WorldBorderTrimFinishedEvent extends Event {
private static final HandlerList handlers = new HandlerList();
private World world;
private long totalChunks;
public WorldBorderTrimFinishedEvent(World world, long totalChunks) {
this.world = world;
this.totalChunks = totalChunks;
}
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
public World getWorld() {
return world;
}
public long getTotalChunks() {
return totalChunks;
}
}

View File

@ -1,14 +1,16 @@
package com.wimbli.WorldBorder;
import java.util.HashSet;
import java.util.List;
import java.util.LinkedList;
import java.util.Set;
import com.wimbli.WorldBorder.Events.WorldBorderFillFinishedEvent;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.entity.Player;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
public class WorldFillTask implements Runnable
@ -312,6 +314,7 @@ public class WorldFillTask implements Runnable
this.paused = true;
reportProgress();
world.save();
Bukkit.getServer().getPluginManager().callEvent(new WorldBorderFillFinishedEvent(world, reportTotal));
sendMessage("task successfully completed for world \"" + refWorld() + "\"!");
this.stop();
}

View File

@ -1,12 +1,17 @@
package com.wimbli.WorldBorder;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import com.wimbli.WorldBorder.Events.WorldBorderTrimFinishedEvent;
import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.ArrayList;
import java.util.List;
public class WorldTrimTask implements Runnable
@ -334,6 +339,7 @@ public class WorldTrimTask implements Runnable
{
reportTotal = reportTarget;
reportProgress();
Bukkit.getServer().getPluginManager().callEvent(new WorldBorderTrimFinishedEvent(world, reportTotal));
sendMessage("task successfully completed!");
this.stop();
}