Skip to content

Commit

Permalink
Perm node update for update checker.
Browse files Browse the repository at this point in the history
Adds some basic world guard protection, but also dependency.
  • Loading branch information
ShakeforProtein committed Aug 11, 2020
1 parent d1beacc commit 98d49cb
Show file tree
Hide file tree
Showing 14 changed files with 752 additions and 613 deletions.
18 changes: 17 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.ShakeforProtein</groupId>
<artifactId>TreeboTrunks</artifactId>
<version>0.0.5</version>
<version>0.0.9</version>
<packaging>jar</packaging>

<name>TreeboTrunks</name>
Expand Down Expand Up @@ -90,6 +90,10 @@
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
<repository> <!-- WorldGuard/WorldEdit -->
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -105,5 +109,17 @@
<version>1.5</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>7.0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
105 changes: 58 additions & 47 deletions src/main/java/me/shakeforprotein/treebotrunks/Commands/Anvil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package me.shakeforprotein.treebotrunks.Commands;

import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.regions.RegionQuery;
import me.shakeforprotein.treebotrunks.TreeboTrunk;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
Expand Down Expand Up @@ -33,58 +37,65 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
if (sender instanceof Player) {
Player p = (Player) sender;
if (pl.whitelistHash.containsKey(p.getLocation().getBlock().getType())) {
if (!p.getLocation().subtract(0, 1, 0).getBlock().isEmpty()) {
if (!p.getLocation().subtract(0, 1, 0).getBlock().isLiquid()) {
long time = System.currentTimeMillis();
Location l = p.getLocation().getBlock().getLocation();
pl.getConfig().set("Anvils." + time + ".X", l.getBlockX());
pl.getConfig().set("Anvils." + time + ".Y", l.getBlockY());
pl.getConfig().set("Anvils." + time + ".Z", l.getBlockZ());
pl.getConfig().set("Anvils." + time + ".World", l.getWorld().getName());
LocalPlayer wgPlayer = pl.worldGuardPlugin.wrapPlayer(p);

p.getLocation().getBlock().setType(Material.ANVIL);
ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l.add(0.5, -0.5, 0.5), EntityType.ARMOR_STAND); //Spawn the ArmorStand
int delay = 600;
as.setGravity(false); //Make sure it doesn't fall
as.setCanPickupItems(false); //I'm not sure what happens if you leave this as it is, but you might as well disable it
as.setCustomName("" + (delay / 20)); //Set this to the text you want
as.setCustomNameVisible(true); //This makes the text appear no matter if your looking at the entity or not
as.setVisible(false);
pl.getConfig().set("Anvils." + time + ".AST", as.getUniqueId());
pl.astHash.putIfAbsent(as, delay / 20);
BukkitRunnable runnable = new BukkitRunnable() {
@Override
public void run() {
int currentVal = pl.astHash.get(as);
if (currentVal > 0) {
currentVal--;
String newName = currentVal + "";
as.setCustomName(ChatColor.GOLD + newName);
pl.astHash.replace(as, currentVal);
} else {
this.cancel();
if (pl.hasBypass(wgPlayer, p.getLocation()) || pl.canBuild(wgPlayer, p.getLocation())) {

if (!p.getLocation().subtract(0, 1, 0).getBlock().isEmpty()) {
if (!p.getLocation().subtract(0, 1, 0).getBlock().isLiquid()) {
long time = System.currentTimeMillis();
Location l = p.getLocation().getBlock().getLocation();
pl.getConfig().set("Anvils." + time + ".X", l.getBlockX());
pl.getConfig().set("Anvils." + time + ".Y", l.getBlockY());
pl.getConfig().set("Anvils." + time + ".Z", l.getBlockZ());
pl.getConfig().set("Anvils." + time + ".World", l.getWorld().getName());

p.getLocation().getBlock().setType(Material.ANVIL);
ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l.add(0.5, -0.5, 0.5), EntityType.ARMOR_STAND); //Spawn the ArmorStand
int delay = 600;
as.setGravity(false); //Make sure it doesn't fall
as.setCanPickupItems(false); //I'm not sure what happens if you leave this as it is, but you might as well disable it
as.setCustomName("" + (delay / 20)); //Set this to the text you want
as.setCustomNameVisible(true); //This makes the text appear no matter if your looking at the entity or not
as.setVisible(false);
pl.getConfig().set("Anvils." + time + ".AST", as.getUniqueId());
pl.astHash.putIfAbsent(as, delay / 20);
BukkitRunnable runnable = new BukkitRunnable() {
@Override
public void run() {
int currentVal = pl.astHash.get(as);
if (currentVal > 0) {
currentVal--;
String newName = currentVal + "";
as.setCustomName(ChatColor.GOLD + newName);
pl.astHash.replace(as, currentVal);
} else {
this.cancel();
}
}
}
};
};

runnable.runTaskTimer(pl, 20L, 20L);
Bukkit.getScheduler().runTaskLater(pl, new Runnable() {
@Override
public void run() {
int x, y, z = 0;
x = pl.getConfig().getInt("Anvils." + time + ".X");
y = pl.getConfig().getInt("Anvils." + time + ".Y");
z = pl.getConfig().getInt("Anvils." + time + ".Z");
String world = pl.getConfig().getString("Anvils." + time + ".World");
Location loc = new Location(Bukkit.getWorld(world), x, y, z);
loc.getBlock().setType(Material.AIR);
if (pl.getConfig().getString("Anvils." + time + ".AST") != null) {
Bukkit.getEntity(UUID.fromString(pl.getConfig().getString("Anvils." + time + ".AST"))).remove();
runnable.runTaskTimer(pl, 20L, 20L);
Bukkit.getScheduler().runTaskLater(pl, new Runnable() {
@Override
public void run() {
int x, y, z = 0;
x = pl.getConfig().getInt("Anvils." + time + ".X");
y = pl.getConfig().getInt("Anvils." + time + ".Y");
z = pl.getConfig().getInt("Anvils." + time + ".Z");
String world = pl.getConfig().getString("Anvils." + time + ".World");
Location loc = new Location(Bukkit.getWorld(world), x, y, z);
loc.getBlock().setType(Material.AIR);
if (pl.getConfig().getString("Anvils." + time + ".AST") != null) {
Bukkit.getEntity(UUID.fromString(pl.getConfig().getString("Anvils." + time + ".AST"))).remove();
}
pl.getConfig().set("Anvils." + time, null);
}
pl.getConfig().set("Anvils." + time, null);
}
}, delay);
}, delay);
}
}
} else {
p.sendMessage(pl.badge + pl.err + "You are not entitled to build here");
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.shakeforprotein.treebotrunks.Commands;

import com.sk89q.worldguard.LocalPlayer;
import me.shakeforprotein.treebotrunks.TreeboTrunk;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
Expand Down Expand Up @@ -34,59 +35,65 @@ public boolean onCommand(CommandSender sender, Command cmd, String label, String
Player p = (Player) sender;
int delay = 3600;
if (pl.whitelistHash.containsKey(p.getLocation().getBlock().getType())) {
if (!p.getLocation().subtract(0, 1, 0).getBlock().isEmpty()) {
if (!p.getLocation().subtract(0, 1, 0).getBlock().isLiquid()) {
long time = System.currentTimeMillis();
Location l = p.getLocation().getBlock().getLocation();
pl.getConfig().set("BlastFurnaces." + time + ".X", l.getBlockX());
pl.getConfig().set("BlastFurnaces." + time + ".Y", l.getBlockY());
pl.getConfig().set("BlastFurnaces." + time + ".Z", l.getBlockZ());
pl.getConfig().set("BlastFurnaces." + time + ".World", l.getWorld().getName());

p.getLocation().getBlock().setType(Material.BLAST_FURNACE);

ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l.add(0.5, -0.5, 0.5), EntityType.ARMOR_STAND); //Spawn the ArmorStand

as.setGravity(false); //Make sure it doesn't fall
as.setCanPickupItems(false); //I'm not sure what happens if you leave this as it is, but you might as well disable it
as.setCustomName((delay / 20) + ""); //Set this to the text you want
as.setCustomNameVisible(true); //This makes the text appear no matter if your looking at the entity or not
as.setVisible(false);
pl.getConfig().set("BlastFurnaces." + time + ".AST", as.getUniqueId());
pl.astHash.putIfAbsent(as, delay / 20);
BukkitRunnable runnable = new BukkitRunnable() {
@Override
public void run() {
int currentVal = pl.astHash.get(as);
if (currentVal > 0) {
currentVal--;
String newName = currentVal + "";
as.setCustomName(ChatColor.GOLD + newName);
pl.astHash.replace(as, currentVal);
} else {
this.cancel();
LocalPlayer wgPlayer = pl.worldGuardPlugin.wrapPlayer(p);

if (pl.hasBypass(wgPlayer, p.getLocation()) || pl.canBuild(wgPlayer, p.getLocation())) {
if (!p.getLocation().subtract(0, 1, 0).getBlock().isEmpty()) {
if (!p.getLocation().subtract(0, 1, 0).getBlock().isLiquid()) {
long time = System.currentTimeMillis();
Location l = p.getLocation().getBlock().getLocation();
pl.getConfig().set("BlastFurnaces." + time + ".X", l.getBlockX());
pl.getConfig().set("BlastFurnaces." + time + ".Y", l.getBlockY());
pl.getConfig().set("BlastFurnaces." + time + ".Z", l.getBlockZ());
pl.getConfig().set("BlastFurnaces." + time + ".World", l.getWorld().getName());

p.getLocation().getBlock().setType(Material.BLAST_FURNACE);

ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l.add(0.5, -0.5, 0.5), EntityType.ARMOR_STAND); //Spawn the ArmorStand

as.setGravity(false); //Make sure it doesn't fall
as.setCanPickupItems(false); //I'm not sure what happens if you leave this as it is, but you might as well disable it
as.setCustomName((delay / 20) + ""); //Set this to the text you want
as.setCustomNameVisible(true); //This makes the text appear no matter if your looking at the entity or not
as.setVisible(false);
pl.getConfig().set("BlastFurnaces." + time + ".AST", as.getUniqueId());
pl.astHash.putIfAbsent(as, delay / 20);
BukkitRunnable runnable = new BukkitRunnable() {
@Override
public void run() {
int currentVal = pl.astHash.get(as);
if (currentVal > 0) {
currentVal--;
String newName = currentVal + "";
as.setCustomName(ChatColor.GOLD + newName);
pl.astHash.replace(as, currentVal);
} else {
this.cancel();
}
}
}
};
runnable.runTaskTimer(pl, 20L, 20L);
Bukkit.getScheduler().runTaskLater(pl, new Runnable() {
@Override
public void run() {
int x, y, z = 0;
x = pl.getConfig().getInt("BlastFurnaces." + time + ".X");
y = pl.getConfig().getInt("BlastFurnaces." + time + ".Y");
z = pl.getConfig().getInt("BlastFurnaces." + time + ".Z");
String world = pl.getConfig().getString("BlastFurnaces." + time + ".World");
Location loc = new Location(Bukkit.getWorld(world), x, y, z);

loc.getBlock().setType(Material.AIR);
if (pl.getConfig().getString("BlastFurnaces." + time + ".AST") != null) {
Bukkit.getEntity(UUID.fromString(pl.getConfig().getString("BlastFurnaces." + time + ".AST"))).remove();
};
runnable.runTaskTimer(pl, 20L, 20L);
Bukkit.getScheduler().runTaskLater(pl, new Runnable() {
@Override
public void run() {
int x, y, z = 0;
x = pl.getConfig().getInt("BlastFurnaces." + time + ".X");
y = pl.getConfig().getInt("BlastFurnaces." + time + ".Y");
z = pl.getConfig().getInt("BlastFurnaces." + time + ".Z");
String world = pl.getConfig().getString("BlastFurnaces." + time + ".World");
Location loc = new Location(Bukkit.getWorld(world), x, y, z);

loc.getBlock().setType(Material.AIR);
if (pl.getConfig().getString("BlastFurnaces." + time + ".AST") != null) {
Bukkit.getEntity(UUID.fromString(pl.getConfig().getString("BlastFurnaces." + time + ".AST"))).remove();
}
pl.getConfig().set("BlastFurnaces." + time, null);
}
pl.getConfig().set("BlastFurnaces." + time, null);
}
}, delay);
}, delay);
}
}
} else {
p.sendMessage(pl.badge + pl.err + "You are not entitled to build here");
}
}
} else {
Expand Down
Loading

0 comments on commit 98d49cb

Please sign in to comment.