Skip to content

Commit

Permalink
Added help command, fixed filter radius resetting, more faulty event …
Browse files Browse the repository at this point in the history
…fixes
  • Loading branch information
Karanum committed Jun 9, 2017
1 parent 545ce07 commit b9418e4
Show file tree
Hide file tree
Showing 21 changed files with 108 additions and 13 deletions.
Binary file modified .gradle/2.6/taskArtifacts/cache.properties.lock
Binary file not shown.
Binary file modified .gradle/2.6/taskArtifacts/fileHashes.bin
Binary file not shown.
Binary file modified .gradle/2.6/taskArtifacts/fileSnapshots.bin
Binary file not shown.
Binary file modified .gradle/2.6/taskArtifacts/outputFileStates.bin
Binary file not shown.
Binary file modified .gradle/2.6/taskArtifacts/taskArtifacts.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
}

group= 'com.karanum'
version = '0.2.2'
version = '0.2.3'
description = 'Action logging and rollback plugin for Sponge'

sourceCompatibility = targetCompatibility = "1.8"
Expand All @@ -20,7 +20,7 @@ sponge {
id = 'adamantineshield'
meta {
name = 'AdamantineShield'
version = '0.2.2'
version = '0.2.3'
description = 'Action logging and rollback plugin for Sponge'
url = null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import com.karanumcoding.adamantineshield.lookup.LookupResultManager;
import com.karanumcoding.adamantineshield.util.FilterParser;

@Plugin(id = "adamantineshield", name = "AdamantineShield", version = "0.2.2", authors = { "Karanum", "Snootiful" },
@Plugin(id = "adamantineshield", name = "AdamantineShield", version = "0.2.3", authors = { "Karanum", "Snootiful" },
description = "Action logging and rollback plugin for Sponge"
)
public class AdamantineShield {
Expand Down Expand Up @@ -205,7 +205,7 @@ private void registerCommands(CommandManager man) {
//.child(undoCommand, "undo", "u")
.child(purgeCommand, "purge")
//.child(reloadCommand, "reload")
//.child(helpCommand, "help", "?")
.child(helpCommand, "help", "?")
.executor(new CommandMain())
.build();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,58 @@
package com.karanumcoding.adamantineshield.commands;

import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.spec.CommandExecutor;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;

import com.karanumcoding.adamantineshield.commands.lookup.CommandFilter;
import com.karanumcoding.adamantineshield.commands.lookup.CommandInspect;
import com.karanumcoding.adamantineshield.commands.lookup.CommandLookup;
import com.karanumcoding.adamantineshield.commands.pages.CommandNextPage;
import com.karanumcoding.adamantineshield.commands.pages.CommandPage;
import com.karanumcoding.adamantineshield.commands.pages.CommandPrevPage;
import com.karanumcoding.adamantineshield.enums.Permissions;

public class CommandMain implements CommandExecutor {

@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
// TODO Auto-generated method stub
return CommandResult.empty();
boolean hasAnyPermission = false;
Text text = Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "Available commands: ", Text.NEW_LINE);
if (src.hasPermission(Permissions.LOOKUP.get())) {
hasAnyPermission = true;
text = Text.of(text, CommandInspect.getHelpEntry(), Text.NEW_LINE, CommandLookup.getHelpEntry(), Text.NEW_LINE);
}
if (src.hasPermission(Permissions.FILTER.get())) {
hasAnyPermission = true;
text = Text.of(text, CommandFilter.getHelpEntry(), Text.NEW_LINE);
}
if (src.hasPermission(Permissions.LOOKUP.get())) {
text = Text.of(text, CommandPage.getHelpEntry(), Text.NEW_LINE, CommandNextPage.getHelpEntry(), Text.NEW_LINE,
CommandPrevPage.getHelpEntry(), Text.NEW_LINE);
}
if (src.hasPermission(Permissions.PURGE.get())) {
hasAnyPermission = true;
text = Text.of(text, CommandPurge.getHelpEntry(), Text.NEW_LINE);
}

if (hasAnyPermission) {
text = Text.of(text, getHelpEntry(), Text.NEW_LINE);
} else {
text = Text.of(TextColors.DARK_AQUA, "[AS] ", TextColors.YELLOW, "AdmantineShield v",
Sponge.getPluginManager().getPlugin("adamantineshield").get().getVersion(), " by Karanum");
}

src.sendMessage(text);
return CommandResult.success();
}

public static Text getHelpEntry() {
return Text.of(TextColors.YELLOW, "/ashield help", TextColors.AQUA, " - Shows command help");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@ public void doPurge(CommandSource src, long before) {
src.sendMessage(Text.of(TextColors.BLUE, "[AS] ", TextColors.RED, "Purge failed! Check console for more information!"));
}
}

public static Text getHelpEntry() {
return Text.of(TextColors.YELLOW, "/ashield purge <time>", TextColors.AQUA, " - Purges old log entries");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.spec.CommandExecutor;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;

public class CommandReload implements CommandExecutor {

Expand All @@ -13,5 +15,9 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
// TODO Auto-generated method stub
return CommandResult.empty();
}

public static Text getHelpEntry() {
return Text.of(TextColors.YELLOW, "/ashield reload", TextColors.AQUA, " - Reloads this plugin");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
return CommandResult.empty();
}

FilterSet filterSet = new FilterSet(plugin, p);
FilterSet filterSet = new FilterSet(plugin, p, false);
filterSet.forceLookupType(lookup.getLookupType());
FilterParser.parse(filters, filterSet);
lookup.filterResult(filterSet);

lookup.showPage(p, 1);
return CommandResult.success();
}

public static Text getHelpEntry() {
return Text.of(TextColors.YELLOW, "/ashield filter [filters]", TextColors.AQUA, " - Filters your last result");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,9 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm

return CommandResult.success();
}

public static Text getHelpEntry() {
return Text.of(TextColors.YELLOW, "/ashield inspect", TextColors.AQUA, " - Toggles the inspector");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
Player p = (Player) src;
Collection<String> filters = args.getAll("filter");

FilterSet filterSet = new FilterSet(plugin, p);
FilterSet filterSet = new FilterSet(plugin, p, true);
FilterParser.parse(filters, filterSet);
String targetTable = filterSet.getLookupType().getTable();

Expand Down Expand Up @@ -79,5 +79,9 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
});
return CommandResult.success();
}

public static Text getHelpEntry() {
return Text.of(TextColors.YELLOW, "/ashield lookup [filters]", TextColors.AQUA, " - Performs a lookup");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
result.showPage((Player) src, page);
return CommandResult.success();
}

public static Text getHelpEntry() {
return Text.of(TextColors.YELLOW, "/ashield nextpage", TextColors.AQUA, " - Switches to next result page");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
result.showPage((Player) src, page);
return CommandResult.success();
}

public static Text getHelpEntry() {
return Text.of(TextColors.YELLOW, "/ashield page <page>", TextColors.AQUA, " - Switches lookup result page");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,9 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
result.showPage((Player) src, page);
return CommandResult.success();
}

public static Text getHelpEntry() {
return Text.of(TextColors.YELLOW, "/ashield prevpage", TextColors.AQUA, " - Switches to previous result page");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.spec.CommandExecutor;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;

public class CommandRollback implements CommandExecutor {

Expand All @@ -13,5 +15,9 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
// TODO Auto-generated method stub
return CommandResult.empty();
}

public static Text getHelpEntry() {
return Text.of(TextColors.YELLOW, "/ashield rollback [filters]", TextColors.AQUA, " - Performs a rollback");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.spec.CommandExecutor;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;

public class CommandUndo implements CommandExecutor {

Expand All @@ -13,5 +15,9 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
// TODO Auto-generated method stub
return CommandResult.empty();
}

public static Text getHelpEntry() {
return Text.of(TextColors.YELLOW, "/ashield undo [filters]", TextColors.AQUA, " - Undoes rollback results");
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.karanumcoding.adamantineshield.enums;

public enum Permissions {
ROLLBACK("use.rollback"),
ROLLBACK("use.rollback.base"),
UNDO("use.rollback.undo"),
REDO("use.rollback.redo"),
LOOKUP("use.lookup"),
LOOKUP("use.lookup.base"),
RELOAD("admin.reload"),
PURGE("admin.purge"),
FILTER("use.lookup.filter");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public void onBlockPrimaryInteract(InteractBlockEvent.Primary.MainHand e, @First

e.setCancelled(true);
BlockSnapshot block = e.getTargetBlock();
if (block == null || !block.getLocation().isPresent())
return;

Location<World> loc = block.getLocation().get();

p.sendMessage(Text.of(TextColors.BLUE, "Querying database, please wait..."));
Expand All @@ -45,6 +48,9 @@ public void onBlockSecondaryInteract(InteractBlockEvent.Secondary.MainHand e, @F

e.setCancelled(true);
BlockSnapshot block = e.getTargetBlock();
if (block == null || !block.getLocation().isPresent())
return;

Location<World> loc = block.getLocation().get();

p.sendMessage(Text.of(TextColors.BLUE, "Querying database, please wait..."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ public class FilterSet {
private Map<Class<? extends FilterBase>, FilterBase> filters;
private LookupType lookupType;

public FilterSet(AdamantineShield plugin, Player p) {
public FilterSet(AdamantineShield plugin, Player p, boolean initialFilter) {
lookupType = null;
filters = Maps.newHashMap();
filters.put(PositionFilter.class, new PositionFilter(p.getLocation().getBlockPosition(),
plugin.getConfig().getInt("lookup", "default-radius")));
if (initialFilter) {
filters.put(PositionFilter.class, new PositionFilter(p.getLocation().getBlockPosition(),
plugin.getConfig().getInt("lookup", "default-radius")));
}
}

public <T extends FilterBase> Optional<FilterBase> getFilter(Class<T> filter) {
Expand Down

0 comments on commit b9418e4

Please sign in to comment.