Compare commits

...

26 Commits

Author SHA1 Message Date
Jikoo
60dcb64558 Bump version for alpha release 2018-07-15 12:05:52 -04:00
Jikoo
077b34d304 Support 1.13-pre7 2018-07-15 12:01:45 -04:00
Jikoo
8ce6e2f8d3 Reverse order of wildcard permission check, respect explicit values (#85) 2018-05-26 06:58:56 -04:00
Jikoo
f5dce23f18 Bump version to 3.3.4-SNAPSHOT for development 2018-02-07 18:36:15 -05:00
Jikoo
669cfd72aa Bump version to 3.3.3 for release 2018-02-07 18:35:39 -05:00
Jikoo
9e66885690 First load should not "update" nonexistent config, just use a default 2018-02-07 18:17:33 -05:00
Jikoo
a802769265 Sneaky tabs, trying to slip in there. 2018-02-04 10:35:35 -05:00
Jikoo
50c45b6616 Cleaned up code, updated copyright at long last. 2018-02-04 10:29:09 -05:00
Jikoo
eaf01fa32c Don't cache simultaneously added players forever 2017-11-19 14:46:52 -05:00
Jikoo
4abaa6ea51 Backport spectate abuse to 1.8-1.10 to support PaperSpigot
This may break functionality on C(K)auldron and other server implementations with different remapping names.
2017-11-08 19:07:23 -05:00
Jikoo
7c621bf899 Bump version to 3.3.3-SNAPSHOT for development 2017-11-08 17:53:16 -05:00
Jikoo
f5c682ff2b Bump version to 3.3.2 for release 2017-11-08 17:52:41 -05:00
Jikoo
e652b43670 Classic mistake, changed my mind and only changed part of the code.
Also the actual mistake. Never forget. (#81)
2017-11-08 17:40:01 -05:00
Jikoo
f07cef5621 Bump version to 3.3.2-SNAPSHOT for development 2017-11-07 18:18:33 -05:00
Jikoo
ded6421e33 Bump version to 3.3.1 for release 2017-11-07 18:17:12 -05:00
Jikoo
cbb2b4d232 Lowercase permissions can wait for a major version bump
I don't want to double our permissions checks for backwards compatibility.
2017-11-07 18:16:38 -05:00
Jikoo
48c61eeb82 Support lowercase permissions for consistency. 2017-11-06 19:23:26 -05:00
Jikoo
e3d1af010b Add permissions to alter the default state of Any/SilentChest (#76) 2017-11-05 20:00:22 -05:00
Jikoo
2195677651 Actually fix CME (#71) 2017-08-06 16:35:18 -04:00
Jikoo
c72af5dbac Bump version to 3.3.1-SNAPSHOT for development 2017-07-05 05:53:38 -04:00
Jikoo
931cdb6fb1 Bump version to 3.3.0 for release 2017-07-05 05:52:33 -04:00
Jikoo
9db18613a1 Abuse spectator mode for SilentContainer (#64, #68)
Potentially causes issues with Cauldron and similar mods that use different mapping names.
2017-07-04 13:22:03 -04:00
Jikoo
784935a975 Synchronize cache (for real), updated dependencies
Closes #69
2017-07-03 18:06:18 -04:00
Jikoo
d9abe76531 Bump version to 3.2.2-SNAPSHOT for development 2017-06-09 20:21:30 -04:00
Jikoo
ca85a392aa Correct field name for list of inventory contents (#66) 2017-06-09 20:15:51 -04:00
Jikoo
307f47e4d3 Bump version to 3.2.1-SNAPSHOT for development 2017-06-08 18:44:10 -04:00
184 changed files with 3510 additions and 1993 deletions

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@
**/.project
**/.classpath
**/.idea
**/.iml
**/target
**/bin
**/out

View File

@@ -7,12 +7,12 @@ OpenInv is a [Bukkit plugin](https://dev.bukkit.org/bukkit-plugins/openinv/) whi
- Cross-world support! Don't grant `OpenInv.crossworld`
- No self-opening! Don't grant `OpenInv.openself`
- Drop items as the player! Place items in the unused slots to the right of the armor to drop them
- **OpenEnder**: Open anyone's inventory, even if they're offline.
- **OpenEnder**: Open anyone's ender chest, even if they're offline.
- Read-only mode! No edits allowed! Don't grant `OpenInv.editender`
- Cross-world support! Don't grant `OpenInv.crossworld`
- No opening others! Don't grant `OpenInv.openenderall`
- **SilentChest**: Open containers without displaying an animation or making sound.
- **AnyChest**: Open containers, even if blocked by ocelots or blocks.
- **SilentContainer**: Open containers without displaying an animation or making sound.
- **AnyContainer**: Open containers, even if blocked by ocelots or blocks.
## Commands
<table width=100%>
@@ -42,14 +42,19 @@ OpenInv is a [Bukkit plugin](https://dev.bukkit.org/bukkit-plugins/openinv/) whi
<td>Lists all online players that have a certain item in their ender chest.</td>
</tr>
<tr>
<td>/anychest [check]</td>
<td>ac</td>
<td>Check or toggle the AnyChest function, allowing opening blocked containers.</td>
<td>/searchenchant &lt[enchantment] [MinLevel]&gt</td>
<td>searchenchants</td>
<td>Lists all online players with a specific enchantment.</td>
</tr>
<tr>
<td>/silentchest [check]</td>
<td>sc</td>
<td>Check or toggle the SilentChest function, allowing opening containers silently.</td>
<td>/anycontainer [check]</td>
<td>ac, anychest</td>
<td>Check or toggle the AnyContainer function, allowing opening blocked containers.</td>
</tr>
<tr>
<td>/silentcontainer [check]</td>
<td>sc, silentchest</td>
<td>Check or toggle the SilentContainer function, allowing opening containers silently.</td>
</tr>
</table>
@@ -103,13 +108,25 @@ OpenInv is a [Bukkit plugin](https://dev.bukkit.org/bukkit-plugins/openinv/) whi
<td>OpenInv.search</td>
<td>Required to use /searchinv and /searchender.</td>
</tr>
<tr>
<td>OpenInv.searchenchant</td>
<td>Required to use /searchenchant.</td>
</tr>
<tr>
<td>OpenInv.anychest</td>
<td>Required to use /anychest.</td>
</tr>
<tr>
<td>OpenInv.any.default</td>
<td>Cause AnyContainer to be enabled by default.</td>
</tr>
<tr>
<td>OpenInv.silent</td>
<td>Required to use /silentchest.</td>
<td>Required to use /silentcontainer.</td>
</tr>
<tr>
<td>OpenInv.silent.default</td>
<td>Cause SilentContainer to be enabled by default.</td>
</tr>
</table>
@@ -117,13 +134,13 @@ OpenInv is a [Bukkit plugin](https://dev.bukkit.org/bukkit-plugins/openinv/) whi
To compile, the relevant Craftbukkit/Spigot jars must be installed in your local repository using the install plugin.
Ex: `mvn install:install-file -Dpackaging=jar -Dfile=spigot-1.11-R0.1-SNAPSHOT.jar -DgroupId=org.spigotmc -DartifactId=spigot -Dversion=1.11-R0.1-SNAPSHOT`
To compile for a specific version or set of versions, you'll need to use a profile. Provided profiles are `latest`, `modern` (versions 1.8+), and `all`. Select an existing profile using the `-P` argument (ex: `mvn clean package -am -P all`) or make your own. For more information, check out the [official guide](http://maven.apache.org/guides/introduction/introduction-to-profiles.html).
To compile for a specific version or set of versions, you'll need to use a profile. Provided profiles are `latest`, `recent` (last 2 major Minecraft versions), and `all`. Select an existing profile using the `-P` argument (ex: `mvn clean package -am -P all`) or make your own. For more information, check out the [official guide](http://maven.apache.org/guides/introduction/introduction-to-profiles.html).
The final file is target/OpenInv.jar
## License
```
Copyright (C) 2011-2014 lishid. All rights reserved.
Copyright (C) 2011-2018 lishid. All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvapi</artifactId>

View File

@@ -1,3 +1,19 @@
/*
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv;
import javax.annotation.Nullable;
@@ -26,7 +42,7 @@ public interface IOpenInv {
*
* @return false unless configured otherwise
*/
public boolean disableSaving();
boolean disableSaving();
/**
* Gets the active ISilentContainer implementation. May return null if the server version is
@@ -35,35 +51,35 @@ public interface IOpenInv {
* @return the ISilentContainer
* @throws IllegalStateException if the server version is unsupported
*/
public IAnySilentContainer getAnySilentContainer();
IAnySilentContainer getAnySilentContainer();
/**
* Gets an ISpecialEnderChest for the given Player. Returns null if the ISpecialEnderChest could
* not be instantiated.
*
* @deprecated Use {@link IOpenInv#getSpecialEnderChest(Player, boolean)}
* @param player the Player
* @param online true if the Player is currently online
* @return the ISpecialEnderChest
* @throws IllegalStateException if the server version is unsupported
* @deprecated Use {@link IOpenInv#getSpecialEnderChest(Player, boolean)}
*/
@Deprecated
@Nullable
public ISpecialEnderChest getEnderChest(Player player, boolean online);
ISpecialEnderChest getEnderChest(Player player, boolean online);
/**
* Gets an ISpecialPlayerInventory for the given Player. Returns null if the
* ISpecialPlayerInventory could not be instantiated.
*
* @deprecated Use {@link IOpenInv#getSpecialInventory(Player, boolean)}
* @param player the Player
* @param online true if the Player is currently online
* @return the ISpecialPlayerInventory
* @throws IllegalStateException if the server version is unsupported
* @deprecated Use {@link IOpenInv#getSpecialInventory(Player, boolean)}
*/
@Deprecated
@Nullable
public ISpecialPlayerInventory getInventory(Player player, boolean online);
ISpecialPlayerInventory getInventory(Player player, boolean online);
/**
* Gets the active IInventoryAccess implementation. May return null if the server version is
@@ -72,7 +88,7 @@ public interface IOpenInv {
* @return the IInventoryAccess
* @throws IllegalStateException if the server version is unsupported
*/
public IInventoryAccess getInventoryAccess();
IInventoryAccess getInventoryAccess();
/**
* Gets the provided player's AnyChest setting.
@@ -81,7 +97,7 @@ public interface IOpenInv {
* @return true if AnyChest is enabled
* @throws IllegalStateException if the server version is unsupported
*/
public boolean getPlayerAnyChestStatus(OfflinePlayer player);
boolean getPlayerAnyChestStatus(OfflinePlayer player);
/**
* Gets a unique identifier by which the OfflinePlayer can be referenced. Using the value
@@ -91,7 +107,7 @@ public interface IOpenInv {
* @return the identifier
* @throws IllegalStateException if the server version is unsupported
*/
public String getPlayerID(OfflinePlayer offline);
String getPlayerID(OfflinePlayer offline);
/**
* Gets a player's SilentChest setting.
@@ -100,7 +116,7 @@ public interface IOpenInv {
* @return true if SilentChest is enabled
* @throws IllegalStateException if the server version is unsupported
*/
public boolean getPlayerSilentChestStatus(OfflinePlayer player);
boolean getPlayerSilentChestStatus(OfflinePlayer player);
/**
* Gets an ISpecialEnderChest for the given Player.
@@ -111,7 +127,7 @@ public interface IOpenInv {
* @throws IllegalStateException if the server version is unsupported
* @throws InstantiationException if the ISpecialEnderChest could not be instantiated
*/
public ISpecialEnderChest getSpecialEnderChest(Player player, boolean online) throws InstantiationException;
ISpecialEnderChest getSpecialEnderChest(Player player, boolean online) throws InstantiationException;
/**
* Gets an ISpecialPlayerInventory for the given Player.
@@ -122,14 +138,14 @@ public interface IOpenInv {
* @throws IllegalStateException if the server version is unsupported
* @throws InstantiationException if the ISpecialPlayerInventory could not be instantiated
*/
public ISpecialPlayerInventory getSpecialInventory(Player player, boolean online) throws InstantiationException;
ISpecialPlayerInventory getSpecialInventory(Player player, boolean online) throws InstantiationException;
/**
* Checks if the server version is supported by OpenInv.
*
* @return true if the server version is supported
*/
public boolean isSupportedVersion();
boolean isSupportedVersion();
/**
* Load a Player from an OfflinePlayer. May return null under some circumstances.
@@ -139,7 +155,7 @@ public interface IOpenInv {
* @throws IllegalStateException if the server version is unsupported
*/
@Nullable
public Player loadPlayer(final OfflinePlayer offline);
Player loadPlayer(final OfflinePlayer offline);
/**
* Get an OfflinePlayer by name.
@@ -152,7 +168,7 @@ public interface IOpenInv {
* @return the OfflinePlayer with the closest matching name or null if no players have ever logged in
*/
@Nullable
public OfflinePlayer matchPlayer(String name);
OfflinePlayer matchPlayer(String name);
/**
* Check the configuration value for whether or not OpenInv displays a notification to the user
@@ -160,7 +176,7 @@ public interface IOpenInv {
*
* @return true unless configured otherwise
*/
public boolean notifyAnyChest();
boolean notifyAnyChest();
/**
* Check the configuration value for whether or not OpenInv displays a notification to the user
@@ -168,7 +184,7 @@ public interface IOpenInv {
*
* @return true unless configured otherwise
*/
public boolean notifySilentChest();
boolean notifySilentChest();
/**
* Mark a Player as no longer in use by a Plugin to allow OpenInv to remove it from the cache
@@ -178,7 +194,7 @@ public interface IOpenInv {
* @param plugin the Plugin no longer holding a reference to the Player
* @throws IllegalStateException if the server version is unsupported
*/
public void releasePlayer(Player player, Plugin plugin);
void releasePlayer(Player player, Plugin plugin);
/**
* Mark a Player as in use by a Plugin to prevent it from being removed from the cache. Used to
@@ -203,7 +219,7 @@ public interface IOpenInv {
* @param plugin the Plugin holding the reference to the Player
* @throws IllegalStateException if the server version is unsupported
*/
public void retainPlayer(Player player, Plugin plugin);
void retainPlayer(Player player, Plugin plugin);
/**
* Sets a player's AnyChest setting.
@@ -212,7 +228,7 @@ public interface IOpenInv {
* @param status the status
* @throws IllegalStateException if the server version is unsupported
*/
public void setPlayerAnyChestStatus(OfflinePlayer player, boolean status);
void setPlayerAnyChestStatus(OfflinePlayer player, boolean status);
/**
* Sets a player's SilentChest setting.
@@ -221,7 +237,7 @@ public interface IOpenInv {
* @param status the status
* @throws IllegalStateException if the server version is unsupported
*/
public void setPlayerSilentChestStatus(OfflinePlayer player, boolean status);
void setPlayerSilentChestStatus(OfflinePlayer player, boolean status);
/**
* Forcibly unload a cached Player's data.
@@ -229,6 +245,6 @@ public interface IOpenInv {
* @param player the OfflinePlayer to unload
* @throws IllegalStateException if the server version is unsupported
*/
public void unload(OfflinePlayer player);
void unload(OfflinePlayer player);
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal;
import org.bukkit.block.Block;
@@ -6,12 +22,23 @@ import org.bukkit.entity.Player;
public interface IAnySilentContainer {
/**
* Checks if the given block is a container which can be unblocked or silenced.
* Opens the container at the given coordinates for the Player. If you do not want blocked
* containers to open, be sure to check {@link #isAnyContainerNeeded(Player, Block)}
* first.
*
* @param block the BlockState
* @return true if the Block is a supported container
* @param player the Player opening the container
* @param silentchest whether the container's noise is to be silenced
* @param block the Block
* @return true if the container can be opened
*/
public boolean isAnySilentContainer(Block block);
boolean activateContainer(Player player, boolean silentchest, Block block);
/**
* Closes the Player's currently open container silently, if necessary.
*
* @param player the Player closing a container
*/
void deactivateContainer(Player player);
/**
* Checks if the container at the given coordinates is blocked.
@@ -20,18 +47,14 @@ public interface IAnySilentContainer {
* @param block the Block
* @return true if the container is blocked
*/
public boolean isAnyContainerNeeded(Player player, Block block);
boolean isAnyContainerNeeded(Player player, Block block);
/**
* Opens the container at the given coordinates for the Player. If you do not want blocked
* containers to open, be sure to check {@link #isAnyContainerNeeded(Player, Block)}
* first.
* Checks if the given block is a container which can be unblocked or silenced.
*
* @param player
* @param silentchest whether the container's noise is to be silenced
* @param block the Block
* @return true if the container can be opened
* @param block the BlockState
* @return true if the Block is a supported container
*/
public boolean activateContainer(Player player, boolean silentchest, Block block);
boolean isAnySilentContainer(Block block);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@ public interface IInventoryAccess {
* @return the ISpecialEnderChest or null
*/
@Nullable
public ISpecialEnderChest getSpecialEnderChest(Inventory inventory);
ISpecialEnderChest getSpecialEnderChest(Inventory inventory);
/**
* Gets an ISpecialPlayerInventory from an Inventory or null if the Inventory is not backed by
@@ -40,7 +40,7 @@ public interface IInventoryAccess {
* @return the ISpecialPlayerInventory or null
*/
@Nullable
public ISpecialPlayerInventory getSpecialPlayerInventory(Inventory inventory);
ISpecialPlayerInventory getSpecialPlayerInventory(Inventory inventory);
/**
* Check if an Inventory is an ISpecialEnderChest implementation.
@@ -48,7 +48,7 @@ public interface IInventoryAccess {
* @param inventory the Inventory
* @return true if the Inventory is backed by an ISpecialEnderChest
*/
public boolean isSpecialEnderChest(Inventory inventory);
boolean isSpecialEnderChest(Inventory inventory);
/**
* Check if an Inventory is an ISpecialPlayerInventory implementation.
@@ -56,6 +56,6 @@ public interface IInventoryAccess {
* @param inventory the Inventory
* @return true if the Inventory is backed by an ISpecialPlayerInventory
*/
public boolean isSpecialPlayerInventory(Inventory inventory);
boolean isSpecialPlayerInventory(Inventory inventory);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,25 +26,25 @@ public interface ISpecialEnderChest {
*
* @return the Inventory
*/
public Inventory getBukkitInventory();
Inventory getBukkitInventory();
/**
* Sets the Player associated with this ISpecialEnderChest online.
*
* @param player the Player coming online
*/
public void setPlayerOnline(Player player);
void setPlayerOnline(Player player);
/**
* Sets the Player associated with this ISpecialEnderChest offline.
*/
public void setPlayerOffline();
void setPlayerOffline();
/**
* Gets whether or not this ISpecialEnderChest is in use.
*
* @return true if the ISpecialEnderChest is in use
*/
public boolean isInUse();
boolean isInUse();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,25 +26,25 @@ public interface ISpecialPlayerInventory {
*
* @return the Inventory
*/
public Inventory getBukkitInventory();
Inventory getBukkitInventory();
/**
* Sets the Player associated with this ISpecialPlayerInventory online.
*
* @param player the Player coming online
*/
public void setPlayerOnline(Player player);
void setPlayerOnline(Player player);
/**
* Sets the Player associated with this ISpecialPlayerInventory offline.
*/
public void setPlayerOffline();
void setPlayerOffline();
/**
* Gets whether or not this ISpecialPlayerInventory is in use.
*
* @return true if the ISpecialPlayerInventory is in use
*/
public boolean isInUse();
boolean isInUse();
}

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvassembly</artifactId>

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvcommon</artifactId>
@@ -22,7 +38,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvapi</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,18 +28,18 @@ public interface IPlayerDataManager {
* </p>
* This method is potentially blocking, and should not be called on the main thread.
*
* @param offline
* @return
* @param offline the OfflinePlayer
* @return the Player loaded
*/
public Player loadPlayer(OfflinePlayer offline);
Player loadPlayer(OfflinePlayer offline);
/**
* Gets a unique identifying string for an OfflinePlayer.
*
* @param player
* @return
* @param offline the OfflinePlayer
* @return the unique identifier
*/
public String getPlayerDataID(OfflinePlayer player);
String getPlayerDataID(OfflinePlayer offline);
/**
* Gets an OfflinePlayer by the given unique identifier.
@@ -47,13 +47,13 @@ public interface IPlayerDataManager {
* @param identifier the unique identifier
* @return the OfflinePlayer, or null if no exact match was found
*/
public OfflinePlayer getPlayerByID(String identifier);
OfflinePlayer getPlayerByID(String identifier);
/**
* Gets a Collection of all Players currently online.
*
* @return the Collection of Players
*/
public Collection<? extends Player> getOnlinePlayers();
Collection<? extends Player> getOnlinePlayers();
}

View File

@@ -1,8 +1,26 @@
/*
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.util;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import com.google.common.collect.Multimap;
@@ -27,19 +45,19 @@ public class Cache<K, V> {
* @param inUseCheck Function used to check if a key is considered in use
* @param postRemoval Function used to perform any operations required when a key is invalidated
*/
public Cache(long retention, Function<V> inUseCheck, Function<V> postRemoval) {
public Cache(final long retention, final Function<V> inUseCheck, final Function<V> postRemoval) {
this.internal = new HashMap<K, V>();
this.expiry = TreeMultimap.create(new Comparator<Long>() {
@Override
public int compare(Long long1, Long long2) {
public int compare(final Long long1, final Long long2) {
return long1.compareTo(long2);
}
},
new Comparator<K>() {
@Override
public int compare(K k1, K k2) {
return 0;
public int compare(final K k1, final K k2) {
return k1 == k2 || k1 != null && k1.equals(k2) ? 0 : 1;
}
});
@@ -55,13 +73,13 @@ public class Cache<K, V> {
* @param key key with which the specified value is to be associated
* @param value value to be associated with the specified key
*/
public void put(K key, V value) {
public void put(final K key, final V value) {
// Invalidate key - runs lazy check and ensures value won't be cleaned up early
invalidate(key);
this.invalidate(key);
synchronized (internal) {
internal.put(key, value);
expiry.put(System.currentTimeMillis() + retention, key);
synchronized (this.internal) {
this.internal.put(key, value);
this.expiry.put(System.currentTimeMillis() + this.retention, key);
}
}
@@ -71,12 +89,12 @@ public class Cache<K, V> {
* @param key the key whose associated value is to be returned
* @return the value to which the specified key is mapped, or null if no value is mapped for the key
*/
public V get(K key) {
synchronized (internal) {
public V get(final K key) {
// Run lazy check to clean cache
lazyCheck();
this.lazyCheck();
return internal.get(key);
synchronized (this.internal) {
return this.internal.get(key);
}
}
@@ -86,12 +104,12 @@ public class Cache<K, V> {
* @param key key to check if a mapping exists for
* @return true if a mapping exists for the specified key
*/
public boolean containsKey(K key) {
synchronized (internal) {
public boolean containsKey(final K key) {
// Run lazy check to clean cache
lazyCheck();
this.lazyCheck();
return internal.containsKey(key);
synchronized (this.internal) {
return this.internal.containsKey(key);
}
}
@@ -100,21 +118,21 @@ public class Cache<K, V> {
*
* @param key key to invalidate
*/
public void invalidate(K key) {
synchronized (internal) {
public void invalidate(final K key) {
// Run lazy check to clean cache
lazyCheck();
this.lazyCheck();
if (!internal.containsKey(key)) {
synchronized (this.internal) {
if (!this.internal.containsKey(key)) {
// Value either not present or cleaned by lazy check. Either way, we're good
return;
}
// Remove stored object
internal.remove(key);
this.internal.remove(key);
// Remove expiration entry - prevents more work later, plus prevents issues with values invalidating early
for (Iterator<Map.Entry<Long, K>> iterator = expiry.entries().iterator(); iterator.hasNext();) {
for (Iterator<Map.Entry<Long, K>> iterator = this.expiry.entries().iterator(); iterator.hasNext();) {
if (key.equals(iterator.next().getValue())) {
iterator.remove();
break;
@@ -127,12 +145,12 @@ public class Cache<K, V> {
* Forcibly invalidates all keys, even if they are considered to be in use.
*/
public void invalidateAll() {
synchronized (internal) {
for (V value : internal.values()) {
postRemoval.run(value);
synchronized (this.internal) {
for (V value : this.internal.values()) {
this.postRemoval.run(value);
}
expiry.clear();
internal.clear();
this.expiry.clear();
this.internal.clear();
}
}
@@ -142,8 +160,10 @@ public class Cache<K, V> {
*/
private void lazyCheck() {
long now = System.currentTimeMillis();
long nextExpiry = now + retention;
for (Iterator<Map.Entry<Long, K>> iterator = expiry.entries().iterator(); iterator.hasNext();) {
synchronized (this.internal) {
List<K> inUse = new ArrayList<K>();
for (Iterator<Map.Entry<Long, K>> iterator = this.expiry.entries().iterator(); iterator
.hasNext();) {
Map.Entry<Long, K> entry = iterator.next();
if (entry.getKey() > now) {
@@ -152,18 +172,24 @@ public class Cache<K, V> {
iterator.remove();
if (inUseCheck.run(internal.get(entry.getValue()))) {
expiry.put(nextExpiry, entry.getValue());
if (this.inUseCheck.run(this.internal.get(entry.getValue()))) {
inUse.add(entry.getValue());
continue;
}
V value = internal.remove(entry.getValue());
V value = this.internal.remove(entry.getValue());
if (value == null) {
continue;
}
postRemoval.run(value);
this.postRemoval.run(value);
}
long nextExpiry = now + this.retention;
for (K value : inUse) {
this.expiry.put(nextExpiry, value);
}
}
}

View File

@@ -1,3 +1,19 @@
/*
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.util;
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -108,9 +108,7 @@ public class InternalAccessor {
for (Object object : params) {
builder.append(object.getClass().getName()).append(", ");
}
if (params.length > 0) {
builder.delete(builder.length() - 2, builder.length());
}
String message = builder.append(']').toString();
this.plugin.getLogger().warning(message);

View File

@@ -1,38 +1,69 @@
/*
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.util;
import org.bukkit.permissions.Permissible;
public enum Permissions {
OPENINV("OpenInv.openinv"),
OVERRIDE("OpenInv.override"),
EXEMPT("OpenInv.exempt"),
CROSSWORLD("OpenInv.crossworld"),
SILENT("OpenInv.silent"),
ANYCHEST("OpenInv.anychest"),
ENDERCHEST("OpenInv.openender"),
ENDERCHEST_ALL("OpenInv.openenderall"),
SEARCH("OpenInv.search"),
EDITINV("OpenInv.editinv"),
EDITENDER("OpenInv.editender"),
OPENSELF("OpenInv.openself");
OPENINV("openinv"),
OVERRIDE("override"),
EXEMPT("exempt"),
CROSSWORLD("crossworld"),
SILENT("silent"),
SILENT_DEFAULT("silent.default"),
ANYCHEST("anychest"),
ANY_DEFAULT("any.default"),
ENDERCHEST("openender"),
ENDERCHEST_ALL("openenderall"),
SEARCH("search"),
EDITINV("editinv"),
EDITENDER("editender"),
OPENSELF("openself");
private final String permission;
private Permissions(String permission) {
this.permission = permission;
Permissions(String permission) {
this.permission = "OpenInv." + permission;
}
public boolean hasPermission(Permissible permissible) {
String[] parts = permission.split("\\.");
String perm = "";
for (int i = 0; i < parts.length; i++) {
if (permissible.hasPermission(perm + "*")) {
return true;
boolean hasPermission = permissible.hasPermission(permission);
if (hasPermission || permissible.isPermissionSet(permission)) {
return hasPermission;
}
perm += parts[i] + ".";
StringBuilder permissionDestroyer = new StringBuilder(permission);
for (int lastPeriod = permissionDestroyer.lastIndexOf("."); lastPeriod > 0;
lastPeriod = permissionDestroyer.lastIndexOf(".")) {
permissionDestroyer.delete(lastPeriod + 1, permissionDestroyer.length()).append('*');
hasPermission = permissible.hasPermission(permissionDestroyer.toString());
if (hasPermission || permissible.isPermissionSet(permissionDestroyer.toString())) {
return hasPermission;
}
return permissible.hasPermission(permission);
permissionDestroyer.delete(lastPeriod, permissionDestroyer.length());
}
return permissible.hasPermission("*");
}
}

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvadapter1_4_5</artifactId>
@@ -21,7 +37,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -59,8 +59,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
@Override
public String getPlayerDataID(OfflinePlayer player) {
return player.getName();
public String getPlayerDataID(OfflinePlayer offline) {
return offline.getName();
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@ import net.minecraft.server.v1_4_5.IInventory;
import net.minecraft.server.v1_4_5.ItemStack;
import net.minecraft.server.v1_4_5.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
class SilentContainerChest extends ContainerChest {
public SilentContainerChest(IInventory i1, IInventory i2) {
super(i1, i2);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,13 +42,14 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
private final InventoryEnderChest enderChest;
private final CraftInventory inventory = new CraftInventory(this);
private final List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private boolean playerOnline = false;
private boolean playerOnline;
private CraftPlayer owner;
private int maxStack = MAX_STACK;
public SpecialEnderChest(Player player, Boolean online) {
super(((CraftPlayer) player).getHandle().getEnderChest().getName(),
((CraftPlayer) player).getHandle().getEnderChest().getSize());
super(PlayerDataManager.getHandle(player).getEnderChest().getName(),
PlayerDataManager.getHandle(player).getEnderChest().getSize());
this.playerOnline = online;
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.enderChest = nmsPlayer.getEnderChest();
this.owner = nmsPlayer.getBukkitEntity();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
private final ItemStack[] extra = new ItemStack[5];
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialPlayerInventory(Player bukkitPlayer, Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvadapter1_4_6</artifactId>
@@ -21,7 +37,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -59,8 +59,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
@Override
public String getPlayerDataID(OfflinePlayer player) {
return player.getName();
public String getPlayerDataID(OfflinePlayer offline) {
return offline.getName();
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@ import net.minecraft.server.v1_4_6.IInventory;
import net.minecraft.server.v1_4_6.ItemStack;
import net.minecraft.server.v1_4_6.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
class SilentContainerChest extends ContainerChest {
public SilentContainerChest(IInventory i1, IInventory i2) {
super(i1, i2);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,13 +42,14 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
private final InventoryEnderChest enderChest;
private final CraftInventory inventory = new CraftInventory(this);
private final List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private boolean playerOnline = false;
private boolean playerOnline;
private CraftPlayer owner;
private int maxStack = MAX_STACK;
public SpecialEnderChest(Player player, Boolean online) {
super(((CraftPlayer) player).getHandle().getEnderChest().getName(),
((CraftPlayer) player).getHandle().getEnderChest().getSize());
super(PlayerDataManager.getHandle(player).getEnderChest().getName(),
PlayerDataManager.getHandle(player).getEnderChest().getSize());
this.playerOnline = online;
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.enderChest = nmsPlayer.getEnderChest();
this.owner = nmsPlayer.getBukkitEntity();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
private final ItemStack[] extra = new ItemStack[5];
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialPlayerInventory(Player bukkitPlayer, Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));

View File

@@ -1,11 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvparent</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvinternal</artifactId>
@@ -26,8 +41,8 @@
<id>recent</id>
<!-- The recent profile is for the most recent 2 versions. -->
<modules>
<module>v1_11_R1</module>
<module>v1_12_R1</module>
<module>v1_13_R1</module>
</modules>
</profile>
@@ -44,7 +59,6 @@
<module>v1_6_R1</module>
<module>v1_6_R2</module>
<module>v1_6_R3</module>
<!-- TODO: Recompile CB for 1_7_R1 through 1_7_R4, currently using whatever jars worked -->
<module>v1_7_R1</module>
<module>v1_7_R2</module>
<module>v1_7_R3</module>
@@ -57,6 +71,7 @@
<module>v1_10_R1</module>
<module>v1_11_R1</module>
<module>v1_12_R1</module>
<module>v1_13_R1</module>
</modules>
</profile>

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvadapter1_10_R1</artifactId>
@@ -21,7 +37,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,36 +16,48 @@
package com.lishid.openinv.internal.v1_10_R1;
import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import net.minecraft.server.v1_10_R1.AxisAlignedBB;
import net.minecraft.server.v1_10_R1.Block;
import net.minecraft.server.v1_10_R1.BlockChest;
import net.minecraft.server.v1_10_R1.BlockEnderChest;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Container;
import net.minecraft.server.v1_10_R1.Entity;
import net.minecraft.server.v1_10_R1.EntityOcelot;
import net.minecraft.server.v1_10_R1.EntityPlayer;
import net.minecraft.server.v1_10_R1.EnumDirection;
import net.minecraft.server.v1_10_R1.EnumGamemode;
import net.minecraft.server.v1_10_R1.ITileInventory;
import net.minecraft.server.v1_10_R1.InventoryEnderChest;
import net.minecraft.server.v1_10_R1.InventoryLargeChest;
import net.minecraft.server.v1_10_R1.PacketPlayOutOpenWindow;
import net.minecraft.server.v1_10_R1.PlayerInteractManager;
import net.minecraft.server.v1_10_R1.StatisticList;
import net.minecraft.server.v1_10_R1.TileEntity;
import net.minecraft.server.v1_10_R1.TileEntityChest;
import net.minecraft.server.v1_10_R1.TileEntityEnderChest;
import net.minecraft.server.v1_10_R1.World;
import org.bukkit.craftbukkit.v1_10_R1.event.CraftEventFactory;
public class AnySilentContainer implements IAnySilentContainer {
private Field playerInteractManagerGamemode;
public AnySilentContainer() {
try {
this.playerInteractManagerGamemode = PlayerInteractManager.class.getDeclaredField("gamemode");
this.playerInteractManagerGamemode.setAccessible(true);
} catch (Exception e) {
System.err.println("[OpenInv] Unable to directly write player gamemode! SilentChest will fail.");
e.printStackTrace();
}
}
@Override
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
@@ -144,7 +156,6 @@ public class AnySilentContainer implements IAnySilentContainer {
ITileInventory tileInventory = (ITileInventory) tile;
Block block = world.getType(blockPosition).getBlock();
Container container = null;
if (block instanceof BlockChest) {
for (EnumDirection localEnumDirection : EnumDirection.EnumDirectionLimit.HORIZONTAL) {
@@ -176,38 +187,63 @@ public class AnySilentContainer implements IAnySilentContainer {
} else if (blockChest.g == BlockChest.Type.TRAP) {
player.b(StatisticList.W);
}
if (silentchest) {
container = new SilentContainerChest(player.inventory, tileInventory, player);
}
}
// AnyChest only - SilentChest not active or container unsupported
if (!silentchest || container == null) {
// AnyChest only - SilentChest not active, container unsupported, or unnecessary.
if (!silentchest || player.playerInteractManager.getGameMode() == EnumGamemode.SPECTATOR) {
player.openContainer(tileInventory);
return true;
}
// SilentChest
try {
// Call InventoryOpenEvent
container = CraftEventFactory.callInventoryOpenEvent(player, container, false);
if (container == null) {
// SilentChest requires access to setting players' gamemode directly.
if (this.playerInteractManagerGamemode == null) {
return false;
}
// Open window
int windowId = player.nextContainerCounter();
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, tileInventory.getContainerName(), tileInventory.getScoreboardDisplayName(), tileInventory.getSize()));
player.activeContainer = container;
player.activeContainer.windowId = windowId;
player.activeContainer.addSlotListener(player);
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
this.forceGameMode(player, EnumGamemode.SPECTATOR);
player.openContainer(tileInventory);
this.forceGameMode(player, gamemode);
return true;
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {
if (this.playerInteractManagerGamemode == null) {
return;
}
InventoryView view = bukkitPlayer.getOpenInventory();
switch (view.getType()) {
case CHEST:
case ENDER_CHEST:
break;
default:
return;
}
EntityPlayer player = PlayerDataManager.getHandle(bukkitPlayer);
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
this.forceGameMode(player, EnumGamemode.SPECTATOR);
player.activeContainer.b(player);
player.activeContainer = player.defaultContainer;
this.forceGameMode(player, gamemode);
}
private void forceGameMode(final EntityPlayer player, final EnumGamemode gameMode) {
if (this.playerInteractManagerGamemode == null) {
// No need to warn repeatedly, error on startup and lack of function should be enough.
return;
}
try {
if (!this.playerInteractManagerGamemode.isAccessible()) {
// Just in case, ensure accessible.
this.playerInteractManagerGamemode.setAccessible(true);
}
this.playerInteractManagerGamemode.set(player.playerInteractManager, gameMode);
} catch (Exception e) {
e.printStackTrace();
p.sendMessage(ChatColor.RED + "Error while sending silent container.");
return false;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -61,8 +61,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
@Override
public String getPlayerDataID(OfflinePlayer player) {
return player.getUniqueId().toString();
public String getPlayerDataID(OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@Override

View File

@@ -1,45 +0,0 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_10_R1;
import net.minecraft.server.v1_10_R1.ContainerChest;
import net.minecraft.server.v1_10_R1.EntityHuman;
import net.minecraft.server.v1_10_R1.IInventory;
import net.minecraft.server.v1_10_R1.ItemStack;
import net.minecraft.server.v1_10_R1.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
public SilentContainerChest(IInventory i1, IInventory i2, EntityHuman e1) {
super(i1, i2, e1);
// Send close signal
i2.closeContainer(e1);
}
@Override
public void b(EntityHuman entityHuman) {
// Don't send close signal twice, might screw up
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -36,12 +36,13 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
private final InventoryEnderChest enderChest;
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialEnderChest(Player player, Boolean online) {
super(PlayerDataManager.getHandle(player).getEnderChest().getName(),
PlayerDataManager.getHandle(player).getEnderChest().hasCustomName(),
PlayerDataManager.getHandle(player).getEnderChest().getSize());
this.playerOnline = online;
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.enderChest = nmsPlayer.getEnderChest();
this.bukkitOwner = nmsPlayer.getBukkitEntity();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -34,7 +34,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
private final ItemStack[] extra = new ItemStack[4];
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialPlayerInventory(Player bukkitPlayer, Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));
@@ -286,6 +286,11 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
return player.getName();
}
@Override
public boolean hasCustomName() {
return true;
}
@Override
public boolean a(EntityHuman entityhuman) {
return true;

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvadapter1_11_R1</artifactId>
@@ -21,7 +37,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,14 +16,14 @@
package com.lishid.openinv.internal.v1_11_R1;
import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.inventory.InventoryView;
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
import net.minecraft.server.v1_11_R1.Block;
@@ -31,7 +31,6 @@ import net.minecraft.server.v1_11_R1.BlockChest;
import net.minecraft.server.v1_11_R1.BlockEnderChest;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.BlockShulkerBox;
import net.minecraft.server.v1_11_R1.Container;
import net.minecraft.server.v1_11_R1.Entity;
import net.minecraft.server.v1_11_R1.EntityOcelot;
import net.minecraft.server.v1_11_R1.EntityPlayer;
@@ -40,18 +39,29 @@ import net.minecraft.server.v1_11_R1.IBlockData;
import net.minecraft.server.v1_11_R1.ITileInventory;
import net.minecraft.server.v1_11_R1.InventoryEnderChest;
import net.minecraft.server.v1_11_R1.InventoryLargeChest;
import net.minecraft.server.v1_11_R1.PacketPlayOutOpenWindow;
import net.minecraft.server.v1_11_R1.StatisticList;
import net.minecraft.server.v1_11_R1.TileEntity;
import net.minecraft.server.v1_11_R1.TileEntityChest;
import net.minecraft.server.v1_11_R1.TileEntityEnderChest;
import net.minecraft.server.v1_11_R1.TileEntityShulkerBox;
import net.minecraft.server.v1_11_R1.World;
import org.bukkit.craftbukkit.v1_11_R1.event.CraftEventFactory;
import net.minecraft.server.v1_11_R1.EnumGamemode;
import net.minecraft.server.v1_11_R1.PlayerInteractManager;
public class AnySilentContainer implements IAnySilentContainer {
private Field playerInteractManagerGamemode;
public AnySilentContainer() {
try {
this.playerInteractManagerGamemode = PlayerInteractManager.class.getDeclaredField("gamemode");
this.playerInteractManagerGamemode.setAccessible(true);
} catch (Exception e) {
System.err.println("[OpenInv] Unable to directly write player gamemode! SilentChest will fail.");
e.printStackTrace();
}
}
@Override
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
if (block.getType() == Material.ENDER_CHEST) {
@@ -186,7 +196,6 @@ public class AnySilentContainer implements IAnySilentContainer {
ITileInventory tileInventory = (ITileInventory) tile;
Block block = world.getType(blockPosition).getBlock();
Container container = null;
if (block instanceof BlockChest) {
for (EnumDirection localEnumDirection : EnumDirection.EnumDirectionLimit.HORIZONTAL) {
@@ -218,68 +227,68 @@ public class AnySilentContainer implements IAnySilentContainer {
} else if (blockChest.g == BlockChest.Type.TRAP) {
player.b(StatisticList.getStatistic("stat.trappedChestTriggered"));
}
if (silentchest) {
container = new SilentContainerChest(player.inventory, tileInventory, player);
}
}
if (block instanceof BlockShulkerBox) {
player.b(StatisticList.getStatistic("stat.shulkerBoxOpened"));
if (silentchest && tileInventory instanceof TileEntityShulkerBox) {
// Set value to current + 1. Ensures consistency later when resetting.
SilentContainerShulkerBox.setOpenValue((TileEntityShulkerBox) tileInventory,
SilentContainerShulkerBox.getOpenValue((TileEntityShulkerBox) tileInventory) + 1);
container = new SilentContainerShulkerBox(player.inventory, tileInventory, player);
}
}
// AnyChest only - SilentChest not active or container unsupported
if (!silentchest || container == null) {
// AnyChest only - SilentChest not active, container unsupported, or unnecessary.
if (!silentchest || player.playerInteractManager.getGameMode() == EnumGamemode.SPECTATOR) {
player.openContainer(tileInventory);
return true;
}
// SilentChest
try {
// Call InventoryOpenEvent
container = CraftEventFactory.callInventoryOpenEvent(player, container, false);
if (container == null) {
// SilentChest requires access to setting players' gamemode directly.
if (this.playerInteractManagerGamemode == null) {
return false;
}
// Open window
int windowId = player.nextContainerCounter();
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, tileInventory.getContainerName(), tileInventory.getScoreboardDisplayName(), tileInventory.getSize()));
player.activeContainer = container;
player.activeContainer.windowId = windowId;
player.activeContainer.addSlotListener(player);
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
this.forceGameMode(player, EnumGamemode.SPECTATOR);
player.openContainer(tileInventory);
this.forceGameMode(player, gamemode);
return true;
}
// Special handling for shulker boxes - reset value for viewers to what it was initially.
if (tile instanceof TileEntityShulkerBox) {
new BukkitRunnable() {
@Override
public void run() {
// TODO hacky
Object tile = world.getTileEntity(blockPosition);
if (!(tile instanceof TileEntityShulkerBox)) {
public void deactivateContainer(final Player bukkitPlayer) {
if (this.playerInteractManagerGamemode == null) {
return;
}
TileEntityShulkerBox box = (TileEntityShulkerBox) tile;
// Reset back - we added 1, and calling TileEntityShulkerBox#startOpen adds 1 more.
SilentContainerShulkerBox.setOpenValue(box,
SilentContainerShulkerBox.getOpenValue((TileEntityShulkerBox) tile) - 2);
}
}.runTaskLater(Bukkit.getPluginManager().getPlugin("OpenInv"), 2);
InventoryView view = bukkitPlayer.getOpenInventory();
switch (view.getType()) {
case CHEST:
case ENDER_CHEST:
case SHULKER_BOX:
break;
default:
return;
}
return true;
EntityPlayer player = PlayerDataManager.getHandle(bukkitPlayer);
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
this.forceGameMode(player, EnumGamemode.SPECTATOR);
player.activeContainer.b(player);
player.activeContainer = player.defaultContainer;
this.forceGameMode(player, gamemode);
}
private void forceGameMode(final EntityPlayer player, final EnumGamemode gameMode) {
if (this.playerInteractManagerGamemode == null) {
// No need to warn repeatedly, error on startup and lack of function should be enough.
return;
}
try {
if (!this.playerInteractManagerGamemode.isAccessible()) {
// Just in case, ensure accessible.
this.playerInteractManagerGamemode.setAccessible(true);
}
this.playerInteractManagerGamemode.set(player.playerInteractManager, gameMode);
} catch (Exception e) {
e.printStackTrace();
p.sendMessage(ChatColor.RED + "Error while sending silent container.");
return false;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -61,8 +61,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
@Override
public String getPlayerDataID(OfflinePlayer player) {
return player.getUniqueId().toString();
public String getPlayerDataID(OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@Override

View File

@@ -1,46 +0,0 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_11_R1;
import net.minecraft.server.v1_11_R1.ContainerChest;
import net.minecraft.server.v1_11_R1.EntityHuman;
import net.minecraft.server.v1_11_R1.IInventory;
import net.minecraft.server.v1_11_R1.ItemStack;
import net.minecraft.server.v1_11_R1.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
public SilentContainerChest(PlayerInventory playerInventory, IInventory iInventory,
EntityHuman entityHuman) {
super(playerInventory, iInventory, entityHuman);
// Send close signal
iInventory.closeContainer(entityHuman);
}
@Override
public void b(EntityHuman entityHuman) {
// Don't send close signal twice, might screw up
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != ItemStack.a) {
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(ItemStack.a);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -1,56 +0,0 @@
package com.lishid.openinv.internal.v1_11_R1;
import java.lang.reflect.Field;
import net.minecraft.server.v1_11_R1.ContainerShulkerBox;
import net.minecraft.server.v1_11_R1.EntityHuman;
import net.minecraft.server.v1_11_R1.IInventory;
import net.minecraft.server.v1_11_R1.ItemStack;
import net.minecraft.server.v1_11_R1.PlayerInventory;
import net.minecraft.server.v1_11_R1.TileEntityShulkerBox;
public class SilentContainerShulkerBox extends ContainerShulkerBox {
private static Field fieldShulkerActionData;
public SilentContainerShulkerBox(PlayerInventory playerInventory, IInventory iInventory,
EntityHuman entityHuman) {
super(playerInventory, iInventory, entityHuman);
}
@Override
public void b(EntityHuman entityHuman) {
PlayerInventory playerinventory = entityHuman.inventory;
if (!playerinventory.getCarried().isEmpty()) {
entityHuman.drop(playerinventory.getCarried(), false);
playerinventory.setCarried(ItemStack.a);
}
}
private static Field exposeOpenStatus() throws NoSuchFieldException, SecurityException {
if (fieldShulkerActionData == null) {
fieldShulkerActionData = TileEntityShulkerBox.class.getDeclaredField("h");
fieldShulkerActionData.setAccessible(true);
}
return fieldShulkerActionData;
}
public static void setOpenValue(TileEntityShulkerBox tileShulkerBox, Object value) {
try {
exposeOpenStatus().set(tileShulkerBox, value);
} catch (Exception e) {
e.printStackTrace();
}
}
public static Integer getOpenValue(TileEntityShulkerBox tileShulkerBox) {
try {
return (Integer) exposeOpenStatus().get(tileShulkerBox);
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,12 +37,13 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
private final InventoryEnderChest enderChest;
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialEnderChest(Player player, Boolean online) {
super(PlayerDataManager.getHandle(player).getEnderChest().getName(),
PlayerDataManager.getHandle(player).getEnderChest().hasCustomName(),
PlayerDataManager.getHandle(player).getEnderChest().getSize());
this.playerOnline = online;
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.enderChest = nmsPlayer.getEnderChest();
this.bukkitOwner = nmsPlayer.getBukkitEntity();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -36,7 +36,7 @@ import org.bukkit.craftbukkit.v1_11_R1.inventory.CraftInventory;
public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialPlayerInventory(Player bukkitPlayer, Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));
@@ -70,7 +70,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
field = PlayerInventory.class.getDeclaredField("g");
field.setAccessible(true);
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, Arrays.asList(new NonNullList[] { items, armor, extraSlots }));
field.set(inventory, Arrays.asList(items, armor, extraSlots));
} catch (NoSuchFieldException e) {
// Unable to set final fields to item arrays, we're screwed. Noisily fail.
e.printStackTrace();
@@ -89,7 +89,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
@Override
public void setPlayerOnline(Player player) {
if (!playerOnline) {
this.player = PlayerDataManager.getHandle(player);;
this.player = PlayerDataManager.getHandle(player);
setItemArrays(this.player.inventory, items, armor, extraSlots);
playerOnline = true;
}
@@ -157,7 +157,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
return ItemStack.a;
}
return list == null || list.get(i).isEmpty() ? ItemStack.a : ContainerUtil.a(list, i, j);
return list.get(i).isEmpty() ? ItemStack.a : ContainerUtil.a(list, i, j);
}
@Override
@@ -182,7 +182,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
return ItemStack.a;
}
if (list != null && !list.get(i).isEmpty()) {
if (!list.get(i).isEmpty()) {
ItemStack itemstack = list.get(i);
list.set(i, ItemStack.a);
@@ -215,10 +215,8 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
return;
}
if (list != null) {
list.set(i, itemstack);
}
}
private int getReversedItemSlotNum(int i) {
if (i >= 27) {
@@ -251,6 +249,11 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
return player.getName();
}
@Override
public boolean hasCustomName() {
return true;
}
@Override
public boolean a(EntityHuman entityhuman) {
return true;

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvadapter1_12_R1</artifactId>
@@ -21,8 +37,21 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -1,24 +1,30 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved. This program is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, version 3. This program 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 General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_12_R1;
import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.inventory.InventoryView;
import net.minecraft.server.v1_12_R1.AxisAlignedBB;
import net.minecraft.server.v1_12_R1.Block;
@@ -26,176 +32,44 @@ import net.minecraft.server.v1_12_R1.BlockChest;
import net.minecraft.server.v1_12_R1.BlockEnderChest;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.BlockShulkerBox;
import net.minecraft.server.v1_12_R1.Container;
import net.minecraft.server.v1_12_R1.Entity;
import net.minecraft.server.v1_12_R1.EntityOcelot;
import net.minecraft.server.v1_12_R1.EntityPlayer;
import net.minecraft.server.v1_12_R1.EnumDirection;
import net.minecraft.server.v1_12_R1.EnumGamemode;
import net.minecraft.server.v1_12_R1.IBlockData;
import net.minecraft.server.v1_12_R1.ITileInventory;
import net.minecraft.server.v1_12_R1.InventoryEnderChest;
import net.minecraft.server.v1_12_R1.InventoryLargeChest;
import net.minecraft.server.v1_12_R1.PacketPlayOutOpenWindow;
import net.minecraft.server.v1_12_R1.PlayerInteractManager;
import net.minecraft.server.v1_12_R1.TileEntity;
import net.minecraft.server.v1_12_R1.TileEntityChest;
import net.minecraft.server.v1_12_R1.TileEntityEnderChest;
import net.minecraft.server.v1_12_R1.TileEntityShulkerBox;
import net.minecraft.server.v1_12_R1.World;
import org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean activateContainer(final Player bukkitPlayer, final boolean silentchest,
final org.bukkit.block.Block bukkitBlock) {
private Field playerInteractManagerGamemode;
// Silent ender chest is API-only
if (silentchest && bukkitBlock.getType() == Material.ENDER_CHEST) {
bukkitPlayer.openInventory(bukkitPlayer.getEnderChest());
bukkitPlayer.incrementStatistic(Statistic.ENDERCHEST_OPENED);
return true;
}
EntityPlayer player = PlayerDataManager.getHandle(bukkitPlayer);
final World world = player.world;
final BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
final Object tile = world.getTileEntity(blockPosition);
if (tile == null) {
return false;
}
if (tile instanceof TileEntityEnderChest) {
// Anychest ender chest. See net.minecraft.server.BlockEnderChest
InventoryEnderChest enderChest = player.getEnderChest();
enderChest.a((TileEntityEnderChest) tile);
player.openContainer(enderChest);
bukkitPlayer.incrementStatistic(Statistic.ENDERCHEST_OPENED);
return true;
}
if (!(tile instanceof ITileInventory)) {
return false;
}
ITileInventory tileInventory = (ITileInventory) tile;
Block block = world.getType(blockPosition).getBlock();
Container container = null;
if (block instanceof BlockChest) {
for (EnumDirection localEnumDirection : EnumDirection.EnumDirectionLimit.HORIZONTAL) {
BlockPosition localBlockPosition = blockPosition.shift(localEnumDirection);
Block localBlock = world.getType(localBlockPosition).getBlock();
if (localBlock != block) {
continue;
}
TileEntity localTileEntity = world.getTileEntity(localBlockPosition);
if (!(localTileEntity instanceof TileEntityChest)) {
continue;
}
if (localEnumDirection == EnumDirection.WEST
|| localEnumDirection == EnumDirection.NORTH) {
tileInventory = new InventoryLargeChest("container.chestDouble",
(TileEntityChest) localTileEntity, tileInventory);
} else {
tileInventory = new InventoryLargeChest("container.chestDouble", tileInventory,
(TileEntityChest) localTileEntity);
}
break;
}
BlockChest blockChest = (BlockChest) block;
if (blockChest.g == BlockChest.Type.BASIC) {
bukkitPlayer.incrementStatistic(Statistic.CHEST_OPENED);
} else if (blockChest.g == BlockChest.Type.TRAP) {
bukkitPlayer.incrementStatistic(Statistic.TRAPPED_CHEST_TRIGGERED);
}
if (silentchest) {
container = new SilentContainerChest(player.inventory, tileInventory, player);
}
}
if (block instanceof BlockShulkerBox) {
bukkitPlayer.incrementStatistic(Statistic.SHULKER_BOX_OPENED);
if (silentchest && tileInventory instanceof TileEntityShulkerBox) {
// Set value to current + 1. Ensures consistency later when resetting.
SilentContainerShulkerBox.setOpenValue((TileEntityShulkerBox) tileInventory,
SilentContainerShulkerBox.getOpenValue((TileEntityShulkerBox) tileInventory)
+ 1);
container = new SilentContainerShulkerBox(player.inventory, tileInventory, player);
}
}
// AnyChest only - SilentChest not active or container unsupported
if (!silentchest || container == null) {
player.openContainer(tileInventory);
return true;
}
// SilentChest
public AnySilentContainer() {
try {
// Call InventoryOpenEvent
container = CraftEventFactory.callInventoryOpenEvent(player, container, false);
if (container == null) {
return false;
}
// Open window
int windowId = player.nextContainerCounter();
player.playerConnection.sendPacket(
new PacketPlayOutOpenWindow(windowId, tileInventory.getContainerName(),
tileInventory.getScoreboardDisplayName(), tileInventory.getSize()));
player.activeContainer = container;
player.activeContainer.windowId = windowId;
player.activeContainer.addSlotListener(player);
// Special handling for shulker boxes - reset value for viewers to what it was initially.
if (tile instanceof TileEntityShulkerBox) {
new BukkitRunnable() {
@Override
public void run() {
// TODO hacky
Object tile = world.getTileEntity(blockPosition);
if (!(tile instanceof TileEntityShulkerBox)) {
return;
}
TileEntityShulkerBox box = (TileEntityShulkerBox) tile;
// Reset back - we added 1, and calling TileEntityShulkerBox#startOpen adds 1 more.
SilentContainerShulkerBox.setOpenValue(box,
SilentContainerShulkerBox.getOpenValue((TileEntityShulkerBox) tile)
- 2);
}
}.runTaskLater(Bukkit.getPluginManager().getPlugin("OpenInv"), 2);
}
return true;
} catch (Exception e) {
this.playerInteractManagerGamemode = PlayerInteractManager.class.getDeclaredField("gamemode");
this.playerInteractManagerGamemode.setAccessible(true);
} catch (NoSuchFieldException | SecurityException e) {
System.err.println("[OpenInv] Unable to directly write player gamemode! SilentChest will fail.");
e.printStackTrace();
bukkitPlayer.sendMessage(ChatColor.RED + "Error while sending silent container.");
return false;
}
}
private boolean hasOcelotOnTop(final World world, final BlockPosition blockPosition) {
for (Entity localEntity : world.a(EntityOcelot.class,
new AxisAlignedBB(blockPosition.getX(), blockPosition.getY() + 1,
blockPosition.getZ(), blockPosition.getX() + 1, blockPosition.getY() + 2,
blockPosition.getZ() + 1))) {
EntityOcelot localEntityOcelot = (EntityOcelot) localEntity;
if (localEntityOcelot.isSitting()) {
@Override
public boolean isAnySilentContainer(final org.bukkit.block.Block block) {
if (block.getType() == Material.ENDER_CHEST) {
return true;
}
}
return false;
BlockState state = block.getState();
return state instanceof org.bukkit.block.Chest
|| state instanceof org.bukkit.block.ShulkerBox;
}
@Override
@@ -242,21 +116,6 @@ public class AnySilentContainer implements IAnySilentContainer {
return false;
}
@Override
public boolean isAnySilentContainer(final org.bukkit.block.Block block) {
if (block.getType() == Material.ENDER_CHEST) {
return true;
}
BlockState state = block.getState();
return state instanceof org.bukkit.block.Chest
|| state instanceof org.bukkit.block.ShulkerBox;
}
private boolean isBlockedChest(final World world, final BlockPosition blockPosition) {
// For reference, loot at net.minecraft.server.BlockChest
return world.getType(blockPosition.up()).l() || this.hasOcelotOnTop(world, blockPosition);
}
private boolean isBlockedShulkerBox(final World world, final BlockPosition blockPosition,
final IBlockData blockData) {
// For reference, look at net.minecraft.server.BlockShulkerBox
@@ -279,4 +138,156 @@ public class AnySilentContainer implements IAnySilentContainer {
return false;
}
private boolean isBlockedChest(final World world, final BlockPosition blockPosition) {
// For reference, loot at net.minecraft.server.BlockChest
return world.getType(blockPosition.up()).l() || this.hasOcelotOnTop(world, blockPosition);
}
private boolean hasOcelotOnTop(final World world, final BlockPosition blockPosition) {
for (Entity localEntity : world.a(EntityOcelot.class,
new AxisAlignedBB(blockPosition.getX(), blockPosition.getY() + 1,
blockPosition.getZ(), blockPosition.getX() + 1, blockPosition.getY() + 2,
blockPosition.getZ() + 1))) {
EntityOcelot localEntityOcelot = (EntityOcelot) localEntity;
if (localEntityOcelot.isSitting()) {
return true;
}
}
return false;
}
@Override
public boolean activateContainer(final Player bukkitPlayer, final boolean silentchest,
final org.bukkit.block.Block bukkitBlock) {
// Silent ender chest is API-only
if (silentchest && bukkitBlock.getType() == Material.ENDER_CHEST) {
bukkitPlayer.openInventory(bukkitPlayer.getEnderChest());
bukkitPlayer.incrementStatistic(Statistic.ENDERCHEST_OPENED);
return true;
}
EntityPlayer player = PlayerDataManager.getHandle(bukkitPlayer);
final World world = player.world;
final BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
final Object tile = world.getTileEntity(blockPosition);
if (tile == null) {
return false;
}
if (tile instanceof TileEntityEnderChest) {
// Anychest ender chest. See net.minecraft.server.BlockEnderChest
InventoryEnderChest enderChest = player.getEnderChest();
enderChest.a((TileEntityEnderChest) tile);
player.openContainer(enderChest);
bukkitPlayer.incrementStatistic(Statistic.ENDERCHEST_OPENED);
return true;
}
if (!(tile instanceof ITileInventory)) {
return false;
}
ITileInventory tileInventory = (ITileInventory) tile;
Block block = world.getType(blockPosition).getBlock();
if (block instanceof BlockChest) {
for (EnumDirection localEnumDirection : EnumDirection.EnumDirectionLimit.HORIZONTAL) {
BlockPosition localBlockPosition = blockPosition.shift(localEnumDirection);
Block localBlock = world.getType(localBlockPosition).getBlock();
if (localBlock != block) {
continue;
}
TileEntity localTileEntity = world.getTileEntity(localBlockPosition);
if (!(localTileEntity instanceof TileEntityChest)) {
continue;
}
if (localEnumDirection == EnumDirection.WEST
|| localEnumDirection == EnumDirection.NORTH) {
tileInventory = new InventoryLargeChest("container.chestDouble",
(TileEntityChest) localTileEntity, tileInventory);
} else {
tileInventory = new InventoryLargeChest("container.chestDouble", tileInventory,
(TileEntityChest) localTileEntity);
}
break;
}
BlockChest blockChest = (BlockChest) block;
if (blockChest.g == BlockChest.Type.BASIC) {
bukkitPlayer.incrementStatistic(Statistic.CHEST_OPENED);
} else if (blockChest.g == BlockChest.Type.TRAP) {
bukkitPlayer.incrementStatistic(Statistic.TRAPPED_CHEST_TRIGGERED);
}
}
if (block instanceof BlockShulkerBox) {
bukkitPlayer.incrementStatistic(Statistic.SHULKER_BOX_OPENED);
}
// AnyChest only - SilentChest not active, container unsupported, or unnecessary.
if (!silentchest || player.playerInteractManager.getGameMode() == EnumGamemode.SPECTATOR) {
player.openContainer(tileInventory);
return true;
}
// SilentChest requires access to setting players' gamemode directly.
if (this.playerInteractManagerGamemode == null) {
return false;
}
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
this.forceGameMode(player, EnumGamemode.SPECTATOR);
player.openContainer(tileInventory);
this.forceGameMode(player, gamemode);
return true;
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {
if (this.playerInteractManagerGamemode == null) {
return;
}
InventoryView view = bukkitPlayer.getOpenInventory();
switch (view.getType()) {
case CHEST:
case ENDER_CHEST:
case SHULKER_BOX:
break;
default:
return;
}
EntityPlayer player = PlayerDataManager.getHandle(bukkitPlayer);
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
this.forceGameMode(player, EnumGamemode.SPECTATOR);
player.activeContainer.b(player);
player.activeContainer = player.defaultContainer;
this.forceGameMode(player, gamemode);
}
private void forceGameMode(final EntityPlayer player, final EnumGamemode gameMode) {
if (this.playerInteractManagerGamemode == null) {
// No need to warn repeatedly, error on startup and lack of function should be enough.
return;
}
try {
if (!this.playerInteractManagerGamemode.isAccessible()) {
// Just in case, ensure accessible.
this.playerInteractManagerGamemode.setAccessible(true);
}
this.playerInteractManagerGamemode.set(player.playerInteractManager, gameMode);
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
}

View File

@@ -1,11 +1,17 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved. This program is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, version 3. This program 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 General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_12_R1;

View File

@@ -1,11 +1,17 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved. This program is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, version 3. This program 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 General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_12_R1;
@@ -74,8 +80,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
@Override
public String getPlayerDataID(final OfflinePlayer player) {
return player.getUniqueId().toString();
public String getPlayerDataID(final OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@Override

View File

@@ -1,40 +0,0 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved. This program is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, version 3. This program 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 General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_12_R1;
import net.minecraft.server.v1_12_R1.ContainerChest;
import net.minecraft.server.v1_12_R1.EntityHuman;
import net.minecraft.server.v1_12_R1.IInventory;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
public SilentContainerChest(final PlayerInventory playerInventory, final IInventory iInventory,
final EntityHuman entityHuman) {
super(playerInventory, iInventory, entityHuman);
// Send close signal
iInventory.closeContainer(entityHuman);
}
@Override
public void b(final EntityHuman entityHuman) {
// Don't send close signal twice, might screw up
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != ItemStack.a) {
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(ItemStack.a);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -1,57 +0,0 @@
package com.lishid.openinv.internal.v1_12_R1;
import java.lang.reflect.Field;
import net.minecraft.server.v1_12_R1.ContainerShulkerBox;
import net.minecraft.server.v1_12_R1.EntityHuman;
import net.minecraft.server.v1_12_R1.IInventory;
import net.minecraft.server.v1_12_R1.ItemStack;
import net.minecraft.server.v1_12_R1.PlayerInventory;
import net.minecraft.server.v1_12_R1.TileEntityShulkerBox;
public class SilentContainerShulkerBox extends ContainerShulkerBox {
private static Field fieldShulkerActionData;
private static Field exposeOpenStatus() throws NoSuchFieldException, SecurityException {
if (SilentContainerShulkerBox.fieldShulkerActionData == null) {
SilentContainerShulkerBox.fieldShulkerActionData = TileEntityShulkerBox.class
.getDeclaredField("h");
SilentContainerShulkerBox.fieldShulkerActionData.setAccessible(true);
}
return SilentContainerShulkerBox.fieldShulkerActionData;
}
public static Integer getOpenValue(final TileEntityShulkerBox tileShulkerBox) {
try {
return (Integer) SilentContainerShulkerBox.exposeOpenStatus().get(tileShulkerBox);
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
public static void setOpenValue(final TileEntityShulkerBox tileShulkerBox, final Object value) {
try {
SilentContainerShulkerBox.exposeOpenStatus().set(tileShulkerBox, value);
} catch (Exception e) {
e.printStackTrace();
}
}
public SilentContainerShulkerBox(final PlayerInventory playerInventory,
final IInventory iInventory, final EntityHuman entityHuman) {
super(playerInventory, iInventory, entityHuman);
}
@Override
public void b(final EntityHuman entityHuman) {
PlayerInventory playerinventory = entityHuman.inventory;
if (!playerinventory.getCarried().isEmpty()) {
entityHuman.drop(playerinventory.getCarried(), false);
playerinventory.setCarried(ItemStack.a);
}
}
}

View File

@@ -1,11 +1,17 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved. This program is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, version 3. This program 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 General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_12_R1;
@@ -32,12 +38,13 @@ public class SpecialEnderChest extends InventorySubcontainer
private final InventoryEnderChest enderChest;
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialEnderChest(final Player player, final Boolean online) {
super(PlayerDataManager.getHandle(player).getEnderChest().getName(),
PlayerDataManager.getHandle(player).getEnderChest().hasCustomName(),
PlayerDataManager.getHandle(player).getEnderChest().getSize());
this.playerOnline = online;
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.enderChest = nmsPlayer.getEnderChest();
this.bukkitOwner = nmsPlayer.getBukkitEntity();
@@ -64,13 +71,8 @@ public class SpecialEnderChest extends InventorySubcontainer
Field field = InventorySubcontainer.class.getField("items");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(subcontainer, list);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (SecurityException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException
| IllegalAccessException e) {
e.printStackTrace();
}
}

View File

@@ -1,11 +1,17 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved. This program is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public License as published
* by the Free Software Foundation, version 3. This program 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 General Public License along with this program. If not, see
* <http://www.gnu.org/licenses/>.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_12_R1;
@@ -30,7 +36,7 @@ import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftInventory;
public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialPlayerInventory(final Player bukkitPlayer, final Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));
@@ -82,6 +88,11 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
return this.player.getName();
}
@Override
public boolean hasCustomName() {
return true;
}
private int getReversedArmorSlotNum(final int i) {
if (i == 0) {
return 3;
@@ -138,10 +149,8 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
return;
}
if (list != null) {
list.set(i, itemstack);
}
}
private void setItemArrays(final PlayerInventory inventory, final NonNullList<ItemStack> items,
final NonNullList<ItemStack> armor, final NonNullList<ItemStack> extraSlots) {
@@ -150,32 +159,28 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
Field modifiers = Field.class.getDeclaredField("modifiers");
modifiers.setAccessible(true);
// Access and replace main inventory array
// Access and replace main inventory list
Field field = PlayerInventory.class.getField("items");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, items);
// Access and replace armor inventory array
// Access and replace armor inventory list
field = PlayerInventory.class.getField("armor");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, armor);
// Access and replace offhand inventory array
// Access and replace offhand inventory list
field = PlayerInventory.class.getField("extraSlots");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, extraSlots);
// Access and replace array containing all inventory arrays
field = PlayerInventory.class.getDeclaredField("g");
// Access and replace list containing all inventory lists
field = PlayerInventory.class.getDeclaredField("f");
field.setAccessible(true);
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, Arrays.asList(new NonNullList[] { items, armor, extraSlots }));
} catch (NoSuchFieldException e) {
// Unable to set final fields to item arrays, we're screwed. Noisily fail.
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
field.set(inventory, Arrays.asList(items, armor, extraSlots));
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
// Unable to set final fields to item lists, we're screwed. Noisily fail.
e.printStackTrace();
}
}
@@ -189,7 +194,6 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
public void setPlayerOnline(final Player player) {
if (!this.playerOnline) {
this.player = PlayerDataManager.getHandle(player);
;
this.setItemArrays(this.player.inventory, this.items, this.armor, this.extraSlots);
this.playerOnline = true;
}
@@ -217,7 +221,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
return ItemStack.a;
}
return list == null || list.get(i).isEmpty() ? ItemStack.a : ContainerUtil.a(list, i, j);
return list.get(i).isEmpty() ? ItemStack.a : ContainerUtil.a(list, i, j);
}
@Override
@@ -242,7 +246,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
return ItemStack.a;
}
if (list != null && !list.get(i).isEmpty()) {
if (!list.get(i).isEmpty()) {
ItemStack itemstack = list.get(i);
list.set(i, ItemStack.a);

57
internal/v1_13_R1/pom.xml Normal file
View File

@@ -0,0 +1,57 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvadapter1_13_R1</artifactId>
<name>OpenInvAdapter1_13_R1</name>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.13-pre7-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.3.4-A1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,293 @@
/*
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_13_R1;
import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import net.minecraft.server.v1_13_R1.BlockChestTrapped;
import net.minecraft.server.v1_13_R1.ChatMessage;
import net.minecraft.server.v1_13_R1.VoxelShapes;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryView;
import net.minecraft.server.v1_13_R1.AxisAlignedBB;
import net.minecraft.server.v1_13_R1.Block;
import net.minecraft.server.v1_13_R1.BlockChest;
import net.minecraft.server.v1_13_R1.BlockEnderChest;
import net.minecraft.server.v1_13_R1.BlockPosition;
import net.minecraft.server.v1_13_R1.BlockShulkerBox;
import net.minecraft.server.v1_13_R1.Entity;
import net.minecraft.server.v1_13_R1.EntityOcelot;
import net.minecraft.server.v1_13_R1.EntityPlayer;
import net.minecraft.server.v1_13_R1.EnumDirection;
import net.minecraft.server.v1_13_R1.EnumGamemode;
import net.minecraft.server.v1_13_R1.IBlockData;
import net.minecraft.server.v1_13_R1.ITileInventory;
import net.minecraft.server.v1_13_R1.InventoryEnderChest;
import net.minecraft.server.v1_13_R1.InventoryLargeChest;
import net.minecraft.server.v1_13_R1.PlayerInteractManager;
import net.minecraft.server.v1_13_R1.TileEntity;
import net.minecraft.server.v1_13_R1.TileEntityChest;
import net.minecraft.server.v1_13_R1.TileEntityEnderChest;
import net.minecraft.server.v1_13_R1.TileEntityShulkerBox;
import net.minecraft.server.v1_13_R1.World;
public class AnySilentContainer implements IAnySilentContainer {
private Field playerInteractManagerGamemode;
public AnySilentContainer() {
try {
this.playerInteractManagerGamemode = PlayerInteractManager.class.getDeclaredField("gamemode");
this.playerInteractManagerGamemode.setAccessible(true);
} catch (NoSuchFieldException | SecurityException e) {
System.err.println("[OpenInv] Unable to directly write player gamemode! SilentChest will fail.");
e.printStackTrace();
}
}
@Override
public boolean isAnySilentContainer(final org.bukkit.block.Block block) {
if (block.getType() == Material.ENDER_CHEST) {
return true;
}
BlockState state = block.getState();
return state instanceof org.bukkit.block.Chest
|| state instanceof org.bukkit.block.ShulkerBox;
}
@Override
public boolean isAnyContainerNeeded(final Player p, final org.bukkit.block.Block b) {
EntityPlayer player = com.lishid.openinv.internal.v1_13_R1.PlayerDataManager.getHandle(p);
World world = player.world;
BlockPosition blockPosition = new BlockPosition(b.getX(), b.getY(), b.getZ());
IBlockData blockData = world.getType(blockPosition);
Block block = blockData.getBlock();
if (block instanceof BlockShulkerBox) {
return this.isBlockedShulkerBox(world, blockPosition, blockData);
}
if (block instanceof BlockEnderChest) {
// Ender chests are not blocked by ocelots.
return world.getType(blockPosition.up()).isOccluding();
}
// Check if chest is blocked or has an ocelot on top
if (this.isBlockedChest(world, blockPosition)) {
return true;
}
// Check for matching adjacent chests that are blocked or have an ocelot on top
for (EnumDirection localEnumDirection : EnumDirection.EnumDirectionLimit.HORIZONTAL) {
BlockPosition localBlockPosition = blockPosition.shift(localEnumDirection);
Block localBlock = world.getType(localBlockPosition).getBlock();
if (localBlock != block) {
continue;
}
TileEntity localTileEntity = world.getTileEntity(localBlockPosition);
if (!(localTileEntity instanceof TileEntityChest)) {
continue;
}
if (this.isBlockedChest(world, localBlockPosition)) {
return true;
}
}
return false;
}
private boolean isBlockedShulkerBox(final World world, final BlockPosition blockPosition,
final IBlockData blockData) {
// For reference, look at net.minecraft.server.BlockShulkerBox
TileEntity tile = world.getTileEntity(blockPosition);
if (!(tile instanceof TileEntityShulkerBox)) {
return false;
}
EnumDirection enumDirection = blockData.get(BlockShulkerBox.a);
if (((TileEntityShulkerBox) tile).r() == TileEntityShulkerBox.AnimationPhase.CLOSED) {
AxisAlignedBB axisAlignedBB = VoxelShapes.b().a()
.b(0.5F * enumDirection.getAdjacentX(), 0.5F * enumDirection.getAdjacentY(), 0.5F * enumDirection.getAdjacentZ())
.a(enumDirection.getAdjacentX(), enumDirection.getAdjacentY(), enumDirection.getAdjacentZ());
return !world.getCubes(null, axisAlignedBB.a(blockPosition.shift(enumDirection)));
}
return false;
}
private boolean isBlockedChest(final World world, final BlockPosition blockPosition) {
// For reference, loot at net.minecraft.server.BlockChest
return world.getType(blockPosition.up()).isOccluding() || this.hasOcelotOnTop(world, blockPosition);
}
private boolean hasOcelotOnTop(final World world, final BlockPosition blockPosition) {
for (Entity entity : world.a(EntityOcelot.class,
new AxisAlignedBB(blockPosition.getX(), blockPosition.getY() + 1,
blockPosition.getZ(), blockPosition.getX() + 1, blockPosition.getY() + 2,
blockPosition.getZ() + 1))) {
EntityOcelot entityOcelot = (EntityOcelot) entity;
if (entityOcelot.isSitting()) {
return true;
}
}
return false;
}
@Override
public boolean activateContainer(final Player bukkitPlayer, final boolean silentchest,
final org.bukkit.block.Block bukkitBlock) {
// Silent ender chest is API-only
if (silentchest && bukkitBlock.getType() == Material.ENDER_CHEST) {
bukkitPlayer.openInventory(bukkitPlayer.getEnderChest());
bukkitPlayer.incrementStatistic(Statistic.ENDERCHEST_OPENED);
return true;
}
EntityPlayer player = com.lishid.openinv.internal.v1_13_R1.PlayerDataManager.getHandle(bukkitPlayer);
final World world = player.world;
final BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
final Object tile = world.getTileEntity(blockPosition);
if (tile == null) {
return false;
}
if (tile instanceof TileEntityEnderChest) {
// Anychest ender chest. See net.minecraft.server.BlockEnderChest
InventoryEnderChest enderChest = player.getEnderChest();
enderChest.a((TileEntityEnderChest) tile);
player.openContainer(enderChest);
bukkitPlayer.incrementStatistic(Statistic.ENDERCHEST_OPENED);
return true;
}
if (!(tile instanceof ITileInventory)) {
return false;
}
ITileInventory tileInventory = (ITileInventory) tile;
Block block = world.getType(blockPosition).getBlock();
if (block instanceof BlockChest) {
for (EnumDirection localEnumDirection : EnumDirection.EnumDirectionLimit.HORIZONTAL) {
BlockPosition localBlockPosition = blockPosition.shift(localEnumDirection);
Block localBlock = world.getType(localBlockPosition).getBlock();
if (localBlock != block) {
continue;
}
TileEntity localTileEntity = world.getTileEntity(localBlockPosition);
if (!(localTileEntity instanceof TileEntityChest)) {
continue;
}
if (localEnumDirection == EnumDirection.WEST
|| localEnumDirection == EnumDirection.NORTH) {
tileInventory = new InventoryLargeChest(new ChatMessage("container.chestDouble"),
(TileEntityChest) localTileEntity, tileInventory);
} else {
tileInventory = new InventoryLargeChest(new ChatMessage("container.chestDouble"),
tileInventory, (TileEntityChest) localTileEntity);
}
break;
}
if (block instanceof BlockChestTrapped) {
bukkitPlayer.incrementStatistic(Statistic.TRAPPED_CHEST_TRIGGERED);
} else {
bukkitPlayer.incrementStatistic(Statistic.CHEST_OPENED);
}
}
if (block instanceof BlockShulkerBox) {
bukkitPlayer.incrementStatistic(Statistic.SHULKER_BOX_OPENED);
}
// AnyChest only - SilentChest not active, container unsupported, or unnecessary.
if (!silentchest || player.playerInteractManager.getGameMode() == EnumGamemode.SPECTATOR) {
player.openContainer(tileInventory);
return true;
}
// SilentChest requires access to setting players' gamemode directly.
if (this.playerInteractManagerGamemode == null) {
return false;
}
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
this.forceGameMode(player, EnumGamemode.SPECTATOR);
player.openContainer(tileInventory);
this.forceGameMode(player, gamemode);
return true;
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {
if (this.playerInteractManagerGamemode == null) {
return;
}
InventoryView view = bukkitPlayer.getOpenInventory();
switch (view.getType()) {
case CHEST:
case ENDER_CHEST:
case SHULKER_BOX:
break;
default:
return;
}
EntityPlayer player = com.lishid.openinv.internal.v1_13_R1.PlayerDataManager.getHandle(bukkitPlayer);
EnumGamemode gamemode = player.playerInteractManager.getGameMode();
this.forceGameMode(player, EnumGamemode.SPECTATOR);
player.activeContainer.b(player);
player.activeContainer = player.defaultContainer;
this.forceGameMode(player, gamemode);
}
private void forceGameMode(final EntityPlayer player, final EnumGamemode gameMode) {
if (this.playerInteractManagerGamemode == null) {
// No need to warn repeatedly, error on startup and lack of function should be enough.
return;
}
try {
if (!this.playerInteractManagerGamemode.isAccessible()) {
// Just in case, ensure accessible.
this.playerInteractManagerGamemode.setAccessible(true);
}
this.playerInteractManagerGamemode.set(player.playerInteractManager, gameMode);
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
}

View File

@@ -0,0 +1,80 @@
/*
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_13_R1;
import com.lishid.openinv.internal.IInventoryAccess;
import com.lishid.openinv.internal.ISpecialEnderChest;
import com.lishid.openinv.internal.ISpecialPlayerInventory;
import com.lishid.openinv.util.InternalAccessor;
import org.bukkit.inventory.Inventory;
import net.minecraft.server.v1_13_R1.IInventory;
import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftInventory;
public class InventoryAccess implements IInventoryAccess {
@Override
public ISpecialEnderChest getSpecialEnderChest(final Inventory inventory) {
IInventory inv;
if (inventory instanceof CraftInventory) {
inv = ((CraftInventory) inventory).getInventory();
} else {
inv = InternalAccessor.grabFieldOfTypeFromObject(IInventory.class, inventory);
}
if (inv instanceof com.lishid.openinv.internal.v1_13_R1.SpecialEnderChest) {
return (com.lishid.openinv.internal.v1_13_R1.SpecialEnderChest) inv;
}
return null;
}
@Override
public ISpecialPlayerInventory getSpecialPlayerInventory(final Inventory inventory) {
IInventory inv;
if (inventory instanceof CraftInventory) {
inv = ((CraftInventory) inventory).getInventory();
} else {
inv = InternalAccessor.grabFieldOfTypeFromObject(IInventory.class, inventory);
}
if (inv instanceof com.lishid.openinv.internal.v1_13_R1.SpecialPlayerInventory) {
return (com.lishid.openinv.internal.v1_13_R1.SpecialPlayerInventory) inv;
}
return null;
}
@Override
public boolean isSpecialEnderChest(final Inventory inventory) {
if (inventory instanceof CraftInventory) {
return ((CraftInventory) inventory).getInventory() instanceof ISpecialEnderChest;
}
return InternalAccessor.grabFieldOfTypeFromObject(IInventory.class,
inventory) instanceof ISpecialEnderChest;
}
@Override
public boolean isSpecialPlayerInventory(final Inventory inventory) {
if (inventory instanceof CraftInventory) {
return ((CraftInventory) inventory).getInventory() instanceof ISpecialPlayerInventory;
}
return InternalAccessor.grabFieldOfTypeFromObject(IInventory.class,
inventory) instanceof ISpecialPlayerInventory;
}
}

View File

@@ -0,0 +1,109 @@
/*
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_13_R1;
import java.util.Collection;
import java.util.UUID;
import com.lishid.openinv.internal.IPlayerDataManager;
import com.mojang.authlib.GameProfile;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import net.minecraft.server.v1_13_R1.EntityPlayer;
import net.minecraft.server.v1_13_R1.MinecraftServer;
import net.minecraft.server.v1_13_R1.PlayerInteractManager;
import org.bukkit.craftbukkit.v1_13_R1.CraftServer;
import org.bukkit.craftbukkit.v1_13_R1.entity.CraftPlayer;
public class PlayerDataManager implements IPlayerDataManager {
public static EntityPlayer getHandle(final Player player) {
if (player instanceof CraftPlayer) {
return ((CraftPlayer) player).getHandle();
}
Server server = player.getServer();
EntityPlayer nmsPlayer = null;
if (server instanceof CraftServer) {
nmsPlayer = ((CraftServer) server).getHandle().getPlayer(player.getName());
}
if (nmsPlayer == null) {
// Could use reflection to examine fields, but it's honestly not worth the bother.
throw new RuntimeException("Unable to fetch EntityPlayer from provided Player implementation");
}
return nmsPlayer;
}
@Override
public Collection<? extends Player> getOnlinePlayers() {
return Bukkit.getOnlinePlayers();
}
@Override
public OfflinePlayer getPlayerByID(final String identifier) {
try {
UUID uuid = UUID.fromString(identifier);
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
// Ensure player is a real player, otherwise return null
if (player == null || !player.hasPlayedBefore() && !player.isOnline()) {
return null;
}
return player;
} catch (IllegalArgumentException e) {
// Not a UUID
return null;
}
}
@Override
public String getPlayerDataID(final OfflinePlayer offline) {
return offline.getUniqueId().toString();
}
@Override
public Player loadPlayer(final OfflinePlayer offline) {
// Ensure player has data
if (offline == null || !offline.hasPlayedBefore()) {
return null;
}
// Create a profile and entity to load the player data
GameProfile profile = new GameProfile(offline.getUniqueId(), offline.getName());
MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile,
new PlayerInteractManager(server.getWorldServer(0)));
// Get the bukkit entity
Player target = entity == null ? null : entity.getBukkitEntity();
if (target != null) {
// Load data
target.loadData();
}
// Return the entity
return target;
}
}

View File

@@ -0,0 +1,99 @@
/*
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_13_R1;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.List;
import com.lishid.openinv.internal.ISpecialEnderChest;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import net.minecraft.server.v1_13_R1.EntityPlayer;
import net.minecraft.server.v1_13_R1.IInventory;
import net.minecraft.server.v1_13_R1.InventoryEnderChest;
import net.minecraft.server.v1_13_R1.InventorySubcontainer;
import net.minecraft.server.v1_13_R1.ItemStack;
import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftInventory;
public class SpecialEnderChest extends InventorySubcontainer
implements IInventory, ISpecialEnderChest {
private final InventoryEnderChest enderChest;
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline;
public SpecialEnderChest(final Player player, final Boolean online) {
super(PlayerDataManager.getHandle(player).getEnderChest().getDisplayName(),
PlayerDataManager.getHandle(player).getEnderChest().getSize(), player);
this.playerOnline = online;
this.enderChest = PlayerDataManager.getHandle(player).getEnderChest();
this.setItemLists(this, this.enderChest.getContents());
}
@Override
public Inventory getBukkitInventory() {
return this.inventory;
}
@Override
public boolean isInUse() {
return !this.getViewers().isEmpty();
}
private void setItemLists(final InventorySubcontainer subcontainer, final List<ItemStack> list) {
try {
// Prepare to remove final modifier
Field modifiers = Field.class.getDeclaredField("modifiers");
modifiers.setAccessible(true);
// Access and replace main inventory array
Field field = InventorySubcontainer.class.getField("items");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(subcontainer, list);
} catch (NoSuchFieldException | SecurityException | IllegalArgumentException
| IllegalAccessException e) {
e.printStackTrace();
}
}
@Override
public void setPlayerOffline() {
this.playerOnline = false;
}
@Override
public void setPlayerOnline(final Player player) {
if (!this.playerOnline) {
try {
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.bukkitOwner = nmsPlayer.getBukkitEntity();
this.setItemLists(nmsPlayer.getEnderChest(), this.items);
} catch (Exception e) {}
this.playerOnline = true;
}
}
@Override
public void update() {
super.update();
this.enderChest.update();
}
}

View File

@@ -0,0 +1,258 @@
/*
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program 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 General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.lishid.openinv.internal.v1_13_R1;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Arrays;
import com.lishid.openinv.internal.ISpecialPlayerInventory;
import net.minecraft.server.v1_13_R1.ChatMessage;
import net.minecraft.server.v1_13_R1.IChatBaseComponent;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import net.minecraft.server.v1_13_R1.ContainerUtil;
import net.minecraft.server.v1_13_R1.EntityHuman;
import net.minecraft.server.v1_13_R1.ItemStack;
import net.minecraft.server.v1_13_R1.NonNullList;
import net.minecraft.server.v1_13_R1.PlayerInventory;
import org.bukkit.craftbukkit.v1_13_R1.inventory.CraftInventory;
public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline;
public SpecialPlayerInventory(final Player bukkitPlayer, final Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));
this.playerOnline = online;
this.setItemArrays(this, this.player.inventory.items, this.player.inventory.armor,
this.player.inventory.extraSlots);
}
@Override
public boolean a(final EntityHuman entityhuman) {
return true;
}
@Override
public Inventory getBukkitInventory() {
return this.inventory;
}
@Override
public ItemStack getItem(int i) {
NonNullList<ItemStack> list = this.items;
if (i >= list.size()) {
i -= list.size();
list = this.armor;
} else {
i = this.getReversedItemSlotNum(i);
}
if (i >= list.size()) {
i -= list.size();
list = this.extraSlots;
} else if (list == this.armor) {
i = this.getReversedArmorSlotNum(i);
}
if (i >= list.size()) {
return ItemStack.a;
}
return list.get(i);
}
@Override
public IChatBaseComponent getDisplayName() {
return new ChatMessage(this.player.getName());
}
@Override
public boolean hasCustomName() {
return true;
}
private int getReversedArmorSlotNum(final int i) {
if (i == 0) {
return 3;
}
if (i == 1) {
return 2;
}
if (i == 2) {
return 1;
}
if (i == 3) {
return 0;
}
return i;
}
private int getReversedItemSlotNum(final int i) {
if (i >= 27) {
return i - 27;
}
return i + 9;
}
@Override
public int getSize() {
return super.getSize() + 4;
}
@Override
public boolean isInUse() {
return !this.getViewers().isEmpty();
}
@Override
public void setItem(int i, final ItemStack itemstack) {
NonNullList<ItemStack> list = this.items;
if (i >= list.size()) {
i -= list.size();
list = this.armor;
} else {
i = this.getReversedItemSlotNum(i);
}
if (i >= list.size()) {
i -= list.size();
list = this.extraSlots;
} else if (list == this.armor) {
i = this.getReversedArmorSlotNum(i);
}
if (i >= list.size()) {
this.player.drop(itemstack, true);
return;
}
list.set(i, itemstack);
}
private void setItemArrays(final PlayerInventory inventory, final NonNullList<ItemStack> items,
final NonNullList<ItemStack> armor, final NonNullList<ItemStack> extraSlots) {
try {
// Prepare to remove final modifier
Field modifiers = Field.class.getDeclaredField("modifiers");
modifiers.setAccessible(true);
// Access and replace main inventory list
Field field = PlayerInventory.class.getField("items");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, items);
// Access and replace armor inventory list
field = PlayerInventory.class.getField("armor");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, armor);
// Access and replace offhand inventory list
field = PlayerInventory.class.getField("extraSlots");
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, extraSlots);
// Access and replace list containing all inventory lists
field = PlayerInventory.class.getDeclaredField("f");
field.setAccessible(true);
modifiers.setInt(field, field.getModifiers() & ~Modifier.FINAL);
field.set(inventory, Arrays.asList(items, armor, extraSlots));
} catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
// Unable to set final fields to item lists, we're screwed. Noisily fail.
e.printStackTrace();
}
}
@Override
public void setPlayerOffline() {
this.playerOnline = false;
}
@Override
public void setPlayerOnline(final Player player) {
if (!this.playerOnline) {
this.player = PlayerDataManager.getHandle(player);
this.setItemArrays(this.player.inventory, this.items, this.armor, this.extraSlots);
this.playerOnline = true;
}
}
@Override
public ItemStack splitStack(int i, final int j) {
NonNullList<ItemStack> list = this.items;
if (i >= list.size()) {
i -= list.size();
list = this.armor;
} else {
i = this.getReversedItemSlotNum(i);
}
if (i >= list.size()) {
i -= list.size();
list = this.extraSlots;
} else if (list == this.armor) {
i = this.getReversedArmorSlotNum(i);
}
if (i >= list.size()) {
return ItemStack.a;
}
return list.get(i).isEmpty() ? ItemStack.a : ContainerUtil.a(list, i, j);
}
@Override
public ItemStack splitWithoutUpdate(int i) {
NonNullList<ItemStack> list = this.items;
if (i >= list.size()) {
i -= list.size();
list = this.armor;
} else {
i = this.getReversedItemSlotNum(i);
}
if (i >= list.size()) {
i -= list.size();
list = this.extraSlots;
} else if (list == this.armor) {
i = this.getReversedArmorSlotNum(i);
}
if (i >= list.size()) {
return ItemStack.a;
}
if (!list.get(i).isEmpty()) {
ItemStack itemstack = list.get(i);
list.set(i, ItemStack.a);
return itemstack;
}
return ItemStack.a;
}
}

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvadapter1_4_R1</artifactId>
@@ -21,7 +37,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -60,8 +60,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
@Override
public String getPlayerDataID(OfflinePlayer player) {
return player.getName();
public String getPlayerDataID(OfflinePlayer offline) {
return offline.getName();
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@ import net.minecraft.server.v1_4_R1.IInventory;
import net.minecraft.server.v1_4_R1.ItemStack;
import net.minecraft.server.v1_4_R1.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
class SilentContainerChest extends ContainerChest {
public SilentContainerChest(IInventory i1, IInventory i2) {
super(i1, i2);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,13 +42,14 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
private final InventoryEnderChest enderChest;
private final CraftInventory inventory = new CraftInventory(this);
private final List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private boolean playerOnline = false;
private boolean playerOnline;
private CraftPlayer owner;
private int maxStack = MAX_STACK;
public SpecialEnderChest(Player player, Boolean online) {
super(PlayerDataManager.getHandle(player).getEnderChest().getName(),
PlayerDataManager.getHandle(player).getEnderChest().getSize());
this.playerOnline = online;
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.enderChest = nmsPlayer.getEnderChest();
this.owner = nmsPlayer.getBukkitEntity();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
private final ItemStack[] extra = new ItemStack[5];
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialPlayerInventory(Player bukkitPlayer, Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvadapter1_5_R2</artifactId>
@@ -21,7 +37,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -59,8 +59,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
@Override
public String getPlayerDataID(OfflinePlayer player) {
return player.getName();
public String getPlayerDataID(OfflinePlayer offline) {
return offline.getName();
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@ import net.minecraft.server.v1_5_R2.IInventory;
import net.minecraft.server.v1_5_R2.ItemStack;
import net.minecraft.server.v1_5_R2.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
class SilentContainerChest extends ContainerChest {
public SilentContainerChest(IInventory i1, IInventory i2) {
super(i1, i2);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
private final InventoryEnderChest enderChest;
private final CraftInventory inventory = new CraftInventory(this);
private final List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private boolean playerOnline = false;
private boolean playerOnline;
private CraftPlayer owner;
private int maxStack = MAX_STACK;
@@ -50,6 +50,7 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
super(PlayerDataManager.getHandle(player).getEnderChest().getName(),
PlayerDataManager.getHandle(player).getEnderChest().c(),
PlayerDataManager.getHandle(player).getEnderChest().getSize());
this.playerOnline = online;
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.enderChest = nmsPlayer.getEnderChest();
this.owner = nmsPlayer.getBukkitEntity();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
private final ItemStack[] extra = new ItemStack[5];
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialPlayerInventory(Player bukkitPlayer, Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvadapter1_5_R3</artifactId>
@@ -21,7 +37,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -59,8 +59,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
@Override
public String getPlayerDataID(OfflinePlayer player) {
return player.getName();
public String getPlayerDataID(OfflinePlayer offline) {
return offline.getName();
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@ import net.minecraft.server.v1_5_R3.IInventory;
import net.minecraft.server.v1_5_R3.ItemStack;
import net.minecraft.server.v1_5_R3.PlayerInventory;
public class SilentContainerChest extends ContainerChest { public IInventory inv;
class SilentContainerChest extends ContainerChest {
public SilentContainerChest(IInventory i1, IInventory i2) {
super(i1, i2);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
private final InventoryEnderChest enderChest;
private final CraftInventory inventory = new CraftInventory(this);
private final List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private boolean playerOnline = false;
private boolean playerOnline;
private CraftPlayer owner;
private int maxStack = MAX_STACK;
@@ -50,6 +50,7 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
super(PlayerDataManager.getHandle(player).getEnderChest().getName(),
PlayerDataManager.getHandle(player).getEnderChest().c(),
PlayerDataManager.getHandle(player).getEnderChest().getSize());
this.playerOnline = online;
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.enderChest = nmsPlayer.getEnderChest();
this.owner = nmsPlayer.getBukkitEntity();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
private final ItemStack[] extra = new ItemStack[5];
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialPlayerInventory(Player bukkitPlayer, Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvadapter1_6_R1</artifactId>
@@ -21,7 +37,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -59,8 +59,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
@Override
public String getPlayerDataID(OfflinePlayer player) {
return player.getName();
public String getPlayerDataID(OfflinePlayer offline) {
return offline.getName();
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@ import net.minecraft.server.v1_6_R1.IInventory;
import net.minecraft.server.v1_6_R1.ItemStack;
import net.minecraft.server.v1_6_R1.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
class SilentContainerChest extends ContainerChest {
public SilentContainerChest(IInventory i1, IInventory i2) {
super(i1, i2);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
private final InventoryEnderChest enderChest;
private final CraftInventory inventory = new CraftInventory(this);
private final List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private boolean playerOnline = false;
private boolean playerOnline;
private CraftPlayer owner;
private int maxStack = MAX_STACK;
@@ -50,6 +50,7 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
super(PlayerDataManager.getHandle(player).getEnderChest().getName(),
PlayerDataManager.getHandle(player).getEnderChest().c(),
PlayerDataManager.getHandle(player).getEnderChest().getSize());
this.playerOnline = online;
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.enderChest = nmsPlayer.getEnderChest();
this.owner = nmsPlayer.getBukkitEntity();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
private final ItemStack[] extra = new ItemStack[5];
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialPlayerInventory(Player bukkitPlayer, Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvadapter1_6_R2</artifactId>
@@ -21,7 +37,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -59,8 +59,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
@Override
public String getPlayerDataID(OfflinePlayer player) {
return player.getName();
public String getPlayerDataID(OfflinePlayer offline) {
return offline.getName();
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@ import net.minecraft.server.v1_6_R2.IInventory;
import net.minecraft.server.v1_6_R2.ItemStack;
import net.minecraft.server.v1_6_R2.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
class SilentContainerChest extends ContainerChest {
public SilentContainerChest(IInventory i1, IInventory i2) {
super(i1, i2);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
private final InventoryEnderChest enderChest;
private final CraftInventory inventory = new CraftInventory(this);
private final List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private boolean playerOnline = false;
private boolean playerOnline;
private CraftPlayer owner;
private int maxStack = MAX_STACK;
@@ -50,6 +50,7 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
super(PlayerDataManager.getHandle(player).getEnderChest().getName(),
PlayerDataManager.getHandle(player).getEnderChest().c(),
PlayerDataManager.getHandle(player).getEnderChest().getSize());
this.playerOnline = online;
EntityPlayer nmsPlayer = PlayerDataManager.getHandle(player);
this.enderChest = nmsPlayer.getEnderChest();
this.owner = nmsPlayer.getBukkitEntity();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,7 +30,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
private final ItemStack[] extra = new ItemStack[5];
private final CraftInventory inventory = new CraftInventory(this);
private boolean playerOnline = false;
private boolean playerOnline;
public SpecialPlayerInventory(Player bukkitPlayer, Boolean online) {
super(PlayerDataManager.getHandle(bukkitPlayer));

View File

@@ -1,3 +1,19 @@
<!--
~ Copyright (C) 2011-2018 lishid. All rights reserved.
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program 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 General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
@@ -5,7 +21,7 @@
<parent>
<groupId>com.lishid</groupId>
<artifactId>openinvinternal</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</parent>
<artifactId>openinvadapter1_6_R3</artifactId>
@@ -21,7 +37,7 @@
<dependency>
<groupId>com.lishid</groupId>
<artifactId>openinvcommon</artifactId>
<version>3.2.0</version>
<version>3.3.4-A1</version>
</dependency>
</dependencies>

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -165,4 +165,7 @@ public class AnySilentContainer implements IAnySilentContainer {
}
}
@Override
public void deactivateContainer(final Player bukkitPlayer) {}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -59,8 +59,8 @@ public class PlayerDataManager implements IPlayerDataManager {
}
@Override
public String getPlayerDataID(OfflinePlayer player) {
return player.getName();
public String getPlayerDataID(OfflinePlayer offline) {
return offline.getName();
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2011-2014 lishid. All rights reserved.
* Copyright (C) 2011-2018 lishid. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@ import net.minecraft.server.v1_6_R3.IInventory;
import net.minecraft.server.v1_6_R3.ItemStack;
import net.minecraft.server.v1_6_R3.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
class SilentContainerChest extends ContainerChest {
public SilentContainerChest(IInventory i1, IInventory i2) {
super(i1, i2);

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