Skip to content

Commit

Permalink
1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
hultberg committed Oct 18, 2017
1 parent 6cd8a5a commit 073f1f5
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 66 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.3

* Log block changes in new Threads.
* Showing blocklog is now done own thread, preventing lag.
* Remove setting whole Plugin in block listener

### 1.3.2

* Deny /spawn, /tp, /tphere, /group and /home-commands access when user is restricted.
Expand Down
6 changes: 3 additions & 3 deletions 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.2</version>
<version>1.3.3</version>
<developers>
<developer>
<id>thypthon</id>
Expand All @@ -28,8 +28,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
Expand Down
6 changes: 3 additions & 3 deletions 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.2</version>
<version>1.3.3</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -69,8 +69,8 @@
<version>2.3.2</version>

<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public boolean unProtect(int x, int y, int z, String world) {
ps.setString(4, world);

if (ps.executeUpdate() < 1) {
this.plugin.getLogger().log(Level.INFO, "Unexpected number of rows changed when unprotecting block.");
// this.plugin.getLogger().log(Level.INFO, "Unexpected number of rows changed when unprotecting block.");
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.mittnett.reke.Rekeverden.handlers;

import com.sun.org.apache.xpath.internal.operations.Bool;
import net.mittnett.reke.Rekeverden.Rekeverden;

import net.mittnett.reke.Rekeverden.mysql.SQLSelectResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

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

import net.mittnett.reke.Rekeverden.Rekeverden;
import net.mittnett.reke.Rekeverden.handlers.BlockAction;
import net.mittnett.reke.Rekeverden.handlers.BlockProtectionHandler;
import net.mittnett.reke.Rekeverden.handlers.User;
import net.mittnett.reke.Rekeverden.handlers.UserHandler;
import net.mittnett.reke.Rekeverden.handlers.*;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
Expand All @@ -21,14 +20,14 @@
import org.bukkit.event.block.BlockPlaceEvent;

public class BlockListener implements org.bukkit.event.Listener {
private Rekeverden plugin;
private UserHandler userHandler;
private BlockProtectionHandler bpHandler;
private BlockInfoHandler blockInfoHandler;

public BlockListener(Rekeverden plugin) {
this.plugin = plugin;
this.userHandler = plugin.getUserHandler();
this.bpHandler = plugin.getBlockProtectionHandler();
this.userHandler = plugin.getUserHandler();
this.bpHandler = plugin.getBlockProtectionHandler();
this.blockInfoHandler = plugin.getBlockInfoHandler();
}

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
Expand All @@ -53,22 +52,25 @@ public void onBlockPlace(BlockPlaceEvent event) {
return;
}

Object localObject;
String s;
if ((block.getType() == Material.SPONGE) && (user.getAccessLevel() > 2)) {
player.sendMessage(ChatColor.BLUE + "--------- BlockLog ---------");

ArrayList<String> rows = this.plugin.getBlockInfoHandler().getBlockLog(block.getLocation());
if (rows.size() > 0) {
new Thread(() -> {
Object localObject;
String s;

ArrayList<String> rows = this.blockInfoHandler.getBlockLog(block.getLocation());
if (rows.size() > 0) {
for (localObject = rows.iterator(); ((Iterator) localObject).hasNext(); ) {
s = (String) ((Iterator) localObject).next();
player.sendMessage(s);
s = (String) ((Iterator) localObject).next();
player.sendMessage(s);
}
} else {
} else {
player.sendMessage("(no log found on this location)");
}
}

player.sendMessage("");
player.sendMessage("");
}).start();


event.setCancelled(true);
Expand All @@ -85,7 +87,7 @@ public void onBlockPlace(BlockPlaceEvent event) {
// Validate that the target block is a chest.
if ((relativeChest != null) && (relativeChest.getType() == Material.CHEST)) {
// Fetch owner, if it is owned and the user is not current. Cancel event.
User owner = this.plugin.getBlockProtectionHandler().getOwnerUser(relativeChest.getLocation());
User owner = this.bpHandler.getOwnerUser(relativeChest.getLocation());
if ((owner != null) && (owner.getId() != user.getId())) {
event.setCancelled(true);
return;
Expand All @@ -94,16 +96,16 @@ public void onBlockPlace(BlockPlaceEvent event) {
}
}


this.plugin.getBlockInfoHandler().log(user
.getId(), l
.getBlockX(), l
.getBlockY(), l
.getBlockZ(), l
.getWorld().getName(), block
.getTypeId(), block
.getData(), BlockAction.PLACED);

new Thread(() -> {
this.blockInfoHandler.log(user
.getId(), l
.getBlockX(), l
.getBlockY(), l
.getBlockZ(), l
.getWorld().getName(), block
.getTypeId(), block
.getData(), BlockAction.PLACED);
}).start();

if ((block.getType() != Material.DIRT) &&
(block.getType() != Material.GRASS) &&
Expand All @@ -112,7 +114,13 @@ public void onBlockPlace(BlockPlaceEvent event) {
(block.getType() != Material.WATER) &&
(block.getType() != Material.LAVA) &&
(block.getType() != Material.AIR)) {
this.plugin.getBlockProtectionHandler().protect(user.getId(), l.getBlockX(), l.getBlockY(), l.getBlockZ(), l.getWorld().getName());
this.bpHandler.protect(
user.getId(),
l.getBlockX(),
l.getBlockY(),
l.getBlockZ(),
l.getWorld().getName()
);
}
}

Expand Down Expand Up @@ -159,7 +167,7 @@ public void onBlockBreak(BlockBreakEvent event) {
case BURNING_FURNACE:
Sign privateSign = getPrivateSignOfChest(block);
if (privateSign != null) {
User ownerOfSign = this.plugin.getBlockProtectionHandler().getOwnerUser(privateSign.getLocation());
User ownerOfSign = this.bpHandler.getOwnerUser(privateSign.getLocation());
if ((ownerOfSign != null) && (ownerOfSign.equals(owner)) && (!owner.equals(user))) {
event.setCancelled(true);
return;
Expand Down Expand Up @@ -202,20 +210,28 @@ public void onBlockBreak(BlockBreakEvent event) {
return;
}

// Remove protection of this block.
this.plugin.getBlockProtectionHandler().unProtect(l.getBlockX(), l.getBlockY(), l.getBlockZ(), l.getWorld().getName());
// Remove protection of this block.
new Thread(() -> {
this.bpHandler.unProtect(
l.getBlockX(),
l.getBlockY(),
l.getBlockZ(),
l.getWorld().getName()
);
}).start();
}


// Log removal of this block.
this.plugin.getBlockInfoHandler().log(user
.getId(), l
.getBlockX(), l
.getBlockY(), l
.getBlockZ(), l
.getWorld().getName(), block
.getTypeId(), block
.getData(), BlockAction.REMOVED);
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();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public void onPlayerQuit(PlayerQuitEvent event) {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getPlayer() != null) {
User user = this.plugin.getUserHandler().getUser(event.getPlayer().getUniqueId());
User user = this.userHandler.getUser(event.getPlayer().getUniqueId());

if (user != null && !user.isAllowedInteraction()) {
event.setCancelled(true);
Expand Down Expand Up @@ -142,29 +142,35 @@ private void handleRightClickBlock(PlayerInteractEvent event) {
if (user.hasAccessLevel(User.MODERATOR)) {
player.sendMessage(ChatColor.BLUE + "--------- BlockBP ---------");

ArrayList<String> rows = this.plugin.getBlockInfoHandler().getBlockLog(clickedBlock.getLocation());
if (rows.size() > 0) {
for (String s : rows) {
player.sendMessage(s);
new Thread(() -> {
ArrayList<String> rows = this.plugin.getBlockInfoHandler().getBlockLog(clickedBlock.getLocation());
if (rows.size() > 0) {
for (String s : rows) {
player.sendMessage(s);
}
} else {
player.sendMessage("(no log found on this location)");
}
} else {
player.sendMessage("(no log found on this location)");
}

User owner = this.plugin.getBlockProtectionHandler().getOwnerUser(clickedBlock.getLocation());
player.sendMessage(
ChatColor.WHITE + "Owned by: " + ChatColor.BLUE + (owner != null ? owner.getName() : "no owner"));
User owner = this.plugin.getBlockProtectionHandler().getOwnerUser(clickedBlock.getLocation());
player.sendMessage(
ChatColor.WHITE + "Owned by: " + ChatColor.BLUE + (owner != null ? owner.getName() : "no owner"));

player.sendMessage("");
player.sendMessage("");
}).start();
}
return;

case STICK:
if (user.hasAccessLevel(User.MODERATOR)) {
Location l = clickedBlock.getLocation();
this.plugin.getBlockProtectionHandler().unProtect(l.getBlockX(), l.getBlockY(), l.getBlockZ(),
l.getWorld().getName());
this.plugin.getBlockInfoHandler().log(user, l, clickedBlock, BlockAction.ADMIN_STICKED);

new Thread(() -> {
this.plugin.getBlockProtectionHandler().unProtect(l.getBlockX(), l.getBlockY(), l.getBlockZ(),
l.getWorld().getName());
this.plugin.getBlockInfoHandler().log(user, l, clickedBlock, BlockAction.ADMIN_STICKED);
}).start();

clickedBlock.setType(Material.AIR);
}
return;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Reke
main: net.mittnett.reke.Rekeverden.Rekeverden
version: 1.3.2
version: 1.3.3
description: rekeverden
authors: ['Thypthon']

Expand Down

0 comments on commit 073f1f5

Please sign in to comment.