This commit is contained in:
disclearing 2019-01-21 21:42:10 +00:00
parent d73fc1733d
commit 7e842c1512
5188 changed files with 709282 additions and 1 deletions

View File

@ -1 +1 @@
# WenjaPVP-is-skid
WenjaPVP

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="C:/Users/Owner/Map1/HQPOTS - HCF/libs/paperspigot-api.jar"/>
<classpathentry kind="lib" path="C:/Users/Owner/Map1/HQPOTS - HCF/libs/ProtocolLib.jar"/>
<classpathentry kind="lib" path="C:/Users/Owner/Map1/HQPOTS - HCF/libs/trove-3.1a1-src.jar"/>
<classpathentry kind="lib" path="C:/Users/Owner/Map1/HQPOTS - HCF/libs/WorldEdit.jar"/>
<classpathentry kind="lib" path="C:/Development/Plugins.rar/Plugins.rar/PermissionsEx-1.23.3.jar"/>
<classpathentry kind="lib" path="C:/Users/Owner/Pictures/Screenshots/plugins/EssentialsX-2.0.1.jar"/>
<classpathentry kind="lib" path="C:/Development/Plugins.rar/Plugins.rar/Depend/lombok-1.16.6.jar"/>
<classpathentry kind="lib" path="C:/Development/Plugins.rar/Plugins.rar/Server/paperspigot.jar"/>
<classpathentry kind="lib" path="C:/Development/Plugins.rar/Plugins.rar/Server/plugins/WorldEdit/Vault.jar"/>
<classpathentry kind="lib" path="C:/Development/Plugins.rar/Plugins.rar/Server/plugins/WorldEdit/Pathogen.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -0,0 +1,8 @@
<component name="ArtifactManager">
<artifact type="jar" name="HCFactions:jar">
<output-path>$PROJECT_DIR$/classes/artifacts/HCFactions_jar</output-path>
<root id="archive" name="WenjaPvP - HCF - BetaMap.jar">
<element id="module-output" name="HCFactions" />
</root>
</artifact>
</component>

View File

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="true">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
</project>

View File

@ -0,0 +1,3 @@
<component name="CopyrightManager">
<settings default="" />
</component>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="KotlinCommonCompilerArguments">
<option name="languageVersion" value="1.1" />
<option name="apiVersion" value="1.1" />
</component>
</project>

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ClientPropertiesManager">
<properties class="javax.swing.AbstractButton">
<property name="hideActionText" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JComponent">
<property name="html.disable" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JEditorPane">
<property name="JEditorPane.w3cLengthUnits" class="java.lang.Boolean" />
<property name="JEditorPane.honorDisplayProperties" class="java.lang.Boolean" />
<property name="charset" class="java.lang.String" />
</properties>
<properties class="javax.swing.JList">
<property name="List.isFileList" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JPasswordField">
<property name="JPasswordField.cutCopyAllowed" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JSlider">
<property name="Slider.paintThumbArrowShape" class="java.lang.Boolean" />
<property name="JSlider.isFilled" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JTable">
<property name="Table.isFileList" class="java.lang.Boolean" />
<property name="JTable.autoStartsEdit" class="java.lang.Boolean" />
<property name="terminateEditOnFocusLost" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JToolBar">
<property name="JToolBar.isRollover" class="java.lang.Boolean" />
</properties>
<properties class="javax.swing.JTree">
<property name="JTree.lineStyle" class="java.lang.String" />
</properties>
<properties class="javax.swing.text.JTextComponent">
<property name="caretAspectRatio" class="java.lang.Double" />
<property name="caretWidth" class="java.lang.Integer" />
</properties>
</component>
<component name="EntryPointsManager">
<entry_points version="2.0" />
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="mavenHome" value="Bundled (Maven 3)" />
</MavenGeneralSettings>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/classes" />
</component>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/HCFactions.iml" filepath="$PROJECT_DIR$/HCFactions.iml" />
</modules>
</component>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>WenjaPvP - HCFactions</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager">
<libelement value="jar://$USER_HOME$/Map1/HQPOTS - HCF/libs/lombok-1.16.6.jar!/" />
<libelement value="jar://$USER_HOME$/Map1/HQPOTS - HCF/libs/paperspigot-api.jar!/" />
<libelement value="jar://$USER_HOME$/Map1/HQPOTS - HCF/libs/ProtocolLib.jar!/" />
<libelement value="jar://$USER_HOME$/Map1/HQPOTS - HCF/libs/spigot.jar!/" />
<libelement value="jar://$USER_HOME$/Map1/HQPOTS - HCF/libs/trove-3.1a1-src.jar!/" />
<libelement value="jar://$USER_HOME$/Map1/HQPOTS - HCF/libs/Vault.jar!/" />
<libelement value="jar://$USER_HOME$/Map1/HQPOTS - HCF/libs/WorldEdit.jar!/" />
<libelement value="jar://C:/Development/Plugins.rar/zPermissions-1.2a.jar!/" />
<libelement value="jar://C:/Development/Plugins.rar/Plugins.rar/PermissionsEx-1.23.3.jar!/" />
<libelement value="jar://C:/Development/Plugins.rar/Plugins.rar/Server - Hub 1/plugins/EssentialsX-2.0.1.jar!/" />
<src_description expected_position="0">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
</src_description>
</component>
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/bin" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="module-library">
<library name="lombok-1.16.6.jar">
<CLASSES>
<root url="jar://$USER_HOME$/Map1/HQPOTS - HCF/libs/lombok-1.16.6.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="ProtocolLib.jar">
<CLASSES>
<root url="jar://$USER_HOME$/Map1/HQPOTS - HCF/libs/ProtocolLib.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="trove-3.1a1-src.jar">
<CLASSES>
<root url="jar://$USER_HOME$/Map1/HQPOTS - HCF/libs/trove-3.1a1-src.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="Vault.jar">
<CLASSES>
<root url="jar://$USER_HOME$/Map1/HQPOTS - HCF/libs/Vault.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="WorldEdit.jar">
<CLASSES>
<root url="jar://$USER_HOME$/Map1/HQPOTS - HCF/libs/WorldEdit.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="PermissionsEx-1.23.3.jar">
<CLASSES>
<root url="jar://C:/Development/Plugins.rar/Plugins.rar/PermissionsEx-1.23.3.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Development/Plugins.rar/Plugins.rar/Depend/Essentials.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://C:/Development/Plugins.rar/Plugins.rar/Server/paperspigot-1.7.10-R0.1-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://C:/Development/Plugins.rar/Plugins.rar/Server/paperspigot-1.7.10-R0.1-SNAPSHOT.jar!/" />
</SOURCES>
</library>
</orderEntry>
</component>
</module>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1 @@
balances: {}

View File

@ -0,0 +1,87 @@
death-signs: true
diamond-ore-notifications: true
death-lightning: true
map-number: 1
kit-map: false
prevent-ally-damage: true
exp-multiplier:
global: 2.0
fishing: 2.0
smelting: 2.0
looting-per-level: 1.5
luck-per-level: 1.5
fortune-per-level: 1.5
roads:
allow-claims-besides: true
scoreboard:
sidebar:
title: "&a&lHCF &c[Map {MAP_NUMBER}]"
enabled: true
nametags:
enabled: true
combatlog:
enabled: true
despawn-delay-ticks: 600
conquest:
point-loss-per-death: 20
victory-points: 300
allow-negative-points: true
warzone:
radius: 800
factions:
disallowed-faction-names:
- EOTW
min-name-characters: 3
max-name-characters: 16
max-members: 25
max-allies: 1
subclaims:
min-name-characters: 3
max-name-characters: 16
relation-colours:
wilderness: DARK_GREEN
warzone: LIGHT_PURPLE
teammate: GREEN
ally: GOLD
enemy: RED
road: GOLD
deaths-till-raidable:
maximum: 6
millis-between-updates: 45000
increment-between-updates: 0.1
deathban:
base-duration-minutes: 120
respawn-screen-seconds-before-kick: 15
enchantment-limits:
PROTECTION_ENVIRONMENTAL: 3
PROTECTION_FIRE: 3
SILK_TOUCH: 1
DURABILITY: 3
PROTECTION_EXPLOSIONS: 3
LOOT_BONUS_BLOCKS: 3
PROTECTION_PROJECTILE: 3
OXYGEN: 3
WATER_WORKER: 1
THORNS: 0
DAMAGE_ALL: 3
ARROW_KNOCKBACK: 1
KNOCKBACK: 1
FIRE_ASPECT: 1
LOOT_BONUS_MOBS: 3
LUCK: 3
LURE: 3
end:
open: true
exit: world,0.5,75,0.5,0,0
eotw:
chat-symbol-prefix: ""
chat-symbol-suffix: ""
last-map-cappers: []
potion-limits:
STRENGTH: 0
INVISIBILITY: 0
REGEN: 0
WEAKNESS: 0
INSTANT_DAMAGE: 0
SLOWNESS: 1
POISON: 1

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,2 @@
# year, month, day, hour, minute: eventName (24 hour clock)
# 2015,1,1,2,0:Example This would run event named 'Example' at 2AM on the 1st of January, 2015.

View File

@ -0,0 +1 @@
users: {}

View File

@ -0,0 +1 @@
factions: {}

View File

@ -0,0 +1,24 @@
<!--
~ ///////////////////////////////////////////////////////////////////////////////
~ // Copyright (c) 2009, Rob Eden All Rights Reserved.
~ //
~ // This library is free software; you can redistribute it and/or
~ // modify it under the terms of the GNU Lesser General Public
~ // License as published by the Free Software Foundation; either
~ // version 2.1 of the License, or (at your option) any later version.
~ //
~ // This library is distributed in the hope that it will be useful,
~ // but WITHOUT ANY WARRANTY; without even the implied warranty of
~ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ // GNU General Public License for more details.
~ //
~ // You should have received a copy of the GNU Lesser General Public
~ // License along with this program; if not, write to the Free Software
~ // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
~ ///////////////////////////////////////////////////////////////////////////////
-->
<html>
This package (and its sub-packages) contain internal implementations used in Trove. These
classes should <strong>not</strong> be accessed directly (treat them like <tt>com.sun</tt>
classes.
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

View File

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
lives: {}

View File

@ -0,0 +1 @@
SCOREBOARD.TITLE: "&6&lHCGames"

View File

@ -0,0 +1,113 @@
<!-- $Id: overview.html 1469004 2013-04-17 17:37:03Z tn $ -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<body>
<p>
Commons-Collections contains implementations, enhancements and utilities
that complement the Java Collections Framework.
</p>
<p>
The Apache Commons Collections Framework component adds a significant
amount of enhancements to the standard JDK collections. These enhancements
come in the form of new interfaces, new implementations and utility classes.
</p>
<p>
See also the <code>java.util</code> package for the standard Java collections.
</p>
<h4>Main features</h4>
<p>
Commons-Collections defines a number of key interfaces:
</p>
<table border="1" cellspacing="0" cellpadding="3">
<tr bgcolor="#CCCCFF" class="TableHeadingColor">
<th>Interface</th><th>Description</th>
</tr>
<tr>
<td>
{@link org.apache.commons.collections.Bag}
</td>
<td valign="top">
A new <code>Collection</code> subinterface that stores each object together
with the number of occurrences. Methods are provided to get the number of
occurrences, and to add and remove a certain number of that object.
</td>
</tr>
<tr>
<td>
{@link org.apache.commons.collections.Buffer}
</td>
<td valign="top">
A new <code>Collection</code> subinterface that allows objects to be removed
in some well-defined order. Methods enable the next item to be peeked and removed.
</td>
</tr>
<tr>
<td>
{@link org.apache.commons.collections.BidiMap}
</td>
<td valign="top">
A new <code>Map</code> subinterface that allows lookup from key to value and
from value to key with equal ease.
</td>
</tr>
<tr>
<td>
{@link org.apache.commons.collections.OrderedMap}
</td>
<td valign="top">
A new <code>Map</code> subinterface that is used when a map has an order, but is
not sorted. Methods enable bidirectional iteration through the map.
</td>
</tr>
<tr>
<td>
{@link org.apache.commons.collections.MapIterator}
</td>
<td valign="top">
A new <code>Iterator</code> subinterface specially designed for maps. This iterator
avoids the need for entrySet iteration of a map, and is simpler to use.
</td>
</tr>
<tr>
<td>
{@link org.apache.commons.collections.ResettableIterator}
</td>
<td valign="top">
A new <code>Iterator</code> subinterface that allows the iteration to be reset back
to the start. Many iterators in this library have this functionality.
</td>
</tr>
<tr>
<td>
{@link org.apache.commons.collections.Closure}<br />
{@link org.apache.commons.collections.Predicate}<br />
{@link org.apache.commons.collections.Transformer}<br />
{@link org.apache.commons.collections.Factory}<br />
</td>
<td valign="top">
A group of <i>functor</i> interfaces that provide plugin behaviour to various
collections and utilities.
</td>
</tr>
</table>
<p>
In addition to the interfaces, there are many implementations.
Consult each subpackage for full details of these.
</p>
</body>

View File

@ -0,0 +1,84 @@
name: WenjaPvPHCF
version: 1.1-RELEASE
description: "Custom HCFCore Forked by Gender"
author: DoctorDark, Mason
main: server.wenjapvp.hcf.HCF
softdepend: [ProtocolLib]
commands:
hcf:
spawn:
enderdragon:
hub:
this:
playtime:
cobble:
staffinfo:
aliases: [staffbaninfo]
crowgive:
aliases: [crowbar, crowbargive]
wenja:
hcfhelp:
aliases: [help, ehelp]
conquest:
description: Command used to handle Conquest events.
economy:
aliases: [$, bal, money, eco, econ]
description: Command used to modify the economy.
eotw:
aliases: [endoftheworld]
description: Sets if the server is in End of the World mode.
event:
description: Command used to manage minigame events.
faction:
aliases: [f, fac]
description: Faction related commands.
gopple:
description: Command to check remaining OP apple cooldown time.
aliases: [opple, goppletimer, goppletime, oppletimer, oppletime]
hcf:
aliases: [hardcorefactions, hcfactions]
koth:
description: Make or delete KotH arenas.
lives:
description: Management of lives or deathbans.
location:
aliases: [loc]
description: Check the faction location of a player.
logout:
aliases: [disconnect]
description: Command to safely logout without an NPC spawning.
mapkit:
aliases: [viewkit]
description: Used to check the current map restrictions.
pay:
aliases: [p2p]
description: Allow players to pay money.
pvptimer:
aliases: [pvp]
description: Command to enable or disable pvp timer protection.
regen:
description: Check ETA until a faction is able to regenerate DTR.
servertime:
description: Checks the date and time of server.
sotw:
aliases: [startoftheworld]
description: Command used to manage start of the world.
spawncannon:
aliases: [cannon, playercannon]
description: Shoots you into the warzone.
staffrevive:
description: Command used by staff to revive players.
timer:
description: Command to manage timers.
togglebroadcasts:
aliases: [tb]
description: Toggle found diamond ore notifications.
togglecapzoneentry:
aliases: [togglecapentry]
description: Command used to hide or show capture zone entry messages.
togglelightning:
aliases: [lightningtoggle, togglestrikes]
description: Toggles the lightning strikes for when a player dies.
togglesidebar:
aliases: [sidebartoggle, sidebar, hud, togglehud]
description: Toggles the scoreboard timers displayed on sidebar.

View File

@ -0,0 +1,106 @@
disable_obsidian_generators: true
server_time_zone: "EST"
warzone_radius: 400
donate_url: freshcrafthcf.us/shop"
spawn_buffer: 128
map_number: 3
kit_map: false
disallowed_faction_names:
- "kohieotw"
- "kohisotw"
- "hcteams"
- "hcteamsseotw"
- "hcteamssotw"
- "para"
- "parahcf"
- "parasotw"
- "paraeotw"
enchantment_limits:
PROTECTION_ENVIRONMENTAL: 1
DAMAGE_ALL: 1
ARROW_KNOCKBACK: 0
KNOCKBACK: 0
FIRE_ASPECT: 0
THORNS: 0
ARROW_FIRE: 1
ARROW_DAMAGE: 3
potion_limits:
STRENGTH: 0
WEAKNESS: 0
SLOWNESS: 0
INVISIBILITY: 0
POISON: 0
road_lengths:
NORMAL: 4000
NETHER: 4000
border_sizes:
NORMAL: 2000
NETHER: 1000
THE_END: 1500
spawn_radius_map:
NORMAL: 50
NETHER: 25
THE_END: 15
diamond_ore_alerts: false
subclaim_name_characters_min: 3
subclaim_name_characters_max: 16
faction_name_characters_min: 3
faction_name_characters_max: 16
max_members_per_faction: 15
road_distance: 2500
road_min_height: 0
road_max_height: 256
end_portal_radius: 20
end_portal_center: 750
#milliseconds, default 1hour
default_deathban_duration: 3600000
teammate_colour: "DARK_GREEN"
ally_colour: "LIGHT_PURPLE"
enemy_colour: "YELLOW"
safezone_colour: "GREEN"
road_colour: "RED"
warzone_colour: "RED"
wilderness_colour: "GRAY"
scoreboard_title: "&6&lHQPots &c[Map 1]"
max_allies_per_faction: 1
max_claims_per_faction: 8
allow_claiming_besides_roads: false
dtr_millis_between_updates: 45000
dtr_increment_between_updates: 0.1
maximum_dtr: 6.0
exp_multiplier_general: 2.0
exp_multiplier_fishing: 2.0
exp_multiplier_smelting: 2.0
exp_multiplier_looting_per_level: 6.0
exp_multiplier_luck_per_level: 1.5
exp_multiplier_fortune_per_level: 1.5
conquest_point_loss_per_death: 30
conquest_required_win_points: 300
found_diamonds_alerts: true
combat_log_despawn_ticks: 600
combat_log_prevention_enabled: true

View File

View File

View File

@ -0,0 +1 @@
balances: {}

View File

@ -0,0 +1,47 @@
package com.doctordark.compat.com.google.common.collect;
import com.google.common.annotations.*;
import java.util.*;
import javax.annotation.*;
import com.google.common.base.*;
import com.google.common.collect.*;
@GwtCompatible(emulated = true)
public abstract class FluentIterableCompat<E> implements Iterable<E> {
private final Iterable<E> iterable;
FluentIterableCompat(final Iterable<E> iterable) {
this.iterable = (Iterable<E>) Preconditions.checkNotNull((Object) iterable);
}
@CheckReturnValue
public static <E> FluentIterableCompat<E> from(final Iterable<E> iterable) {
return (iterable instanceof FluentIterableCompat) ? ((FluentIterableCompat) iterable) : new FluentIterableCompat<E>(iterable) {
@Override
public Iterator<E> iterator() {
return iterable.iterator();
}
};
}
@CheckReturnValue
@Override
public String toString() {
return Iterables.toString((Iterable) this.iterable);
}
@CheckReturnValue
public final FluentIterableCompat<E> filter(final Predicate<? super E> predicate) {
return from((Iterable<E>) Iterables.filter((Iterable) this.iterable, (Predicate) predicate));
}
@CheckReturnValue
public final <T> FluentIterableCompat<T> transform(final Function<? super E, T> function) {
return from((Iterable<T>) Iterables.transform((Iterable) this.iterable, (Function) function));
}
@CheckReturnValue
public final ImmutableList<E> toList() {
return (ImmutableList<E>) ImmutableList.copyOf((Iterable) this.iterable);
}
}

View File

@ -0,0 +1,20 @@
package com.doctordark.compat.com.google.common.collect;
import com.google.common.base.*;
import javax.annotation.*;
public class GuavaCompat {
public static <T extends Enum<T>> Optional<T> getIfPresent(final Class<T> enumClass, final String value) {
Preconditions.checkNotNull((Object) enumClass);
Preconditions.checkNotNull((Object) value);
try {
return (Optional<T>) Optional.of(Enum.valueOf(enumClass, value));
} catch (IllegalArgumentException iae) {
return Optional.absent();
}
}
public static <T> T firstNonNull(@Nullable final T first, @Nullable final T second) {
return (T) ((first != null) ? first : Preconditions.checkNotNull(second));
}
}

View File

@ -0,0 +1,11 @@
package com.doctordark.internal.com.doctordark.base;
import org.bukkit.*;
public final class BaseConstants {
public static final String PLAYER_WITH_NAME_OR_UUID_NOT_FOUND;
static {
PLAYER_WITH_NAME_OR_UUID_NOT_FOUND = ChatColor.GOLD + "Player with name or UUID '" + ChatColor.WHITE + "%1$s" + ChatColor.GOLD + "' not found.";
}
}

View File

@ -0,0 +1,67 @@
package com.doctordark.internal.com.doctordark.base;
import java.util.*;
import org.bukkit.plugin.java.*;
import com.doctordark.util.*;
import org.bukkit.configuration.serialization.*;
import com.doctordark.util.cuboid.*;
import com.doctordark.util.itemdb.*;
import com.doctordark.util.chat.*;
import java.io.*;
import org.bukkit.block.*;
public class BasePlugin {
private Random random;
private ItemDb itemDb;
private SignHandler signHandler;
private static BasePlugin plugin;
private JavaPlugin javaPlugin;
private BasePlugin() {
this.random = new Random();
}
public void init(final JavaPlugin plugin) {
this.javaPlugin = plugin;
ConfigurationSerialization.registerClass((Class) PersistableLocation.class);
ConfigurationSerialization.registerClass((Class) Cuboid.class);
ConfigurationSerialization.registerClass((Class) NamedCuboid.class);
this.itemDb = new SimpleItemDb(plugin);
this.signHandler = new SignHandler(plugin);
try {
Lang.initialize("en_US");
} catch (IOException ex) {
ex.printStackTrace();
}
}
public void disable() {
this.signHandler.cancelTasks(null);
this.javaPlugin = null;
BasePlugin.plugin = null;
}
public Random getRandom() {
return this.random;
}
public ItemDb getItemDb() {
return this.itemDb;
}
public SignHandler getSignHandler() {
return this.signHandler;
}
public static BasePlugin getPlugin() {
return BasePlugin.plugin;
}
public JavaPlugin getJavaPlugin() {
return this.javaPlugin;
}
static {
BasePlugin.plugin = new BasePlugin();
}
}

View File

@ -0,0 +1,5 @@
package com.doctordark.internal.com.doctordark.base;
public interface Callback<V> {
void done(final V p0, final Throwable p1);
}

View File

@ -0,0 +1,173 @@
package com.doctordark.util;
import com.google.common.collect.*;
import gnu.trove.list.*;
import java.util.stream.*;
import org.bukkit.command.*;
import org.bukkit.craftbukkit.v1_7_R4.entity.*;
import net.minecraft.server.v1_7_R4.*;
import org.bukkit.event.entity.*;
import org.bukkit.projectiles.*;
import org.bukkit.*;
import org.bukkit.World;
import org.bukkit.block.*;
import org.bukkit.block.Block;
import org.bukkit.potion.*;
import org.bukkit.entity.*;
import org.bukkit.entity.Entity;
import java.util.*;
import com.google.common.base.*;
import gnu.trove.list.array.*;
public final class BukkitUtils {
private static final ImmutableMap<ChatColor, DyeColor> CHAT_DYE_COLOUR_MAP;
private static final ImmutableSet<PotionEffectType> DEBUFF_TYPES;
private static final int DEFAULT_COMPLETION_LIMIT = 80;
private static final String STRAIGHT_LINE_TEMPLATE;
public static final String STRAIGHT_LINE_DEFAULT;
private static final TCharList COLOUR_CHARACTER_LIST;
public static int countColoursUsed(final String id, final boolean ignoreDuplicates) {
int count = 0;
final Set<ChatColor> found = new HashSet<ChatColor>();
for (int i = 1; i < id.length(); ++i) {
final char current = id.charAt(i);
if (BukkitUtils.COLOUR_CHARACTER_LIST.contains(current) && id.charAt(i - 1) == '&' && (ignoreDuplicates || found.add(ChatColor.getByChar(current)))) {
++count;
}
}
return count;
}
public static List<String> getCompletions(final String[] args, final List<String> input) {
return getCompletions(args, input, 80);
}
public static List<String> getCompletions(final String[] args, final List<String> input, final int limit) {
Preconditions.checkNotNull((Object) args);
Preconditions.checkArgument(args.length != 0);
final String argument = args[args.length - 1];
return input.stream().filter(string -> string.regionMatches(true, 0, argument, 0, argument.length())).limit(limit).collect(Collectors.toList());
}
public static String getDisplayName(final CommandSender sender) {
Preconditions.checkNotNull((Object) sender);
return (sender instanceof Player) ? ((Player) sender).getDisplayName() : sender.getName();
}
public static long getIdleTime(final Player player) {
Preconditions.checkNotNull((Object) player);
final long idleTime = ((CraftPlayer) player).getHandle().x();
return (idleTime > 0L) ? (MinecraftServer.ar() - idleTime) : 0L;
}
public static DyeColor toDyeColor(final ChatColor colour) {
return (DyeColor) BukkitUtils.CHAT_DYE_COLOUR_MAP.get((Object) colour);
}
public static Player getFinalAttacker(final EntityDamageEvent ede, final boolean ignoreSelf) {
Player attacker = null;
if (ede instanceof EntityDamageByEntityEvent) {
final EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) ede;
final Entity damager = event.getDamager();
if (event.getDamager() instanceof Player) {
attacker = (Player) damager;
} else if (event.getDamager() instanceof Projectile) {
final Projectile projectile = (Projectile) damager;
final ProjectileSource shooter = projectile.getShooter();
if (shooter instanceof Player) {
attacker = (Player) shooter;
}
}
if (attacker != null && ignoreSelf && event.getEntity().equals(attacker)) {
attacker = null;
}
}
return attacker;
}
public static Player playerWithNameOrUUID(final String string) {
if (string == null) {
return null;
}
return JavaUtils.isUUID(string) ? Bukkit.getPlayer(UUID.fromString(string)) : Bukkit.getPlayer(string);
}
@Deprecated
public static OfflinePlayer offlinePlayerWithNameOrUUID(final String string) {
if (string == null) {
return null;
}
return JavaUtils.isUUID(string) ? Bukkit.getOfflinePlayer(UUID.fromString(string)) : Bukkit.getOfflinePlayer(string);
}
public static boolean isWithinX(final Location location, final Location other, final double distance) {
return location.getWorld().equals(other.getWorld()) && Math.abs(other.getX() - location.getX()) <= distance && Math.abs(other.getZ() - location.getZ()) <= distance;
}
public static Location getHighestLocation(final Location origin) {
return getHighestLocation(origin, null);
}
public static Location getHighestLocation(final Location origin, final Location def) {
Preconditions.checkNotNull((Object) origin, (Object) "The location cannot be null");
final Location cloned = origin.clone();
final World world = cloned.getWorld();
final int x = cloned.getBlockX();
int y = world.getMaxHeight();
final int z = cloned.getBlockZ();
while (y > origin.getBlockY()) {
final Block block = world.getBlockAt(x, --y, z);
if (!block.isEmpty()) {
final Location next = block.getLocation();
next.setPitch(origin.getPitch());
next.setYaw(origin.getYaw());
return next;
}
}
return def;
}
public static boolean isDebuff(final PotionEffectType type) {
return BukkitUtils.DEBUFF_TYPES.contains((Object) type);
}
public static boolean isDebuff(final PotionEffect potionEffect) {
return isDebuff(potionEffect.getType());
}
public static boolean isDebuff(final ThrownPotion thrownPotion) {
for (final PotionEffect effect : thrownPotion.getEffects()) {
if (isDebuff(effect)) {
return true;
}
}
return false;
}
static {
STRAIGHT_LINE_TEMPLATE = ChatColor.STRIKETHROUGH.toString() + Strings.repeat("-", 256);
STRAIGHT_LINE_DEFAULT = BukkitUtils.STRAIGHT_LINE_TEMPLATE.substring(0, 55);
CHAT_DYE_COLOUR_MAP = ImmutableMap.<ChatColor, DyeColor> builder().put(ChatColor.AQUA, DyeColor.LIGHT_BLUE).put(ChatColor.BLACK, DyeColor.BLACK).put(ChatColor.BLUE, DyeColor.LIGHT_BLUE)
.put(ChatColor.DARK_AQUA, DyeColor.CYAN).put(ChatColor.DARK_BLUE, DyeColor.BLUE).put(ChatColor.DARK_GRAY, DyeColor.GRAY).put(ChatColor.DARK_GREEN, DyeColor.GREEN)
.put(ChatColor.DARK_PURPLE, DyeColor.PURPLE).put(ChatColor.DARK_RED, DyeColor.RED).put(ChatColor.GOLD, DyeColor.ORANGE).put(ChatColor.GRAY, DyeColor.SILVER)
.put(ChatColor.GREEN, DyeColor.LIME).put(ChatColor.LIGHT_PURPLE, DyeColor.MAGENTA).put(ChatColor.RED, DyeColor.RED).put(ChatColor.WHITE, DyeColor.WHITE)
.put(ChatColor.YELLOW, DyeColor.YELLOW).build();
DEBUFF_TYPES = ImmutableSet.<PotionEffectType> builder().add(PotionEffectType.BLINDNESS).add(PotionEffectType.CONFUSION).add(PotionEffectType.HARM).add(PotionEffectType.HUNGER)
.add(PotionEffectType.POISON).add(PotionEffectType.SATURATION).add(PotionEffectType.SLOW).add(PotionEffectType.SLOW_DIGGING).add(PotionEffectType.WEAKNESS)
.add(PotionEffectType.WITHER).build();
final ChatColor[] values = ChatColor.values();
COLOUR_CHARACTER_LIST = (TCharList) new TCharArrayList(values.length);
for (final ChatColor colour : values) {
BukkitUtils.COLOUR_CHARACTER_LIST.add(colour.getChar());
}
}
}

View File

@ -0,0 +1,11 @@
package com.doctordark.util;
import org.bukkit.ChatColor;
public class Color
{
public static String translate(String input)
{
return ChatColor.translateAlternateColorCodes('&', input);
}
}

View File

@ -0,0 +1,87 @@
package com.doctordark.util;
import java.io.*;
import java.util.concurrent.*;
import java.util.*;
import javax.annotation.*;
public class ConcurrentValueOrderedMap<K, V extends Comparable<V>> extends AbstractMap<K, V> implements Map<K, V>, Cloneable, Serializable {
private final Set<InternalEntry<K, V>> ordering;
private final ConcurrentMap<K, InternalEntry<K, V>> lookup;
public ConcurrentValueOrderedMap() {
this.ordering = new ConcurrentSkipListSet<InternalEntry<K, V>>();
this.lookup = new ConcurrentHashMap<K, InternalEntry<K, V>>();
}
@Override
public V get(final Object key) {
final InternalEntry<K, V> old = this.lookup.get(key);
return (V) ((old != null) ? old.getValue() : null);
}
@Override
public V put(final K key, final V val) {
final InternalEntry<K, V> entry = new InternalEntry<K, V>(key, val);
final InternalEntry<K, V> old = this.lookup.put(key, entry);
if (old == null) {
this.ordering.add(entry);
return null;
}
this.ordering.remove(old);
this.ordering.add(entry);
return old.getValue();
}
@Override
public V remove(final Object key) {
final InternalEntry<K, V> old = this.lookup.remove(key);
if (old != null) {
this.ordering.remove(old);
return old.getValue();
}
return null;
}
@Override
public void clear() {
this.ordering.clear();
this.lookup.clear();
}
@Nonnull
@Override
public Set<Entry<K, V>> entrySet() {
return Collections.unmodifiableSet((Set<? extends Entry<K, V>>) this.ordering);
}
private static class InternalEntry<K, V extends Comparable<V>> implements Comparable<InternalEntry<K, V>>, Entry<K, V> {
private final K key;
private final V value;
InternalEntry(final K key, final V value) {
this.key = key;
this.value = value;
}
@Override
public K getKey() {
return this.key;
}
@Override
public V getValue() {
return this.value;
}
@Override
public V setValue(final V value) throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
@Override
public int compareTo(@Nonnull final InternalEntry<K, V> o) {
return o.value.compareTo(this.value);
}
}
}

View File

@ -0,0 +1,91 @@
package com.doctordark.util;
import org.bukkit.configuration.file.*;
import org.bukkit.plugin.java.*;
import java.io.*;
public class Config extends YamlConfiguration {
private final String fileName;
private final JavaPlugin plugin;
public Config(final JavaPlugin plugin, final String fileName) {
this(plugin, fileName, ".yml");
}
public Config(final JavaPlugin plugin, final String fileName, final String fileExtension) {
this.plugin = plugin;
this.fileName = fileName + (fileName.endsWith(fileExtension) ? "" : fileExtension);
this.createFile();
}
public String getFileName() {
return this.fileName;
}
public JavaPlugin getPlugin() {
return this.plugin;
}
private void createFile() {
final File folder = this.plugin.getDataFolder();
try {
final File file = new File(folder, this.fileName);
if (!file.exists()) {
if (this.plugin.getResource(this.fileName) != null) {
this.plugin.saveResource(this.fileName, false);
} else {
this.save(file);
}
this.load(file);
} else {
this.load(file);
this.save(file);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void save() {
final File folder = this.plugin.getDataFolder();
try {
this.save(new File(folder, this.fileName));
} catch (Exception ex) {
ex.printStackTrace();
}
}
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Config)) {
return false;
}
final Config config = (Config) o;
Label_0054: {
if (this.fileName != null) {
if (this.fileName.equals(config.fileName)) {
break Label_0054;
}
} else if (config.fileName == null) {
break Label_0054;
}
return false;
}
if (this.plugin != null) {
if (!this.plugin.equals((Object) config.plugin)) {
return false;
}
} else if (config.plugin != null) {
return false;
}
return true;
}
public int hashCode() {
int result = (this.fileName != null) ? this.fileName.hashCode() : 0;
result = 31 * result + ((this.plugin != null) ? this.plugin.hashCode() : 0);
return result;
}
}

View File

@ -0,0 +1,21 @@
package com.doctordark.util;
import org.bukkit.scheduler.*;
import org.bukkit.entity.*;
import org.bukkit.plugin.java.*;
import org.bukkit.plugin.*;
public class DelayedMessageRunnable extends BukkitRunnable {
private final Player player;
private final String message;
public DelayedMessageRunnable(final JavaPlugin plugin, final Player player, final String message) {
this.player = player;
this.message = message;
this.runTask((Plugin) plugin);
}
public void run() {
this.player.sendMessage(this.message);
}
}

View File

@ -0,0 +1,27 @@
package com.doctordark.util;
import org.apache.commons.lang3.time.*;
import server.wenjapvp.hcf.DateTimeFormats;
import java.util.concurrent.*;
public class DurationFormatter {
private static final long MINUTE;
private static final long HOUR;
public static String getRemaining(final long millis, final boolean milliseconds) {
return getRemaining(millis, milliseconds, true);
}
public static String getRemaining(final long duration, final boolean milliseconds, final boolean trail) {
if (milliseconds && duration < DurationFormatter.MINUTE) {
return (trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING : DateTimeFormats.REMAINING_SECONDS).get().format(duration * 0.001) + 's';
}
return DurationFormatUtils.formatDuration(duration, ((duration >= DurationFormatter.HOUR) ? "HH:" : "") + "mm:ss");
}
static {
MINUTE = TimeUnit.MINUTES.toMillis(1L);
HOUR = TimeUnit.HOURS.toMillis(1L);
}
}

View File

@ -0,0 +1,131 @@
package com.doctordark.util;
import java.lang.ref.*;
import org.bukkit.entity.*;
import com.google.common.base.*;
import java.util.*;
public class ExperienceManager {
private static int hardMaxLevel;
private static int[] xpTotalToReachLevel;
private final WeakReference<Player> player;
private final String playerName;
public ExperienceManager(final Player player) {
Preconditions.checkNotNull((Object) player, (Object) "Player cannot be null");
this.player = new WeakReference<Player>(player);
this.playerName = player.getName();
}
public static int getHardMaxLevel() {
return ExperienceManager.hardMaxLevel;
}
public static void setHardMaxLevel(final int hardMaxLevel) {
ExperienceManager.hardMaxLevel = hardMaxLevel;
}
private static void initLookupTables(final int maxLevel) {
ExperienceManager.xpTotalToReachLevel = new int[maxLevel];
for (int i = 0; i < ExperienceManager.xpTotalToReachLevel.length; ++i) {
ExperienceManager.xpTotalToReachLevel[i] = ((i >= 30) ? ((int) (3.5 * i * i - 151.5 * i + 2220.0)) : ((i >= 16) ? ((int) (1.5 * i * i - 29.5 * i + 360.0)) : (17 * i)));
}
}
private static int calculateLevelForExp(final int exp) {
int level = 0;
for (int curExp = 7, incr = 10; curExp <= exp; curExp += incr, ++level, incr += ((level % 2 == 0) ? 3 : 4)) {
}
return level;
}
public Player getPlayer() {
final Player p = this.player.get();
if (p == null) {
throw new IllegalStateException("Player " + this.playerName + " is not online");
}
return p;
}
public void changeExp(final int amt) {
this.changeExp((double) amt);
}
public void changeExp(final double amt) {
this.setExp(this.getCurrentFractionalXP(), amt);
}
public void setExp(final int amt) {
this.setExp(0.0, amt);
}
public void setExp(final double amt) {
this.setExp(0.0, amt);
}
private void setExp(final double base, final double amt) {
final int xp = (int) Math.max(base + amt, 0.0);
final Player player = this.getPlayer();
final int curLvl = player.getLevel();
final int newLvl = this.getLevelForExp(xp);
if (curLvl != newLvl) {
player.setLevel(newLvl);
}
if (xp > base) {
player.setTotalExperience(player.getTotalExperience() + xp - (int) base);
}
final double pct = (base - this.getXpForLevel(newLvl) + amt) / this.getXpNeededToLevelUp(newLvl);
player.setExp((float) pct);
}
public int getCurrentExp() {
final Player player = this.getPlayer();
final int lvl = player.getLevel();
return this.getXpForLevel(lvl) + Math.round(this.getXpNeededToLevelUp(lvl) * player.getExp());
}
private double getCurrentFractionalXP() {
final Player player = this.getPlayer();
final int lvl = player.getLevel();
return this.getXpForLevel(lvl) + this.getXpNeededToLevelUp(lvl) * player.getExp();
}
public boolean hasExp(final int amt) {
return this.getCurrentExp() >= amt;
}
public boolean hasExp(final double amt) {
return this.getCurrentFractionalXP() >= amt;
}
public int getLevelForExp(final int exp) {
if (exp <= 0) {
return 0;
}
if (exp > ExperienceManager.xpTotalToReachLevel[ExperienceManager.xpTotalToReachLevel.length - 1]) {
final int newMax = calculateLevelForExp(exp) * 2;
Preconditions.checkArgument(newMax <= ExperienceManager.hardMaxLevel, (Object) ("Level for exp " + exp + " > hard max level " + ExperienceManager.hardMaxLevel));
initLookupTables(newMax);
}
final int pos = Arrays.binarySearch(ExperienceManager.xpTotalToReachLevel, exp);
return (pos < 0) ? (-pos - 2) : pos;
}
public int getXpNeededToLevelUp(final int level) {
Preconditions.checkArgument(level >= 0, (Object) "Level may not be negative.");
return (level > 30) ? (62 + (level - 30) * 7) : ((level >= 16) ? (17 + (level - 15) * 3) : 17);
}
public int getXpForLevel(final int level) {
Preconditions.checkArgument(level >= 0 && level <= ExperienceManager.hardMaxLevel, (Object) ("Invalid level " + level + "(must be in range 0.." + ExperienceManager.hardMaxLevel + ')'));
if (level >= ExperienceManager.xpTotalToReachLevel.length) {
initLookupTables(level * 2);
}
return ExperienceManager.xpTotalToReachLevel[level];
}
static {
ExperienceManager.hardMaxLevel = 100000;
initLookupTables(25);
}
}

View File

@ -0,0 +1,67 @@
package com.doctordark.util;
import java.util.*;
public final class GenericUtils {
public static <E> List<E> createList(final Object object, final Class<E> type) {
final List<E> output = new ArrayList<E>();
if (object != null && object instanceof List) {
final List<?> input = (List<?>) object;
for (final Object value : input) {
if (value != null) {
if (value.getClass() == null) {
continue;
}
if (!type.isAssignableFrom(value.getClass())) {
final String simpleName = type.getSimpleName();
throw new AssertionError((Object) ("Cannot cast to list! Key " + value + " is not a " + simpleName));
}
final E e = type.cast(value);
output.add(e);
}
}
}
return output;
}
public static <E> Set<E> castSet(final Object object, final Class<E> type) {
final Set<E> output = new HashSet<E>();
if (object != null && object instanceof List) {
final List<?> input = (List<?>) object;
for (final Object value : input) {
if (value != null) {
if (value.getClass() == null) {
continue;
}
if (!type.isAssignableFrom(value.getClass())) {
final String simpleName = type.getSimpleName();
throw new AssertionError((Object) ("Cannot cast to list! Key " + value + " is not a " + simpleName));
}
final E e = type.cast(value);
output.add(e);
}
}
}
return output;
}
public static <K, V> Map<K, V> castMap(final Object object, final Class<K> keyClass, final Class<V> valueClass) {
final Map<K, V> output = new HashMap<K, V>();
if (object != null && object instanceof Map) {
final Map<?, ?> input = (Map<?, ?>) object;
final String keyClassName = keyClass.getSimpleName();
final String valueClassName = valueClass.getSimpleName();
for (final Object key : input.keySet().toArray()) {
if (key != null && !keyClass.isAssignableFrom(key.getClass())) {
throw new AssertionError((Object) ("Cannot cast to HashMap: " + keyClassName + ", " + keyClassName + ". Value " + valueClassName + " is not a " + keyClassName));
}
final Object value = input.get(key);
if (value != null && !valueClass.isAssignableFrom(value.getClass())) {
throw new AssertionError((Object) ("Cannot cast to HashMap: " + valueClassName + ", " + valueClassName + ". Key " + key + " is not a " + valueClassName));
}
output.put(keyClass.cast(key), valueClass.cast(value));
}
}
return output;
}
}

View File

@ -0,0 +1,75 @@
package com.doctordark.util;
import org.yaml.snakeyaml.external.biz.base64Coder.*;
import org.bukkit.util.io.*;
import org.bukkit.*;
import org.bukkit.inventory.*;
import java.io.*;
public class InventorySerialisation {
public static String[] playerInventoryToBase64(final PlayerInventory playerInventory) throws IllegalStateException {
final String content = toBase64((Inventory) playerInventory);
final String armor = itemStackArrayToBase64(playerInventory.getArmorContents());
return new String[] { content, armor };
}
public static String itemStackArrayToBase64(final ItemStack[] items) throws IllegalStateException {
try {
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
final BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream((OutputStream) outputStream);
dataOutput.writeInt(items.length);
for (final ItemStack item : items) {
dataOutput.writeObject((Object) item);
}
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (Exception e) {
throw new IllegalStateException("Unable to save item stacks.", e);
}
}
public static String toBase64(final Inventory inventory) throws IllegalStateException {
try {
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
final BukkitObjectOutputStream dataOutput = new BukkitObjectOutputStream((OutputStream) outputStream);
dataOutput.writeInt(inventory.getSize());
for (int i = 0; i < inventory.getSize(); ++i) {
dataOutput.writeObject((Object) inventory.getItem(i));
}
dataOutput.close();
return Base64Coder.encodeLines(outputStream.toByteArray());
} catch (Exception e) {
throw new IllegalStateException("Unable to save item stacks.", e);
}
}
public static Inventory fromBase64(final String data) throws IOException {
try {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
final BukkitObjectInputStream dataInput = new BukkitObjectInputStream((InputStream) inputStream);
final Inventory inventory = Bukkit.createInventory((InventoryHolder) null, dataInput.readInt());
for (int i = 0; i < inventory.getSize(); ++i) {
inventory.setItem(i, (ItemStack) dataInput.readObject());
}
dataInput.close();
return inventory;
} catch (ClassNotFoundException e) {
throw new IOException("Unable to decode class type.", e);
}
}
public static ItemStack[] itemStackArrayFromBase64(final String data) throws IOException {
try {
final ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
final BukkitObjectInputStream dataInput = new BukkitObjectInputStream((InputStream) inputStream);
final ItemStack[] items = new ItemStack[dataInput.readInt()];
for (int i = 0; i < items.length; ++i) {
items[i] = (ItemStack) dataInput.readObject();
}
dataInput.close();
return items;
} catch (ClassNotFoundException ex) {
throw new IOException("Unable to decode class type.", ex);
}
}
}

View File

@ -0,0 +1,116 @@
package com.doctordark.util;
import com.google.common.base.*;
import org.bukkit.*;
import org.bukkit.event.inventory.*;
import org.bukkit.inventory.*;
import java.util.*;
public final class InventoryUtils {
public static final int DEFAULT_INVENTORY_WIDTH = 9;
public static final int MINIMUM_INVENTORY_HEIGHT = 1;
public static final int MINIMUM_INVENTORY_SIZE = 9;
public static final int MAXIMUM_INVENTORY_HEIGHT = 6;
public static final int MAXIMUM_INVENTORY_SIZE = 54;
public static final int MAXIMUM_SINGLE_CHEST_SIZE = 27;
public static final int MAXIMUM_DOUBLE_CHEST_SIZE = 54;
public static ItemStack[] deepClone(final ItemStack[] origin) {
Preconditions.checkNotNull((Object) origin, (Object) "Origin cannot be null");
final ItemStack[] cloned = new ItemStack[origin.length];
for (int i = 0; i < origin.length; ++i) {
final ItemStack next = origin[i];
cloned[i] = ((next == null) ? null : next.clone());
}
return cloned;
}
public static int getSafestInventorySize(final int initialSize) {
return (initialSize + 8) / 9 * 9;
}
public static void removeItem(final Inventory inventory, final Material type, final short data, final int quantity) {
final ItemStack[] contents = inventory.getContents();
final boolean compareDamage = type.getMaxDurability() == 0;
for (int i = quantity; i > 0; --i) {
for (final ItemStack content : contents) {
if (content != null) {
if (content.getType() == type) {
if (!compareDamage || content.getData().getData() == data) {
if (content.getAmount() <= 1) {
inventory.removeItem(new ItemStack[] { content });
break;
}
content.setAmount(content.getAmount() - 1);
break;
}
}
}
}
}
}
public static int countAmount(final Inventory inventory, final Material type, final short data) {
final ItemStack[] contents = inventory.getContents();
final boolean compareDamage = type.getMaxDurability() == 0;
int counter = 0;
for (final ItemStack item : contents) {
if (item != null) {
if (item.getType() == type) {
if (!compareDamage || item.getData().getData() == data) {
counter += item.getAmount();
}
}
}
}
return counter;
}
public static boolean isEmpty(final Inventory inventory) {
return isEmpty(inventory, true);
}
public static boolean isEmpty(final Inventory inventory, final boolean checkArmour) {
boolean result = true;
final ItemStack[] contents2;
ItemStack[] contents = contents2 = inventory.getContents();
for (final ItemStack content : contents2) {
if (content != null && content.getType() != Material.AIR) {
result = false;
break;
}
}
if (!result) {
return false;
}
if (checkArmour && inventory instanceof PlayerInventory) {
final ItemStack[] armorContents;
contents = (armorContents = ((PlayerInventory) inventory).getArmorContents());
for (final ItemStack content : armorContents) {
if (content != null && content.getType() != Material.AIR) {
result = false;
break;
}
}
}
return result;
}
public static boolean clickedTopInventory(final InventoryDragEvent event) {
final InventoryView view = event.getView();
final Inventory topInventory = view.getTopInventory();
if (topInventory == null) {
return false;
}
boolean result = false;
final Set<Map.Entry<Integer, ItemStack>> entrySet = event.getNewItems().entrySet();
final int size = topInventory.getSize();
for (final Map.Entry<Integer, ItemStack> entry : entrySet) {
if (entry.getKey() < size) {
result = true;
break;
}
}
return result;
}
}

View File

@ -0,0 +1,84 @@
package com.doctordark.util;
import org.bukkit.inventory.*;
import org.bukkit.inventory.meta.*;
import org.bukkit.*;
import com.google.common.base.*;
import java.util.*;
import org.bukkit.enchantments.*;
public class ItemBuilder {
private ItemStack stack;
private ItemMeta meta;
public ItemBuilder(final Material material) {
this(material, 1);
}
public ItemBuilder(final Material material, final int amount) {
this(material, amount, (byte) 0);
}
public ItemBuilder(final ItemStack stack) {
Preconditions.checkNotNull((Object) stack, (Object) "ItemStack cannot be null");
this.stack = stack;
}
public ItemBuilder(final Material material, final int amount, final byte data) {
Preconditions.checkNotNull((Object) material, (Object) "Material cannot be null");
Preconditions.checkArgument(amount > 0, (Object) "Amount must be positive");
this.stack = new ItemStack(material, amount, (short) data);
}
public ItemBuilder displayName(final String name) {
if (this.meta == null) {
this.meta = this.stack.getItemMeta();
}
this.meta.setDisplayName(name);
return this;
}
public ItemBuilder loreLine(final String line) {
if (this.meta == null) {
this.meta = this.stack.getItemMeta();
}
final boolean hasLore = this.meta.hasLore();
final List<String> lore = hasLore ? this.meta.getLore() : new ArrayList<String>();
lore.add(hasLore ? lore.size() : 0, line);
this.lore(line);
return this;
}
public ItemBuilder lore(final String... lore) {
if (this.meta == null) {
this.meta = this.stack.getItemMeta();
}
this.meta.setLore((List) Arrays.asList(lore));
return this;
}
public ItemBuilder enchant(final Enchantment enchantment, final int level) {
return this.enchant(enchantment, level, true);
}
public ItemBuilder enchant(final Enchantment enchantment, final int level, final boolean unsafe) {
if (unsafe && level >= enchantment.getMaxLevel()) {
this.stack.addUnsafeEnchantment(enchantment, level);
} else {
this.stack.addEnchantment(enchantment, level);
}
return this;
}
public ItemBuilder data(final short data) {
this.stack.setDurability(data);
return this;
}
public ItemStack build() {
if (this.meta != null) {
this.stack.setItemMeta(this.meta);
}
return this.stack;
}
}

View File

@ -0,0 +1,129 @@
package com.doctordark.util;
import java.util.regex.*;
import org.apache.commons.lang3.*;
import java.math.*;
import com.google.common.base.*;
import java.util.*;
import java.util.concurrent.*;
public final class JavaUtils {
private static final CharMatcher CHAR_MATCHER_ASCII;
private static final Pattern UUID_PATTERN;
private static final int DEFAULT_NUMBER_FORMAT_DECIMAL_PLACES = 5;
public static Integer tryParseInt(final String string) {
try {
return Integer.parseInt(string);
} catch (IllegalArgumentException ex) {
return null;
}
}
public static Double tryParseDouble(final String string) {
try {
return Double.parseDouble(string);
} catch (IllegalArgumentException ex) {
return null;
}
}
public static boolean isUUID(final String string) {
return JavaUtils.UUID_PATTERN.matcher(string).find();
}
public static boolean isAlphanumeric(final String string) {
return JavaUtils.CHAR_MATCHER_ASCII.matchesAllOf((CharSequence) string);
}
public static boolean containsIgnoreCase(final Iterable<? extends String> elements, final String string) {
for (final String element : elements) {
if (StringUtils.containsIgnoreCase((CharSequence) element, (CharSequence) string)) {
return true;
}
}
return false;
}
public static String format(final Number number) {
return format(number, 5);
}
public static String format(final Number number, final int decimalPlaces) {
return format(number, decimalPlaces, RoundingMode.HALF_DOWN);
}
public static String format(final Number number, final int decimalPlaces, final RoundingMode roundingMode) {
Preconditions.checkNotNull((Object) number, (Object) "The number cannot be null");
return new BigDecimal(number.toString()).setScale(decimalPlaces, roundingMode).stripTrailingZeros().toPlainString();
}
public static String andJoin(final Collection<String> collection, final boolean delimiterBeforeAnd) {
return andJoin(collection, delimiterBeforeAnd, ", ");
}
public static String andJoin(final Collection<String> collection, final boolean delimiterBeforeAnd, final String delimiter) {
if (collection == null || collection.isEmpty()) {
return "";
}
final List<String> contents = new ArrayList<String>(collection);
final String last = contents.remove(contents.size() - 1);
final StringBuilder builder = new StringBuilder(Joiner.on(delimiter).join((Iterable) contents));
if (delimiterBeforeAnd) {
builder.append(delimiter);
}
return builder.append(" and ").append(last).toString();
}
public static long parse(final String input) {
if (input == null || input.isEmpty()) {
return -1L;
}
long result = 0L;
StringBuilder number = new StringBuilder();
for (int i = 0; i < input.length(); ++i) {
final char c = input.charAt(i);
if (Character.isDigit(c)) {
number.append(c);
} else {
final String str;
if (Character.isLetter(c) && !(str = number.toString()).isEmpty()) {
result += convert(Integer.parseInt(str), c);
number = new StringBuilder();
}
}
}
return result;
}
private static long convert(final int value, final char unit) {
switch (unit) {
case 'y': {
return value * TimeUnit.DAYS.toMillis(365L);
}
case 'M': {
return value * TimeUnit.DAYS.toMillis(30L);
}
case 'd': {
return value * TimeUnit.DAYS.toMillis(1L);
}
case 'h': {
return value * TimeUnit.HOURS.toMillis(1L);
}
case 'm': {
return value * TimeUnit.MINUTES.toMillis(1L);
}
case 's': {
return value * TimeUnit.SECONDS.toMillis(1L);
}
default: {
return -1L;
}
}
}
static {
CHAR_MATCHER_ASCII = CharMatcher.inRange('0', '9').or(CharMatcher.inRange('a', 'z')).or(CharMatcher.inRange('A', 'Z')).or(CharMatcher.WHITESPACE).precomputed();
UUID_PATTERN = Pattern.compile("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[34][0-9a-fA-F]{3}-[89ab][0-9a-fA-F]{3}-[0-9a-fA-F]{12}");
}
}

View File

@ -0,0 +1,75 @@
package com.doctordark.util;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Ordering;
@SuppressWarnings("rawtypes")
public class MapSorting {
// Building block - extract key from entry
private static final Function EXTRACT_KEY =
new Function<Entry<Object, Object>, Object>() {
public Object apply(Entry<Object, Object> input) {
return input.getKey();
}
};
// Same as above, only we extract the value
private static final Function EXTRACT_VALUE =
new Function<Entry<Object, Object>, Object>() {
public Object apply(Entry<Object, Object> input) {
return input.getValue();
}
};
/**
* Sort the given map by the value in each entry.
* @param map - map of comparable values.
* @return A new list with the sort result.
*/
public static <T, V extends Comparable<V>> List<Entry<T, V>> sortedValues(Map<T, V> map) {
return sortedValues(map, Ordering.<V>natural());
}
/**
* Sort the given map by the value in each entry.
* @param map - map of comparable values.
* @param valueComparator - object for comparing each values.
* @return A new list with the sort result.
*/
public static <T, V> List<Entry<T, V>> sortedValues(Map<T, V> map, Comparator<V> valueComparator) {
return Ordering.from(valueComparator).onResultOf(MapSorting.<T, V>extractValue()).sortedCopy(map.entrySet());
}
/**
* Retrieve every key in the entry list in order.
* @param entryList - the entry list.
* @return Every key in order.
*/
public static <T, V> Iterable<T> keys(List<Entry<T, V>> entryList) {
return Iterables.transform(entryList, MapSorting.<T, V>extractKey());
}
/**
* Retrieve every value in the entry list in order.
* @param entryList - the entry list.
* @return Every value in order.
*/
public static <T, V> Iterable<V> values(List<Entry<T, V>> entryList) {
return Iterables.transform(entryList, MapSorting.<T, V>extractValue());
}
@SuppressWarnings("unchecked")
private static <T, V> Function<Entry<T, V>, T> extractKey() {
return EXTRACT_KEY;
}
@SuppressWarnings("unchecked")
private static <T, V> Function<Entry<T, V>, V> extractValue() {
return EXTRACT_VALUE;
}
}

View File

@ -0,0 +1,53 @@
package com.doctordark.util;
import org.bukkit.entity.*;
import org.bukkit.craftbukkit.v1_7_R4.entity.*;
import net.minecraft.server.v1_7_R4.*;
import net.minecraft.server.v1_7_R4.ItemStack;
import net.minecraft.server.v1_7_R4.PlayerInventory;
import org.bukkit.inventory.*;
import org.bukkit.craftbukkit.v1_7_R4.inventory.*;
public class NmsUtils {
public static int getProtocolVersion(final Player player) {
return ((CraftPlayer) player).getHandle().playerConnection.networkManager.getVersion();
}
public static void resendHeldItemPacket(final Player player) {
sendItemPacketAtHeldSlot(player, getCleanHeldItem(player));
}
public static void sendItemPacketAtHeldSlot(final Player player, final ItemStack stack) {
sendItemPacketAtSlot(player, stack, player.getInventory().getHeldItemSlot());
}
public static void sendItemPacketAtSlot(final Player player, final ItemStack stack, final int index) {
sendItemPacketAtSlot(player, stack, index, ((CraftPlayer) player).getHandle().defaultContainer.windowId);
}
public static void sendItemPacketAtSlot(final Player player, final ItemStack stack, int index, final int windowID) {
final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
if (entityPlayer.playerConnection != null) {
if (index < PlayerInventory.getHotbarSize()) {
index += 36;
} else if (index > 35) {
index = 8 - (index - 36);
}
entityPlayer.playerConnection.sendPacket((Packet) new PacketPlayOutSetSlot(windowID, index, stack));
}
}
public static ItemStack getCleanItem(final Inventory inventory, final int slot) {
return ((CraftInventory) inventory).getInventory().getItem(slot);
}
public static ItemStack getCleanItem(final Player player, final int slot) {
return getCleanItem((Inventory) player.getInventory(), slot);
}
public static ItemStack getCleanHeldItem(final Player player) {
return getCleanItem(player, player.getInventory().getHeldItemSlot());
}
}

View File

@ -0,0 +1,127 @@
package com.doctordark.util;
import org.bukkit.craftbukkit.v1_7_R4.entity.*;
import java.util.*;
import org.bukkit.entity.*;
import org.bukkit.entity.Entity;
import javax.annotation.*;
import com.google.common.base.*;
import org.bukkit.*;
import org.bukkit.World;
import net.minecraft.server.v1_7_R4.*;
public enum ParticleEffect {
HUGE_EXPLODE("hugeexplosion", 0), LARGE_EXPLODE("largeexplode", 1), FIREWORK_SPARK("fireworksSpark", 2), AIR_BUBBLE("bubble", 3), SUSPEND("suspend", 4), DEPTH_SUSPEND("depthSuspend", 5), TOWN_AURA(
"townaura", 6), CRITICAL_HIT("crit", 7), MAGIC_CRITICAL_HIT("magicCrit", 8), MOB_SPELL("mobSpell", 9), MOB_SPELL_AMBIENT("mobSpellAmbient", 10), SPELL("spell", 11), INSTANT_SPELL(
"instantSpell", 12), BLUE_SPARKLE("witchMagic", 13), NOTE_BLOCK("note", 14), ENDER("portal", 15), ENCHANTMENT_TABLE("enchantmenttable", 16), EXPLODE("explode", 17), FIRE("flame", 18), LAVA_SPARK(
"lava", 19), FOOTSTEP("footstep", 20), SPLASH("splash", 21), LARGE_SMOKE("largesmoke", 22), CLOUD("cloud", 23), REDSTONE_DUST("reddust", 24), SNOWBALL_HIT("snowballpoof", 25), DRIP_WATER(
"dripWater", 26), DRIP_LAVA("dripLava", 27), SNOW_DIG("snowshovel", 28), SLIME("slime", 29), HEART("heart", 30), ANGRY_VILLAGER("angryVillager", 31), GREEN_SPARKLE("happyVillager", 32), ICONCRACK(
"iconcrack", 33), TILECRACK("tilecrack", 34);
private final String name;
@Deprecated
private final int id;
private ParticleEffect(final String name, final int id) {
this.name = name;
this.id = id;
}
@Deprecated
String getName() {
return this.name;
}
@Deprecated
public int getId() {
return this.id;
}
public void display(final Player player, final float x, final float y, final float z, final float speed, final int amount) {
this.display(player, x, y, z, 0.0f, 0.0f, 0.0f, speed, amount);
}
public void display(final Player player, final float x, final float y, final float z, final float offsetX, final float offsetY, final float offsetZ, final float speed, final int amount) {
final Packet packet = (Packet) this.createPacket(x, y, z, offsetX, offsetY, offsetZ, speed, amount);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
public void display(final Player player, final Location location, final float speed, final int amount) {
this.display(player, location, 0.0f, 0.0f, 0.0f, speed, amount);
}
public void display(final Player player, final Location location, final float offsetX, final float offsetY, final float offsetZ, final float speed, final int amount) {
final Packet packet = (Packet) this.createPacket(location, offsetX, offsetY, offsetZ, speed, amount);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
public void broadcast(final float x, final float y, final float z, final float offsetX, final float offsetY, final float offsetZ, final float speed, final int amount) {
final Packet packet = (Packet) this.createPacket(x, y, z, offsetX, offsetY, offsetZ, speed, amount);
for (final Player player : Bukkit.getOnlinePlayers()) {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
public void broadcast(final Location location, final float offsetX, final float offsetY, final float offsetZ, final float speed, final int amount) {
this.broadcast(location, offsetX, offsetY, offsetZ, speed, amount, null, null);
}
public void broadcast(final Location location, final float offsetX, final float offsetY, final float offsetZ, final float speed, final int amount, @Nullable final Player source) {
this.broadcast(location, offsetX, offsetY, offsetZ, speed, amount, source, null);
}
public void broadcast(final Location location, final float offsetX, final float offsetY, final float offsetZ, final float speed, final int amount, @Nullable final Player source,
@Nullable final Predicate<Player> predicate) {
final Packet packet = (Packet) this.createPacket(location, offsetX, offsetY, offsetZ, speed, amount);
for (final Player player : Bukkit.getOnlinePlayers()) {
if ((source == null || player.canSee(source)) && (predicate == null || predicate.apply(player))) {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
}
}
public void sphere(@Nullable final Player player, final Location location, final float radius) {
this.sphere(player, location, radius, 20.0f, 2);
}
public void sphere(@Nullable final Player player, final Location location, final float radius, final float density, final int intensity) {
Preconditions.checkNotNull((Object) location, (Object) "Location cannot be null");
Preconditions.checkArgument(radius >= 0.0f, (Object) "Radius must be positive");
Preconditions.checkArgument(density >= 0.0f, (Object) "Density must be positive");
Preconditions.checkArgument(intensity >= 0, (Object) "Intensity must be positive");
final float deltaPitch = 180.0f / density;
final float deltaYaw = 360.0f / density;
final World world = location.getWorld();
for (int i = 0; i < density; ++i) {
for (int j = 0; j < density; ++j) {
final float pitch = -90.0f + j * deltaPitch;
final float yaw = -180.0f + i * deltaYaw;
final float x = radius * MathHelper.sin(-yaw * 0.017453292f - 3.1415927f) * -MathHelper.cos(-pitch * 0.017453292f) + (float) location.getX();
final float y = radius * MathHelper.sin(-pitch * 0.017453292f) + (float) location.getY();
final float z = radius * MathHelper.cos(-yaw * 0.017453292f - 3.1415927f) * -MathHelper.cos(-pitch * 0.017453292f) + (float) location.getZ();
final Location target = new Location(world, (double) x, (double) y, (double) z);
if (player == null) {
this.broadcast(target, 0.0f, 0.0f, 0.0f, 0.0f, intensity);
} else {
this.display(player, target, 0.0f, 0.0f, 0.0f, 0.0f, intensity);
}
}
}
}
private PacketPlayOutWorldParticles createPacket(final Location location, final float offsetX, final float offsetY, final float offsetZ, final float speed, final int amount) {
return this.createPacket((float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, amount);
}
private PacketPlayOutWorldParticles createPacket(final float x, final float y, final float z, final float offsetX, final float offsetY, final float offsetZ, final float speed, final int amount) {
Preconditions.checkArgument(speed >= 0.0f, (Object) "Speed must be positive");
Preconditions.checkArgument(amount > 0, (Object) "Cannot use less than one particle.");
return new PacketPlayOutWorldParticles(this.name, x, y, z, offsetX, offsetY, offsetZ, speed, amount);
}
}

View File

@ -0,0 +1,247 @@
package com.doctordark.util;
import org.bukkit.configuration.serialization.*;
import com.google.common.base.*;
import java.util.*;
import org.bukkit.*;
public class PersistableLocation implements ConfigurationSerializable, Cloneable {
private Location location;
private World world;
private String worldName;
private UUID worldUID;
private double x;
private double y;
private double z;
private float yaw;
private float pitch;
public PersistableLocation(final Location location) {
Preconditions.checkNotNull((Object) location, (Object) "Location cannot be null");
Preconditions.checkNotNull((Object) location.getWorld(), (Object) "Locations' world cannot be null");
this.world = location.getWorld();
this.worldName = this.world.getName();
this.worldUID = this.world.getUID();
this.x = location.getX();
this.y = location.getY();
this.z = location.getZ();
this.yaw = location.getYaw();
this.pitch = location.getPitch();
}
public PersistableLocation(final World world, final double x, final double y, final double z) {
this.worldName = world.getName();
this.x = x;
this.y = y;
this.z = z;
final float n = 0.0f;
this.yaw = n;
this.pitch = n;
}
public PersistableLocation(final String worldName, final double x, final double y, final double z) {
this.worldName = worldName;
this.x = x;
this.y = y;
this.z = z;
final float n = 0.0f;
this.yaw = n;
this.pitch = n;
}
public PersistableLocation(final Map<String, String> map) {
this.worldName = map.get("worldName");
this.worldUID = UUID.fromString(map.get("worldUID"));
Object o = map.get("x");
if (o instanceof String) {
this.x = Double.parseDouble((String) o);
} else {
this.x = (double) o;
}
o = map.get("y");
if (o instanceof String) {
this.y = Double.parseDouble((String) o);
} else {
this.y = (double) o;
}
o = map.get("z");
if (o instanceof String) {
this.z = Double.parseDouble((String) o);
} else {
this.z = (double) o;
}
this.yaw = Float.parseFloat(map.get("yaw"));
this.pitch = Float.parseFloat(map.get("pitch"));
}
public Map<String, Object> serialize() {
final Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("worldName", this.worldName);
map.put("worldUID", this.worldUID.toString());
map.put("x", this.x);
map.put("y", this.y);
map.put("z", this.z);
map.put("yaw", Float.toString(this.yaw));
map.put("pitch", Float.toString(this.pitch));
return map;
}
public World getWorld() {
Preconditions.checkNotNull((Object) this.worldUID, (Object) "World UUID cannot be null");
Preconditions.checkNotNull((Object) this.worldName, (Object) "World name cannot be null");
if (this.world == null) {
this.world = Bukkit.getWorld(this.worldUID);
}
return this.world;
}
public void setWorld(final World world) {
this.worldName = world.getName();
this.worldUID = world.getUID();
this.world = world;
}
public Location getLocation() {
if (this.location == null) {
this.location = new Location(this.getWorld(), this.x, this.y, this.z, this.yaw, this.pitch);
}
return this.location;
}
public PersistableLocation clone() throws CloneNotSupportedException {
try {
return (PersistableLocation) super.clone();
} catch (CloneNotSupportedException ex) {
ex.printStackTrace();
throw new RuntimeException();
}
}
@Override
public String toString() {
return "PersistableLocation [worldName=" + this.worldName + ", worldUID=" + this.worldUID + ", x=" + this.x + ", y=" + this.y + ", z=" + this.z + ", yaw=" + this.yaw + ", pitch=" + this.pitch
+ ']';
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof PersistableLocation)) {
return false;
}
final PersistableLocation that = (PersistableLocation) o;
if (Double.compare(that.x, this.x) != 0) {
return false;
}
if (Double.compare(that.y, this.y) != 0) {
return false;
}
if (Double.compare(that.z, this.z) != 0) {
return false;
}
if (Float.compare(that.yaw, this.yaw) != 0) {
return false;
}
if (Float.compare(that.pitch, this.pitch) != 0) {
return false;
}
Label_0134: {
if (this.world != null) {
if (this.world.equals(that.world)) {
break Label_0134;
}
} else if (that.world == null) {
break Label_0134;
}
return false;
}
Label_0167: {
if (this.worldName != null) {
if (this.worldName.equals(that.worldName)) {
break Label_0167;
}
} else if (that.worldName == null) {
break Label_0167;
}
return false;
}
if (this.worldUID != null) {
if (!this.worldUID.equals(that.worldUID)) {
return false;
}
} else if (that.worldUID != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = (this.world != null) ? this.world.hashCode() : 0;
result = 31 * result + ((this.worldName != null) ? this.worldName.hashCode() : 0);
result = 31 * result + ((this.worldUID != null) ? this.worldUID.hashCode() : 0);
long temp = Double.doubleToLongBits(this.x);
result = 31 * result + (int) (temp ^ temp >>> 32);
temp = Double.doubleToLongBits(this.y);
result = 31 * result + (int) (temp ^ temp >>> 32);
temp = Double.doubleToLongBits(this.z);
result = 31 * result + (int) (temp ^ temp >>> 32);
result = 31 * result + ((this.yaw != 0.0f) ? Float.floatToIntBits(this.yaw) : 0);
result = 31 * result + ((this.pitch != 0.0f) ? Float.floatToIntBits(this.pitch) : 0);
return result;
}
public String getWorldName() {
return this.worldName;
}
public UUID getWorldUID() {
return this.worldUID;
}
public double getX() {
return this.x;
}
public double getY() {
return this.y;
}
public double getZ() {
return this.z;
}
public float getYaw() {
return this.yaw;
}
public float getPitch() {
return this.pitch;
}
public void setWorldUID(final UUID worldUID) {
this.worldUID = worldUID;
}
public void setX(final double x) {
this.x = x;
}
public void setY(final double y) {
this.y = y;
}
public void setZ(final double z) {
this.z = z;
}
public void setYaw(final float yaw) {
this.yaw = yaw;
}
public void setPitch(final float pitch) {
this.pitch = pitch;
}
}

View File

@ -0,0 +1,121 @@
package com.doctordark.util;
import org.bukkit.plugin.java.*;
import com.google.common.collect.*;
import org.bukkit.event.*;
import org.bukkit.event.player.*;
import org.bukkit.entity.*;
import org.bukkit.scheduler.*;
import org.bukkit.block.*;
import org.bukkit.*;
import org.bukkit.plugin.*;
import javax.annotation.*;
import java.util.*;
public class SignHandler implements Listener {
private final Multimap<UUID, SignChange> signUpdateMap;
private final JavaPlugin plugin;
public SignHandler(final JavaPlugin plugin) {
this.signUpdateMap = HashMultimap.create();
this.plugin = plugin;
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerKick(final PlayerQuitEvent event) {
this.cancelTasks(event.getPlayer(), null, false);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerQuit(final PlayerQuitEvent event) {
this.cancelTasks(event.getPlayer(), null, false);
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onWorldChange(final PlayerChangedWorldEvent event) {
this.cancelTasks(event.getPlayer(), null, false);
}
public boolean showLines(final Player player, final Sign sign, final String[] newLines, final long ticks, final boolean forceChange) {
final String[] lines = sign.getLines();
if (Arrays.equals(lines, newLines)) {
return false;
}
final Collection<SignChange> signChanges = this.getSignChanges(player);
final Iterator<SignChange> iterator = signChanges.iterator();
while (iterator.hasNext()) {
final SignChange signChange = iterator.next();
if (signChange.sign.equals(sign)) {
if (!forceChange && Arrays.equals(signChange.newLines, newLines)) {
return false;
}
signChange.runnable.cancel();
iterator.remove();
break;
}
}
final Location location = sign.getLocation();
player.sendSignChange(location, newLines);
SignChange signChange;
if (signChanges.add(signChange = new SignChange(sign, newLines))) {
final Block block = sign.getBlock();
final BlockState previous = block.getState();
final BukkitRunnable runnable = new BukkitRunnable() {
public void run() {
if (SignHandler.this.signUpdateMap.remove((Object) player.getUniqueId(), (Object) signChange) && previous.equals(block.getState())) {
player.sendSignChange(location, lines);
}
}
};
runnable.runTaskLater((Plugin) this.plugin, ticks);
signChange.runnable = runnable;
}
return true;
}
public Collection<SignChange> getSignChanges(final Player player) {
return (Collection<SignChange>) this.signUpdateMap.get(player.getUniqueId());
}
public void cancelTasks(@Nullable final Sign sign) {
final Iterator<SignChange> iterator = this.signUpdateMap.values().iterator();
while (iterator.hasNext()) {
final SignChange signChange = iterator.next();
if (sign == null || signChange.sign.equals(sign)) {
signChange.runnable.cancel();
signChange.sign.update();
iterator.remove();
}
}
}
public void cancelTasks(final Player player, @Nullable final Sign sign, final boolean revertLines) {
final UUID uuid = player.getUniqueId();
final Iterator<Map.Entry<UUID, SignChange>> iterator = this.signUpdateMap.entries().iterator();
while (iterator.hasNext()) {
final Map.Entry<UUID, SignChange> entry = iterator.next();
if (entry.getKey().equals(uuid)) {
final SignChange signChange = entry.getValue();
if (sign != null && !signChange.sign.equals(sign)) {
continue;
}
if (revertLines) {
player.sendSignChange(signChange.sign.getLocation(), signChange.sign.getLines());
}
signChange.runnable.cancel();
iterator.remove();
}
}
}
private static final class SignChange {
public BukkitRunnable runnable;
public final Sign sign;
public final String[] newLines;
public SignChange(final Sign sign, final String[] newLines) {
this.sign = sign;
this.newLines = newLines;
}
}
}

View File

@ -0,0 +1,79 @@
package com.doctordark.util;
import org.bukkit.*;
public class SpigotUtils {
public static net.md_5.bungee.api.ChatColor toBungee(final ChatColor color) {
switch (color) {
case BLACK: {
return net.md_5.bungee.api.ChatColor.BLACK;
}
case DARK_BLUE: {
return net.md_5.bungee.api.ChatColor.DARK_BLUE;
}
case DARK_GREEN: {
return net.md_5.bungee.api.ChatColor.DARK_GREEN;
}
case DARK_AQUA: {
return net.md_5.bungee.api.ChatColor.DARK_AQUA;
}
case DARK_RED: {
return net.md_5.bungee.api.ChatColor.DARK_RED;
}
case DARK_PURPLE: {
return net.md_5.bungee.api.ChatColor.DARK_PURPLE;
}
case GOLD: {
return net.md_5.bungee.api.ChatColor.GOLD;
}
case GRAY: {
return net.md_5.bungee.api.ChatColor.GRAY;
}
case DARK_GRAY: {
return net.md_5.bungee.api.ChatColor.DARK_GRAY;
}
case BLUE: {
return net.md_5.bungee.api.ChatColor.BLUE;
}
case GREEN: {
return net.md_5.bungee.api.ChatColor.GREEN;
}
case AQUA: {
return net.md_5.bungee.api.ChatColor.AQUA;
}
case RED: {
return net.md_5.bungee.api.ChatColor.RED;
}
case LIGHT_PURPLE: {
return net.md_5.bungee.api.ChatColor.LIGHT_PURPLE;
}
case YELLOW: {
return net.md_5.bungee.api.ChatColor.YELLOW;
}
case WHITE: {
return net.md_5.bungee.api.ChatColor.WHITE;
}
case MAGIC: {
return net.md_5.bungee.api.ChatColor.MAGIC;
}
case BOLD: {
return net.md_5.bungee.api.ChatColor.BOLD;
}
case STRIKETHROUGH: {
return net.md_5.bungee.api.ChatColor.STRIKETHROUGH;
}
case UNDERLINE: {
return net.md_5.bungee.api.ChatColor.UNDERLINE;
}
case ITALIC: {
return net.md_5.bungee.api.ChatColor.ITALIC;
}
case RESET: {
return net.md_5.bungee.api.ChatColor.RESET;
}
default: {
throw new IllegalArgumentException("Unrecognised Bukkit colour " + color.name() + ".");
}
}
}
}

View File

@ -0,0 +1,94 @@
package com.doctordark.util;
import java.util.concurrent.*;
import org.json.simple.parser.*;
import com.google.common.collect.*;
import java.nio.charset.*;
import org.json.simple.*;
import java.io.*;
import java.net.*;
import java.nio.*;
import java.util.*;
public class UUIDFetcher implements Callable<Map<String, UUID>> {
private static final double PROFILES_PER_REQUEST = 100.0;
private static final String PROFILE_URL = "https://api.mojang.com/profiles/minecraft";
private final JSONParser jsonParser;
private final List<String> names;
private final boolean rateLimiting;
public UUIDFetcher(final List<String> names) {
this(names, true);
}
public UUIDFetcher(final List<String> names, final boolean rateLimiting) {
this.jsonParser = new JSONParser();
this.names = (List<String>) ImmutableList.copyOf((Collection) names);
this.rateLimiting = rateLimiting;
}
@Override
public Map<String, UUID> call() throws Exception {
final Map<String, UUID> uuidMap = new HashMap<String, UUID>();
for (int requests = (int) Math.ceil(this.names.size() / 100.0), i = 0; i < requests; ++i) {
final HttpURLConnection connection = createConnection();
final String body = JSONArray.toJSONString((List) this.names.subList(i * 100, Math.min((i + 1) * 100, this.names.size())));
writeBody(connection, body);
final JSONArray array = (JSONArray) this.jsonParser.parse((Reader) new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
for (final Object profile : array) {
final JSONObject jsonProfile = (JSONObject) profile;
final String id = (String) jsonProfile.get((Object) "id");
final String name = (String) jsonProfile.get((Object) "name");
final UUID uuid = getUUID(id);
uuidMap.put(name, uuid);
}
if (this.rateLimiting && i != requests - 1) {
Thread.sleep(100L);
}
}
return uuidMap;
}
private static void writeBody(final HttpURLConnection connection, final String body) throws Exception {
final OutputStream stream = connection.getOutputStream();
stream.write(body.getBytes(StandardCharsets.UTF_8));
stream.flush();
stream.close();
}
private static HttpURLConnection createConnection() throws Exception {
final URL url = new URL("https://api.mojang.com/profiles/minecraft");
final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/json");
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDoOutput(true);
return connection;
}
private static UUID getUUID(final String id) {
return UUID.fromString(id.substring(0, 8) + "-" + id.substring(8, 12) + "-" + id.substring(12, 16) + "-" + id.substring(16, 20) + "-" + id.substring(20, 32));
}
public static byte[] toBytes(final UUID uuid) {
final ByteBuffer byteBuffer = ByteBuffer.wrap(new byte[16]);
byteBuffer.putLong(uuid.getMostSignificantBits());
byteBuffer.putLong(uuid.getLeastSignificantBits());
return byteBuffer.array();
}
public static UUID fromBytes(final byte[] array) {
if (array.length != 16) {
throw new IllegalArgumentException("Illegal byte array length: " + array.length);
}
final ByteBuffer byteBuffer = ByteBuffer.wrap(array);
final long mostSignificant = byteBuffer.getLong();
final long leastSignificant = byteBuffer.getLong();
return new UUID(mostSignificant, leastSignificant);
}
public static UUID getUUIDOf(final String name) throws Exception {
return new UUIDFetcher(Collections.singletonList(name)).call().get(name);
}
}

View File

@ -0,0 +1,69 @@
package com.doctordark.util.chat;
import org.bukkit.potion.*;
import org.apache.commons.lang.*;
import org.bukkit.craftbukkit.v1_7_R4.inventory.*;
import org.bukkit.*;
import org.bukkit.Material;
import org.bukkit.command.*;
import org.bukkit.entity.*;
import org.bukkit.craftbukkit.v1_7_R4.entity.*;
import net.minecraft.server.v1_7_R4.*;
public class ChatUtil
{
public static String getName(final ItemStack stack) {
if (stack.tag != null && stack.tag.hasKeyOfType("display", 10)) {
final NBTTagCompound nbttagcompound = stack.tag.getCompound("display");
if (nbttagcompound.hasKeyOfType("Name", 8)) {
return nbttagcompound.getString("Name");
}
}
return stack.getItem().a(stack) + ".name";
}
public static Trans localFromItem(final org.bukkit.inventory.ItemStack stack) {
if (stack.getType() == Material.POTION && stack.getData().getData() == 0) {
final Potion potion = Potion.fromItemStack(stack);
if (potion != null) {
final PotionType type = potion.getType();
if (type != null && type != PotionType.WATER) {
final String effectName = (potion.isSplash() ? "Splash " : "") + WordUtils.capitalizeFully(type.name().replace('_', ' ')) + " L" + potion.getLevel();
return fromItemStack(stack).append(" of " + effectName);
}
}
}
return fromItemStack(stack);
}
public static Trans fromItemStack(final org.bukkit.inventory.ItemStack stack) {
final ItemStack nms = CraftItemStack.asNMSCopy(stack);
final NBTTagCompound tag = new NBTTagCompound();
nms.save(tag);
return new Trans(getName(nms), new Object[0]).setColor(ChatColor.getByChar(nms.w().e.getChar())).setHover(HoverAction.SHOW_ITEM, (IChatBaseComponent)new ChatComponentText(tag.toString()));
}
public static void reset(final IChatBaseComponent text) {
final ChatModifier modifier = text.getChatModifier();
modifier.a((ChatHoverable)null);
modifier.setChatClickable((ChatClickable)null);
modifier.setBold(false);
modifier.setColor(EnumChatFormat.RESET);
modifier.setItalic(false);
modifier.setRandom(false);
modifier.setStrikethrough(false);
modifier.setUnderline(false);
}
public static void send(final CommandSender sender, final IChatBaseComponent text) {
if (sender instanceof Player) {
final Player player = (Player)sender;
final PacketPlayOutChat packet = new PacketPlayOutChat(text, true);
final EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
entityPlayer.playerConnection.sendPacket((Packet)packet);
}
else {
sender.sendMessage(text.c());
}
}
}

View File

@ -0,0 +1,21 @@
package com.doctordark.util.chat;
import net.minecraft.server.v1_7_R4.*;
public enum ClickAction
{
OPEN_URL(EnumClickAction.OPEN_URL),
OPEN_FILE(EnumClickAction.OPEN_FILE),
RUN_COMMAND(EnumClickAction.RUN_COMMAND),
SUGGEST_COMMAND(EnumClickAction.SUGGEST_COMMAND);
private final EnumClickAction clickAction;
private ClickAction(final EnumClickAction action) {
this.clickAction = action;
}
public EnumClickAction getNMS() {
return this.clickAction;
}
}

View File

@ -0,0 +1,20 @@
package com.doctordark.util.chat;
import net.minecraft.server.v1_7_R4.*;
public enum HoverAction
{
SHOW_TEXT(EnumHoverAction.SHOW_TEXT),
SHOW_ITEM(EnumHoverAction.SHOW_ITEM),
SHOW_ACHIEVEMENT(EnumHoverAction.SHOW_ACHIEVEMENT);
private final EnumHoverAction hoverAction;
private HoverAction(final EnumHoverAction hoverAction) {
this.hoverAction = hoverAction;
}
public EnumHoverAction getNMS() {
return this.hoverAction;
}
}

View File

@ -0,0 +1,97 @@
package com.doctordark.util.chat;
import java.util.*;
import org.bukkit.*;
import java.util.logging.*;
import java.net.*;
import java.nio.charset.*;
import java.util.regex.*;
import java.io.*;
import org.bukkit.inventory.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.craftbukkit.v1_7_R4.inventory.*;
import net.minecraft.server.v1_7_R4.*;
import com.google.common.base.*;
import org.bukkit.enchantments.*;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.potion.*;
import org.bukkit.craftbukkit.v1_7_R4.potion.*;
@Deprecated
public class Lang {
private static final Pattern PATTERN;
private static final String HASH_17 = "03f31164d234f10a3230611656332f1756e570a9";
private static Map<String, String> translations;
public static void initialize(final String lang) throws IOException {
Lang.translations = new HashMap<String, String>();
Bukkit.getLogger().log(Level.INFO, "Initialling");
if ("03f31164d234f10a3230611656332f1756e570a9".length() >= 2) {
final String url = "http://resources.download.minecraft.net/" + "03f31164d234f10a3230611656332f1756e570a9".substring(0, 2) + "/" + "03f31164d234f10a3230611656332f1756e570a9";
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(url).openStream(), StandardCharsets.UTF_8))) {
String line;
while ((line = reader.readLine()) != null) {
line = line.trim();
// Bukkit.getLogger().info(line);
if (line.contains("=")) {
final Matcher matcher = Lang.PATTERN.matcher(line);
if (!matcher.matches()) {
continue;
}
Lang.translations.put(matcher.group(1), matcher.group(2));
}
}
}
}
}
public static String translatableFromStack(final ItemStack stack) {
final net.minecraft.server.v1_7_R4.ItemStack nms = CraftItemStack.asNMSCopy(stack);
final Item item = nms.getItem();
return item.a(nms) + ".name";
}
public static String fromStack(final ItemStack stack) {
final String node = translatableFromStack(stack);
return (String) MoreObjects.firstNonNull((Object) Lang.translations.get(node), (Object) node);
}
public static String translatableFromEnchantment(final Enchantment ench) {
final net.minecraft.server.v1_7_R4.Enchantment nms = net.minecraft.server.v1_7_R4.Enchantment.byId[ench.getId()];
return (nms == null) ? ench.getName() : nms.a();
}
public static String fromEnchantment(final Enchantment enchantment) {
final String node = translatableFromEnchantment(enchantment);
final String trans = Lang.translations.get(node);
return (trans != null) ? trans : node;
}
public static String translatableFromPotionEffectType(final PotionEffectType effectType) {
final CraftPotionEffectType craftType = (CraftPotionEffectType) PotionEffectType.getById(effectType.getId());
return craftType.getHandle().a();
}
public static String fromPotionEffectType(final PotionEffectType effectType) {
final String node = translatableFromPotionEffectType(effectType);
final String val = Lang.translations.get(node);
if (val == null) {
return node;
}
return val;
}
public static String translate(final String key, final Object... args) {
return String.format(Lang.translations.get(key), args);
}
static {
PATTERN = Pattern.compile("^\\s*([\\w\\d\\.]+)\\s*=\\s*(.*)\\s*$");
}
}

View File

@ -0,0 +1,136 @@
package com.doctordark.util.chat;
//Same as Doctor's
import org.bukkit.inventory.*;
import org.bukkit.inventory.ItemStack;
import net.minecraft.server.v1_7_R4.*;
import org.bukkit.command.*;
import org.bukkit.*;
import org.bukkit.entity.*;
import java.util.*;
public class Text extends ChatComponentText
{
public Text() {
super("");
}
public Text(final String string) {
super(string);
}
public Text(final Object object) {
super(String.valueOf(object));
}
public static Trans fromItemStack(final ItemStack stack) {
return ChatUtil.fromItemStack(stack);
}
public Text append(final Object object) {
return this.append(String.valueOf(object));
}
public Text append(final String text) {
return (Text)this.a(text);
}
public Text setClick1(ClickAction action, String value)
{
getChatModifier().setChatClickable(new ChatClickable(action.getNMS(), value));
return this;
}
public Text append(final IChatBaseComponent node) {
return (Text)this.addSibling(node);
}
public Text append(final IChatBaseComponent... nodes) {
for (final IChatBaseComponent node : nodes) {
this.addSibling(node);
}
return this;
}
public Text localText(final ItemStack stack) {
return this.append((IChatBaseComponent)ChatUtil.localFromItem(stack));
}
public Text appendItem(final ItemStack stack) {
return this.append((IChatBaseComponent)ChatUtil.fromItemStack(stack));
}
public Text setBold(final boolean bold) {
this.getChatModifier().setBold(bold);
return this;
}
public Text setItalic(final boolean italic) {
this.getChatModifier().setItalic(italic);
return this;
}
public Text setUnderline(final boolean underline) {
this.getChatModifier().setUnderline(underline);
return this;
}
public Text setRandom(final boolean random) {
this.getChatModifier().setRandom(random);
return this;
}
public Text setStrikethrough(final boolean strikethrough) {
this.getChatModifier().setStrikethrough(strikethrough);
return this;
}
public Text setColor(final ChatColor color) {
this.getChatModifier().setColor(EnumChatFormat.valueOf(color.name()));
return this;
}
public Text setClick(final ClickAction action, final String value) {
this.getChatModifier().setChatClickable(new ChatClickable(action.getNMS(), value));
return this;
}
public Text setHover(final HoverAction action, final IChatBaseComponent value) {
this.getChatModifier().a(new ChatHoverable(action.getNMS(), value));
return this;
}
public Text setHoverText(final String text) {
return this.setHover(HoverAction.SHOW_TEXT, (IChatBaseComponent)new Text(text));
}
public Text reset() {
ChatUtil.reset((IChatBaseComponent)this);
return this;
}
public IChatBaseComponent f() {
return (IChatBaseComponent)this.h();
}
public String toRawText() {
return this.c();
}
public void send(final CommandSender sender) {
ChatUtil.send(sender, (IChatBaseComponent)this);
}
public void broadcast() {
this.broadcast(null);
}
public void broadcast(final String permission) {
for (final Player player : Bukkit.getOnlinePlayers()) {
if (permission == null || player.hasPermission(permission)) {
this.send((CommandSender)player);
}
}
this.send((CommandSender)Bukkit.getConsoleSender());
}
}

View File

@ -0,0 +1,110 @@
package com.doctordark.util.chat;
import org.bukkit.inventory.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.*;
import net.minecraft.server.v1_7_R4.*;
import org.bukkit.command.*;
public class Trans extends ChatMessage
{
public Trans() {
super("", new Object[0]);
}
public Trans(final String string, final Object... objects) {
super(string, objects);
}
public static Trans fromItemStack(final ItemStack stack) {
return ChatUtil.fromItemStack(stack);
}
public IChatBaseComponent f() {
return (IChatBaseComponent)this.h();
}
public Trans append(final Object object) {
return this.append(String.valueOf(object));
}
public Trans append(final String text) {
return (Trans)this.a(text);
}
public Trans append(final IChatBaseComponent node) {
return (Trans)this.addSibling(node);
}
public Trans append(final IChatBaseComponent... nodes) {
for (final IChatBaseComponent node : nodes) {
this.addSibling(node);
}
return this;
}
public Trans appendItem(final ItemStack stack) {
return this.append((IChatBaseComponent)ChatUtil.fromItemStack(stack));
}
public Trans localText(final ItemStack stack) {
return this.append((IChatBaseComponent)ChatUtil.localFromItem(stack));
}
public Trans setBold(final boolean bold) {
this.getChatModifier().setBold(bold);
return this;
}
public Trans setItalic(final boolean italic) {
this.getChatModifier().setItalic(italic);
return this;
}
public Trans setUnderline(final boolean underline) {
this.getChatModifier().setUnderline(underline);
return this;
}
public Trans setRandom(final boolean random) {
this.getChatModifier().setRandom(random);
return this;
}
public Trans setStrikethrough(final boolean strikethrough) {
this.getChatModifier().setStrikethrough(strikethrough);
return this;
}
public Trans setColor(final ChatColor color) {
this.getChatModifier().setColor(EnumChatFormat.valueOf(color.name()));
return this;
}
public Trans setClick(final ClickAction action, final String value) {
this.getChatModifier().setChatClickable(new ChatClickable(action.getNMS(), value));
return this;
}
public Trans setHover(final HoverAction action, final IChatBaseComponent value) {
this.getChatModifier().a(new ChatHoverable(action.getNMS(), value));
return this;
}
public Trans setHoverText(final String text) {
return this.setHover(HoverAction.SHOW_TEXT, (IChatBaseComponent)new Text(text));
}
public Trans reset() {
ChatUtil.reset((IChatBaseComponent)this);
return this;
}
public String toRawText() {
return this.c();
}
public void send(final CommandSender sender) {
ChatUtil.send(sender, (IChatBaseComponent)this);
}
}

View File

@ -0,0 +1,96 @@
package com.doctordark.util.command;
import com.google.common.collect.*;
import java.util.*;
import org.bukkit.command.*;
import org.bukkit.*;
import org.apache.commons.lang3.text.*;
import com.doctordark.util.*;
public abstract class ArgumentExecutor implements CommandExecutor, TabCompleter {
protected final List<CommandArgument> arguments;
protected final String label;
public ArgumentExecutor(final String label) {
this.arguments = new ArrayList<CommandArgument>();
this.label = label;
}
public boolean containsArgument(final CommandArgument argument) {
return this.arguments.contains(argument);
}
public void addArgument(final CommandArgument argument) {
this.arguments.add(argument);
}
public void removeArgument(final CommandArgument argument) {
this.arguments.remove(argument);
}
public CommandArgument getArgument(final String id) {
for (final CommandArgument argument : this.arguments) {
final String name = argument.getName();
if (name.equalsIgnoreCase(id) || Arrays.asList(argument.getAliases()).contains(id.toLowerCase())) {
return argument;
}
}
return null;
}
public String getLabel() {
return this.label;
}
public List<CommandArgument> getArguments() {
return (List<CommandArgument>) ImmutableList.copyOf((Collection) this.arguments);
}
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (args.length < 1) {
sender.sendMessage(ChatColor.DARK_GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
sender.sendMessage(ChatColor.RED + WordUtils.capitalizeFully(this.label + " Help"));
for (final CommandArgument argument : this.arguments) {
final String permission = argument.getPermission();
if (permission == null || sender.hasPermission(permission)) {
sender.sendMessage(ChatColor.GRAY + argument.getUsage(label) + " - " + argument.getDescription() + '.');
sender.sendMessage(ChatColor.DARK_GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
}
}
return true;
}
final CommandArgument argument2 = this.getArgument(args[0]);
final String permission2 = (argument2 == null) ? null : argument2.getPermission();
if (argument2 == null || (permission2 != null && !sender.hasPermission(permission2))) {
sender.sendMessage(ChatColor.RED + WordUtils.capitalizeFully(this.label) + " sub-command " + args[0] + " not found.");
return true;
}
argument2.onCommand(sender, command, label, args);
return true;
}
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label, final String[] args) {
List<String> results = new ArrayList<String>();
if (args.length < 2) {
for (final CommandArgument argument : this.arguments) {
final String permission = argument.getPermission();
if (permission == null || sender.hasPermission(permission)) {
results.add(argument.getName());
}
}
} else {
final CommandArgument argument2 = this.getArgument(args[0]);
if (argument2 == null) {
return results;
}
final String permission2 = argument2.getPermission();
if (permission2 == null || sender.hasPermission(permission2)) {
results = argument2.onTabComplete(sender, command, label, args);
if (results == null) {
return null;
}
}
}
return BukkitUtils.getCompletions(args, results);
}
}

View File

@ -0,0 +1,112 @@
package com.doctordark.util.command;
import org.apache.commons.lang3.*;
import org.bukkit.command.*;
import java.util.*;
public abstract class CommandArgument {
private final String name;
protected boolean isPlayerOnly;
protected String description;
protected String permission;
protected String[] aliases;
public CommandArgument(final String name, final String description) {
this(name, description, (String) null);
}
public CommandArgument(final String name, final String description, final String permission) {
this(name, description, permission, ArrayUtils.EMPTY_STRING_ARRAY);
}
public CommandArgument(final String name, final String description, final String[] aliases) {
this(name, description, null, aliases);
}
public CommandArgument(final String name, final String description, final String permission, final String[] aliases) {
this.isPlayerOnly = false;
this.name = name;
this.description = description;
this.permission = permission;
this.aliases = Arrays.copyOf(aliases, aliases.length);
}
public final String getName() {
return this.name;
}
public boolean isPlayerOnly() {
return this.isPlayerOnly;
}
public final String getDescription() {
return this.description;
}
public final String getPermission() {
return this.permission;
}
public final String[] getAliases() {
if (this.aliases == null) {
this.aliases = ArrayUtils.EMPTY_STRING_ARRAY;
}
return Arrays.copyOf(this.aliases, this.aliases.length);
}
public abstract String getUsage(final String p0);
public abstract boolean onCommand(final CommandSender p0, final Command p1, final String p2, final String[] p3);
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label, final String[] args) {
return Collections.emptyList();
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CommandArgument)) {
return false;
}
final CommandArgument that = (CommandArgument) o;
Label_0054: {
if (this.name != null) {
if (this.name.equals(that.name)) {
break Label_0054;
}
} else if (that.name == null) {
break Label_0054;
}
return false;
}
Label_0087: {
if (this.description != null) {
if (this.description.equals(that.description)) {
break Label_0087;
}
} else if (that.description == null) {
break Label_0087;
}
return false;
}
if (this.permission != null) {
if (this.permission.equals(that.permission)) {
return Arrays.equals(this.aliases, that.aliases);
}
} else if (that.permission == null) {
return Arrays.equals(this.aliases, that.aliases);
}
return false;
}
@Override
public int hashCode() {
int result = (this.name != null) ? this.name.hashCode() : 0;
result = 31 * result + ((this.description != null) ? this.description.hashCode() : 0);
result = 31 * result + ((this.permission != null) ? this.permission.hashCode() : 0);
result = 31 * result + ((this.aliases != null) ? Arrays.hashCode(this.aliases) : 0);
return result;
}
}

View File

@ -0,0 +1,88 @@
package com.doctordark.util.command;
import org.bukkit.command.*;
import org.bukkit.entity.*;
import com.doctordark.util.*;
import org.bukkit.*;
import org.apache.commons.lang3.text.*;
import java.util.*;
import java.io.*;
public class CommandWrapper implements CommandExecutor, TabCompleter {
private final Collection<CommandArgument> arguments;
public CommandWrapper(final Collection<CommandArgument> arguments) {
this.arguments = arguments;
}
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (args.length < 1) {
printUsage(sender, label, this.arguments);
return true;
}
final CommandArgument argument = matchArgument(args[0], sender, this.arguments);
if (argument == null) {
printUsage(sender, label, this.arguments);
return true;
}
return argument.onCommand(sender, command, label, args);
}
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label, final String[] args) {
if (!(sender instanceof Player)) {
return Collections.emptyList();
}
List<String> results;
if (args.length == 1) {
results = getAccessibleArgumentNames(sender, this.arguments);
} else {
final CommandArgument argument = matchArgument(args[0], sender, this.arguments);
if (argument == null) {
return Collections.emptyList();
}
results = argument.onTabComplete(sender, command, label, args);
if (results == null) {
return null;
}
}
return BukkitUtils.getCompletions(args, results);
}
public static void printUsage(final CommandSender sender, final String label, final Collection<CommandArgument> arguments) {
sender.sendMessage(ChatColor.DARK_AQUA + "*** " + WordUtils.capitalizeFully(label) + " Help ***");
for (final CommandArgument argument : arguments) {
final String permission = argument.getPermission();
if (permission == null || sender.hasPermission(permission)) {
sender.sendMessage(ChatColor.GRAY + argument.getUsage(label) + " - " + argument.getDescription());
}
}
}
public static CommandArgument matchArgument(final String id, final CommandSender sender, final Collection<CommandArgument> arguments) {
for (final CommandArgument argument : arguments) {
final String permission = argument.getPermission();
if ((permission == null || sender.hasPermission(permission)) && (argument.getName().equalsIgnoreCase(id) || Arrays.asList(argument.getAliases()).contains(id))) {
return argument;
}
}
return null;
}
public static List<String> getAccessibleArgumentNames(final CommandSender sender, final Collection<CommandArgument> arguments) {
final List<String> results = new ArrayList<String>();
for (final CommandArgument argument : arguments) {
final String permission = argument.getPermission();
if (permission == null || sender.hasPermission(permission)) {
results.add(argument.getName());
}
}
return results;
}
public static class ArgumentComparator implements Comparator<CommandArgument>, Serializable {
@Override
public int compare(final CommandArgument primaryArgument, final CommandArgument secondaryArgument) {
return secondaryArgument.getName().compareTo(primaryArgument.getName());
}
}
}

View File

@ -0,0 +1,69 @@
package com.doctordark.util.cuboid;
import org.bukkit.block.*;
import org.bukkit.*;
public class CoordinatePair {
private final String worldName;
private final int x;
private final int z;
public CoordinatePair(final Block block) {
this(block.getWorld(), block.getX(), block.getZ());
}
public CoordinatePair(final World world, final int x, final int z) {
this.worldName = world.getName();
this.x = x;
this.z = z;
}
public World getWorld() {
return Bukkit.getWorld(this.worldName);
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (!(o instanceof CoordinatePair)) {
return false;
}
final CoordinatePair that = (CoordinatePair) o;
if (this.x != that.x) {
return false;
}
if (this.z != that.z) {
return false;
}
if (this.worldName != null) {
if (!this.worldName.equals(that.worldName)) {
return false;
}
} else if (that.worldName != null) {
return false;
}
return true;
}
@Override
public int hashCode() {
int result = (this.worldName != null) ? this.worldName.hashCode() : 0;
result = 31 * result + this.x;
result = 31 * result + this.z;
return result;
}
public String getWorldName() {
return this.worldName;
}
public int getX() {
return this.x;
}
public int getZ() {
return this.z;
}
}

View File

@ -0,0 +1,509 @@
package com.doctordark.util.cuboid;
import org.bukkit.block.*;
import org.bukkit.configuration.serialization.*;
import com.google.common.base.*;
import org.bukkit.util.*;
import org.bukkit.util.Vector;
import org.bukkit.entity.*;
import java.util.*;
import org.bukkit.*;
public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializable {
protected final String worldName;
protected int x1;
protected int y1;
protected int z1;
protected int x2;
protected int y2;
protected int z2;
private static final int CHUNK_SIZE = 16;
public Cuboid(final Map<String, Object> map) {
this.worldName = (String) map.get("worldName");
this.x1 = (int) map.get("x1");
this.y1 = (int) map.get("y1");
this.z1 = (int) map.get("z1");
this.x2 = (int) map.get("x2");
this.y2 = (int) map.get("y2");
this.z2 = (int) map.get("z2");
}
public Cuboid(final World world, final int x1, final int y1, final int z1, final int x2, final int y2, final int z2) {
this(((World) Preconditions.checkNotNull((Object) world)).getName(), x1, y1, z1, x2, y2, z2);
}
private Cuboid(final String worldName, final int x1, final int y1, final int z1, final int x2, final int y2, final int z2) {
Preconditions.checkNotNull((Object) worldName, (Object) "World name cannot be null");
this.worldName = worldName;
this.x1 = Math.min(x1, x2);
this.y1 = Math.min(y1, y2);
this.z1 = Math.min(z1, z2);
this.x2 = Math.max(x1, x2);
this.y2 = Math.max(y1, y2);
this.z2 = Math.max(z1, z2);
}
public Cuboid(final Location first, final Location second) {
Preconditions.checkNotNull((Object) first, (Object) "Location 1 cannot be null");
Preconditions.checkNotNull((Object) second, (Object) "Location 2 cannot be null");
Preconditions.checkArgument(first.getWorld().equals(second.getWorld()), (Object) "Locations must be on the same world");
this.worldName = first.getWorld().getName();
this.x1 = Math.min(first.getBlockX(), second.getBlockX());
this.y1 = Math.min(first.getBlockY(), second.getBlockY());
this.z1 = Math.min(first.getBlockZ(), second.getBlockZ());
this.x2 = Math.max(first.getBlockX(), second.getBlockX());
this.y2 = Math.max(first.getBlockY(), second.getBlockY());
this.z2 = Math.max(first.getBlockZ(), second.getBlockZ());
}
public Cuboid(final Location location) {
this(location, location);
}
public Cuboid(final Cuboid other) {
this(other.getWorld().getName(), other.x1, other.y1, other.z1, other.x2, other.y2, other.z2);
}
public Map<String, Object> serialize() {
final Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("worldName", this.worldName);
map.put("x1", this.x1);
map.put("y1", this.y1);
map.put("z1", this.z1);
map.put("x2", this.x2);
map.put("y2", this.y2);
map.put("z2", this.z2);
return map;
}
public boolean hasBothPositionsSet() {
return this.getMinimumPoint() != null && this.getMaximumPoint() != null;
}
public int getMinimumX() {
return Math.min(this.x1, this.x2);
}
public int getMinimumZ() {
return Math.min(this.z1, this.z2);
}
public int getMaximumX() {
return Math.max(this.x1, this.x2);
}
public int getMaximumZ() {
return Math.max(this.z1, this.z2);
}
public List<Vector> edges() {
return this.edges(-1, -1, -1, -1);
}
public List<Vector> edges(final int fixedMinX, final int fixedMaxX, final int fixedMinZ, final int fixedMaxZ) {
final Vector v1 = this.getMinimumPoint().toVector();
final Vector v2 = this.getMaximumPoint().toVector();
final int minX = v1.getBlockX();
final int maxX = v2.getBlockX();
final int minZ = v1.getBlockZ();
final int maxZ = v2.getBlockZ();
int capacity = (maxX - minX) * 4 + (maxZ - minZ) * 4;
capacity += 4;
final List<Vector> result = new ArrayList<Vector>(capacity);
if (capacity <= 0) {
return result;
}
final int minY = v1.getBlockY();
final int maxY = v1.getBlockY();
for (int x = minX; x <= maxX; ++x) {
result.add(new Vector(x, minY, minZ));
result.add(new Vector(x, minY, maxZ));
result.add(new Vector(x, maxY, minZ));
result.add(new Vector(x, maxY, maxZ));
}
for (int z = minZ; z <= maxZ; ++z) {
result.add(new Vector(minX, minY, z));
result.add(new Vector(minX, maxY, z));
result.add(new Vector(maxX, minY, z));
result.add(new Vector(maxX, maxY, z));
}
return result;
}
public Set<Player> getPlayers() {
final Set<Player> players = new HashSet<Player>();
for (final Player player : Bukkit.getOnlinePlayers()) {
if (this.contains(player)) {
players.add(player);
}
}
return players;
}
public Location getLowerNE() {
return new Location(this.getWorld(), (double) this.x1, (double) this.y1, (double) this.z1);
}
public Location getUpperSW() {
return new Location(this.getWorld(), (double) this.x2, (double) this.y2, (double) this.z2);
}
public Location getCenter() {
final int x1 = this.x2 + 1;
final int y1 = this.y2 + 1;
final int z1 = this.z2 + 1;
return new Location(this.getWorld(), this.x1 + (x1 - this.x1) / 2.0, this.y1 + (y1 - this.y1) / 2.0, this.z1 + (z1 - this.z1) / 2.0);
}
public String getWorldName() {
return this.worldName;
}
public World getWorld() {
return Bukkit.getWorld(this.worldName);
}
public int getSizeX() {
return this.x2 - this.x1 + 1;
}
public int getSizeY() {
return this.y2 - this.y1 + 1;
}
public int getSizeZ() {
return this.z2 - this.z1 + 1;
}
public int getX1() {
return this.x1;
}
public void setX1(final int x1) {
this.x1 = x1;
}
public int getY1() {
return this.y1;
}
public void setY1(final int y1) {
this.y1 = y1;
}
public int getZ1() {
return this.z1;
}
public void setZ1(final int z1) {
this.z1 = z1;
}
public int getX2() {
return this.x2;
}
public int getY2() {
return this.y2;
}
public void setY2(final int y2) {
this.y2 = y2;
}
public int getZ2() {
return this.z2;
}
public Location[] getCornerLocations() {
final Location[] result = new Location[8];
final Block[] cornerBlocks = this.getCornerBlocks();
for (int i = 0; i < cornerBlocks.length; ++i) {
result[i] = cornerBlocks[i].getLocation();
}
return result;
}
public Block[] getCornerBlocks() {
final Block[] result = new Block[8];
final World world = this.getWorld();
result[0] = world.getBlockAt(this.x1, this.y1, this.z1);
result[1] = world.getBlockAt(this.x1, this.y1, this.z2);
result[2] = world.getBlockAt(this.x1, this.y2, this.z1);
result[3] = world.getBlockAt(this.x1, this.y2, this.z2);
result[4] = world.getBlockAt(this.x2, this.y1, this.z1);
result[5] = world.getBlockAt(this.x2, this.y1, this.z2);
result[6] = world.getBlockAt(this.x2, this.y2, this.z1);
result[7] = world.getBlockAt(this.x2, this.y2, this.z2);
return result;
}
public Cuboid shift(final CuboidDirection direction, final int amount) throws IllegalArgumentException {
return this.expand(direction, amount).expand(direction.opposite(), -amount);
}
public Cuboid inset(final CuboidDirection direction, final int amount) throws IllegalArgumentException {
return this.outset(direction, -amount);
}
public Cuboid expand(final CuboidDirection direction, final int amount) throws IllegalArgumentException {
switch (direction) {
case NORTH: {
return new Cuboid(this.worldName, this.x1 - amount, this.y1, this.z1, this.x2, this.y2, this.z2);
}
case SOUTH: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2 + amount, this.y2, this.z2);
}
case EAST: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1 - amount, this.x2, this.y2, this.z2);
}
case WEST: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, this.z2 + amount);
}
case DOWN: {
return new Cuboid(this.worldName, this.x1, this.y1 - amount, this.z1, this.x2, this.y2, this.z2);
}
case UP: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2 + amount, this.z2);
}
default: {
throw new IllegalArgumentException("Invalid direction " + direction);
}
}
}
public Cuboid outset(final CuboidDirection direction, final int amount) throws IllegalArgumentException {
switch (direction) {
case HORIZONTAL: {
return this.expand(CuboidDirection.NORTH, amount).expand(CuboidDirection.SOUTH, amount).expand(CuboidDirection.EAST, amount).expand(CuboidDirection.WEST, amount);
}
case VERTICAL: {
return this.expand(CuboidDirection.DOWN, amount).expand(CuboidDirection.UP, amount);
}
case BOTH: {
return this.outset(CuboidDirection.HORIZONTAL, amount).outset(CuboidDirection.VERTICAL, amount);
}
default: {
throw new IllegalArgumentException("Invalid direction " + direction);
}
}
}
public boolean contains(final Cuboid cuboid) {
return this.contains(cuboid.getMinimumPoint()) || this.contains(cuboid.getMaximumPoint());
}
public boolean contains(final Player player) {
return this.contains(player.getLocation());
}
public boolean contains(final World world, final int x, final int z) {
return (world == null || this.getWorld().equals(world)) && x >= this.x1 && x <= this.x2 && z >= this.z1 && z <= this.z2;
}
public boolean contains(final int x, final int y, final int z) {
return x >= this.x1 && x <= this.x2 && y >= this.y1 && y <= this.y2 && z >= this.z1 && z <= this.z2;
}
public boolean contains(final Block block) {
return this.contains(block.getLocation());
}
public boolean contains(final Location location) {
if (location == null || this.worldName == null) {
return false;
}
final World world = location.getWorld();
return world != null && this.worldName.equals(location.getWorld().getName()) && this.contains(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
public int getVolume() {
return this.getSizeX() * this.getSizeY() * this.getSizeZ();
}
public int getArea() {
final Location min = this.getMinimumPoint();
final Location max = this.getMaximumPoint();
return (max.getBlockX() - min.getBlockX() + 1) * (max.getBlockZ() - min.getBlockZ() + 1);
}
public byte getAverageLightLevel() {
long total = 0L;
int count = 0;
for (final Block block : this) {
if (block.isEmpty()) {
total += block.getLightLevel();
++count;
}
}
return (byte) ((count > 0) ? ((byte) (total / count)) : 0);
}
public Location getMinimumPoint() {
return new Location(this.getWorld(), (double) Math.min(this.x1, this.x2), (double) Math.min(this.y1, this.y2), (double) Math.min(this.z1, this.z2));
}
public Location getMaximumPoint() {
return new Location(this.getWorld(), (double) Math.max(this.x1, this.x2), (double) Math.max(this.y1, this.y2), (double) Math.max(this.z1, this.z2));
}
public int getWidth() {
return this.getMaximumPoint().getBlockX() - this.getMinimumPoint().getBlockX();
}
public int getHeight() {
return this.getMaximumPoint().getBlockY() - this.getMinimumPoint().getBlockY();
}
public int getLength() {
return this.getMaximumPoint().getBlockZ() - this.getMinimumPoint().getBlockZ();
}
public Cuboid contract() {
return this.contract(CuboidDirection.DOWN).contract(CuboidDirection.SOUTH).contract(CuboidDirection.EAST).contract(CuboidDirection.UP).contract(CuboidDirection.NORTH)
.contract(CuboidDirection.WEST);
}
public Cuboid contract(final CuboidDirection direction) {
Cuboid face = this.getFace(direction.opposite());
switch (direction) {
case DOWN: {
while (face.containsOnly(Material.AIR) && face.y1 > this.y1) {
face = face.shift(CuboidDirection.DOWN, 1);
}
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, face.y2, this.z2);
}
case UP: {
while (face.containsOnly(Material.AIR) && face.y2 < this.y2) {
face = face.shift(CuboidDirection.UP, 1);
}
return new Cuboid(this.worldName, this.x1, face.y1, this.z1, this.x2, this.y2, this.z2);
}
case NORTH: {
while (face.containsOnly(Material.AIR) && face.x1 > this.x1) {
face = face.shift(CuboidDirection.NORTH, 1);
}
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, face.x2, this.y2, this.z2);
}
case SOUTH: {
while (face.containsOnly(Material.AIR) && face.x2 < this.x2) {
face = face.shift(CuboidDirection.SOUTH, 1);
}
return new Cuboid(this.worldName, face.x1, this.y1, this.z1, this.x2, this.y2, this.z2);
}
case EAST: {
while (face.containsOnly(Material.AIR) && face.z1 > this.z1) {
face = face.shift(CuboidDirection.EAST, 1);
}
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, face.z2);
}
case WEST: {
while (face.containsOnly(Material.AIR) && face.z2 < this.z2) {
face = face.shift(CuboidDirection.WEST, 1);
}
return new Cuboid(this.worldName, this.x1, this.y1, face.z1, this.x2, this.y2, this.z2);
}
default: {
throw new IllegalArgumentException("Invalid direction " + direction);
}
}
}
public Cuboid getFace(final CuboidDirection direction) {
switch (direction) {
case DOWN: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y1, this.z2);
}
case UP: {
return new Cuboid(this.worldName, this.x1, this.y2, this.z1, this.x2, this.y2, this.z2);
}
case NORTH: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x1, this.y2, this.z2);
}
case SOUTH: {
return new Cuboid(this.worldName, this.x2, this.y1, this.z1, this.x2, this.y2, this.z2);
}
case EAST: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z1, this.x2, this.y2, this.z1);
}
case WEST: {
return new Cuboid(this.worldName, this.x1, this.y1, this.z2, this.x2, this.y2, this.z2);
}
default: {
throw new IllegalArgumentException("Invalid direction " + direction);
}
}
}
public boolean containsOnly(final Material material) {
for (final Block block : this) {
if (block.getType() != material) {
return false;
}
}
return true;
}
public Cuboid getBoundingCuboid(final Cuboid other) {
if (other == null) {
return this;
}
final int xMin = Math.min(this.x1, other.x1);
final int yMin = Math.min(this.y1, other.y1);
final int zMin = Math.min(this.z1, other.z1);
final int xMax = Math.max(this.x2, other.x2);
final int yMax = Math.max(this.y2, other.y2);
final int zMax = Math.max(this.z2, other.z2);
return new Cuboid(this.worldName, xMin, yMin, zMin, xMax, yMax, zMax);
}
public Block getRelativeBlock(final int x, final int y, final int z) {
return this.getWorld().getBlockAt(this.x1 + x, this.y1 + y, this.z1 + z);
}
public Block getRelativeBlock(final World world, final int x, final int y, final int z) {
return world.getBlockAt(this.x1 + x, this.y1 + y, this.z1 + z);
}
public List<Chunk> getChunks() {
final World world = this.getWorld();
final int x1 = this.x1 & 0xFFFFFFF0;
final int x2 = this.x2 & 0xFFFFFFF0;
final int z1 = this.z1 & 0xFFFFFFF0;
final int z2 = this.z2 & 0xFFFFFFF0;
final List<Chunk> result = new ArrayList<Chunk>(x2 - x1 + 16 + (z2 - z1) * 16);
for (int x3 = x1; x3 <= x2; x3 += 16) {
for (int z3 = z1; z3 <= z2; z3 += 16) {
result.add(world.getChunkAt(x3 >> 4, z3 >> 4));
}
}
return result;
}
@Override
public Iterator<Block> iterator() {
return new CuboidBlockIterator(this.getWorld(), this.x1, this.y1, this.z1, this.x2, this.y2, this.z2);
}
public Iterator<Location> locationIterator() {
return new CuboidLocationIterator(this.getWorld(), this.x1, this.y1, this.z1, this.x2, this.y2, this.z2);
}
public Cuboid clone() {
try {
return (Cuboid) super.clone();
} catch (CloneNotSupportedException ex) {
throw new RuntimeException("This could never happen", ex);
}
}
@Override
public String toString() {
return "Cuboid: " + this.worldName + ',' + this.x1 + ',' + this.y1 + ',' + this.z1 + "=>" + this.x2 + ',' + this.y2 + ',' + this.z2;
}
}

View File

@ -0,0 +1,55 @@
package com.doctordark.util.cuboid;
import java.util.*;
import org.bukkit.block.*;
import org.bukkit.*;
public class CuboidBlockIterator implements Iterator<Block> {
private final World world;
private final int baseX;
private final int baseY;
private final int baseZ;
private final int sizeX;
private final int sizeY;
private final int sizeZ;
private int x;
private int y;
private int z;
public CuboidBlockIterator(final World world, final int x1, final int y1, final int z1, final int x2, final int y2, final int z2) {
this.world = world;
this.baseX = x1;
this.baseY = y1;
this.baseZ = z1;
this.sizeX = Math.abs(x2 - x1) + 1;
this.sizeY = Math.abs(y2 - y1) + 1;
this.sizeZ = Math.abs(z2 - z1) + 1;
final boolean x3 = false;
this.z = (x3 ? 1 : 0);
this.y = (x3 ? 1 : 0);
this.x = (x3 ? 1 : 0);
}
@Override
public boolean hasNext() {
return this.x < this.sizeX && this.y < this.sizeY && this.z < this.sizeZ;
}
@Override
public Block next() {
final Block block = this.world.getBlockAt(this.baseX + this.x, this.baseY + this.y, this.baseZ + this.z);
if (++this.x >= this.sizeX) {
this.x = 0;
if (++this.y >= this.sizeY) {
this.y = 0;
++this.z;
}
}
return block;
}
@Override
public void remove() throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
}

View File

@ -0,0 +1,68 @@
package com.doctordark.util.cuboid;
import org.bukkit.block.*;
public enum CuboidDirection {
NORTH, EAST, SOUTH, WEST, UP, DOWN, HORIZONTAL, VERTICAL, BOTH, UNKNOWN;
public CuboidDirection opposite() {
switch (this) {
case NORTH: {
return CuboidDirection.SOUTH;
}
case EAST: {
return CuboidDirection.WEST;
}
case SOUTH: {
return CuboidDirection.NORTH;
}
case WEST: {
return CuboidDirection.EAST;
}
case HORIZONTAL: {
return CuboidDirection.VERTICAL;
}
case VERTICAL: {
return CuboidDirection.HORIZONTAL;
}
case UP: {
return CuboidDirection.DOWN;
}
case DOWN: {
return CuboidDirection.UP;
}
case BOTH: {
return CuboidDirection.BOTH;
}
default: {
return CuboidDirection.UNKNOWN;
}
}
}
public BlockFace toBukkitDirection() {
switch (this) {
case NORTH: {
return BlockFace.NORTH;
}
case EAST: {
return BlockFace.EAST;
}
case SOUTH: {
return BlockFace.SOUTH;
}
case WEST: {
return BlockFace.WEST;
}
case UP: {
return BlockFace.UP;
}
case DOWN: {
return BlockFace.DOWN;
}
default: {
return null;
}
}
}
}

View File

@ -0,0 +1,54 @@
package com.doctordark.util.cuboid;
import java.util.*;
import org.bukkit.*;
public class CuboidLocationIterator implements Iterator<Location> {
private final World world;
private final int baseX;
private final int baseY;
private final int baseZ;
private final int sizeX;
private final int sizeY;
private final int sizeZ;
private int x;
private int y;
private int z;
public CuboidLocationIterator(final World world, final int x1, final int y1, final int z1, final int x2, final int y2, final int z2) {
this.world = world;
this.baseX = x1;
this.baseY = y1;
this.baseZ = z1;
this.sizeX = Math.abs(x2 - x1) + 1;
this.sizeY = Math.abs(y2 - y1) + 1;
this.sizeZ = Math.abs(z2 - z1) + 1;
final boolean x3 = false;
this.z = (x3 ? 1 : 0);
this.y = (x3 ? 1 : 0);
this.x = (x3 ? 1 : 0);
}
@Override
public boolean hasNext() {
return this.x < this.sizeX && this.y < this.sizeY && this.z < this.sizeZ;
}
@Override
public Location next() {
final Location location = new Location(this.world, (double) (this.baseX + this.x), (double) (this.baseY + this.y), (double) (this.baseZ + this.z));
if (++this.x >= this.sizeX) {
this.x = 0;
if (++this.y >= this.sizeY) {
this.y = 0;
++this.z;
}
}
return location;
}
@Override
public void remove() throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}
}

View File

@ -0,0 +1,55 @@
package com.doctordark.util.cuboid;
import org.bukkit.*;
import java.util.*;
public class NamedCuboid extends Cuboid {
protected String name;
public NamedCuboid(final Cuboid other) {
super(other.getWorld(), other.x1, other.y1, other.z1, other.x2, other.y2, other.z2);
}
public NamedCuboid(final World world, final int x1, final int y1, final int z1, final int x2, final int y2, final int z2) {
super(world, x1, y1, z1, x2, y2, z2);
}
public NamedCuboid(final Location location) {
super(location, location);
}
public NamedCuboid(final Location first, final Location second) {
super(first, second);
}
public NamedCuboid(final Map<String, Object> map) {
super(map);
this.name = (String) map.get("name");
}
@Override
public Map<String, Object> serialize() {
final Map<String, Object> map = super.serialize();
map.put("name", this.name);
return map;
}
public String getName() {
return this.name;
}
public void setName(final String name) {
this.name = name;
}
@Override
public NamedCuboid clone() {
return (NamedCuboid) super.clone();
}
@Override
public String toString() {
return "NamedCuboid: " + this.worldName + ',' + this.x1 + ',' + this.y1 + ',' + this.z1 + "=>" + this.x2 + ',' + this.y2 + ',' + this.z2 + ':' + this.name;
}
}

View File

@ -0,0 +1,15 @@
package com.doctordark.util.imagemessage;
public enum ImageChar {
BLOCK('\u2588'), DARK_SHADE('\u2593'), MEDIUM_SHADE('\u2592'), LIGHT_SHADE('\u2591');
private final char character;
private ImageChar(final char character) {
this.character = character;
}
public char getChar() {
return this.character;
}
}

View File

@ -0,0 +1,178 @@
package com.doctordark.util.imagemessage;
import java.awt.*;
import java.awt.Color;
import com.google.common.base.*;
import org.bukkit.*;
import java.net.*;
import javax.imageio.*;
import java.io.*;
import java.awt.geom.*;
import java.awt.image.*;
import org.bukkit.craftbukkit.libs.joptsimple.internal.*;
import org.bukkit.craftbukkit.libs.joptsimple.internal.Strings;
import java.util.*;
import org.bukkit.entity.*;
public final class ImageMessage {
private static final char TRANSPARENT_CHAR = ' ';
private final String[] lines;
private static final Color[] colors;
private ImageMessage(final String... lines) throws IllegalArgumentException {
Preconditions.checkNotNull((Object) lines, (Object) "Lines cannot be null");
this.lines = lines;
}
public ImageMessage(final BufferedImage image, final int height, final char imageCharacter) throws IllegalArgumentException {
this(toImageMessage(toColourArray(image, height), imageCharacter));
}
public static ImageMessage newInstance(final BufferedImage image, final int height, final char imageCharacter) throws IllegalArgumentException {
Preconditions.checkNotNull((Object) image, (Object) "Image cannot be null");
Preconditions.checkArgument(height >= 0, (Object) "Height must be positive");
return new ImageMessage(image, height, imageCharacter);
}
public static ImageMessage newInstance(final ChatColor[][] chatColors, final char imageCharacter) {
return new ImageMessage(toImageMessage(chatColors, imageCharacter));
}
public static ImageMessage newInstance(final String url, final int height, final char imageCharacter) throws IllegalArgumentException {
Preconditions.checkNotNull((Object) url, (Object) "Image URL cannot be null");
Preconditions.checkArgument(height >= 0, (Object) "Height must be positive");
try {
return newInstance(ImageIO.read(new URL(url)), height, imageCharacter);
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
}
public static ImageMessage newInstance(final String fileName, final File folder, final int height, final char imageCharacter) throws IllegalArgumentException {
Preconditions.checkNotNull((Object) fileName, (Object) "File name cannot be null");
Preconditions.checkNotNull((Object) folder, (Object) "Folder cannot be null");
try {
return newInstance(ImageIO.read(new File(folder, fileName)), height, imageCharacter);
} catch (IOException ex) {
throw new IllegalArgumentException(ex);
}
}
public ImageMessage appendText(final String... text) {
for (int i = 0; i < Math.min(text.length, this.lines.length); ++i) {
final StringBuilder sb = new StringBuilder();
final String[] lines = this.lines;
final int n = i;
lines[n] = sb.append(lines[n]).append(' ').append(text[i]).toString();
}
return this;
}
public ImageMessage appendCenteredText(final String... text) {
for (int i = 0; i < Math.min(text.length, this.lines.length); ++i) {
final String line = this.lines[i];
this.lines[i] = line + this.center(text[i], 65 - line.length());
}
return this;
}
private static ChatColor[][] toColourArray(final BufferedImage image, final int height) {
final double ratio = image.getHeight() / image.getWidth();
final BufferedImage resizedImage = resizeImage(image, (int) (height / ratio), height);
final ChatColor[][] chatImage = new ChatColor[resizedImage.getWidth()][resizedImage.getHeight()];
for (int x = 0; x < resizedImage.getWidth(); ++x) {
for (int y = 0; y < resizedImage.getHeight(); ++y) {
final ChatColor closest = getClosestChatColor(new Color(resizedImage.getRGB(x, y), true));
chatImage[x][y] = closest;
}
}
return chatImage;
}
private static String[] toImageMessage(final ChatColor[][] colors, final char imageCharacter) {
final String[] results = new String[colors[0].length];
for (int i = 0; i < colors[0].length; ++i) {
final StringBuilder line = new StringBuilder();
for (final ChatColor[] color : colors) {
final ChatColor current = color[i];
line.append((current != null) ? (current.toString() + imageCharacter) : ImageMessage.TRANSPARENT_CHAR);
}
results[i] = line.toString() + ChatColor.RESET;
}
return results;
}
private static BufferedImage resizeImage(final BufferedImage image, final int width, final int height) {
final AffineTransform transform = new AffineTransform();
transform.scale(width / image.getWidth(), height / image.getHeight());
return new AffineTransformOp(transform, 1).filter(image, null);
}
private static double getDistance(final Color c1, final Color c2) {
final int red = c1.getRed() - c2.getRed();
final int green = c1.getGreen() - c2.getGreen();
final int blue = c1.getBlue() - c2.getBlue();
final double redMean = (c1.getRed() + c2.getRed()) / 2.0;
final double weightRed = 2.0 + redMean / 256.0;
final double weightGreen = 4.0;
final double weightBlue = 2.0 + (255.0 - redMean) / 256.0;
return weightRed * red * red + weightGreen * green * green + weightBlue * blue * blue;
}
private static boolean areIdentical(final Color c1, final Color c2) {
return Math.abs(c1.getRed() - c2.getRed()) <= 5 && Math.abs(c1.getGreen() - c2.getGreen()) <= 5 && Math.abs(c1.getBlue() - c2.getBlue()) <= 5;
}
private static ChatColor getClosestChatColor(final Color color) {
if (color.getAlpha() < 128) {
return null;
}
for (int i = 0; i < ImageMessage.colors.length; ++i) {
if (areIdentical(ImageMessage.colors[i], color)) {
return ChatColor.values()[i];
}
}
int index = 0;
double best = -1.0;
for (int j = 0; j < ImageMessage.colors.length; ++j) {
final double distance = getDistance(color, ImageMessage.colors[j]);
if (distance < best || best == -1.0) {
best = distance;
index = j;
}
}
return ChatColor.values()[index];
}
private String center(final String string, final int length) {
if (string.length() > length) {
return string.substring(0, length);
}
if (string.length() == length) {
return string;
}
return Strings.repeat(' ', (length - string.length()) / 2) + string;
}
public String[] getLines() {
return Arrays.copyOf(this.lines, this.lines.length);
}
public void sendToPlayer(final Player player) {
player.sendMessage(this.lines);
}
static {
colors = new Color[] { new Color(0, 0, 0), new Color(0, 0, 170), new Color(0, 170, 0), new Color(0, 170, 170), new Color(170, 0, 0), new Color(170, 0, 170), new Color(255, 170, 0),
new Color(170, 170, 170), new Color(85, 85, 85), new Color(85, 85, 255), new Color(85, 255, 85), new Color(85, 255, 255), new Color(255, 85, 85), new Color(255, 85, 255),
new Color(255, 255, 85), new Color(255, 255, 255) };
}
}

View File

@ -0,0 +1,103 @@
package com.doctordark.util.itemdb;
import org.bukkit.configuration.serialization.*;
import org.bukkit.*;
import org.bukkit.material.*;
import org.bukkit.inventory.*;
import java.util.*;
import com.doctordark.internal.com.doctordark.base.*;
public class ItemData implements ConfigurationSerializable {
private final Material material;
private final short itemData;
public ItemData(final MaterialData data) {
this(data.getItemType(), data.getData());
}
public ItemData(final ItemStack stack) {
this(stack.getType(), stack.getData().getData());
}
public ItemData(final Material material, final short itemData) {
this.material = material;
this.itemData = itemData;
}
public ItemData(final Map<String, Object> map) {
Object object = map.get("itemType");
if (!(object instanceof String)) {
throw new AssertionError((Object) "Incorrectly configurised");
}
this.material = Material.getMaterial((String) object);
if ((object = map.get("itemData")) instanceof Short) {
this.itemData = (short) object;
return;
}
throw new AssertionError((Object) "Incorrectly configurised");
}
public Map<String, Object> serialize() {
final Map<String, Object> map = new LinkedHashMap<String, Object>();
map.put("itemType", this.material.name());
map.put("itemData", this.itemData);
return map;
}
public Material getMaterial() {
return this.material;
}
@Deprecated
public short getItemData() {
return this.itemData;
}
public String getItemName() {
return BasePlugin.getPlugin().getItemDb().getName(new ItemStack(this.material, 1, this.itemData));
}
public static ItemData fromItemName(final String string) {
final ItemStack stack = BasePlugin.getPlugin().getItemDb().getItem(string);
return new ItemData(stack.getType(), stack.getData().getData());
}
public static ItemData fromStringValue(final String value) {
final int firstBracketIndex = value.indexOf(40);
if (firstBracketIndex == -1) {
return null;
}
final int otherBracketIndex = value.indexOf(41);
if (otherBracketIndex == -1) {
return null;
}
final String itemName = value.substring(0, firstBracketIndex);
final String itemData = value.substring(firstBracketIndex + 1, otherBracketIndex);
final Material material = Material.getMaterial(itemName);
return new ItemData(material, Short.parseShort(itemData));
}
@Override
public String toString() {
return String.valueOf(this.material.name()) + "(" + String.valueOf(this.itemData) + ")";
}
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || this.getClass() != o.getClass()) {
return false;
}
final ItemData itemData1 = (ItemData) o;
return this.itemData == itemData1.itemData && this.material == itemData1.material;
}
@Override
public int hashCode() {
int result = (this.material != null) ? this.material.hashCode() : 0;
result = 31 * result + this.itemData;
return result;
}
}

View File

@ -0,0 +1,26 @@
package com.doctordark.util.itemdb;
import org.bukkit.inventory.*;
import org.bukkit.entity.*;
import java.util.*;
public interface ItemDb {
void reloadItemDatabase();
ItemStack getPotion(final String p0);
ItemStack getPotion(final String p0, final int p1);
ItemStack getItem(final String p0);
ItemStack getItem(final String p0, final int p1);
String getName(final ItemStack p0);
@Deprecated
String getPrimaryName(final ItemStack p0);
String getNames(final ItemStack p0);
List<ItemStack> getMatching(final Player p0, final String[] p1);
}

View File

@ -0,0 +1,72 @@
package com.doctordark.util.itemdb;
import org.bukkit.plugin.java.*;
import java.util.logging.*;
import java.nio.charset.*;
import java.math.*;
import java.security.*;
import java.nio.file.*;
import com.doctordark.internal.com.doctordark.base.*;
import java.util.*;
import java.io.*;
public class ManagedFile {
private static final int BUFFER_SIZE = 8192;
private final transient File file;
public ManagedFile(final String filename, final JavaPlugin plugin) {
this.file = new File(plugin.getDataFolder(), filename);
if (!this.file.exists()) {
try {
copyResourceAscii('/' + filename, this.file);
} catch (IOException ex) {
plugin.getLogger().log(Level.SEVERE, "items.csv has not been loaded", ex);
}
}
}
public File getFile() {
return this.file;
}
public static void copyResourceAscii(final String resourceName, final File file) throws IOException {
try (final InputStreamReader reader = new InputStreamReader(ManagedFile.class.getResourceAsStream(resourceName), StandardCharsets.UTF_8)) {
final MessageDigest digest = getDigest();
try (final DigestOutputStream digestStream = new DigestOutputStream(new FileOutputStream(file), digest);
final OutputStreamWriter writer = new OutputStreamWriter(digestStream, StandardCharsets.UTF_8)) {
final char[] buffer = new char[8192];
int length;
while ((length = reader.read(buffer)) >= 0) {
writer.write(buffer, 0, length);
}
writer.write("\n");
writer.flush();
digestStream.on(false);
digestStream.write(35);
digestStream.write(new BigInteger(1, digest.digest()).toString(16).getBytes(StandardCharsets.UTF_8));
}
}
}
public static MessageDigest getDigest() throws IOException {
try {
return MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException ex) {
throw new IOException(ex);
}
}
public List<String> getLines() {
try (final BufferedReader reader = Files.newBufferedReader(Paths.get(this.file.getPath(), new String[0]), StandardCharsets.UTF_8)) {
final List<String> lines = new ArrayList<String>();
String line;
while ((line = reader.readLine()) != null) {
lines.add(line);
}
return lines;
} catch (IOException ex) {
BasePlugin.getPlugin().getJavaPlugin().getLogger().log(Level.SEVERE, ex.getMessage(), ex);
return Collections.emptyList();
}
}
}

View File

@ -0,0 +1,311 @@
package com.doctordark.util.itemdb;
import gnu.trove.map.*;
import org.bukkit.plugin.java.*;
import com.google.common.collect.*;
import gnu.trove.map.hash.*;
import com.doctordark.util.*;
import org.bukkit.potion.*;
import org.bukkit.*;
import java.util.regex.*;
import org.bukkit.entity.*;
import org.bukkit.inventory.*;
import org.bukkit.craftbukkit.v1_7_R4.inventory.*;
import java.util.*;
import org.apache.commons.lang3.*;
public class SimpleItemDb implements ItemDb {
private static final Comparator<String> STRING_LENGTH_COMPARATOR;
private final TObjectIntMap<String> items;
private final TreeMultimap<ItemData, String> names;
private final Map<ItemData, String> primaryName;
private final TObjectShortMap<String> durabilities;
private final ManagedFile file;
private final Pattern splitPattern;
private static final Pattern PARTS_PATTERN;
public SimpleItemDb(final JavaPlugin plugin) {
this.items = (TObjectIntMap<String>) new TObjectIntHashMap();
this.names = (TreeMultimap<ItemData, String>) TreeMultimap.create((Comparator) Ordering.arbitrary(), (Comparator) SimpleItemDb.STRING_LENGTH_COMPARATOR);
this.primaryName = new HashMap<ItemData, String>();
this.durabilities = (TObjectShortMap<String>) new TObjectShortHashMap();
this.splitPattern = Pattern.compile("((.*)[:+',;.](\\d+))");
this.file = new ManagedFile("items.csv", plugin);
this.reloadItemDatabase();
}
@Override
public void reloadItemDatabase() {
if (this.file.getFile() == null) {
return;
}
final List<String> lines = this.file.getLines();
if (lines.isEmpty()) {
return;
}
this.durabilities.clear();
this.items.clear();
this.names.clear();
this.primaryName.clear();
for (String line : lines) {
line = line.trim().toLowerCase(Locale.ENGLISH);
if (line.length() > 0 && line.charAt(0) == '#') {
continue;
}
final String[] parts = SimpleItemDb.PARTS_PATTERN.split(line);
if (parts.length < 2) {
continue;
}
Material material;
try {
final int numeric = Integer.parseInt(parts[1]);
material = Material.getMaterial(numeric);
} catch (IllegalArgumentException ex) {
material = Material.getMaterial(parts[1]);
}
final short data = (short) ((parts.length > 2 && !parts[2].equals("0")) ? Short.parseShort(parts[2]) : 0);
final String itemName = parts[0].toLowerCase(Locale.ENGLISH);
this.durabilities.put(itemName, data);
this.items.put(itemName, material.getId());
final ItemData itemData = new ItemData(material, data);
if (this.names.containsKey((Object) itemData)) {
this.names.get(itemData).add(itemName);
} else {
this.names.put(itemData, itemName);
this.primaryName.put(itemData, itemName);
}
}
}
@Override
public ItemStack getPotion(final String id) {
return this.getPotion(id, 1);
}
@Override
public ItemStack getPotion(String id, final int quantity) {
int length = id.length();
if (length <= 1) {
return null;
}
boolean splash = false;
if (length > 1 && id.endsWith("s")) {
id = id.substring(0, --length);
splash = true;
if (length <= 1) {
return null;
}
}
boolean extended = false;
if (id.endsWith("e")) {
id = id.substring(0, --length);
extended = true;
if (length <= 1) {
return null;
}
}
final Integer level = JavaUtils.tryParseInt(id.substring(length - 1, length));
id = id.substring(0, --length);
final String lowerCase = id.toLowerCase(Locale.ENGLISH);
PotionType type = null;
switch (lowerCase) {
case "hp": {
type = PotionType.FIRE_RESISTANCE;
break;
}
case "rp": {
type = PotionType.REGEN;
break;
}
case "dp": {
type = PotionType.INSTANT_DAMAGE;
break;
}
case "swp": {
type = PotionType.SPEED;
break;
}
case "slp": {
type = PotionType.SLOWNESS;
break;
}
case "strp": {
type = PotionType.STRENGTH;
break;
}
case "wp": {
type = PotionType.WEAKNESS;
break;
}
case "pp": {
type = PotionType.POISON;
break;
}
case "frp": {
type = PotionType.FIRE_RESISTANCE;
break;
}
case "invp": {
type = PotionType.INVISIBILITY;
break;
}
case "nvp": {
type = PotionType.NIGHT_VISION;
break;
}
default: {
return null;
}
}
if (level == null || level > type.getMaxLevel()) {
return null;
}
final Potion potion = new Potion(type);
potion.setLevel((int) level);
potion.setSplash(splash);
potion.setHasExtendedDuration(extended);
final ItemStack result = potion.toItemStack(quantity);
result.setDurability((short) (result.getDurability() + 8192));
return result;
}
@Override
public ItemStack getItem(final String id) {
final ItemStack result = this.getItem(id, 1);
if (result == null) {
return null;
}
result.setAmount(result.getMaxStackSize());
return result;
}
@Override
public ItemStack getItem(final String id, final int quantity) {
ItemStack result = this.getPotion(id, quantity);
if (result != null) {
return result;
}
int itemId = 0;
short metaData = 0;
final Matcher parts = this.splitPattern.matcher(id);
String itemName;
if (parts.matches()) {
itemName = parts.group(2);
metaData = Short.parseShort(parts.group(3));
} else {
itemName = id;
}
Integer last;
if ((last = JavaUtils.tryParseInt(itemName)) != null) {
itemId = last;
} else if ((last = JavaUtils.tryParseInt(id)) != null) {
itemId = last;
} else {
itemName = itemName.toLowerCase(Locale.ENGLISH);
}
if (itemId < 1) {
if (this.items.containsKey((Object) itemName)) {
itemId = this.items.get((Object) itemName);
if (this.durabilities.containsKey((Object) itemName) && metaData == 0) {
metaData = this.durabilities.get((Object) itemName);
}
} else if (Material.getMaterial(itemName.toUpperCase(Locale.ENGLISH)) != null) {
final Material bMaterial = Material.getMaterial(itemName.toUpperCase(Locale.ENGLISH));
itemId = bMaterial.getId();
} else {
try {
final Material bMaterial = Bukkit.getUnsafe().getMaterialFromInternalName(itemName.toLowerCase(Locale.ENGLISH));
itemId = bMaterial.getId();
} catch (Exception ex) {
return null;
}
}
}
if (itemId < 1) {
return null;
}
final Material mat = Material.getMaterial(itemId);
if (mat == null) {
return null;
}
result = new ItemStack(mat);
result.setAmount(quantity);
result.setDurability(metaData);
return result;
}
@Override
public List<ItemStack> getMatching(final Player player, final String[] args) {
final List<ItemStack> items = new ArrayList<ItemStack>();
final PlayerInventory inventory = player.getInventory();
if (args.length < 1 || args[0].equalsIgnoreCase("hand")) {
items.add(player.getItemInHand());
} else if (args[0].equalsIgnoreCase("inventory") || args[0].equalsIgnoreCase("invent") || args[0].equalsIgnoreCase("all")) {
for (final ItemStack stack : inventory.getContents()) {
if (stack != null && stack.getType() != Material.AIR) {
items.add(stack);
}
}
} else if (args[0].equalsIgnoreCase("blocks")) {
for (final ItemStack stack : inventory.getContents()) {
if (stack != null && stack.getType() != Material.AIR && stack.getType().isBlock()) {
items.add(stack);
}
}
} else {
items.add(this.getItem(args[0]));
}
if (items.isEmpty() || items.get(0).getType() == Material.AIR) {
return null;
}
return items;
}
@Override
public String getName(final ItemStack item) {
return CraftItemStack.asNMSCopy(item).getName();
}
@Deprecated
@Override
public String getPrimaryName(final ItemStack item) {
ItemData itemData = new ItemData(item.getType(), item.getDurability());
String name = this.primaryName.get(itemData);
if (name == null) {
itemData = new ItemData(item.getType(), (short) 0);
name = this.primaryName.get(itemData);
if (name == null) {
return null;
}
}
return name;
}
@Override
public String getNames(final ItemStack item) {
ItemData itemData = new ItemData(item.getType(), item.getDurability());
Collection<String> nameList = (Collection<String>) this.names.get(itemData);
if (nameList == null) {
itemData = new ItemData(item.getType(), (short) 0);
nameList = (Collection<String>) this.names.get(itemData);
if (nameList == null) {
return null;
}
}
List<String> list = new ArrayList<String>(nameList);
if (nameList.size() > 15) {
list = list.subList(0, 14);
}
return StringUtils.join((Iterable) list, ", ");
}
static {
STRING_LENGTH_COMPARATOR = new Comparator<String>() {
@Override
public int compare(final String o1, final String o2) {
return o1.length() - o2.length();
}
};
PARTS_PATTERN = Pattern.compile("[^a-z0-9]");
}
}

View File

@ -0,0 +1,87 @@
death-signs: true
diamond-ore-notifications: true
death-lightning: true
map-number: 1
kit-map: false
prevent-ally-damage: true
exp-multiplier:
global: 2.0
fishing: 2.0
smelting: 2.0
looting-per-level: 1.5
luck-per-level: 1.5
fortune-per-level: 1.5
roads:
allow-claims-besides: true
scoreboard:
sidebar:
title: "&a&lHCF &c[Map {MAP_NUMBER}]"
enabled: true
nametags:
enabled: true
combatlog:
enabled: true
despawn-delay-ticks: 600
conquest:
point-loss-per-death: 20
victory-points: 300
allow-negative-points: true
warzone:
radius: 800
factions:
disallowed-faction-names:
- EOTW
min-name-characters: 3
max-name-characters: 16
max-members: 25
max-allies: 1
subclaims:
min-name-characters: 3
max-name-characters: 16
relation-colours:
wilderness: DARK_GREEN
warzone: LIGHT_PURPLE
teammate: GREEN
ally: GOLD
enemy: RED
road: GOLD
deaths-till-raidable:
maximum: 6
millis-between-updates: 45000
increment-between-updates: 0.1
deathban:
base-duration-minutes: 120
respawn-screen-seconds-before-kick: 15
enchantment-limits:
PROTECTION_ENVIRONMENTAL: 3
PROTECTION_FIRE: 3
SILK_TOUCH: 1
DURABILITY: 3
PROTECTION_EXPLOSIONS: 3
LOOT_BONUS_BLOCKS: 3
PROTECTION_PROJECTILE: 3
OXYGEN: 3
WATER_WORKER: 1
THORNS: 0
DAMAGE_ALL: 3
ARROW_KNOCKBACK: 1
KNOCKBACK: 1
FIRE_ASPECT: 1
LOOT_BONUS_MOBS: 3
LUCK: 3
LURE: 3
end:
open: true
exit: world,0.5,75,0.5,0,0
eotw:
chat-symbol-prefix: ""
chat-symbol-suffix: ""
last-map-cappers: []
potion-limits:
STRENGTH: 0
INVISIBILITY: 0
REGEN: 0
WEAKNESS: 0
INSTANT_DAMAGE: 0
SLOWNESS: 1
POISON: 1

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,2 @@
# year, month, day, hour, minute: eventName (24 hour clock)
# 2015,1,1,2,0:Example This would run event named 'Example' at 2AM on the 1st of January, 2015.

View File

@ -0,0 +1 @@
users: {}

View File

@ -0,0 +1 @@
factions: {}

View File

@ -0,0 +1,317 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TByteIterator;
import gnu.trove.procedure.TByteProcedure;
import java.util.Collection;
import java.io.Serializable;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TByteCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
byte getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>byte</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( byte entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TByteIterator</code> value
*/
TByteIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
byte[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>byte[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
byte[] toArray( byte[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>byte</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( byte entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>byte</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( byte entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TByteCollection</tt> are present.
*
* @param collection a <code>TByteCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TByteCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of byte primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( byte[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Byte> collection );
/**
* Adds all of the elements in the <tt>TByteCollection</tt> to the collection.
*
* @param collection a <code>TByteCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TByteCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of byte primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( byte[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TByteCollection</tt>.
*
* @param collection a <code>TByteCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TByteCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of byte primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( byte[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TByteCollection</tt> from the collection.
*
* @param collection a <code>TByteCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TByteCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of byte primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( byte[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TByteProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TByteProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TByteCollection

View File

@ -0,0 +1,317 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TCharIterator;
import gnu.trove.procedure.TCharProcedure;
import java.util.Collection;
import java.io.Serializable;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TCharCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
char getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>char</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( char entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TCharIterator</code> value
*/
TCharIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
char[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>char[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
char[] toArray( char[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>char</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( char entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>char</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( char entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TCharCollection</tt> are present.
*
* @param collection a <code>TCharCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TCharCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of char primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( char[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Character> collection );
/**
* Adds all of the elements in the <tt>TCharCollection</tt> to the collection.
*
* @param collection a <code>TCharCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TCharCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of char primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( char[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TCharCollection</tt>.
*
* @param collection a <code>TCharCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TCharCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of char primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( char[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TCharCollection</tt> from the collection.
*
* @param collection a <code>TCharCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TCharCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of char primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( char[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TCharProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TCharProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TCharCollection

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,896 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2008, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
import java.util.*;
import gnu.trove.list.*;
import gnu.trove.map.*;
import gnu.trove.set.*;
import gnu.trove.decorator.*;
/**
* This is a static utility class that provides functions for simplifying creation of
* decorators.
*
* @author Robert D. Eden
* @author Jeff Randall
* @since Trove 2.1
*/
public class TDecorators {
// Hide the constructor
private TDecorators() {}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Double> wrap( TDoubleDoubleMap map ) {
return new TDoubleDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Float> wrap( TDoubleFloatMap map ) {
return new TDoubleFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Integer> wrap( TDoubleIntMap map ) {
return new TDoubleIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Long> wrap( TDoubleLongMap map ) {
return new TDoubleLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Byte> wrap( TDoubleByteMap map ) {
return new TDoubleByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Short> wrap( TDoubleShortMap map ) {
return new TDoubleShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Double,Character> wrap( TDoubleCharMap map ) {
return new TDoubleCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Double> wrap( TFloatDoubleMap map ) {
return new TFloatDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Float> wrap( TFloatFloatMap map ) {
return new TFloatFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Integer> wrap( TFloatIntMap map ) {
return new TFloatIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Long> wrap( TFloatLongMap map ) {
return new TFloatLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Byte> wrap( TFloatByteMap map ) {
return new TFloatByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Short> wrap( TFloatShortMap map ) {
return new TFloatShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Float,Character> wrap( TFloatCharMap map ) {
return new TFloatCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Double> wrap( TIntDoubleMap map ) {
return new TIntDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Float> wrap( TIntFloatMap map ) {
return new TIntFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Integer> wrap( TIntIntMap map ) {
return new TIntIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Long> wrap( TIntLongMap map ) {
return new TIntLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Byte> wrap( TIntByteMap map ) {
return new TIntByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Short> wrap( TIntShortMap map ) {
return new TIntShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Integer,Character> wrap( TIntCharMap map ) {
return new TIntCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Double> wrap( TLongDoubleMap map ) {
return new TLongDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Float> wrap( TLongFloatMap map ) {
return new TLongFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Integer> wrap( TLongIntMap map ) {
return new TLongIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Long> wrap( TLongLongMap map ) {
return new TLongLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Byte> wrap( TLongByteMap map ) {
return new TLongByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Short> wrap( TLongShortMap map ) {
return new TLongShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Long,Character> wrap( TLongCharMap map ) {
return new TLongCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Double> wrap( TByteDoubleMap map ) {
return new TByteDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Float> wrap( TByteFloatMap map ) {
return new TByteFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Integer> wrap( TByteIntMap map ) {
return new TByteIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Long> wrap( TByteLongMap map ) {
return new TByteLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Byte> wrap( TByteByteMap map ) {
return new TByteByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Short> wrap( TByteShortMap map ) {
return new TByteShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Byte,Character> wrap( TByteCharMap map ) {
return new TByteCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Double> wrap( TShortDoubleMap map ) {
return new TShortDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Float> wrap( TShortFloatMap map ) {
return new TShortFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Integer> wrap( TShortIntMap map ) {
return new TShortIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Long> wrap( TShortLongMap map ) {
return new TShortLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Byte> wrap( TShortByteMap map ) {
return new TShortByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Short> wrap( TShortShortMap map ) {
return new TShortShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Short,Character> wrap( TShortCharMap map ) {
return new TShortCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Double> wrap( TCharDoubleMap map ) {
return new TCharDoubleMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Float> wrap( TCharFloatMap map ) {
return new TCharFloatMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Integer> wrap( TCharIntMap map ) {
return new TCharIntMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Long> wrap( TCharLongMap map ) {
return new TCharLongMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Byte> wrap( TCharByteMap map ) {
return new TCharByteMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Short> wrap( TCharShortMap map ) {
return new TCharShortMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static Map<Character,Character> wrap( TCharCharMap map ) {
return new TCharCharMapDecorator( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectDoubleMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Double> wrap( TObjectDoubleMap<T> map ) {
return new TObjectDoubleMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectFloatMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Float> wrap( TObjectFloatMap<T> map ) {
return new TObjectFloatMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectIntMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Integer> wrap( TObjectIntMap<T> map ) {
return new TObjectIntMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectLongMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Long> wrap( TObjectLongMap<T> map ) {
return new TObjectLongMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectByteMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Byte> wrap( TObjectByteMap<T> map ) {
return new TObjectByteMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectShortMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Short> wrap( TObjectShortMap<T> map ) {
return new TObjectShortMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TObjectCharMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<T,Character> wrap( TObjectCharMap<T> map ) {
return new TObjectCharMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TDoubleObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Double,T> wrap( TDoubleObjectMap<T> map ) {
return new TDoubleObjectMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TFloatObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Float,T> wrap( TFloatObjectMap<T> map ) {
return new TFloatObjectMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TIntObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Integer,T> wrap( TIntObjectMap<T> map ) {
return new TIntObjectMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TLongObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Long,T> wrap( TLongObjectMap<T> map ) {
return new TLongObjectMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TByteObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Byte,T> wrap( TByteObjectMap<T> map ) {
return new TByteObjectMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TShortObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Short,T> wrap( TShortObjectMap<T> map ) {
return new TShortObjectMapDecorator<T>( map );
}
/**
* Wrap the given map in a decorator that uses the standard {@link java.util.Map Map}
* interface.
*
* @param map the <tt>TCharObjectMap</tt> to be wrapped
* @return the wrapped map.
*/
public static <T> Map<Character,T> wrap( TCharObjectMap<T> map ) {
return new TCharObjectMapDecorator<T>( map );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TDoubleSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Double> wrap( TDoubleSet set ) {
return new TDoubleSetDecorator( set );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TFloatSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Float> wrap( TFloatSet set ) {
return new TFloatSetDecorator( set );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TIntSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Integer> wrap( TIntSet set ) {
return new TIntSetDecorator( set );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TLongSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Long> wrap( TLongSet set ) {
return new TLongSetDecorator( set );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TByteSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Byte> wrap( TByteSet set ) {
return new TByteSetDecorator( set );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TShortSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Short> wrap( TShortSet set ) {
return new TShortSetDecorator( set );
}
/**
* Wrap the given set in a decorator that uses the standard {@link java.util.Set Set}
* interface.
*
* @param set the <tt>TCharSet</tt> to be wrapped
* @return the wrapped set.
*/
public static Set<Character> wrap( TCharSet set ) {
return new TCharSetDecorator( set );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TDoubleList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Double> wrap( TDoubleList list ) {
return new TDoubleListDecorator( list );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TFloatList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Float> wrap( TFloatList list ) {
return new TFloatListDecorator( list );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TIntList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Integer> wrap( TIntList list ) {
return new TIntListDecorator( list );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TLongList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Long> wrap( TLongList list ) {
return new TLongListDecorator( list );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TByteList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Byte> wrap( TByteList list ) {
return new TByteListDecorator( list );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TShortList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Short> wrap( TShortList list ) {
return new TShortListDecorator( list );
}
/**
* Wrap the given list in a decorator that uses the standard {@link java.util.List List}
* interface.
*
* @param list the <tt>TCharList</tt> to be wrapped
* @return the wrapped list.
*/
public static List<Character> wrap( TCharList list ) {
return new TCharListDecorator( list );
}
}

View File

@ -0,0 +1,317 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TDoubleIterator;
import gnu.trove.procedure.TDoubleProcedure;
import java.util.Collection;
import java.io.Serializable;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TDoubleCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
double getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>double</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( double entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TDoubleIterator</code> value
*/
TDoubleIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
double[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>double[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
double[] toArray( double[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>double</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( double entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>double</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( double entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TDoubleCollection</tt> are present.
*
* @param collection a <code>TDoubleCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TDoubleCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of double primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( double[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Double> collection );
/**
* Adds all of the elements in the <tt>TDoubleCollection</tt> to the collection.
*
* @param collection a <code>TDoubleCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TDoubleCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of double primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( double[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TDoubleCollection</tt>.
*
* @param collection a <code>TDoubleCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TDoubleCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of double primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( double[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TDoubleCollection</tt> from the collection.
*
* @param collection a <code>TDoubleCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TDoubleCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of double primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( double[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TDoubleProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TDoubleProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TDoubleCollection

View File

@ -0,0 +1,317 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TFloatIterator;
import gnu.trove.procedure.TFloatProcedure;
import java.util.Collection;
import java.io.Serializable;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TFloatCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
float getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>float</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( float entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TFloatIterator</code> value
*/
TFloatIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
float[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>float[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
float[] toArray( float[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>float</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( float entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>float</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( float entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TFloatCollection</tt> are present.
*
* @param collection a <code>TFloatCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TFloatCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of float primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( float[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Float> collection );
/**
* Adds all of the elements in the <tt>TFloatCollection</tt> to the collection.
*
* @param collection a <code>TFloatCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TFloatCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of float primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( float[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TFloatCollection</tt>.
*
* @param collection a <code>TFloatCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TFloatCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of float primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( float[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TFloatCollection</tt> from the collection.
*
* @param collection a <code>TFloatCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TFloatCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of float primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( float[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TFloatProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TFloatProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TFloatCollection

View File

@ -0,0 +1,317 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TIntIterator;
import gnu.trove.procedure.TIntProcedure;
import java.util.Collection;
import java.io.Serializable;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TIntCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
int getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>int</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( int entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TIntIterator</code> value
*/
TIntIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
int[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>int[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
int[] toArray( int[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>int</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( int entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>int</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( int entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TIntCollection</tt> are present.
*
* @param collection a <code>TIntCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TIntCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of int primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( int[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Integer> collection );
/**
* Adds all of the elements in the <tt>TIntCollection</tt> to the collection.
*
* @param collection a <code>TIntCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TIntCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of int primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( int[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TIntCollection</tt>.
*
* @param collection a <code>TIntCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TIntCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of int primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( int[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TIntCollection</tt> from the collection.
*
* @param collection a <code>TIntCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TIntCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of int primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( int[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TIntProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TIntProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TIntCollection

View File

@ -0,0 +1,317 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TLongIterator;
import gnu.trove.procedure.TLongProcedure;
import java.util.Collection;
import java.io.Serializable;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TLongCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
long getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>long</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( long entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TLongIterator</code> value
*/
TLongIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
long[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>long[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
long[] toArray( long[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>long</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( long entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>long</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( long entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TLongCollection</tt> are present.
*
* @param collection a <code>TLongCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TLongCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of long primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( long[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Long> collection );
/**
* Adds all of the elements in the <tt>TLongCollection</tt> to the collection.
*
* @param collection a <code>TLongCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TLongCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of long primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( long[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TLongCollection</tt>.
*
* @param collection a <code>TLongCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TLongCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of long primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( long[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TLongCollection</tt> from the collection.
*
* @param collection a <code>TLongCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TLongCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of long primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( long[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TLongProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TLongProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TLongCollection

View File

@ -0,0 +1,317 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
import gnu.trove.iterator.TShortIterator;
import gnu.trove.procedure.TShortProcedure;
import java.util.Collection;
import java.io.Serializable;
/**
* An interface that mimics the <tt>Collection</tt> interface.
*
* @author Eric D. Friedman
* @author Rob Eden
* @author Jeff Randall
* @version $Id: _E_Collection.template,v 1.1.2.2 2009/09/15 02:38:30 upholderoftruth Exp $
*/
public interface TShortCollection {
static final long serialVersionUID = 1L;
/**
* Returns the value that is used to represent null. The default
* value is generally zero, but can be changed during construction
* of the collection.
*
* @return the value that represents null
*/
short getNoEntryValue();
/**
* Returns the number of elements in this collection (its cardinality). If this
* collection contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
* <tt>Integer.MAX_VALUE</tt>.
*
* @return the number of elements in this collection (its cardinality)
*/
int size();
/**
* Returns <tt>true</tt> if this collection contains no elements.
*
* @return <tt>true</tt> if this collection contains no elements
*/
boolean isEmpty();
/**
* Returns <tt>true</tt> if this collection contains the specified element.
*
* @param entry an <code>short</code> value
* @return true if the collection contains the specified element.
*/
boolean contains( short entry );
/**
* Creates an iterator over the values of the collection. The iterator
* supports element deletion.
*
* @return an <code>TShortIterator</code> value
*/
TShortIterator iterator();
/**
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the
* elements in the same order.
*
* <p>The returned array will be "safe" in that no references to it
* are maintained by this collection. (In other words, this method must
* allocate a new array even if this collection is backed by an array).
* The caller is thus free to modify the returned array.
*
* <p>This method acts as bridge between array-based and collection-based
* APIs.
*
* @return an array containing all the elements in this collection
*/
short[] toArray();
/**
* Returns an array containing elements in this collection.
*
* <p>If this collection fits in the specified array with room to spare
* (i.e., the array has more elements than this collection), the element in
* the array immediately following the end of the collection is collection to
* <tt>{@link #getNoEntryValue()}</tt>. (This is useful in determining
* the length of this collection <i>only</i> if the caller knows that this
* collection does not contain any elements representing null.)
*
* <p>If the native array is smaller than the collection size,
* the array will be filled with elements in Iterator order
* until it is full and exclude the remainder.
*
* <p>If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements
* in the same order.
*
* @param dest the array into which the elements of this collection are to be
* stored.
* @return an <tt>short[]</tt> containing all the elements in this collection
* @throws NullPointerException if the specified array is null
*/
short[] toArray( short[] dest );
/**
* Inserts a value into the collection.
*
* @param entry a <code>short</code> value
* @return true if the collection was modified by the add operation
*/
boolean add( short entry );
/**
* Removes <tt>entry</tt> from the collection.
*
* @param entry an <code>short</code> value
* @return true if the collection was modified by the remove operation.
*/
boolean remove( short entry );
/**
* Tests the collection to determine if all of the elements in
* <tt>collection</tt> are present.
*
* @param collection a <code>Collection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( Collection<?> collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>TShortCollection</tt> are present.
*
* @param collection a <code>TShortCollection</code> value
* @return true if all elements were present in the collection.
*/
boolean containsAll( TShortCollection collection );
/**
* Tests the collection to determine if all of the elements in
* <tt>array</tt> are present.
*
* @param array as <code>array</code> of short primitives.
* @return true if all elements were present in the collection.
*/
boolean containsAll( short[] array );
/**
* Adds all of the elements in <tt>collection</tt> to the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( Collection<? extends Short> collection );
/**
* Adds all of the elements in the <tt>TShortCollection</tt> to the collection.
*
* @param collection a <code>TShortCollection</code> value
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( TShortCollection collection );
/**
* Adds all of the elements in the <tt>array</tt> to the collection.
*
* @param array a <code>array</code> of short primitives.
* @return true if the collection was modified by the add all operation.
*/
boolean addAll( short[] array );
/**
* Removes any values in the collection which are not contained in
* <tt>collection</tt>.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( Collection<?> collection );
/**
* Removes any values in the collection which are not contained in
* <tt>TShortCollection</tt>.
*
* @param collection a <code>TShortCollection</code> value
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( TShortCollection collection );
/**
* Removes any values in the collection which are not contained in
* <tt>array</tt>.
*
* @param array an <code>array</code> of short primitives.
* @return true if the collection was modified by the retain all operation
*/
boolean retainAll( short[] array );
/**
* Removes all of the elements in <tt>collection</tt> from the collection.
*
* @param collection a <code>Collection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( Collection<?> collection );
/**
* Removes all of the elements in <tt>TShortCollection</tt> from the collection.
*
* @param collection a <code>TShortCollection</code> value
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( TShortCollection collection );
/**
* Removes all of the elements in <tt>array</tt> from the collection.
*
* @param array an <code>array</code> of short primitives.
* @return true if the collection was modified by the remove all operation.
*/
boolean removeAll( short[] array );
/**
* Empties the collection.
*/
void clear();
/**
* Executes <tt>procedure</tt> for each element in the collection.
*
* @param procedure a <code>TShortProcedure</code> value
* @return false if the loop over the collection terminated because
* the procedure returned false for some value.
*/
boolean forEach( TShortProcedure procedure );
// Comparison and hashing
/**
* Compares the specified object with this collection for equality. Returns
* <tt>true</tt> if the specified object is also a collection, the two collection
* have the same size, and every member of the specified collection is
* contained in this collection (or equivalently, every member of this collection is
* contained in the specified collection). This definition ensures that the
* equals method works properly across different implementations of the
* collection interface.
*
* @param o object to be compared for equality with this collection
* @return <tt>true</tt> if the specified object is equal to this collection
*/
boolean equals( Object o );
/**
* Returns the hash code value for this collection. The hash code of a collection is
* defined to be the sum of the hash codes of the elements in the collection.
* This ensures that <tt>s1.equals(s2)</tt> implies that
* <tt>s1.hashCode()==s2.hashCode()</tt> for any two collection <tt>s1</tt>
* and <tt>s2</tt>, as required by the general contract of
* {@link Object#hashCode}.
*
* @return the hash code value for this collection
* @see Object#equals(Object)
* @see Collection#equals(Object)
*/
int hashCode();
} // TShortCollection

View File

@ -0,0 +1,60 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2001, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Rob Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove;
/**
* Simple class meant as a possible main class (via manifest) to report the
* implementation version of the trove4j jar.
* <p/>
* This may be useful to ask feedback WITH build version information
* <p/>
* The Main-Class entry in the manifest.mf should be set during the build as well
* as the Implementation-Version manifest attribute should be set as well.
* <p/>
* Created by IntelliJ IDEA.
* User: Johan Parent
* Date: 3/03/11
* Time: 22:10
*/
public class Version {
public static void main(String[] args) {
System.out.println(getVersion());
}
/**
* Returns the implementation version of trove4j. Intended for applications
* wanting to return the version of trove4j they are using
* <p/>
* NOTE: this method will only return a useful version when working
* with a trove4j jar as it requires a manifest file
*
* @return
*/
public static String getVersion() {
String version = Version.class.getPackage().getImplementationVersion();
//
if (version != null) {
return "trove4j version " + version;
}
return "Sorry no Implementation-Version manifest attribute available";
}
}

View File

@ -0,0 +1,406 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TByteByteMap;
import gnu.trove.iterator.TByteByteIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteByteMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TByteByteMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteByteMapDecorator extends AbstractMap<Byte, Byte>
implements Map<Byte, Byte>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TByteByteMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteByteMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TByteByteMap</tt> to wrap.
*/
public TByteByteMapDecorator( TByteByteMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TByteByteMap</tt> instance.
*/
public TByteByteMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Byte(0) if none was found.
*/
public Byte put( Byte key, Byte value ) {
byte k;
byte v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
byte retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Byte get( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Byte remove( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
byte v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Byte,Byte>> entrySet() {
return new AbstractSet<Map.Entry<Byte,Byte>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteByteMapDecorator.this.isEmpty();
}
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TByteByteMapDecorator.this.containsKey(k)
&& TByteByteMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Byte,Byte>> iterator() {
return new Iterator<Map.Entry<Byte,Byte>>() {
private final TByteByteIterator it = _map.iterator();
public Map.Entry<Byte,Byte> next() {
it.advance();
byte ik = it.key();
final Byte key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
byte iv = it.value();
final Byte v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Byte,Byte>() {
private Byte val = v;
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Byte getKey() {
return key;
}
public Byte getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Byte setValue( Byte value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Byte,Byte> o ) {
throw new UnsupportedOperationException();
}
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Byte key = ( ( Map.Entry<Byte,Byte> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Byte, Byte>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TByteByteMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Byte && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Byte && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Byte, ? extends Byte> map ) {
Iterator<? extends Entry<? extends Byte,? extends Byte>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Byte,? extends Byte> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Byte wrapKey( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected byte unwrapKey( Object key ) {
return ( ( Byte ) key ).byteValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Byte wrapValue( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected byte unwrapValue( Object value ) {
return ( ( Byte ) value ).byteValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TByteByteMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TByteByteHashMapDecorator

View File

@ -0,0 +1,406 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TByteCharMap;
import gnu.trove.iterator.TByteCharIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteCharMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TByteCharMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteCharMapDecorator extends AbstractMap<Byte, Character>
implements Map<Byte, Character>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TByteCharMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteCharMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TByteCharMap</tt> to wrap.
*/
public TByteCharMapDecorator( TByteCharMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TByteCharMap</tt> instance.
*/
public TByteCharMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Character(0) if none was found.
*/
public Character put( Byte key, Character value ) {
byte k;
char v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
char retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Character get( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Character remove( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
char v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Byte,Character>> entrySet() {
return new AbstractSet<Map.Entry<Byte,Character>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteCharMapDecorator.this.isEmpty();
}
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TByteCharMapDecorator.this.containsKey(k)
&& TByteCharMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Byte,Character>> iterator() {
return new Iterator<Map.Entry<Byte,Character>>() {
private final TByteCharIterator it = _map.iterator();
public Map.Entry<Byte,Character> next() {
it.advance();
byte ik = it.key();
final Byte key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
char iv = it.value();
final Character v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Byte,Character>() {
private Character val = v;
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Byte getKey() {
return key;
}
public Character getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Character setValue( Character value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Byte,Character> o ) {
throw new UnsupportedOperationException();
}
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Byte key = ( ( Map.Entry<Byte,Character> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Byte, Character>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TByteCharMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Character && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Byte && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Byte, ? extends Character> map ) {
Iterator<? extends Entry<? extends Byte,? extends Character>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Byte,? extends Character> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Byte wrapKey( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected byte unwrapKey( Object key ) {
return ( ( Byte ) key ).byteValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Character wrapValue( char k ) {
return Character.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected char unwrapValue( Object value ) {
return ( ( Character ) value ).charValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TByteCharMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TByteCharHashMapDecorator

View File

@ -0,0 +1,406 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TByteDoubleMap;
import gnu.trove.iterator.TByteDoubleIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteDoubleMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TByteDoubleMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteDoubleMapDecorator extends AbstractMap<Byte, Double>
implements Map<Byte, Double>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TByteDoubleMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteDoubleMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TByteDoubleMap</tt> to wrap.
*/
public TByteDoubleMapDecorator( TByteDoubleMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TByteDoubleMap</tt> instance.
*/
public TByteDoubleMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Double(0) if none was found.
*/
public Double put( Byte key, Double value ) {
byte k;
double v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
double retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Double get( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Double remove( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
double v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Byte,Double>> entrySet() {
return new AbstractSet<Map.Entry<Byte,Double>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteDoubleMapDecorator.this.isEmpty();
}
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TByteDoubleMapDecorator.this.containsKey(k)
&& TByteDoubleMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Byte,Double>> iterator() {
return new Iterator<Map.Entry<Byte,Double>>() {
private final TByteDoubleIterator it = _map.iterator();
public Map.Entry<Byte,Double> next() {
it.advance();
byte ik = it.key();
final Byte key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
double iv = it.value();
final Double v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Byte,Double>() {
private Double val = v;
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Byte getKey() {
return key;
}
public Double getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Double setValue( Double value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Byte,Double> o ) {
throw new UnsupportedOperationException();
}
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Byte key = ( ( Map.Entry<Byte,Double> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Byte, Double>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TByteDoubleMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Double && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Byte && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Byte, ? extends Double> map ) {
Iterator<? extends Entry<? extends Byte,? extends Double>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Byte,? extends Double> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Byte wrapKey( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected byte unwrapKey( Object key ) {
return ( ( Byte ) key ).byteValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Double wrapValue( double k ) {
return Double.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected double unwrapValue( Object value ) {
return ( ( Double ) value ).doubleValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TByteDoubleMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TByteDoubleHashMapDecorator

View File

@ -0,0 +1,406 @@
///////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2002, Eric D. Friedman All Rights Reserved.
// Copyright (c) 2009, Robert D. Eden All Rights Reserved.
// Copyright (c) 2009, Jeff Randall All Rights Reserved.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
///////////////////////////////////////////////////////////////////////////////
package gnu.trove.decorator;
import gnu.trove.map.TByteFloatMap;
import gnu.trove.iterator.TByteFloatIterator;
import java.io.*;
import java.util.*;
//////////////////////////////////////////////////
// THIS IS A GENERATED CLASS. DO NOT HAND EDIT! //
//////////////////////////////////////////////////
/**
* Wrapper class to make a TByteFloatMap conform to the <tt>java.util.Map</tt> API.
* This class simply decorates an underlying TByteFloatMap and translates the Object-based
* APIs into their Trove primitive analogs.
* <p/>
* Note that wrapping and unwrapping primitive values is extremely inefficient. If
* possible, users of this class should override the appropriate methods in this class
* and use a table of canonical values.
* <p/>
* Created: Mon Sep 23 22:07:40 PDT 2002
*
* @author Eric D. Friedman
* @author Robert D. Eden
* @author Jeff Randall
*/
public class TByteFloatMapDecorator extends AbstractMap<Byte, Float>
implements Map<Byte, Float>, Externalizable, Cloneable {
static final long serialVersionUID = 1L;
/** the wrapped primitive map */
protected TByteFloatMap _map;
/**
* FOR EXTERNALIZATION ONLY!!
*/
public TByteFloatMapDecorator() {}
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TByteFloatMap</tt> to wrap.
*/
public TByteFloatMapDecorator( TByteFloatMap map ) {
super();
this._map = map;
}
/**
* Returns a reference to the map wrapped by this decorator.
*
* @return the wrapped <tt>TByteFloatMap</tt> instance.
*/
public TByteFloatMap getMap() {
return _map;
}
/**
* Inserts a key/value pair into the map.
*
* @param key an <code>Object</code> value
* @param value an <code>Object</code> value
* @return the previous value associated with <tt>key</tt>,
* or Float(0) if none was found.
*/
public Float put( Byte key, Float value ) {
byte k;
float v;
if ( key == null ) {
k = _map.getNoEntryKey();
} else {
k = unwrapKey( key );
}
if ( value == null ) {
v = _map.getNoEntryValue();
} else {
v = unwrapValue( value );
}
float retval = _map.put( k, v );
if ( retval == _map.getNoEntryValue() ) {
return null;
}
return wrapValue( retval );
}
/**
* Retrieves the value for <tt>key</tt>
*
* @param key an <code>Object</code> value
* @return the value of <tt>key</tt> or null if no such mapping exists.
*/
public Float get( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.get( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Empties the map.
*/
public void clear() {
this._map.clear();
}
/**
* Deletes a key/value pair from the map.
*
* @param key an <code>Object</code> value
* @return the removed value, or null if it was not found in the map
*/
public Float remove( Object key ) {
byte k;
if ( key != null ) {
if ( key instanceof Byte ) {
k = unwrapKey( key );
} else {
return null;
}
} else {
k = _map.getNoEntryKey();
}
float v = _map.remove( k );
// There may be a false positive since primitive maps
// cannot return null, so we have to do an extra
// check here.
if ( v == _map.getNoEntryValue() ) {
return null;
} else {
return wrapValue( v );
}
}
/**
* Returns a Set view on the entries of the map.
*
* @return a <code>Set</code> value
*/
public Set<Map.Entry<Byte,Float>> entrySet() {
return new AbstractSet<Map.Entry<Byte,Float>>() {
public int size() {
return _map.size();
}
public boolean isEmpty() {
return TByteFloatMapDecorator.this.isEmpty();
}
public boolean contains( Object o ) {
if (o instanceof Map.Entry) {
Object k = ( ( Map.Entry ) o ).getKey();
Object v = ( ( Map.Entry ) o ).getValue();
return TByteFloatMapDecorator.this.containsKey(k)
&& TByteFloatMapDecorator.this.get(k).equals(v);
} else {
return false;
}
}
public Iterator<Map.Entry<Byte,Float>> iterator() {
return new Iterator<Map.Entry<Byte,Float>>() {
private final TByteFloatIterator it = _map.iterator();
public Map.Entry<Byte,Float> next() {
it.advance();
byte ik = it.key();
final Byte key = (ik == _map.getNoEntryKey()) ? null : wrapKey( ik );
float iv = it.value();
final Float v = (iv == _map.getNoEntryValue()) ? null : wrapValue( iv );
return new Map.Entry<Byte,Float>() {
private Float val = v;
public boolean equals( Object o ) {
return o instanceof Map.Entry
&& ( ( Map.Entry ) o ).getKey().equals(key)
&& ( ( Map.Entry ) o ).getValue().equals(val);
}
public Byte getKey() {
return key;
}
public Float getValue() {
return val;
}
public int hashCode() {
return key.hashCode() + val.hashCode();
}
public Float setValue( Float value ) {
val = value;
return put( key, value );
}
};
}
public boolean hasNext() {
return it.hasNext();
}
public void remove() {
it.remove();
}
};
}
public boolean add( Map.Entry<Byte,Float> o ) {
throw new UnsupportedOperationException();
}
public boolean remove( Object o ) {
boolean modified = false;
if ( contains( o ) ) {
//noinspection unchecked
Byte key = ( ( Map.Entry<Byte,Float> ) o ).getKey();
_map.remove( unwrapKey( key ) );
modified = true;
}
return modified;
}
public boolean addAll( Collection<? extends Map.Entry<Byte, Float>> c ) {
throw new UnsupportedOperationException();
}
public void clear() {
TByteFloatMapDecorator.this.clear();
}
};
}
/**
* Checks for the presence of <tt>val</tt> in the values of the map.
*
* @param val an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsValue( Object val ) {
return val instanceof Float && _map.containsValue( unwrapValue( val ) );
}
/**
* Checks for the present of <tt>key</tt> in the keys of the map.
*
* @param key an <code>Object</code> value
* @return a <code>boolean</code> value
*/
public boolean containsKey( Object key ) {
if ( key == null ) return _map.containsKey( _map.getNoEntryKey() );
return key instanceof Byte && _map.containsKey( unwrapKey( key ) );
}
/**
* Returns the number of entries in the map.
*
* @return the map's size.
*/
public int size() {
return this._map.size();
}
/**
* Indicates whether map has any entries.
*
* @return true if the map is empty
*/
public boolean isEmpty() {
return size() == 0;
}
/**
* Copies the key/value mappings in <tt>map</tt> into this map.
* Note that this will be a <b>deep</b> copy, as storage is by
* primitive value.
*
* @param map a <code>Map</code> value
*/
public void putAll( Map<? extends Byte, ? extends Float> map ) {
Iterator<? extends Entry<? extends Byte,? extends Float>> it =
map.entrySet().iterator();
for ( int i = map.size(); i-- > 0; ) {
Entry<? extends Byte,? extends Float> e = it.next();
this.put( e.getKey(), e.getValue() );
}
}
/**
* Wraps a key
*
* @param k key in the underlying map
* @return an Object representation of the key
*/
protected Byte wrapKey( byte k ) {
return Byte.valueOf( k );
}
/**
* Unwraps a key
*
* @param key wrapped key
* @return an unwrapped representation of the key
*/
protected byte unwrapKey( Object key ) {
return ( ( Byte ) key ).byteValue();
}
/**
* Wraps a value
*
* @param k value in the underlying map
* @return an Object representation of the value
*/
protected Float wrapValue( float k ) {
return Float.valueOf( k );
}
/**
* Unwraps a value
*
* @param value wrapped value
* @return an unwrapped representation of the value
*/
protected float unwrapValue( Object value ) {
return ( ( Float ) value ).floatValue();
}
// Implements Externalizable
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TByteFloatMap ) in.readObject();
}
// Implements Externalizable
public void writeExternal( ObjectOutput out ) throws IOException {
// VERSION
out.writeByte(0);
// MAP
out.writeObject( _map );
}
} // TByteFloatHashMapDecorator

Some files were not shown because too many files have changed in this diff Show More