forked from EssentialsX/Essentials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix legacy compatibility (Fixes EssentialsX#5851)
- Loading branch information
Showing
7 changed files
with
116 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...s/1_12Provider/src/main/java/net/ess3/provider/providers/LegacyInventoryViewProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.ess3.provider.providers; | ||
|
||
import net.ess3.provider.InventoryViewProvider; | ||
import org.bukkit.inventory.Inventory; | ||
import org.bukkit.inventory.InventoryView; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
public class LegacyInventoryViewProvider implements InventoryViewProvider { | ||
@Override | ||
public Inventory getTopInventory(InventoryView view) { | ||
return view.getTopInventory(); | ||
} | ||
|
||
@Override | ||
public Inventory getBottomInventory(InventoryView view) { | ||
return view.getBottomInventory(); | ||
} | ||
|
||
@Override | ||
public void setItem(InventoryView view, int slot, ItemStack item) { | ||
view.setItem(slot, item); | ||
} | ||
|
||
@Override | ||
public void close(InventoryView view) { | ||
view.close(); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "Legacy InventoryView Abstract Class ABI Provider"; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
providers/BaseProviders/src/main/java/net/ess3/provider/InventoryViewProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package net.ess3.provider; | ||
|
||
import org.bukkit.inventory.Inventory; | ||
import org.bukkit.inventory.InventoryView; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
/** | ||
* Bukkit changed InventoryView to an interface in 1.21. We need to use providers | ||
* to avoid breaking ABI compatibility with earlier versions of Bukkit. | ||
*/ | ||
public interface InventoryViewProvider extends Provider { | ||
Inventory getTopInventory(InventoryView view); | ||
|
||
void close(InventoryView view); | ||
|
||
Inventory getBottomInventory(InventoryView view); | ||
|
||
void setItem(InventoryView view, int slot, ItemStack item); | ||
} |
33 changes: 33 additions & 0 deletions
33
...rs/BaseProviders/src/main/java/net/ess3/provider/providers/BaseInventoryViewProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package net.ess3.provider.providers; | ||
|
||
import net.ess3.provider.InventoryViewProvider; | ||
import org.bukkit.inventory.Inventory; | ||
import org.bukkit.inventory.InventoryView; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
public class BaseInventoryViewProvider implements InventoryViewProvider { | ||
@Override | ||
public Inventory getTopInventory(InventoryView view) { | ||
return view.getTopInventory(); | ||
} | ||
|
||
@Override | ||
public Inventory getBottomInventory(InventoryView view) { | ||
return view.getBottomInventory(); | ||
} | ||
|
||
@Override | ||
public void setItem(InventoryView view, int slot, ItemStack item) { | ||
view.setItem(slot, item); | ||
} | ||
|
||
@Override | ||
public void close(InventoryView view) { | ||
view.close(); | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return "1.21+ InventoryView Interface ABI Provider"; | ||
} | ||
} |