Skip to content

Commit

Permalink
v0.1.11
Browse files Browse the repository at this point in the history
Fix typo in Lang
Fix tag showMessages config option not working
Fixed issues w/track raw stats
Added tablist option for track raw stats
  • Loading branch information
Machine-Maker committed Jul 27, 2020
1 parent bf7bb60 commit 57e8c74
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 31 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.machinemaker</groupId>
<artifactId>vanillatweaks</artifactId>
<version>0.1.10</version>
<version>0.1.11</version>
<packaging>jar</packaging>

<name>VanillaTweaks</name>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/machinemaker/vanillatweaks/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public enum Lang {
PILLAGER_TOGGLE("pillagertools.", "&6%setting% &ehas been set to &6%val%&e."),

// Workstation Highlights
NO_VILLAGER("workstationhightlights.", "&eNo villager found withing 3 blocks."),
NO_VILLAGER("workstationhightlights.", "&eNo villager found within 3 blocks."),
NO_JOB_SITE("workstationhighlights.", "&eThis villager does not have a job site."),
HIGHLIGHTED_SITE("workstationhighlights.", "&aHighlighted the workstation!"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataContainer;
Expand Down Expand Up @@ -97,6 +98,13 @@ public void onPlayerSneak(PlayerToggleSneakEvent event) {
});
}

@EventHandler
public void onPlayerInteractEntity(PlayerInteractAtEntityEvent event) {
if (event.getRightClicked().getType() != EntityType.ARMOR_STAND) return;
if (!event.getRightClicked().getPersistentDataContainer().has(PLAYER_UUID, DataType.UUID)) return;
event.setCancelled(true);
}

private void setupStand(ArmorStand stand, Material head) {
stand.setInvulnerable(true);
stand.setGravity(false);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/me/machinemaker/vanillatweaks/tag/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public void onPlayerDamage(EntityDamageByEntityEvent event) {
}
setAsIt(damagee);
removeAsIt(damager);
Bukkit.broadcastMessage(Lang.PLAYER_IS_IT.toString().replace("%name%", damagee.getDisplayName()));
if (config.showMessages)
Bukkit.broadcastMessage(Lang.PLAYER_IS_IT.toString().replace("%name%", damagee.getDisplayName()));
}

void setAsIt(Player player) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Default;
import co.aikar.commands.annotation.Description;
import co.aikar.commands.annotation.HelpCommand;
import co.aikar.commands.annotation.Subcommand;
Expand All @@ -27,25 +28,42 @@ public void help(CommandSender sender, CommandHelp help) {
help.showHelp();
}

@Subcommand("toggle")
@Description("Toggle the scoreboard visibility")
@CommandPermission("vanillatweaks.trackrawstats.toggle")
public void toggle(Player player) {
if (player.getScoreboard().equals(this.module.board)) {
player.sendMessage(Lang.SCOREBOARD_OFF.p().replace("%board%", "TrackRawStats"));
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard());
} else {
player.setScoreboard(this.module.board);
player.sendMessage(Lang.SCOREBOARD_ON.p().replace("%board%", "TrackRawStats"));
@Subcommand("clear")
@Description("Clears the sidebar or tablist")
@CommandCompletion("*")
@CommandPermission("vanillatweaks.trackrawstats.clear")
public void toggle(Player player, @Default("SIDEBAR") Slot slot) {
if (player.getScoreboard().equals(Bukkit.getScoreboardManager().getMainScoreboard())) {
switch (slot) {
case TABLIST:
player.getScoreboard().clearSlot(DisplaySlot.PLAYER_LIST);
player.sendMessage(Lang.SCOREBOARD_OFF.p().replace("%board%", "TABLIST"));
break;
case SIDEBAR:
player.getScoreboard().clearSlot(DisplaySlot.SIDEBAR);
player.sendMessage(Lang.SCOREBOARD_OFF.p().replace("%board%", "SIDEBAR"));
break;
}
}

}

@Subcommand("show")
@CommandCompletion("@trs/stattypes @trs/objective")
@CommandCompletion("@trs/stattypes @trs/objective *")
@Description("Show a specific stat on the scoreboard")
@CommandPermission("vanillatweaks.trackrawstats.show")
public void show(Player player, StatType type, Objective objective) {
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
public void show(Player player, StatType type, Objective objective, @Default("SIDEBAR") Slot slot) {
switch (slot) {
case SIDEBAR:
objective.setDisplaySlot(DisplaySlot.SIDEBAR);
break;
case TABLIST:
objective.setDisplaySlot(DisplaySlot.PLAYER_LIST);
break;
}
}

private enum Slot {
SIDEBAR,
TABLIST
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class TrackRawStats extends BaseModule {

Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
private final Set<IStat> statTypes = Sets.newHashSet();
private Commands commands;

Expand All @@ -38,17 +38,12 @@ public TrackRawStats(VanillaTweaks plugin) {
if (type == null) return Sets.newHashSet();
return type.objectiveMap.keySet();
});
}

@Override
public void register() {
this.commands = new Commands(this);
this.registerCommands(commands);
for (StatType type : StatType.values()) {
statTypes.addAll(type.stats);
type.stats.forEach(stat -> {
try {
Objective obj = board.registerNewObjective(stat.getName(), stat.getCriteria(), stat.getDisplayName());
Objective obj = board.getObjective(stat.getName());
if (obj == null) obj = board.registerNewObjective(stat.getName(), stat.getCriteria(), stat.getDisplayName());
type.addToMap(stat, obj);
} catch (IllegalArgumentException exception) {
this.plugin.getLogger().severe("Error loading objectives for TrackRawStats");
Expand All @@ -60,12 +55,14 @@ public void register() {
}
}

@Override
public void register() {
this.commands = new Commands(this);
this.registerCommands(commands);
}

@Override
public void unregister() {
this.unregisterCommands(commands);
for (StatType statType : StatType.values()) {
statType.objectiveMap.values().forEach(Objective::unregister);
}
statTypes.clear();
}
}
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ permissions:
vanillatweaks.thundershrine.remove: true
vanillatweaks.thundershrine.create: true
vanillatweaks.thundershrine.help: true
vanillatweaks.trackrawstats.toggle:
vanillatweaks.trackrawstats.clear:
default: true
description: Toggles the scoreboard for Track Raw Stats
description: Clear a scoreboard slot
vanillatweaks.trackrawstats.show:
default: true
description: Shows a specific stat to that player
Expand Down

0 comments on commit 57e8c74

Please sign in to comment.