Skip to content

Commit

Permalink
This is v3.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Bysokar committed Jun 24, 2017
1 parent f926f39 commit c32f7f1
Show file tree
Hide file tree
Showing 16 changed files with 1,026 additions and 819 deletions.
2 changes: 0 additions & 2 deletions com/draksterau/Regenerator/RegeneratorPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.draksterau.Regenerator.listeners.eventListener;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.logging.Logger;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
Expand All @@ -13,7 +12,6 @@
import com.draksterau.Regenerator.integration.Integration;
import com.draksterau.Regenerator.tasks.lagTask;
import com.draksterau.Regenerator.tasks.regenTask;
import com.draksterau.Regenerator.Handlers.RChunk;
import com.draksterau.Regenerator.Handlers.RConfig;
import com.draksterau.Regenerator.Handlers.RLang;
import com.draksterau.Regenerator.Handlers.RUtils;
Expand Down
57 changes: 32 additions & 25 deletions com/draksterau/Regenerator/commands/regenCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
package com.draksterau.Regenerator.commands;

import com.draksterau.Regenerator.Handlers.RChunk;
import com.draksterau.Regenerator.Handlers.RWorld;
import com.draksterau.Regenerator.event.RegenerationRequestEvent;
import com.draksterau.Regenerator.event.RequestTrigger;
import com.draksterau.Regenerator.integration.Integration;
import com.draksterau.Regenerator.tasks.ChunkTask;
import org.bukkit.Bukkit;
Expand All @@ -32,36 +33,42 @@ public void doCommand() {
} else {
if (command.plugin.utils.isLagOK()) {
Chunk rootChunk = command.plugin.utils.getSenderPlayer(command.sender).getLocation().getChunk();
RChunk rChunk = new RChunk(command.plugin, rootChunk.getX(), rootChunk.getZ(), rootChunk.getWorld().getName());
if (command.plugin.utils.canManuallyRegen(command.plugin.utils.getSenderPlayer(command.sender), rootChunk)) {
Bukkit.getServer().getScheduler().runTask(command.plugin, new ChunkTask(rChunk, true));
rChunk.resetActivity();
Player player = command.plugin.utils.getSenderPlayer(command.sender);
Integration integration = command.plugin.utils.getIntegrationForChunk(player.getLocation().getChunk());
if (integration != null && integration.isChunkClaimed(rootChunk)) {
player.sendMessage(command.plugin.utils.getFancyName() + integration.getPlayerRegenReason(player, rootChunk));
} else {
player.sendMessage(command.plugin.utils.getFancyName() + ChatColor.GREEN + "The unclaimed area around you has been regenerated.");
}
} else {
Chunk senderChunk = command.plugin.utils.getSenderChunk(command.sender);
Player player = command.plugin.utils.getSenderPlayer(command.sender);
if (!rChunk.canManualRegen()) {
player.sendMessage(command.plugin.utils.getFancyName() + ChatColor.RED + "Failed to perform manual regeneration as the world you are on has it disabled.");
RChunk rChunk = new RChunk(command.plugin, rootChunk.getX(), rootChunk.getZ(), rootChunk.getWorld().getName());
Player player = command.plugin.utils.getSenderPlayer(command.sender);
RegenerationRequestEvent requestEvent = new RegenerationRequestEvent(player.getLocation(), player, RequestTrigger.Command, command.plugin);
Bukkit.getServer().getPluginManager().callEvent(requestEvent);
if (!requestEvent.isCancelled()) {
if (command.plugin.utils.canManuallyRegen(command.plugin.utils.getSenderPlayer(command.sender), rootChunk)) {
Bukkit.getServer().getScheduler().runTask(command.plugin, new ChunkTask(rChunk, true));
rChunk.resetActivity();
Integration integration = command.plugin.utils.getIntegrationForChunk(player.getLocation().getChunk());
if (integration != null && integration.isChunkClaimed(rootChunk)) {
player.sendMessage(command.plugin.utils.getFancyName() + integration.getPlayerRegenReason(player, rootChunk));
} else {
player.sendMessage(command.plugin.utils.getFancyName() + ChatColor.GREEN + "The unclaimed area around you has been regenerated.");
}
} else {
if (command.plugin.utils.getCountIntegration(player.getLocation().getChunk()) == 1) {
player.sendMessage(command.plugin.utils.getFancyName() + command.plugin.utils.getIntegrationForChunk(senderChunk).getPlayerRegenReason(player, rootChunk));
player.sendMessage(command.plugin.utils.getFancyName() + "This requires the permission node: " + command.plugin.utils.getIntegrationForChunk(senderChunk).getPermissionRequiredToRegen(player, rootChunk));
Chunk senderChunk = command.plugin.utils.getSenderChunk(command.sender);
if (!rChunk.canManualRegen()) {
player.sendMessage(command.plugin.utils.getFancyName() + ChatColor.RED + "Failed to perform manual regeneration as the world you are on has it disabled.");
} else {
if (command.plugin.utils.getCountIntegration(player.getLocation().getChunk()) > 1) {
player.sendMessage(command.plugin.utils.getFancyName() + ChatColor.RED + "This chunk is claimed by more than one grief prevention plugin. It can only be regenerated by OPS or those with the regenerator.regen.override permission node.");
if (command.plugin.utils.getCountIntegration(player.getLocation().getChunk()) == 1) {
player.sendMessage(command.plugin.utils.getFancyName() + command.plugin.utils.getIntegrationForChunk(senderChunk).getPlayerRegenReason(player, rootChunk));
player.sendMessage(command.plugin.utils.getFancyName() + "This requires the permission node: " + command.plugin.utils.getIntegrationForChunk(senderChunk).getPermissionRequiredToRegen(player, rootChunk));
} else {
player.sendMessage(command.plugin.utils.getFancyName() + ChatColor.RED + "This chunk is unclaimed and requires the regenerator.regen.unclaimed permission node to regenerate.");
if (command.plugin.utils.getCountIntegration(player.getLocation().getChunk()) > 1) {
player.sendMessage(command.plugin.utils.getFancyName() + ChatColor.RED + "This chunk is claimed by more than one grief prevention plugin. It can only be regenerated by OPS or those with the regenerator.regen.override permission node.");
} else {
player.sendMessage(command.plugin.utils.getFancyName() + ChatColor.RED + "This chunk is unclaimed and requires the regenerator.regen.unclaimed permission node to regenerate.");
}
}
}
}


} else {
player.sendMessage(command.plugin.utils.getFancyName() + ChatColor.RED + "Regeneration Request denied due to the following:");
for (String s : requestEvent.getCancelledReasons().keySet()) {
player.sendMessage(command.plugin.utils.getFancyName() + ChatColor.RED + s + " provided by : " + requestEvent.getCancelledReasons().get(s).getName() + ".");
}
}
} else {
command.plugin.utils.getSenderPlayer(command.sender).sendMessage(command.plugin.utils.getFancyName() + ChatColor.RED + "Regeneration capabilities have been suspended - TPS has dropped below what is set in configuration.");
Expand Down
20 changes: 20 additions & 0 deletions com/draksterau/Regenerator/event/RegenerationActionEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.draksterau.Regenerator.event;

import org.bukkit.Chunk;
import org.bukkit.Location;

/**
*
* @author draks
*/
public class RegenerationActionEvent extends RegenerationEvent {

public RegenerationActionEvent(Location location) {
super(location);
}
}
80 changes: 80 additions & 0 deletions com/draksterau/Regenerator/event/RegenerationEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.draksterau.Regenerator.event;

import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;

/**
*
* @author draks
*/
public class RegenerationEvent extends Event {

private Location location;
private boolean cancelled = false;
private HashMap<String, JavaPlugin> reasons = new HashMap<>();
private static final HandlerList handlers = new HandlerList();

public static HandlerList getHandlerList() {
return handlers;
}

public RegenerationEvent(Location location) {
this.location = location;
}

@Override
public HandlerList getHandlers() {
return handlers;
}

public boolean isCancelled() {
return this.cancelled;
}

public Chunk getChunk() {
return location.getChunk();
}

public Block getBlock() {
return location.getBlock();
}

public Location getLocation() {
return this.location;
}

public World getWorld() {
return location.getWorld();
}

public void clearCancellations() {
this.reasons.clear();
this.cancelled = false;
}

public HashMap<String, JavaPlugin> getCancelledReasons() {
return this.reasons;
}

public void cancelWithReason(String reason, JavaPlugin yourPlugin) {
if (!this.cancelled) this.cancelled = true;
if (!this.reasons.keySet().contains(reason)) this.reasons.put(reason, yourPlugin);
}

}



49 changes: 49 additions & 0 deletions com/draksterau/Regenerator/event/RegenerationRequestEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.draksterau.Regenerator.event;

import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

/**
*
* @author draks
*/
public class RegenerationRequestEvent extends RegenerationEvent {

private final Player requestor;
private RequestTrigger trigger = RequestTrigger.Unknown;
private boolean performImmediately = false;
private JavaPlugin plugin;

public RegenerationRequestEvent(Location location, Player player, RequestTrigger trigger, JavaPlugin requestingPlugin) {
super(location);
this.requestor = player;
this.trigger = trigger;
this.plugin = requestingPlugin;
}

public JavaPlugin getPluginRequestor() {
return this.plugin;
}

public boolean isImmediate() {
return this.performImmediately;
}

public void setIsImmediate(boolean val) {
this.performImmediately = val;
}

public RequestTrigger getTrigger() {
return this.trigger;
}

public Player getRequestor() {
return this.requestor;
}
}
18 changes: 18 additions & 0 deletions com/draksterau/Regenerator/event/RequestTrigger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.draksterau.Regenerator.event;

/**
*
* @author draks
*/
public enum RequestTrigger {
Break,
Place,
Explosion,
Command,
Unknown;
}
Loading

0 comments on commit c32f7f1

Please sign in to comment.