use of org.apache.tapestry5.Block in project DragonsOnline by UniverseCraft.
the class AntiCheatCommand method onCommand.
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (label.equalsIgnoreCase("acping")) {
if (!requirePermission(sender, PermissionLevel.MODERATOR))
return true;
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "/acping <player>");
return true;
}
Player target = lookupPlayer(sender, args[0]);
if (target == null)
return true;
sender.sendMessage(ChatColor.GREEN + "Ping of " + target.getName() + " is " + plugin.getCombatRewinder().getInstantaneousPing(target) + "ms (Bukkit: " + plugin.getDragonsInstance().getBridge().getPing(target) + "ms)");
return true;
} else if (label.equalsIgnoreCase("acpps")) {
if (!requirePermission(sender, PermissionLevel.MODERATOR))
return true;
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "/acpps <player>");
return true;
}
Player target = lookupPlayer(sender, args[0]);
FastPackets check = plugin.getCheckRegistry().getCheckByClass(FastPackets.class);
sender.sendMessage(ChatColor.GREEN + "Current PPS of " + target.getName() + " is " + MathUtil.round(check.getPPS(target)) + " (" + plugin.getCombatRewinder().getInstantaneousPing(target) + "ms i, " + plugin.getDragonsInstance().getBridge().getPing(target) + "ms b)");
return true;
}
if (!requirePermission(sender, PermissionLevel.DEVELOPER))
return true;
Player player = player(sender);
if (label.equalsIgnoreCase("acdebug")) {
plugin.setDebug(!plugin.isDebug());
if (plugin.isDebug()) {
sender.sendMessage(ChatColor.GREEN + "Now debugging anticheat");
} else {
sender.sendMessage(ChatColor.GREEN + "No longer debugging anticheat");
}
return true;
} else if (label.equalsIgnoreCase("acdump")) {
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "/acdump <Player>");
return true;
}
User target = lookupUser(sender, args[0]);
sender.sendMessage("CHECK - CATEGORY - VL");
for (Check check : plugin.getCheckRegistry().getChecks()) {
ViolationData violationData = ViolationData.of(check, target);
sender.sendMessage(check.getName() + " - " + check.getType() + " - " + MathUtil.round(violationData.vl));
}
} else if (label.equalsIgnoreCase("acresetplayer")) {
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "/acresetplayer <Player>");
return true;
}
User target = lookupUser(sender, args[0]);
for (Check check : plugin.getCheckRegistry().getChecks()) {
ViolationData violationData = ViolationData.of(check, target);
violationData.vl = 0;
}
MoveData moveData = MoveData.of(target);
moveData.lastRubberband = 0L;
moveData.lastValidLocation = target.getPlayer().getLocation();
moveData.validMoves = MoveData.MIN_VALID_MOVES_TO_SET_VALID_LOCATION;
sender.sendMessage("Reset check data for " + target.getName());
} else if (label.equalsIgnoreCase("acflushlog")) {
plugin.getTestingMoveListener().dumpLog();
plugin.getTestingMoveListener().disableLog();
sender.sendMessage(ChatColor.GREEN + "Dumped log to console and cleared");
return true;
} else if (label.equalsIgnoreCase("acstartlog")) {
plugin.getTestingMoveListener().clearLog();
plugin.getTestingMoveListener().enableLog();
return true;
} else if (label.equalsIgnoreCase("acblockdata")) {
IBlockData blockData = ((CraftWorld) player.getWorld()).getHandle().getType(new BlockPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()));
Block nmsBlock = blockData.getBlock();
sender.sendMessage("nmsBlock=" + nmsBlock);
float ff = nmsBlock.getFrictionFactor();
sender.sendMessage("frictionFactor=" + ff);
// ?
ff *= 0.91;
sender.sendMessage("*multiplier=" + 0.1 * (0.1627714 / (ff * ff * ff)));
sender.sendMessage("*a=" + ff);
sender.sendMessage("calculated onGround=" + ACUtil.isOnGround(player));
return true;
} else if (label.equalsIgnoreCase("acban")) {
if (!requirePermission(sender, SystemProfileFlag.MODERATION))
return true;
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "/acban <player> [internal info]");
return true;
}
User target = lookupUser(sender, args[0]);
String info = StringUtil.concatArgs(args, 1);
if (target == null)
return true;
Report report = reportLoader.fileInternalReport(target, new Document("type", "ac_ban").append("info", info));
report.addNote("Action automatically taken on this report");
report.setStatus(ReportStatus.ACTION_TAKEN);
WrappedUser.of(target).punish(PunishmentType.BAN, PunishmentCode.AC_BAN, PunishmentCode.AC_BAN.getStandingLevel(), "ID " + report.getId(), user(sender));
sender.sendMessage(ChatColor.GREEN + "Anticheat ban executed successfully. Correlated Report ID: " + report.getId());
} else if (label.equalsIgnoreCase("ackick")) {
if (!requirePermission(sender, SystemProfileFlag.MODERATION))
return true;
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "/ackick <player>");
return true;
}
User target = lookupUser(sender, args[0]);
if (target == null)
return true;
WrappedUser.of(target).punish(PunishmentType.KICK, PunishmentCode.CHEATING_WARNING, 0, null, null);
sender.sendMessage(ChatColor.GREEN + "Kicked " + target.getName() + " for illegal client modifications");
} else if (label.equalsIgnoreCase("acspoofping")) {
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "/acspoofping <value|off>");
return true;
}
if (args[0].equalsIgnoreCase("off")) {
plugin.getCombatRewinder().debug_pingSpoof.remove(player);
sender.sendMessage(ChatColor.GREEN + "Stopped spoofing your ping.");
} else {
plugin.getCombatRewinder().debug_pingSpoof.put(player, (long) parseInt(player, args[0]));
sender.sendMessage(ChatColor.GREEN + "Began spoofing your anticheat ping to " + args[0] + "ms");
}
} else if (label.equalsIgnoreCase("acraytol")) {
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "/acraytol <tolerance>");
return true;
}
Double tol = parseDouble(sender, args[0]);
if (tol == null)
return true;
plugin.getCombatRewinder().rayTraceTolerance = tol;
sender.sendMessage(ChatColor.GREEN + "Set combat rewind ray tracing tolerance to +/- " + args[0] + " blocks");
} else if (label.equalsIgnoreCase("acstatus")) {
for (Check check : plugin.getCheckRegistry().getChecks()) {
sender.sendMessage((check.isEnabled() ? ChatColor.DARK_GREEN : ChatColor.RED) + check.getName() + (check.isEnabled() ? "(Enabled)" : "(Disabled)"));
}
} else if (label.equalsIgnoreCase("actoggle")) {
// If all checks are inactive, make them all active
if (args.length == 0) {
if (plugin.getCheckRegistry().getChecks().stream().filter(c -> c.isEnabled()).count() > 0) {
plugin.getCheckRegistry().getChecks().forEach(c -> c.setEnabled(false));
sender.sendMessage(ChatColor.GREEN + "Disabled all checks.");
} else {
plugin.getCheckRegistry().getChecks().forEach(c -> c.setEnabled(true));
sender.sendMessage(ChatColor.GREEN + "Enabled all checks.");
}
} else {
Check check = plugin.getCheckRegistry().getCheckByName(args[0]);
if (check == null) {
sender.sendMessage(ChatColor.RED + "No check by that name exists! /acstatus");
return true;
}
check.setEnabled(!check.isEnabled());
sender.sendMessage(ChatColor.GREEN + (check.isEnabled() ? "Enabled" : "Disabled") + " check " + check.getName());
}
} else if (label.equalsIgnoreCase("achitstats")) {
Map<Player, Boolean> toggle = plugin.getCombatRewinder().debug_hitStats;
toggle.put(player, !toggle.getOrDefault(player, false));
sender.sendMessage(ChatColor.GREEN + "Toggled hit rejection stats in action bar");
} else if (label.equalsIgnoreCase("acresethitstats")) {
plugin.getCombatRewinder().debug_hitCount.remove(player);
plugin.getCombatRewinder().debug_rejectedCount.remove(player);
sender.sendMessage(ChatColor.GREEN + "Reset your hit rejection stats");
} else {
sender.sendMessage(ChatColor.GREEN + "Dragons Online custom anti-cheat (ALPHA)");
}
return true;
}
use of org.apache.tapestry5.Block in project tapestry-5 by apache.
the class SaxTemplateParser method element.
/**
* Processes an element through to its matching end tag.
*
* An element can be:
*
* a Tapestry component via <t:type>
*
* a Tapestry component via t:type="type" and/or t:id="id"
*
* a Tapestry component via a library namespace
*
* A parameter element via <t:parameter>
*
* A parameter element via <p:name>
*
* A <t:remove> element (in the 5.1 schema)
*
* A <t:content> element (in the 5.1 schema)
*
* A <t:block> element
*
* The body <t:body>
*
* An ordinary element
*/
void element(TemplateParserState initialState) {
TemplateParserState state = setupForElement(initialState);
String uri = tokenStream.getNamespaceURI();
String name = tokenStream.getLocalName();
Version version = NAMESPACE_URI_TO_VERSION.get(uri);
if (T_5_1.sameOrEarlier(version)) {
if (name.equalsIgnoreCase("remove")) {
removeContent();
return;
}
if (name.equalsIgnoreCase("content")) {
limitContent(state);
return;
}
if (name.equalsIgnoreCase("extension-point")) {
extensionPoint(state);
return;
}
if (name.equalsIgnoreCase("replace")) {
throw new RuntimeException("The <replace> element may only appear directly within an extend element.");
}
if (MUST_BE_ROOT.contains(name))
mustBeRoot(name);
}
if (version != null) {
if (name.equalsIgnoreCase("body")) {
body();
return;
}
if (name.equalsIgnoreCase("container")) {
mustBeRoot(name);
}
if (name.equalsIgnoreCase("block")) {
block(state);
return;
}
if (name.equalsIgnoreCase("parameter")) {
if (T_5_3.sameOrEarlier(version)) {
throw new RuntimeException(String.format("The <parameter> element has been deprecated in Tapestry 5.3 in favour of '%s' namespace.", TAPESTRY_PARAMETERS_URI));
}
classicParameter(state);
return;
}
possibleTapestryComponent(state, null, tokenStream.getLocalName().replace('.', '/'));
return;
}
if (uri != null && uri.startsWith(LIB_NAMESPACE_URI_PREFIX)) {
libraryNamespaceComponent(state);
return;
}
if (TAPESTRY_PARAMETERS_URI.equals(uri)) {
parameterElement(state);
return;
}
// Just an ordinary element ... unless it has t:id or t:type
possibleTapestryComponent(state, tokenStream.getLocalName(), null);
}
use of org.apache.tapestry5.Block in project tapestry-5 by apache.
the class RenderCommandComponentEventResultProcessor method renderMarkup.
/**
* As a filter, this class does three things:
* <ul>
* <li>It creates an outer element to capture the partial page content that will be rendered</li>
* <li>It does setup and cleanup with the {@link AjaxFormUpdateController}</li>
* <li>It extracts the child markup and stuffs it into the reply's "content" property.</li>
* </ul>
*/
public void renderMarkup(MarkupWriter writer, JSONObject reply, PartialMarkupRenderer renderer) {
// The partial will quite often contain multiple elements (or just a block of plain text),
// so those must be enclosed in a root element.
Element root = writer.element("ajax-partial");
ajaxFormUpdateController.setupBeforePartialZoneRender(writer);
renderer.renderMarkup(writer, reply);
ajaxFormUpdateController.cleanupAfterPartialZoneRender();
writer.end();
String content = root.getChildMarkup().trim();
reply.put("content", content);
}
use of org.apache.tapestry5.Block in project tapestry-5 by apache.
the class BeanBlockSourceImplTest method found_display_block_in_override.
@Test
public void found_display_block_in_override() {
Block block = mockBlock();
RequestPageCache cache = mockRequestPageCache();
BeanBlockOverrideSource overrideSource = mockBeanBlockOverrideSource();
String datatype = "MyData";
expect(overrideSource.hasDisplayBlock(datatype)).andReturn(true);
expect(overrideSource.getDisplayBlock(datatype)).andReturn(block);
replay();
BeanBlockSource source = new BeanBlockSourceImpl(cache, overrideSource, EMPTY_CONFIGURATION);
// Check case insensitivity while we are at it.
assertTrue(source.hasDisplayBlock(datatype));
Block actual = source.getDisplayBlock(datatype);
assertSame(actual, block);
verify();
}
use of org.apache.tapestry5.Block in project tapestry-5 by apache.
the class BeanBlockSourceImplTest method found_edit_block_in_override.
@Test
public void found_edit_block_in_override() {
Block block = mockBlock();
RequestPageCache cache = mockRequestPageCache();
BeanBlockOverrideSource overrideSource = mockBeanBlockOverrideSource();
String datatype = "MyData";
expect(overrideSource.getEditBlock(datatype)).andReturn(block);
replay();
BeanBlockSource source = new BeanBlockSourceImpl(cache, overrideSource, EMPTY_CONFIGURATION);
Block actual = source.getEditBlock(datatype);
assertSame(actual, block);
verify();
}
Aggregations