Skip to content

Commit

Permalink
Fix several issues from #10
Browse files Browse the repository at this point in the history
  • Loading branch information
SeanOMik committed Sep 25, 2020
1 parent e6ba317 commit d55b6e8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
import org.bukkit.plugin.java.JavaPlugin;

// @TODO: Add more config options
/*
* Change Log:
* - Fix /esgive command runner from getting kicked with "Illegal Characters" error.
* - Fix systems that were placed on the walls.
*/
public final class EnergeticStorage extends JavaPlugin implements Listener {
private static EnergeticStorage plugin;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.util.Arrays;
import java.util.List;

import static net.md_5.bungee.api.ChatColor.STRIP_COLOR_PATTERN;

public class ESGiveCommand implements TabExecutor {
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
Expand All @@ -33,14 +35,14 @@ public List<String> onTabComplete(CommandSender sender, Command command, String
tab.addAll(Arrays.asList("1k", "4k", "16k", "64k"));
} else if (args[0].equals("system")) {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
tab.add(player.getDisplayName());
tab.add(ChatColor.stripColor(player.getDisplayName()));
}
}
break;
case 3:
if (args[0].equals("drive")) {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
tab.add(player.getDisplayName());
tab.add(ChatColor.stripColor(player.getDisplayName()));
}
}

Expand Down Expand Up @@ -97,6 +99,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if (sender instanceof Player) {
Player player = (Player) sender;
player.getInventory().addItem(ItemConstructor.createSystemBlock());

sender.sendMessage(Reference.PREFIX + ChatColor.GREEN + "Gave an ES System to " + player.getDisplayName());
} else {
sender.sendMessage(Reference.PREFIX + ChatColor.RED + "Supply a player to run this command!");
sender.sendMessage(generateCommandUsage(args));
Expand Down Expand Up @@ -131,6 +135,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if (sender instanceof Player) {
Player player = (Player) sender;
player.getInventory().addItem(ItemConstructor.createDrive(size, 0, 0));

sender.sendMessage(Reference.PREFIX + ChatColor.GREEN + "Gave an ES Drive to " + player.getDisplayName());
} else {
sender.sendMessage(Reference.PREFIX + ChatColor.RED + "Supply a player to run this command!");
sender.sendMessage(generateCommandUsage(args));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public void onInventoryClick(InventoryClickEvent event) {
}
} else {
// At main menu
if (slot == 0) {
if (slot == 0) { // Back
Reference.ES_TERMINAL_GUI.openInventory(player, openSystem);
} else if (slot == 3) { // Add player
new AnvilGUI.Builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class BlockBreakListener implements Listener {

@EventHandler
public void onBlockBreakListener(BlockBreakEvent event) {
if (event.getBlock().getType() == Material.PLAYER_HEAD) {
if (event.getBlock().getType() == Material.PLAYER_HEAD || event.getBlock().getType() == Material.PLAYER_WALL_HEAD) {
Block block = event.getBlock();
Player player = event.getPlayer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class BlockPlaceListener implements Listener {

@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (event.getBlock().getType() == Material.PLAYER_HEAD) {
if (event.getBlock().getType() == Material.PLAYER_HEAD || event.getBlock().getType() == Material.PLAYER_WALL_HEAD) {
Block block = event.getBlock();
Player player = event.getPlayer();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class PlayerInteractListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getHand() == EquipmentSlot.HAND) {
if (event.getClickedBlock().getType() == Material.PLAYER_HEAD) {
if (event.getClickedBlock().getType() == Material.PLAYER_HEAD || event.getClickedBlock().getType() == Material.PLAYER_WALL_HEAD) {
Block block = event.getClickedBlock();
Player player = event.getPlayer();

Expand Down

0 comments on commit d55b6e8

Please sign in to comment.