Skip to content

Commit

Permalink
1.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
hultberg committed Oct 25, 2017
1 parent 29030df commit 7ee9972
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 28 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

### 1.3.5

* Deny builders to place water and lava.
* Deny builders placing and removing bedrock.
* Deny builders to ignite blocks.

### 1.3.4

* Allow to configure motd.
Expand Down
2 changes: 1 addition & 1 deletion dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.mittnett.reke</groupId>
<artifactId>Rekeverden</artifactId>
<version>1.3.4</version>
<version>1.3.5</version>
<developers>
<developer>
<id>thypthon</id>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

<groupId>net.mittnett.reke</groupId>
<artifactId>Rekeverden</artifactId>
<version>1.3.4</version>
<version>1.3.5</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package net.mittnett.reke.Rekeverden.listeners;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

Expand All @@ -17,6 +19,7 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockPlaceEvent;

public class BlockListener implements org.bukkit.event.Listener {
Expand All @@ -30,6 +33,11 @@ public BlockListener(Rekeverden plugin) {
this.blockInfoHandler = plugin.getBlockInfoHandler();
}

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockIgnite(BlockIgniteEvent event) {
event.setCancelled(true);
}

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
Block block = event.getBlock();
Expand All @@ -47,6 +55,16 @@ public void onBlockPlace(BlockPlaceEvent event) {
return;
}

if (block.getType() == Material.BEDROCK && !user.hasAccessLevel(User.MODERATOR)) {
event.setCancelled(true);
return;
}

if (!user.hasAccessLevel(User.MODERATOR) && (block.getType() == Material.LAVA || block.getType() == Material.WATER)) {
event.setCancelled(true);
return;
}

if (block.getType() == Material.TNT && !user.hasAccessLevel(User.MODERATOR)) {
event.setCancelled(true);
return;
Expand Down Expand Up @@ -149,8 +167,13 @@ public void onBlockBreak(BlockBreakEvent event) {
return;
}

User owner = this.bpHandler.getOwnerUser(l);
if (block.getType() == Material.BEDROCK && !user.hasAccessLevel(User.MODERATOR)) {
event.setCancelled(true);
return;
}

User owner = this.bpHandler.getOwnerUser(l);
HashSet<Block> blocks = new HashSet<>();

switch (block.getType()) {
case WALL_SIGN:
Expand All @@ -160,7 +183,6 @@ public void onBlockBreak(BlockBreakEvent event) {
return;
}


break;
case CHEST:
case FURNACE:
Expand Down Expand Up @@ -193,9 +215,10 @@ public void onBlockBreak(BlockBreakEvent event) {
player.sendMessage(ChatColor.RED + "to create a group or invite a user.");
event.setCancelled(true);
return;
} else if (ownerOfUp != null) {
blocks.add(blockOver);
}


break;
}

Expand All @@ -210,28 +233,35 @@ public void onBlockBreak(BlockBreakEvent event) {
return;
}

// Remove protection of this block.
new Thread(() -> {
blocks.add(block);
}

if (!blocks.isEmpty()) {
// Remove protection of this block.
new Thread(() -> {
for (Block blockToRemove : blocks) {
Location locOfBlock = blockToRemove.getLocation();

this.bpHandler.unProtect(
l.getBlockX(),
l.getBlockY(),
l.getBlockZ(),
l.getWorld().getName()
locOfBlock.getBlockX(),
locOfBlock.getBlockY(),
locOfBlock.getBlockZ(),
locOfBlock.getWorld().getName()
);
}).start();
}

new Thread(() -> {
// Log removal of this block.
this.blockInfoHandler.log(user
.getId(), l
.getBlockX(), l
.getBlockY(), l
.getBlockZ(), l
.getWorld().getName(), block
.getTypeId(), block
.getData(), BlockAction.REMOVED);
}).start();
this.blockInfoHandler.log(
user.getId(),
locOfBlock.getBlockX(),
locOfBlock.getBlockY(),
locOfBlock.getBlockZ(),
locOfBlock.getWorld().getName(),
blockToRemove.getTypeId(),
blockToRemove.getData(),
BlockAction.REMOVED
);
}
}).start();
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,21 @@ public void onPlayerInteract(PlayerInteractEvent event) {
}

private void handInteractEvent(PlayerInteractEvent event) {
if (event.getHand() != null && event.getItem() != null) {
switch (event.getItem().getType()) {
case LAVA_BUCKET:
case WATER_BUCKET:
User user = this.userHandler.getUser(event.getPlayer().getUniqueId());

if (user != null && !user.hasAccessLevel(User.MODERATOR)) {
event.setCancelled(true);
return;
}

break;
}
}

switch (event.getAction()) {
case LEFT_CLICK_BLOCK:
this.handLeftClickBlock(event);
Expand Down Expand Up @@ -230,6 +245,10 @@ private void handleRightClickBlock(PlayerInteractEvent event) {
}

private void handLeftClickBlock(PlayerInteractEvent event) {
Player player = event.getPlayer();
Block clickedBlock = event.getClickedBlock();
User user = this.plugin.getUserHandler().getUser(player.getUniqueId());

if (event.getItem() != null) {
switch (event.getItem().getType()) {
case DIAMOND_PICKAXE:
Expand All @@ -256,10 +275,6 @@ private void handLeftClickBlock(PlayerInteractEvent event) {
return;

case BOOK:
Player player = event.getPlayer();
Block clickedBlock = event.getClickedBlock();
User user = this.plugin.getUserHandler().getUser(player.getUniqueId());

if ((player.getGameMode() != GameMode.CREATIVE) && (user.hasEnabledSelectTool())) {
user.setSelectToolPoint1(clickedBlock.getLocation());
player.sendMessage(
Expand Down

0 comments on commit 7ee9972

Please sign in to comment.