-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added area of effect command, help page and fixed tab completion
- Loading branch information
TheDutchMC
committed
Oct 6, 2020
1 parent
49dac1a
commit 72f5039
Showing
12 changed files
with
250 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Ignore Gradle project-specific cache directory | ||
.gradle/ | ||
|
||
# Ignore Gradle build output directory | ||
build/ | ||
releases/ | ||
|
||
# Minecraft | ||
server/ | ||
|
||
# Eclipse | ||
.project | ||
.settings/ | ||
.classpath | ||
bin/ | ||
|
||
#NMS Version directory excludes | ||
Spigot_1_16_R2/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
pluginVersion = 1.0 | ||
pluginVersion = 2.0 | ||
pluginGroup = nl.thedutchmc.harotorch | ||
pluginName = HaroTorch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/nl/thedutchmc/harotorch/commands/TorchCommandTabCompleter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package nl.thedutchmc.harotorch.commands; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.command.TabCompleter; | ||
|
||
public class TorchCommandTabCompleter implements TabCompleter { | ||
|
||
@Override | ||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) { | ||
|
||
if(args.length == 1) { | ||
List<String> result = new ArrayList<>(); | ||
if(sender.hasPermission("harotorch.highlight")) result.add("highlight"); | ||
if(sender.hasPermission("harotorch.help")) result.add("help"); | ||
if(sender.hasPermission("harotorch.give")) result.add("give"); | ||
if(sender.hasPermission("harotorch.convert")) result.add("convert"); | ||
if(sender.hasPermission("harotorch.version")) result.add("version"); | ||
if(sender.hasPermission("harotorch.aoe")) result.add("aoe"); | ||
|
||
return result; | ||
} | ||
|
||
List<String> result = new ArrayList<>(); | ||
return result; | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/nl/thedutchmc/harotorch/commands/torchSubCmds/HelpExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package nl.thedutchmc.harotorch.commands.torchSubCmds; | ||
|
||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.CommandSender; | ||
|
||
import nl.thedutchmc.harotorch.HaroTorch; | ||
|
||
public class HelpExecutor { | ||
|
||
public static boolean help(CommandSender sender) { | ||
|
||
sender.sendMessage(HaroTorch.getMessagePrefix() + ChatColor.GOLD + "HaroTorch help menu"); | ||
sender.sendMessage("- " + ChatColor.GOLD + "/torch help " + ChatColor.WHITE + "Shows you this page."); | ||
sender.sendMessage("- " + ChatColor.GOLD + "/torch highlight " + ChatColor.WHITE + "Highlight all nearby torches."); | ||
sender.sendMessage("- " + ChatColor.GOLD + "/torch give " + ChatColor.WHITE + "Give yourself a HaroTorch."); | ||
sender.sendMessage("- " + ChatColor.GOLD + "/torch convert " + ChatColor.WHITE + "Convert v1 torches to v2 torches."); | ||
sender.sendMessage("- " + ChatColor.GOLD + "/torch version " + ChatColor.WHITE + "Get the HaroTorch and NMS version number."); | ||
|
||
return true; | ||
} | ||
|
||
} |
115 changes: 115 additions & 0 deletions
115
...ain/java/nl/thedutchmc/harotorch/commands/torchSubCmds/HighlightAreaOfEffectExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package nl.thedutchmc.harotorch.commands.torchSubCmds; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.bukkit.Color; | ||
import org.bukkit.Location; | ||
import org.bukkit.Particle; | ||
import org.bukkit.World; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
import org.bukkit.scheduler.BukkitTask; | ||
|
||
import net.md_5.bungee.api.ChatColor; | ||
import nl.thedutchmc.harotorch.HaroTorch; | ||
import nl.thedutchmc.harotorch.torch.TorchHandler; | ||
|
||
public class HighlightAreaOfEffectExecutor { | ||
|
||
public static boolean aoe(CommandSender sender, HaroTorch plugin) { | ||
|
||
sender.sendMessage(HaroTorch.getMessagePrefix() + ChatColor.GOLD + "Showing the area of effect for " + ChatColor.RED + HaroTorch.getConfigHandler().torchHighlightTime + ChatColor.GOLD + " seconds!"); | ||
|
||
List<Location> nearbyTorches = TorchHandler.getTorchLocationsNearPlayer((Player) sender, HaroTorch.getConfigHandler().torchHighlightRange); | ||
final List<TorchParticleObject> torchParticles = new ArrayList<>(); | ||
|
||
for(Location l : nearbyTorches) { | ||
|
||
final List<Location> blocksOnTorchRadius = new ArrayList<>(); | ||
|
||
final int radius = HaroTorch.getConfigHandler().torchRange; | ||
final int cx = l.getBlockX(); | ||
final int cz = l.getBlockZ(); | ||
final World w = l.getWorld(); | ||
|
||
for(int i = 0; i < 360; i++) { | ||
|
||
final double rad = i * ((2 * Math.PI)/360); | ||
|
||
final int x = (int) (cx + (radius * Math.cos(rad))); | ||
final int z = (int) (cz + (radius * Math.sin(rad))); | ||
|
||
final int y = w.getHighestBlockAt(x, z).getY() + 1; | ||
|
||
blocksOnTorchRadius.add(new Location(w, x, y, z)); | ||
} | ||
|
||
final int r = (int) (Math.random() * 256D); | ||
final int g = (int) (Math.random() * 256D); | ||
final int b = (int) (Math.random() * 256D); | ||
|
||
torchParticles.add(new TorchParticleObject(r, g, b, blocksOnTorchRadius, l)); | ||
} | ||
|
||
final BukkitTask particle = new BukkitRunnable() { | ||
|
||
@Override | ||
public void run() { | ||
|
||
for(TorchParticleObject torchParticle : torchParticles) { | ||
|
||
final Location torchLoc = torchParticle.getTorch(); | ||
|
||
torchLoc.getWorld().spawnParticle(Particle.REDSTONE, torchLoc.getX() + 0.5D, torchLoc.getY() + 1.5D, torchLoc.getZ() + 0.5D, 25, 0D, 0D, 0D, 0.005, new Particle.DustOptions(torchParticle.getTorchParticleColor(), 1)); | ||
|
||
for(Location l : torchParticle.getCircleLocations()) { | ||
|
||
for(int i = 0; i < HaroTorch.getConfigHandler().torchAoeParticleHeight; i++) { | ||
torchLoc.getWorld().spawnParticle(Particle.REDSTONE, l.getX() + 0.5D, l.getY() + 0.5D + i, l.getZ() + 0.5D, 5, 0D, 0D, 0D, 0.005, new Particle.DustOptions(torchParticle.getTorchParticleColor(), 1)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
}.runTaskTimer(plugin, 60L, 10L); | ||
|
||
new BukkitRunnable() { | ||
|
||
@Override | ||
public void run() { | ||
particle.cancel(); | ||
sender.sendMessage(HaroTorch.getMessagePrefix() + ChatColor.GOLD + "Highlighting has ended!"); | ||
} | ||
}.runTaskLater(plugin, 30L * 20L); | ||
|
||
return true; | ||
} | ||
|
||
private static class TorchParticleObject { | ||
|
||
private Color particleColor; | ||
private List<Location> circleLocations; | ||
private Location torch; | ||
|
||
public TorchParticleObject(int r, int g, int b, List<Location> circleLocations, Location torch) { | ||
this.particleColor = Color.fromRGB(r, g, b); | ||
this.circleLocations = circleLocations; | ||
this.torch = torch; | ||
} | ||
|
||
public Color getTorchParticleColor() { | ||
return this.particleColor; | ||
} | ||
|
||
public List<Location> getCircleLocations() { | ||
return this.circleLocations; | ||
} | ||
|
||
public Location getTorch() { | ||
return this.torch; | ||
} | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/nl/thedutchmc/harotorch/commands/torchSubCmds/VersionExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package nl.thedutchmc.harotorch.commands.torchSubCmds; | ||
|
||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.CommandSender; | ||
|
||
import nl.thedutchmc.harotorch.HaroTorch; | ||
|
||
public class VersionExecutor { | ||
|
||
public static boolean version(CommandSender sender, HaroTorch plugin) { | ||
|
||
sender.sendMessage(HaroTorch.getMessagePrefix() + ChatColor.GOLD + "You are running HaroTorch version " + ChatColor.RED + plugin.getDescription().getVersion() + ChatColor.GOLD + " and NMS version " + ChatColor.RED + HaroTorch.NMS_VERSION); | ||
|
||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters