name
stringlengths
12
178
code_snippet
stringlengths
8
36.5k
score
float64
3.26
3.68
MagicPlugin_BaseSpell_onCast_rdh
/** * Called when this spell is cast. * * <p>This is where you do your work! * * <p>If parameters were passed to this spell, either via a variant or the command line, * they will be passed in here. * * @param parameters * Any parameters that were passed to this spell * @return The SpellResult of this cast. */ public SpellResult onCast(ConfigurationSection parameters) { throw new UnsupportedOperationException("The onCast method has not been implemented"); }
3.26
MagicPlugin_BaseSpell_getPlayerFacing_rdh
/** * Get the direction the player is facing as a BlockFace. * * @return a BlockFace representing the direction the player is facing */ public BlockFace getPlayerFacing() {return getFacing(getLocation()); }
3.26
MagicPlugin_BaseSpell_onPlayerDeath_rdh
/** * Listener method, called on player move for registered spells. * * @param event * The original entity death event */ public void onPlayerDeath(EntityDeathEvent event) { }
3.26
MagicPlugin_BaseSpell_isUnderwater_rdh
/** * Check to see if the player is underwater * * @return true if the player is underwater */ public boolean isUnderwater() { Block playerBlock = getPlayerBlock();if (playerBlock == null)return false; playerBlock = playerBlock.getRelative(BlockFace.UP); Block eyeBlock = playerBlock.getRelative(BlockFace.UP); return m1(playerBlock.getType()) && m1(eyeBlock.getType()); }
3.26
MagicPlugin_BaseSpell_isOkToStandIn_rdh
/* Ground / location search and test functions */ // Material @Deprecated public boolean isOkToStandIn(Material mat) { if (isHalfBlock(mat)) { return false; } return passthroughMaterials.testMaterial(mat) && (!unsafeMaterials.testMaterial(mat)); }
3.26
MagicPlugin_BaseSpell_isPassthrough_rdh
// Material @Deprecated public boolean isPassthrough(Material mat) { return (passthroughMaterials != null) && passthroughMaterials.testMaterial(mat); }
3.26
MagicPlugin_BaseSpell_getConsumeReduction_rdh
// // CostReducer Implementation // @Override public float getConsumeReduction() { CostReducer reducer = (mageClass != null) ? mageClass : currentCast != null ? currentCast.getWand() : mage; if (reducer == null) { reducer = mage; } if (reducer == null) { return consumeReduction; } return consumeReduction + reducer.getConsumeReduction(); }
3.26
MagicPlugin_BaseSpell_getPlayerBlock_rdh
/** * Get the block the player is standing on. * * @return The Block the player is standing on */ @Nullable public Block getPlayerBlock() { Location location = getLocation(); if (location == null) return null; if (!CompatibilityLib.getCompatibilityUtils().isChunkLoaded(location)) return null; return location.getBlock().getRelative(BlockFace.DOWN); }
3.26
MagicPlugin_BaseSpell_isBypassRegionPermission_rdh
/** * * @return Whether or not this spell can bypass region permissions such as custom world-guard flags. */public boolean isBypassRegionPermission() { return bypassRegionPermission; }
3.26
MagicPlugin_BaseSpell_sendMessage_rdh
/** * Send a message to a player. * * <p>Use this to send messages to the player that are important. * * @param message * The message to send */ @Override public void sendMessage(String message) { sendMessage(mage, message); }
3.26
MagicPlugin_BaseSpell_isOkToStandOn_rdh
// Material @Deprecated public boolean isOkToStandOn(Material mat) { if (isHalfBlock(mat)) { return true; } return ((mat != Material.AIR) && (!unsafeMaterials.testMaterial(mat))) && (!passthroughMaterials.testMaterial(mat)); }
3.26
MagicPlugin_BaseSpell_createSpell_rdh
// // Public API Implementation // @Nullable @Override@Deprecated public Spell createSpell() {return createMageSpell(null); }
3.26
MagicPlugin_ModernMythicMobManager_getActiveMob_rdh
// Not in the API... @SuppressWarnings("unchecked") public Optional<ActiveMob> getActiveMob(UUID id) { try { MobManager manager = api.getMobManager(); Method getActiveMobMethod = manager.getClass().getMethod("getActiveMob", UUID.class); if (getActiveMobMethod != null) { return ((Optional<ActiveMob>) (getActiveMobMethod.invoke(manager, id)));} else { controller.getLogger().warning("MythicMobs integration has gone wrong, disabling"); api = null; } } catch (Exception ex) {controller.getLogger().warning("MythicMobs integration has gone wrong, disabling"); api = null; } return Optional.empty();}
3.26
MagicPlugin_MageSpell_save_rdh
/** * This method is no longer used, and was never called correctly. * Spells should use getVariables instead if they need to store custom data. */ @Deprecated default void save(SpellData spellData) { }
3.26
MagicPlugin_CompatibilityLib_isLegacy_rdh
// This is here as a bit of a hack, MaterialAndData needs to know how to parse materials, but this is used // by the MaterialSetTest test framework, where we don't actually have a server and can't really // initialize CompatibilityLib. // Kind of ugly, but this sidesteps the problem. public static boolean isLegacy(Material material) { CompatibilityUtils compatibilityUtils = (platform == null) ? null : platform.getCompatibilityUtils(); return compatibilityUtils == null ? false : compatibilityUtils.isLegacy(material); }
3.26
MagicPlugin_MagicPlugin_onDisable_rdh
/* Help commands */ @Override public void onDisable() { if ((controller != null) && controller.isLoaded()) { // Safety fallback in case we've missed some pending batches from logged out mages controller.onShutdown(); controller.undoScheduled(); controller.save(); controller.clear(); } }
3.26
MagicPlugin_MagicPlugin_getPlugin_rdh
/* API Implementation */ @Override public Plugin getPlugin() { return this; }
3.26
MagicPlugin_SelectorAction_getSelectorOption_rdh
// This is mainly here for MagicMeta interrogation public SelectorConfiguration getSelectorOption(ConfigurationSection section) { return new SelectorConfiguration(section); }
3.26
MagicPlugin_MageConversation_sayNextLine_rdh
/** * Returns true when finished */ public boolean sayNextLine(List<String> dialog) { Player target = targetPlayer.get(); if ((target == null) || (nextLine >= dialog.size())) { return true; } String configuredLines = dialog.get(nextLine); if (!configuredLines.isEmpty()) { String[] lines = configuredLines.split("\n"); for (String line : lines) { String message = formatString.replace("$line", line); message = message.replace("$speaker", speaker.getDisplayName()).replace("$target", target.getDisplayName()); target.sendMessage(CompatibilityLib.getCompatibilityUtils().translateColors(message)); } } nextLine++; return nextLine >= dialog.size(); }
3.26
MagicPlugin_EntityExtraData_isSplittable_rdh
// Here for slime-like mobs public boolean isSplittable() { return true; }
3.26
MagicPlugin_PlayerController_onPlayerPreLogin_rdh
// TODO: Why not MONITOR? @EventHandler(priority = EventPriority.HIGHEST) public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event) { if (event.getLoginResult() != Result.ALLOWED) { // Did not emit any events prior to this, nothing to clean up return; } controller.onPreLogin(event); }
3.26
MagicPlugin_TextUtils_m0_rdh
// This is mainly meant for colors, since it only uses 6 characters for RGB public static String m0(int i) { return String.format("%06X", i); }
3.26
MagicPlugin_SkriptManager_get_rdh
// Eclipse bug @SuppressWarnings("null") @Nullable @Override public Entity get(final EarnEvent e) {return e.getMage().getEntity(); }
3.26
MagicPlugin_SkriptManager_m0_rdh
// Eclipse bug @SuppressWarnings("null") @Nullable @Override public Entity m0(final StartCastEvent e) { return e.getMage().getEntity(); }
3.26
MagicPlugin_SpellResult_isFree_rdh
/** * Determine if this result is a free cast or not. * * @return True if this cast should not consume costs. */ public boolean isFree() { return free; }
3.26
MagicPlugin_SpellResult_isFailure_rdh
/** * Determine if this result is a failure or not. * * <p>Note that a spell result can be neither failure nor * success. * * @return True if this cast was a failure. */ public boolean isFailure() { return failure; }
3.26
MagicPlugin_SpellResult_isSuccess_rdh
/** * Determine if this result is a success or not, * possibly counting no_target as a success. * * @return True if this cast was a success. */ public boolean isSuccess(boolean castOnNoTarget) { if (((this == SpellResult.NO_TARGET) || (this == SpellResult.NO_ACTION)) || (this == SpellResult.STOP)) { return castOnNoTarget; } return isSuccess(); }
3.26
MagicPlugin_Currency_hasMinValue_rdh
/** * Check to see if this currency has a lower limit for player balances. * * @return true if this currency should be limited, typically to prevent negative balances. */ default boolean hasMinValue() { return false; }
3.26
MagicPlugin_Currency_getMinValue_rdh
/** * Get the minimum value for this currency. * Player balances will be capped to this value. * Only has an effect if @hasMinValue returns true. * * @return The minimum for player balances of this currency, typically 0 if set */ default double getMinValue() { return 0; }
3.26
MagicPlugin_ColorHD_convertHSBtoRGB_rdh
// Borrowed from Sun AWT Color class public static int[] convertHSBtoRGB(float hue, float saturation, float brightness) { int r = 0; int g = 0; int b = 0; if (saturation == 0) { r = g = b = ((int) ((brightness * 255.0F) + 0.5F)); } else { float h = (hue - ((float) (Math.floor(hue)))) * 6.0F; float f = h - ((float) (Math.floor(h))); float p = brightness * (1.0F - saturation); float q = brightness * (1.0F - (saturation * f)); float t = brightness * (1.0F - (saturation * (1.0F - f))); switch (((int) (h))) { case 0 : r = ((int) ((brightness * 255.0F) + 0.5F)); g = ((int) ((t * 255.0F) + 0.5F)); b = ((int) ((p * 255.0F) + 0.5F)); break; case 1 : r = ((int) ((q * 255.0F) + 0.5F)); g = ((int) ((brightness * 255.0F) + 0.5F)); b = ((int) ((p * 255.0F) + 0.5F)); break; case 2 : r = ((int) ((p * 255.0F) + 0.5F)); g = ((int) ((brightness * 255.0F) + 0.5F));b = ((int) ((t * 255.0F) + 0.5F)); break; case 3 : r = ((int) ((p * 255.0F) + 0.5F)); g = ((int) ((q * 255.0F) + 0.5F)); b = ((int) ((brightness * 255.0F) + 0.5F)); break; case 4 : r = ((int) ((t * 255.0F) + 0.5F)); g = ((int) ((p * 255.0F) + 0.5F)); b = ((int) ((brightness * 255.0F) + 0.5F)); break; case 5 : r = ((int) ((brightness * 255.0F) + 0.5F)); g = ((int) ((p * 255.0F) + 0.5F)); b = ((int) ((q * 255.0F) + 0.5F)); break; } } components[0] = r; components[1] = g; components[2] = b; return components; }
3.26
MagicPlugin_Messages_getSpace_rdh
/** * This relies on the negative space font RP: * https://github.com/AmberWat/NegativeSpaceFont */ @Nonnull @Override public String getSpace(int pixels) { if (pixels == 0) { return ""; } if (spaceAmounts.containsKey(pixels)) { return spaceAmounts.get(pixels); } int totalPixels = pixels; int absPixels = Math.abs(pixels); List<Integer> spaceValues = (pixels > 0) ? positiveSpace : negativeSpace; StringBuilder output = new StringBuilder(); for (Integer spaceValue : spaceValues) { int absValue = Math.abs(spaceValue); // See if we can fit this space in if (absPixels < absValue) continue; // Append as many of these as we can String entryGlyph = spaceAmounts.get(spaceValue); int amount = absPixels / absValue; for (int i = 0; i < amount; i++) { output.append(entryGlyph); } // Subtract off the amount of space we just added pixels = pixels - (amount * spaceValue); // See if we are done absPixels = Math.abs(pixels); if (absPixels == 0) break; } // Cache this string so we don't have to recompute it later String result = output.toString(); spaceAmounts.put(totalPixels, result); return result; }
3.26
MagicPlugin_UndoRegistry_removeDamage_rdh
/** * Subtract some amount of damage * * @param block * The block to remove damage from. * @return The amount of damage remaining, or null if no damage was removed. */ @Nullable public Double removeDamage(BlockData block) { double amount = block.getDamage(); if (amount <= 0) return null; Double currentAmount = breaking.get(block.getId()); if (currentAmount == null) return null; currentAmount -= amount; if (currentAmount <= 0) { removeBreaking(block); return 0.0; } else { breaking.put(block.getId(), currentAmount); } return currentAmount; }
3.26
MagicPlugin_MageData_getLastDeathLocation_rdh
/** * Data can be saved asynchronously, and Locations' Worlds can be invalidated if the server unloads a world. * So do not call this method during saving. */ @Nullable public Location getLastDeathLocation() { return lastDeathLocation == null ? null : lastDeathLocation.asLocation(); }
3.26
MagicPlugin_BoundingBox_scaleFromBase_rdh
/** * Scale this BoundingBox, but keep the min-Y value constant. * * <p>Useful for scaling entity AABB's. * * @return the scaled BB (this object) */ public BoundingBox scaleFromBase(double scale, double scaleY) { if ((scale <= 0) || (scale == 1)) return this; Vector center = this.center(); this.min.setX(((this.min.getX() - center.getX()) * scale) + center.getX()); // We just skip setting minY, scaling Y only upward this.min.setZ(((this.min.getZ() - center.getZ()) * scale) + center.getZ()); this.max.setX(((this.max.getX() - center.getX()) * scale) + center.getX()); this.max.setY(((this.max.getY() - center.getY()) * scaleY) + center.getY()); this.max.setZ(((this.max.getZ() - center.getZ()) * scale) + center.getZ()); return this; }
3.26
MagicPlugin_BoundingBox_intersectsLine_rdh
// Source: // [url]http://www.gamedev.net/topic/338987-aabb---line-segment-intersection-test/[/url] public boolean intersectsLine(Vector p1, Vector p2) { final double epsilon = 1.0E-4F; p1 = p1.clone(); p2 = p2.clone(); Vector d = p2.subtract(p1).multiply(0.5); Vector e = max.clone().subtract(min).multiply(0.5); Vector c = p1.add(d).subtract(min.clone().add(max).multiply(0.5)); Vector ad = new Vector(Math.abs(d.getX()), Math.abs(d.getY()), Math.abs(d.getZ())); if (Math.abs(c.getX()) > (e.getX() + ad.getX())) return false; if (Math.abs(c.getY()) > (e.getY() + ad.getY())) return false; if (Math.abs(c.getZ()) > (e.getZ() + ad.getZ())) return false; if (Math.abs((d.getY() * c.getZ()) - (d.getZ() * c.getY())) > (((e.getY() * ad.getZ()) + (e.getZ() * ad.getY())) + epsilon)) return false; if (Math.abs((d.getZ() * c.getX()) - (d.getX() * c.getZ())) > (((e.getZ() * ad.getX()) + (e.getX() * ad.getZ())) + epsilon)) return false; if (Math.abs((d.getX() * c.getY()) - (d.getY() * c.getX())) > (((e.getX() * ad.getY()) + (e.getY() * ad.getX())) + epsilon)) return false; return true; }
3.26
MagicPlugin_MagicConfigCommandExecutor_m0_rdh
/** * Note that this gets called asynchronously */ protected void m0(CommandSender sender, String session) { final Plugin plugin = magic.getPlugin(); plugin.getServer().getScheduler().runTask(plugin, new Runnable() { @Override public void run() { Mage mage = controller.getMage(sender); sessions.put(mage.getId(), session); } }); }
3.26
MagicPlugin_TargetingSpell_m0_rdh
// Material @Deprecated public boolean m0(Material mat) { return reflectiveMaterials.testMaterial(mat); }
3.26
MagicPlugin_BlockSpell_goLeft_rdh
/** * A helper function to go change a given direction to the direction "to the right". * * <p>There's probably some better matrix-y, math-y way to do this. * It'd be nice if this was in BlockFace. * * @param direction * The current direction * @return The direction to the left */ public static BlockFace goLeft(BlockFace direction) { switch (direction) { case EAST : return BlockFace.NORTH; case NORTH : return BlockFace.WEST; case WEST : return BlockFace.SOUTH;case SOUTH : return BlockFace.EAST; default : return direction; } }
3.26
MagicPlugin_BlockSpell_goRight_rdh
/** * A helper function to go change a given direction to the direction "to the right". * * <p>There's probably some better matrix-y, math-y way to do this. * It'd be nice if this was in BlockFace. * * @param direction * The current direction * @return The direction to the right */ public static BlockFace goRight(BlockFace direction) { switch (direction) { case EAST : return BlockFace.SOUTH; case SOUTH :return BlockFace.WEST; case WEST :return BlockFace.NORTH; case NORTH :return BlockFace.EAST; default : return direction; } }
3.26
MagicPlugin_BlockController_onChunkUnload_rdh
// Is cancellable in <1.13 @EventHandler(ignoreCancelled = true)public void onChunkUnload(ChunkUnloadEvent e) { controller.pauseMagicBlocks(e.getChunk()); }
3.26
MagicPlugin_Base64Coder_encode_rdh
/** * Encodes a byte array into Base64 format. * No blanks or line breaks are inserted in the output. * * @param in * An array containing the data bytes to be encoded. * @param iOff * Offset of the first byte in <code>in</code> to be processed. * @param iLen * Number of bytes to process in <code>in</code>, starting at <code>iOff</code>. * @return A character array containing the Base64 encoded data. */ public static char[] encode(byte[] in, int iOff, int iLen) { int oDataLen = ((iLen * 4) + 2) / 3;// output length without padding int oLen = ((iLen + 2) / 3) * 4;// output length including padding char[] out = new char[oLen]; int ip = iOff; int iEnd = iOff + iLen; int op = 0; while (ip < iEnd) { int i0 = in[ip++] & 0xff; int i1 = (ip < iEnd) ? in[ip++] & 0xff : 0;int i2 = (ip < iEnd) ? in[ip++] & 0xff : 0; int o0 = i0 >>> 2; int v22 = ((i0 & 3) << 4) | (i1 >>> 4); int v23 = ((i1 & 0xf) << 2) | (i2 >>> 6); int o3 = i2 & 0x3f; out[op++] = map1[o0]; out[op++] = map1[v22]; out[op] = (op < oDataLen) ? map1[v23] : '='; op++; out[op] = (op < oDataLen) ? map1[o3] : '='; op++; } return out; }
3.26
MagicPlugin_Base64Coder_decodeLines_rdh
/** * Decodes a byte array from Base64 format and ignores line separators, tabs and blanks. * CR, LF, Tab and Space characters are ignored in the input data. * This method is compatible with <code>sun.misc.BASE64Decoder.decodeBuffer(String)</code>. * * @param s * A Base64 String to be decoded. * @return An array containing the decoded data bytes. * @throws IllegalArgumentException * If the input is not valid Base64 encoded data. */ public static byte[] decodeLines(String s) { char[] buf = new char[s.length()]; int p = 0; for (int ip = 0; ip < s.length(); ip++) { char c = s.charAt(ip); if ((((c != ' ') && (c != '\r')) && (c != '\n')) && (c != '\t')) buf[p++] = c; } return decode(buf, 0, p); }
3.26
MagicPlugin_Base64Coder_encodeLines_rdh
/** * Encodes a byte array into Base 64 format and breaks the output into lines. * * @param in * An array containing the data bytes to be encoded. * @param iOff * Offset of the first byte in <code>in</code> to be processed. * @param iLen * Number of bytes to be processed in <code>in</code>, starting at <code>iOff</code>. * @param lineLen * Line length for the output data. Should be a multiple of 4. * @param lineSeparator * The line separator to be used to separate the output lines. * @return A String containing the Base64 encoded data, broken into lines. */ public static String encodeLines(byte[] in, int iOff, int iLen, int lineLen, String lineSeparator) { int blockLen = (lineLen * 3) / 4; if (blockLen <= 0) throw new IllegalArgumentException(); int lines = ((iLen + blockLen) - 1) / blockLen; int bufLen = (((iLen + 2) / 3) * 4) + (lines * lineSeparator.length()); StringBuilder buf = new StringBuilder(bufLen); int v10 = 0; while (v10 < iLen) { int l = Math.min(iLen - v10, blockLen); buf.append(encode(in, iOff + v10, l)); buf.append(lineSeparator); v10 += l; } return buf.toString(); }
3.26
MagicPlugin_Base64Coder_encodeString_rdh
/** * Encodes a string into Base64 format. * No blanks or line breaks are inserted. * * @param s * A String to be encoded. * @return A String containing the Base64 encoded data. */ public static String encodeString(String s) { return new String(encode(s.getBytes(StandardCharsets.UTF_8))); }
3.26
MagicPlugin_Base64Coder_decode_rdh
/** * Decodes a byte array from Base64 format. * No blanks or line breaks are allowed within the Base64 encoded input data. * * @param in * A character array containing the Base64 encoded data. * @param iOff * Offset of the first character in <code>in</code> to be processed. * @param iLen * Number of characters to process in <code>in</code>, starting at <code>iOff</code>. * @return An array containing the decoded data bytes. * @throws IllegalArgumentException * If the input is not valid Base64 encoded data. */ public static byte[] decode(char[] in, int iOff, int iLen) { if ((iLen % 4) != 0) throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4."); while ((iLen > 0) && (in[(iOff + iLen) - 1] == '=')) iLen--; int oLen = (iLen * 3) / 4; byte[] out = new byte[oLen]; int ip = iOff; int iEnd = iOff + iLen; int op = 0; while (ip < iEnd) { int i0 = in[ip++];int i1 = in[ip++]; int i2 = (ip < iEnd) ? in[ip++] : 'A'; int i3 = (ip < iEnd) ? in[ip++] : 'A'; if ((((i0 > 127) || (i1 > 127)) || (i2 > 127)) || (i3 > 127)) throw new IllegalArgumentException("Illegal character in Base64 encoded data."); int b0 = map2[i0]; int b1 = map2[i1]; int b2 = map2[i2]; int b3 = map2[i3]; if ((((b0 < 0) || (b1 < 0)) || (b2 < 0)) || (b3 < 0))throw new IllegalArgumentException("Illegal character in Base64 encoded data.");int o0 = (b0 << 2) | (b1 >>> 4); int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2); int o2 = ((b2 & 3) << 6) | b3; out[op++] = ((byte) (o0)); if (op < oLen) out[op++] = ((byte) (o1)); if (op < oLen) out[op++] = ((byte) (o2)); } return out; }
3.26
MagicPlugin_Base64Coder_decodeString_rdh
/** * Decodes a string from Base64 format. * No blanks or line breaks are allowed within the Base64 encoded input data. * * @param s * A Base64 String to be decoded. * @return A String containing the decoded data. * @throws IllegalArgumentException * If the input is not valid Base64 encoded data. */ public static String decodeString(String s) { return new String(decode(s), StandardCharsets.UTF_8); }
3.26
MagicPlugin_TranslatingConfigurationSection_createSection_rdh
/** * Borrowed from Bukkit's MemorySection */ @Override public ConfigurationSection createSection(String path) { Validate.notEmpty(path, "Cannot create section at empty path"); Configuration root = getRoot(); if (root == null) { throw new IllegalStateException("Cannot create section without a root"); } final char separator = root.options().pathSeparator(); // i1 is the leading (higher) index // i2 is the trailing (lower) index int i1 = -1; int i2; ConfigurationSection section = this; while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != (-1)) { String node = path.substring(i2, i1); ConfigurationSection subSection = section.getConfigurationSection(node); if (subSection == null) { section = section.createSection(node); } else { section = subSection; } } String key = path.substring(i2); if (section == this) { ConfigurationSection result = createSection(this, key); super.set(key, result); return result; } return section.createSection(key); }
3.26
MagicPlugin_Mage_getArrowToLaunch_rdh
/** * Get the item slot of the arrow that will be fired from a bow. * -1 : Main hand * -2 : Offhand * >=0 : Inventory slot * * @return null if the player is not holding an arrow */ @Nullable public Integer getArrowToLaunch() { Player player = getPlayer(); PlayerInventory v641 = (player == null) ? null : player.getInventory(); if (v641 == null) { return null; } ItemStack itemStack = v641.getItemInMainHand(); if (itemStack.getType() == Material.ARROW) { return -1; }itemStack = v641.getItemInOffHand(); if (itemStack.getType() == Material.ARROW) { return -2; } ItemStack[] contents = v641.getContents(); for (int i = 0; i < contents.length; i++) { ItemStack item = contents[i]; if ((item != null) && (item.getType() == Material.ARROW)) { return i;}} return null; }
3.26
MagicPlugin_Mage_getConversations_rdh
/** * This isa non-API method that returns the live version of the conversation map */ @Nonnull public Map<Player, MageConversation> getConversations() { return conversations; }
3.26
MagicPlugin_Mage_doSetCurrency_rdh
// Returns the change, which may have been capped by min or max private double doSetCurrency(String key, double newValue) { Currency currency = initCurrency(key); return doSetCurrency(currency, key, newValue); }
3.26
MagicPlugin_Mage_castMessage_rdh
/** * Send a message to this Mage when a spell is cast. * * @param message * The message to send */ @Override public void castMessage(String message) { if (!controller.showCastMessages())return; sendMessage(controller.getCastMessagePrefix(), message); }
3.26
MagicPlugin_Mage_getProjectileWand_rdh
// Gets the main hand wand if it is a bow or crossbow, otherwise gets the offhand wand public Wand getProjectileWand() { Wand wand = getActiveWand(); if (wand != null) { Material wandIcon = wand.getIcon().getMaterial(); if (!DefaultMaterials.isBow(wandIcon)) {wand = null; } } if (wand == null) { wand = getOffhandWand(); if (wand != null) { Material wandIcon = wand.getIcon().getMaterial();if (!DefaultMaterials.isBow(wandIcon)) { wand = null; } } } return wand; }
3.26
MagicPlugin_Mage_getPendingBatches_rdh
/* API Implementation */ @Overridepublic Collection<Batch> getPendingBatches() { Collection<Batch> pending = new ArrayList<>(); pending.addAll(pendingBatches); return pending; }
3.26
MagicPlugin_Mage_sendMessage_rdh
/** * Send a message to this Mage. * <p/> * Use this to send messages to the player that are important. * * @param message * The message to send */ @Override public void sendMessage(String message) { sendMessage(controller.getMessagePrefix(), message); }
3.26
MagicPlugin_Targeting_getNextBlock_rdh
/** * Move "steps" forward along line of vision and returns the block there * * @return The block at the new location */ @Nullable protected Block getNextBlock() { previousPreviousBlock = previousBlock; previousBlock = currentBlock; if ((f0 == null) || (!f0.hasNext())) { currentBlock = null; } else { currentBlock = f0.next(); } return currentBlock; }
3.26
MagicPlugin_Targeting_findTarget_rdh
/** * Returns the block at the cursor, or null if out of range * * @return The target block */ protected Target findTarget(MageContext context, double range) { if (targetType == TargetType.NONE) { return new Target(source); } boolean isBlock = (targetType == TargetType.BLOCK) || (targetType == TargetType.SELECT); Mage mage = context.getMage(); final Entity mageEntity = mage.getEntity(); if ((targetType == TargetType.SELF) && (mageEntity != null)) { result = TargetingResult.ENTITY; return new Target(source, mageEntity); } CommandSender sender = mage.getCommandSender(); if ((((targetType == TargetType.SELF) && (mageEntity == null)) && (sender != null)) && (sender instanceof BlockCommandSender)) { BlockCommandSender commandBlock = ((BlockCommandSender) (mage.getCommandSender())); return new Target(commandBlock.getBlock().getLocation(), commandBlock.getBlock()); }if ((targetType == TargetType.SELF) && (source != null)) { return new Target(source, source.getBlock()); } if (targetType == TargetType.SELF) {return new Target(source); } Block block = null; if (!ignoreBlocks) { findTargetBlock(context, range); block = currentBlock; } Target targetBlock = null; if ((block != null) || isBlock) { if (result == TargetingResult.BLOCK) { targetBlock = new Target(source, block, useHitbox, hitboxBlockPadding); } else { Vector direction = source.getDirection(); Location targetLocation = source.clone().add(direction.multiply(range)); targetBlock = new Target(source, targetLocation, useHitbox, hitboxBlockPadding); } } if (isBlock) { return targetBlock; } // Don't target entities beyond the block we just hit, // but only if that block was solid, and not just at max range if ((((targetBlock != null) && (source != null)) && source.getWorld().equals(block.getWorld())) && (!result.isMiss())) { range = Math.min(range, source.distance(targetBlock.getLocation())); } // Pick the closest candidate entity Target entityTarget = null; List<Target> scored = getAllTargetEntities(context, range); if (scored.size() > 0) { entityTarget = scored.get(0); } // Don't allow targeting entities in an area you couldn't cast the spell in if (context instanceof CastContext) { CastContext castContext = ((CastContext) (context)); if ((entityTarget != null) && (!castContext.canCast(entityTarget.getLocation()))) { entityTarget = null; } if ((targetBlock != null) && (!castContext.canCast(targetBlock.getLocation()))) {result = TargetingResult.MISS; targetBlock = null; } } if ((targetType == TargetType.OTHER_ENTITY) && (entityTarget == null)) { result = TargetingResult.MISS; return new Target(source); } if ((targetType == TargetType.ANY_ENTITY) && (entityTarget == null)) { result = TargetingResult.ENTITY; return new Target(source, mageEntity); } if (((entityTarget == null) && (targetType == TargetType.ANY)) && (mageEntity != null)) { result = TargetingResult.ENTITY; return new Target(source, mageEntity, targetBlock == null ? null : targetBlock.getBlock()); } if ((targetBlock != null) && (entityTarget != null)) { if ((targetBlock.getDistanceSquared() < (entityTarget.getDistanceSquared() - (hitboxPadding * hitboxPadding))) && (!result.isMiss())) { entityTarget = null; } else { targetBlock = null;} } if (entityTarget != null) { result = TargetingResult.ENTITY; return entityTarget; } else if (targetBlock != null) {return targetBlock; } result = TargetingResult.MISS; return new Target(source); }
3.26
MagicPlugin_Targeting_getPreviousBlock_rdh
/** * Returns the previous block along the line of vision * * @return The block */ public Block getPreviousBlock() { return previousBlock; }
3.26
MagicPlugin_Wand_getExpToLevel_rdh
// Taken from NMS HumanEntity public static int getExpToLevel(int expLevel) { return expLevel >= 30 ? 112 + ((expLevel - 30) * 9) : expLevel >= 15 ? 37 + ((expLevel - 15) * 5) : 7 + (expLevel * 2); }
3.26
MagicPlugin_Wand_isLost_rdh
/* Public API Implementation */ @Override public boolean isLost(LostWand lostWand) { return (this.id != null) && this.id.equals(lostWand.getId()); }
3.26
MagicPlugin_Wand_updateHotbarCount_rdh
// Update the hotbars inventory list to match the most recently configured value // This will be followed with checkHotbarCount, after the inventories have been built // This catches the case of the hotbar count having changed so we can preserve the location // of spells in the main inventories. protected void updateHotbarCount() { int hotbarCount = 0; if (hasProperty("hotbar_inventory_count")) {hotbarCount = Math.max(1, getInt("hotbar_inventory_count", 1)); } else { hotbarCount = getHotbarCount(); } if (hotbarCount != hotbars.size()) { if (isInventoryOpen()) { closeInventory(); } hotbars.clear(); while (hotbars.size() < hotbarCount) { hotbars.add(new WandInventory(HOTBAR_INVENTORY_SIZE));} while (hotbars.size() > hotbarCount) { hotbars.remove(0); } } }
3.26
MagicPlugin_Wand_checkSpellLevelsAndInventory_rdh
/** * Covers the special case of a wand having spell levels and inventory slots that came from configs, * but now we've modified the spells list and need to figure out if we also need to persist the levels and * slots separately. * * <p>This should all be moved to CasterProperties at some point to handle the same sort of issues with mage class * configs. */ private void checkSpellLevelsAndInventory() {if (!spellLevels.isEmpty()) {MagicProperties storage = m16("spell_levels"); if ((storage == null) || (storage == this)) { if (!configuration.contains("spell_levels")) { configuration.set("spell_levels", spellLevels); } } } if (!spellInventory.isEmpty()) { MagicProperties storage = m16("spell_inventory"); if ((storage == null) || (storage == this)) { if (!configuration.contains("spell_inventory")) { configuration.set("spell_inventory", spellInventory); } } } }
3.26
MagicPlugin_Wand_checkHotbarCount_rdh
// This catches the hotbar_count having changed since the last time the inventory was built // in which case we want to add a new hotbar inventory without re-arranging the main inventories // newly added hotbars will be empty, spells in removed hotbars will be added to the end of the inventories. protected void checkHotbarCount() { if ((!hasInventory) || (getHotbarCount() == 0)) return; int v37 = Math.max(1, getInt("hotbar_count", 1)); if (v37 != hotbars.size()) { while (hotbars.size() < v37) { hotbars.add(new WandInventory(HOTBAR_INVENTORY_SIZE)); } while (hotbars.size() > v37) { hotbars.remove(0); } List<WandInventory> pages = new ArrayList<>(inventories); int slotOffset = getInt("hotbar_count") * HOTBAR_INVENTORY_SIZE; int index = 0; for (WandInventory inventory : pages) { for (ItemStack itemStack : inventory.items) { updateSlot(index + slotOffset, itemStack); index++; } } updateSpellInventory(); updateBrushInventory(); } setProperty("hotbar_inventory_count", v37); }
3.26
MagicPlugin_Wand_setMage_rdh
// This should be used sparingly, if at all... currently only // used when applying an upgrade to a wand while not held public void setMage(Mage mage) { this.mage = mage; }
3.26
MagicPlugin_Wand_wasInventoryOpen_rdh
// Somewhat hacky method to handle inventory close event knowing that this was a wand inventory that just closed. public boolean wasInventoryOpen() { return inventoryWasOpen; }
3.26
MagicPlugin_MapController_m0_rdh
/** * Force reload of a player headshot. */ @Override public void m0(String worldName, String playerName) { String url = CompatibilityLib.getSkinUtils().getOnlineSkinURL(playerName); if (url != null) { m1(worldName, url, 8, 8, 8, 8); } }
3.26
MagicPlugin_MapController_createMap_rdh
// This is copied from MagicController, which I'm still trying to keep out of this class. Shrug? public ItemStack createMap(int mapId) { short durability = (CompatibilityLib.isCurrentVersion()) ? 0 : ((short) (mapId)); ItemStack mapItem = CompatibilityLib.getDeprecatedUtils().createItemStack(DefaultMaterials.getFilledMap(), 1, durability); if (CompatibilityLib.isCurrentVersion()) { mapItem = CompatibilityLib.getItemUtils().makeReal(mapItem); CompatibilityLib.getNBTUtils().setInt(mapItem, "map", mapId); } return mapItem; }
3.26
MagicPlugin_MapController_resetAll_rdh
/** * Resets all internal data. * * <p>Can be called prior to save() to permanently delete all map images. * Can also be called prior to load() to load a fresh config file. */ public void resetAll() { for (URLMap map : f0.values()) { map.reset(); } }
3.26
MagicPlugin_MapController_getAll_rdh
// Public API @Override public List<URLMap> getAll() { return new ArrayList<>(idMap.values()); }
3.26
MagicPlugin_MapController_m1_rdh
/** * Force reload of the specific url and cropping. */ public void m1(String worldName, String url, int x, int y, int width, int height) { get(worldName, url, x, y, width, height).reload(); }
3.26
MagicPlugin_MapController_resend_rdh
/** * Force resending all maps to a specific player. */ public void resend(String playerName) {for (URLMap map : f0.values()) { map.resendTo(playerName); } }
3.26
MagicPlugin_MapController_save_rdh
/** * Saves the configuration file. * * <p>This is called automatically as changes are made, but you can call it in onDisable to be safe. */ public void save(boolean asynchronous) { if (!loaded) { if (plugin == null) { Bukkit.getLogger().warning("[Magic] Attempted to save image map data before initialization"); } else { plugin.getLogger().warning("Attempted to save image map data before initialization"); } return; } if ((configurationFile == null) || disabled) return; if (asynchronous && ((saveTask != null) || (plugin == null))) return; Runnable runnable = new SaveMapsRunnable(this, idMap.values()); if (asynchronous) { saveTask = Bukkit.getScheduler().runTaskAsynchronously(plugin, runnable); } else { runnable.run(); } }
3.26
MagicPlugin_MapController_getMapItem_rdh
/** * A helper function to get an ItemStack from a MapView. * * @param name * The display name to give the new item. Optional. */ public ItemStack getMapItem(String name, int mapId) {ItemStack newMapItem = createMap(mapId); if (name != null) { ItemMeta meta = newMapItem.getItemMeta(); meta.setDisplayName(name); newMapItem.setItemMeta(meta); } return newMapItem; }
3.26
MagicPlugin_MapController_getPlayerPortrait_rdh
/** * Get an ItemStack that is a headshot of a player's skin. */ @Nullable @Override public ItemStack getPlayerPortrait(String worldName, String playerName, Integer priority, String photoLabel) { photoLabel = (photoLabel == null) ? playerName : photoLabel; String url = CompatibilityLib.getSkinUtils().getOnlineSkinURL(playerName); if (url != null) { MapView mapView = getURL(worldName, url, photoLabel, 8, 8, 40, 8, 8, 8, priority, playerName); return getMapItem(photoLabel, mapView); }MapView mapView = getURL(worldName, null, photoLabel, 8, 8, 40, 8, 8, 8, priority, playerName); return getMapItem(photoLabel, mapView); }
3.26
MagicPlugin_MapController_getURLItem_rdh
/** * Get a new ItemStack for the specified url with a specific cropping. */ @Override public ItemStack getURLItem(String world, String url, String name, int x, int y, int width, int height, Integer priority) { MapView mapView = getURL(world, url, name, x, y, null, null, width, height, priority); return getMapItem(name, mapView); }
3.26
MagicPlugin_SpellAction_load_rdh
/** * This mechanism never worked properly and is no longer called. * Actions that need to store data should interact with CastContext.getVariables instead. */ @Deprecateddefault void load(Mage mage, ConfigurationSection data) { }
3.26
MagicPlugin_SpellAction_save_rdh
/** * This mechanism never worked properly and is no longer called. * Actions that need to store data should interact with CastContext.getVariables instead. */ @Deprecated default void save(Mage mage, ConfigurationSection data) { }
3.26
MagicPlugin_CraftingController_isCraftingSlot_rdh
// Borrowed from InventoryView and pruned, // TODO: Switch to InventoryView.getSlotType when dropping 1.9 compat public final boolean isCraftingSlot(InventoryView view, int slot) { if ((slot >= 0) && (slot < view.getTopInventory().getSize())) { if ((view.getType() == InventoryType.WORKBENCH) || (view.getType() == InventoryType.CRAFTING)) { return slot > 0; } } return false; }
3.26
MagicPlugin_BlockFace_getModZ_rdh
/** * Get the amount of Z-coordinates to modify to get the represented block * * @return Amount of Z-coordinates to modify */ public int getModZ() { return modZ; }
3.26
MagicPlugin_BlockFace_getModY_rdh
/** * Get the amount of Y-coordinates to modify to get the represented block * * @return Amount of Y-coordinates to modify */ public int getModY() { return modY; }
3.26
MagicPlugin_EnteredStateTracker_touch_rdh
/** * This is just here to avoid compiler warnings by giving the user something to call */ public void touch() { }
3.26
MagicPlugin_PreLoadEvent_registerCurrency_rdh
/** * Register a custom currency, which can be used in shops, spell worth/earns and casting costs. * * @param currency * A currency instance to register */ public void registerCurrency(Currency currency) { currencies.add(currency); }
3.26
MagicPlugin_PreLoadEvent_registerPVPManager_rdh
/** * Register a PVPManager, for controlling whether or not players can harm other players with magic. * * @param manager * The manager to add. */ public void registerPVPManager(PVPManager manager) { pvpManagers.add(manager); }
3.26
MagicPlugin_PreLoadEvent_registerCastPermissionManager_rdh
/** * Register a CastPermissionManager, for controlling whether or not players can cast spells in * specific regions. * * @param manager * The manager to add. */ public void registerCastPermissionManager(CastPermissionManager manager) { castManagers.add(manager); }
3.26
MagicPlugin_PreLoadEvent_registerBlockBuildManager_rdh
/** * Register a BlockBuildManager, for controlling whether or not players can place blocks with magic. * * @param manager * The manager to add. */ public void registerBlockBuildManager(BlockBuildManager manager) { blockBuildManager.add(manager); }
3.26
MagicPlugin_PreLoadEvent_registerAttributeProvider_rdh
/** * Register an AttributeProvider, for adding custom attribute support to spells and mages. * * @param provider * The provider to add. */ public void registerAttributeProvider(AttributeProvider provider) { attributeProviders.add(provider);}
3.26
MagicPlugin_PreLoadEvent_registerPlayerWarpManager_rdh
/** * Register a PlayerWarpManager, for providing warps to be used in the Recall menu. * The name of the manager as registered corresponds with the "allow_player_warps" map in the recall * spell configuration. * * @param key * The name of the manager * @param manager * The manager to add */ public void registerPlayerWarpManager(String key, PlayerWarpManager manager) { warpManagers.put(key, manager); }
3.26
MagicPlugin_PreLoadEvent_registerRequirementsProcessor_rdh
/** * Register a RequirementsProcessor for handling a specific type of requirement. * * <p>Requirement types are 1:1 with processors, each type may only have one processor associated with it. * * <p>Processors must be re-registered with each load. * * <p>Example requirement block, which might appear in a spell, Selector or other config: * * <code> * requirements: * - type: skillapi * skill: enchanting * - type: avengers * power: hulkout * character: Hulk * </code> * * @param requirementType * The type of requirements this processor handles * @param processor * The processor to register */ public void registerRequirementsProcessor(String requirementType, RequirementsProcessor processor) { if (requirementProcessors.containsKey(requirementType)) { controller.getLogger().warning("Tried to register RequiremensProcessor twice for same type: " + requirementType); } requirementProcessors.put(requirementType, processor); }
3.26
MagicPlugin_PreLoadEvent_registerTeamProvider_rdh
/** * Register a TeamProvider, to be able to make decisions about who players and mobs can target. * * @param provider * The provider to add. */ public void registerTeamProvider(TeamProvider provider) { teamProviders.add(provider); }
3.26
MagicPlugin_PreLoadEvent_registerEntityTargetingManager_rdh
/** * Register an EntityTargetingProvider, for determining when one entity may target another with spells. * * @param manager * The manager to add. */ public void registerEntityTargetingManager(EntityTargetingManager manager) { f0.add(manager); }
3.26
MagicPlugin_PreLoadEvent_registerBlockBlockManager_rdh
/** * Register a BlockBreakManager, for controlling whether or not players can break blocks with magic. * * @param manager * The manager to add. */ public void registerBlockBlockManager(BlockBreakManager manager) { blockBreakManagers.add(manager); }
3.26
MagicPlugin_BlinkSpell_delayTeleport_rdh
/** * Delay tp by one tick, mainly for effects. */ protected void delayTeleport(final Entity entity, final Location location) { registerMoved(entity);Bukkit.getScheduler().scheduleSyncDelayedTask(controller.getPlugin(), new Runnable() { @Override public void run() { entity.teleport(location); registerForUndo(); playEffects("teleport"); } }, 1); }
3.26
MagicPlugin_ActionFactory_construct_rdh
/** * Constructs a new action from a class name. * * @param actionClassName * The class name of the action. * @return The constructed action. * @throws ActionFactoryException * If no action could be constructed. */public static BaseSpellAction construct(String actionClassName) throws ActionFactoryException { List<String> attempts = new ArrayList<>(); for (ActionResolver resolver : resolvers) { ActionConstructor constructor = resolver.resolve(actionClassName, attempts); if (constructor != null) { return constructor.construct(); } } throw new ActionFactoryException((("Failed to resolve class: " + actionClassName) + "\nTried: ") + attempts); }
3.26
MagicPlugin_ActionFactory_m0_rdh
/** * Unregister a resolver. * * @param actionResolver * The action resolver to remove. * @throws NullPointerException * When actionResolver is null. */ public static void m0(ActionResolver actionResolver) { Preconditions.checkNotNull(actionResolver); Iterator<ActionResolver> it = resolvers.iterator(); while (it.hasNext()) { if (it.next().equals(actionResolver)) { it.remove(); } } }
3.26
MagicPlugin_ActionFactory_getActionResolvers_rdh
/** * * @return An unmodifiable list of action resolvers. */ public static List<ActionResolver> getActionResolvers() { return Collections.unmodifiableList(resolvers); }
3.26
MagicPlugin_ActionFactory_registerResolver_rdh
/** * Registers an action resolver. * * @param actionResolver * The action resolver to register. * @param highPriority * When this is set to true, the resolver is registered such that * it is used before any of the currently registered resolvers. * @throws NullPointerException * When actionResolver is null. */ public static void registerResolver(ActionResolver actionResolver, boolean highPriority) { Preconditions.checkNotNull(actionResolver); if (!resolvers.contains(actionResolver)) { if (highPriority) { resolvers.add(0, actionResolver); } else { resolvers.add(actionResolver); } } }
3.26
MagicPlugin_MagicSpawnHandler_process_rdh
/** * Returns true if the spawn should be cancelled */ public boolean process(Plugin plugin, LivingEntity entity) { List<SpawnRule> entityRules = entityTypeMap.get(entity.getType()); SpawnResult result = processRules(plugin, entity, entityRules); if (result == SpawnResult.STOP) return false; if (result != SpawnResult.SKIP) return true; result = processRules(plugin, entity, globalRules); return (result == SpawnResult.REMOVE) || (result == SpawnResult.REPLACE); }
3.26
MagicPlugin_URLMap_render_rdh
// Render method override @Override public void render(MapView mapView, MapCanvas canvas, Player player) { if (((animated && (frameTimes != null)) && (frameTimes.size() > 0)) && controller.isAnimationAllowed()) { long now = System.currentTimeMillis(); long delay = frameTimes.get(frame); if (now > (lastFrameChange + delay)) { frame = (frame + 1) % frameTimes.size(); sentToPlayers.clear(); rendered = false; lastFrameChange = now; } } if (rendered) { if ((priority != null) && (player != null)) { sendToPlayer(player, mapView); } return; } BufferedImage image = getImage(); if (image != null) { canvas.drawImage(0, 0, image); rendered = true; } }
3.26
MagicPlugin_CompoundAction_addAction_rdh
// These are here for legacy spell support // via programmatic action building public void addAction(SpellAction action) { addAction(action, null); }
3.26
MagicPlugin_CustomProjectileAction_m0_rdh
// This is used by EntityProjectile when first spawning the entity protected Location m0(Location location) { if (startDistance != 0) { Vector velocity = location.getDirection().clone().normalize(); location.add(velocity.clone().multiply(startDistance)); } return location; }
3.26
MagicPlugin_DirectionUtils_goLeft_rdh
/** * A helper function to go change a given direction to the direction "to the right". * * <p>There's probably some better matrix-y, math-y way to do this. * It'd be nice if this was in BlockFace. * * @param direction * The current direction * @return The direction to the left */ public static BlockFace goLeft(BlockFace direction) { switch (direction) { case EAST : return BlockFace.NORTH; case NORTH : return BlockFace.WEST; case WEST : return BlockFace.SOUTH; case SOUTH : return BlockFace.EAST; default : return direction; } }
3.26