-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c827b16
commit 16cbe60
Showing
36 changed files
with
808 additions
and
276 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
76 changes: 24 additions & 52 deletions
76
...++_Common/src/main/java/com/janboerman/invsee/spigot/api/EnderSpectatorInventoryView.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 |
---|---|---|
@@ -1,52 +1,24 @@ | ||
package com.janboerman.invsee.spigot.api; | ||
|
||
import com.janboerman.invsee.spigot.api.template.EnderChestSlot; | ||
import org.bukkit.event.inventory.InventoryType; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
/** | ||
* Represents an open window for an {@link EnderSpectatorInventory}. | ||
*/ | ||
public abstract class EnderSpectatorInventoryView extends SpectatorInventoryView<EnderChestSlot> { | ||
|
||
protected EnderSpectatorInventoryView(CreationOptions<EnderChestSlot> creationOptions) { | ||
super(creationOptions); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public abstract EnderSpectatorInventory getTopInventory(); | ||
|
||
/** Sets the item in the desired slot of the InventoryView. If the slot is in the top inventory, then the inventory slot will be computed using | ||
* {@code getMirror().getSlot(slot).defaultIndex()}. | ||
* @see com.janboerman.invsee.spigot.api.template.Mirror */ | ||
@Override | ||
public void setItem(int slot, ItemStack item) { | ||
if (slot == -999 || slot >= getTopInventory().getSize()) { | ||
super.setItem(slot, item); | ||
} else { | ||
EnderChestSlot ecSlot = getMirror().getSlot(slot); | ||
if (ecSlot != null) super.setItem(ecSlot.defaultIndex(), item); | ||
} | ||
} | ||
|
||
/** Gets the item in the desired slot of the InventoryView. If the slot is in the top inventory, then the inventory slot will be computed using | ||
* {@code getMirror().getSlot(slot).defaultIndex()}. | ||
* @see com.janboerman.invsee.spigot.api.template.Mirror */ | ||
@Override | ||
public ItemStack getItem(int slot) { | ||
if (slot == -999 || slot >= getTopInventory().getSize()) { | ||
return super.getItem(slot); | ||
} else { | ||
EnderChestSlot ecSlot = getMirror().getSlot(slot); | ||
return ecSlot == null ? null : super.getItem(ecSlot.defaultIndex()); | ||
} | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public InventoryType getType() { | ||
return InventoryType.CHEST; | ||
} | ||
|
||
} | ||
package com.janboerman.invsee.spigot.api; | ||
|
||
import com.janboerman.invsee.spigot.api.template.EnderChestSlot; | ||
|
||
import org.bukkit.event.inventory.InventoryType; | ||
|
||
/** | ||
* Represents an open window for an {@link EnderSpectatorInventory}. | ||
*/ | ||
public interface EnderSpectatorInventoryView extends SpectatorInventoryView<EnderChestSlot> { | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public EnderSpectatorInventory getTopInventory(); | ||
|
||
/** | ||
* Get the inventory type. | ||
* @return the inventory type | ||
*/ | ||
public default InventoryType getType() { | ||
return InventoryType.CHEST; | ||
} | ||
|
||
} |
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
73 changes: 21 additions & 52 deletions
73
...e++_Common/src/main/java/com/janboerman/invsee/spigot/api/MainSpectatorInventoryView.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 |
---|---|---|
@@ -1,52 +1,21 @@ | ||
package com.janboerman.invsee.spigot.api; | ||
|
||
import com.janboerman.invsee.spigot.api.template.PlayerInventorySlot; | ||
import org.bukkit.event.inventory.InventoryType; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
/** | ||
* Represents an open window for a {@link MainSpectatorInventory}. | ||
*/ | ||
public abstract class MainSpectatorInventoryView extends SpectatorInventoryView<PlayerInventorySlot> { | ||
|
||
protected MainSpectatorInventoryView(CreationOptions<PlayerInventorySlot> creationOptions) { | ||
super(creationOptions); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public abstract MainSpectatorInventory getTopInventory(); | ||
|
||
/** Sets the item in the desired slot of the InventoryView. If the slot is in the top inventory, then the inventory slot will be computed using | ||
* {@code getMirror().getSlot(slot).defaultIndex()}. | ||
* @see com.janboerman.invsee.spigot.api.template.Mirror */ | ||
@Override | ||
public void setItem(int slot, ItemStack item) { | ||
if (0 <= slot && slot < getTopInventory().getSize()) { | ||
PlayerInventorySlot piSlot = getMirror().getSlot(slot); | ||
if (piSlot != null) super.setItem(piSlot.defaultIndex(), item); | ||
} else { | ||
super.setItem(slot, item); | ||
} | ||
} | ||
|
||
/** Gets the item in the desired slot of the InventoryView. If the slot is in the top inventory, then the inventory slot will be computed using | ||
* {@code getMirror().getSlot(slot).defaultIndex()}. | ||
* @see com.janboerman.invsee.spigot.api.template.Mirror */ | ||
@Override | ||
public ItemStack getItem(int slot) { | ||
if (0 <= slot && slot < getTopInventory().getSize()) { | ||
PlayerInventorySlot piSlot = getMirror().getSlot(slot); | ||
return piSlot == null ? null : super.getItem(piSlot.defaultIndex()); | ||
} else { | ||
return super.getItem(slot); | ||
} | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public InventoryType getType() { | ||
return InventoryType.CHEST; | ||
} | ||
|
||
} | ||
package com.janboerman.invsee.spigot.api; | ||
|
||
import com.janboerman.invsee.spigot.api.template.PlayerInventorySlot; | ||
|
||
import org.bukkit.event.inventory.InventoryType; | ||
|
||
public interface MainSpectatorInventoryView extends SpectatorInventoryView<PlayerInventorySlot> { | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public MainSpectatorInventory getTopInventory(); | ||
|
||
/** | ||
* Get the inventory type. | ||
* @return the inventory type | ||
*/ | ||
public default InventoryType getType() { | ||
return InventoryType.CHEST; | ||
} | ||
|
||
} |
117 changes: 53 additions & 64 deletions
117
InvSee++_Common/src/main/java/com/janboerman/invsee/spigot/api/SpectatorInventoryView.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 |
---|---|---|
@@ -1,64 +1,53 @@ | ||
package com.janboerman.invsee.spigot.api; | ||
|
||
import com.janboerman.invsee.spigot.api.logging.Difference; | ||
import com.janboerman.invsee.spigot.api.target.Target; | ||
import com.janboerman.invsee.spigot.api.template.Mirror; | ||
import org.bukkit.inventory.InventoryView; | ||
|
||
import javax.annotation.Nullable; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Represents an open window for a {@link SpectatorInventory}. | ||
* @param <Slot> the inventory's slot type. | ||
*/ | ||
public abstract class SpectatorInventoryView<Slot> extends InventoryView { | ||
|
||
private final CreationOptions<Slot> creationOptions; | ||
protected Target target; | ||
|
||
protected SpectatorInventoryView(CreationOptions<Slot> creationOptions) { | ||
this.creationOptions = Objects.requireNonNull(creationOptions, "creation options cannot be null"); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override | ||
public abstract SpectatorInventory<Slot> getTopInventory(); | ||
|
||
/** | ||
* Get the difference tracked by this window. | ||
* @return the difference | ||
*/ | ||
public abstract @Nullable Difference getTrackedDifference(); | ||
|
||
/** | ||
* Get the options this window was created with. | ||
* @return a copy of the creation options | ||
*/ | ||
public CreationOptions<Slot> getCreationOptions() { | ||
return creationOptions.clone(); | ||
} | ||
|
||
//can't override getTitle because that does not work on 1.12 (the method is final :/) | ||
//can't override title() either because of Adventure Text (because I can't have return type String) | ||
//ooh the burden of supporting multiple versions! | ||
|
||
/** | ||
* Get the mirror the {@link SpectatorInventory} is viewed through. | ||
* @return the mirror | ||
* @see <a href="https://github.com/Jannyboy11/InvSee-plus-plus/wiki/Customising-spectator-inventories#mirror">Mirror explanation in the InvSee++ wiki</a> | ||
*/ | ||
public Mirror<Slot> getMirror() { | ||
return creationOptions.getMirror(); | ||
} | ||
|
||
/** | ||
* Get the target of the {@link SpectatorInventory}. | ||
* @return the target | ||
*/ | ||
public Target getTarget() { | ||
SpectatorInventory<Slot> top = getTopInventory(); | ||
return target == null ? target = Target.byGameProfile(top.getSpectatedPlayerId(), top.getSpectatedPlayerName()) : target; | ||
} | ||
|
||
} | ||
package com.janboerman.invsee.spigot.api; | ||
|
||
import javax.annotation.Nullable; | ||
|
||
import com.janboerman.invsee.spigot.api.logging.Difference; | ||
import com.janboerman.invsee.spigot.api.target.Target; | ||
import com.janboerman.invsee.spigot.api.template.Mirror; | ||
|
||
/** | ||
* Represents an open window for a {@link SpectatorInventory}. | ||
* @param <Slot> the inventory's slot type. | ||
*/ | ||
// cannot extend InventoryView, because this class was not an interface before Bukkit 1.21. | ||
public interface SpectatorInventoryView<Slot> { | ||
|
||
/** | ||
* Get the top inventory of this view. | ||
* @return the top inventory | ||
*/ | ||
public SpectatorInventory<Slot> getTopInventory(); | ||
|
||
/** | ||
* Get the difference tracked by this window. | ||
* @return the difference | ||
*/ | ||
public @Nullable Difference getTrackedDifference(); | ||
|
||
/** | ||
* Get the options this window was created with. | ||
* @return a copy of the creation options | ||
*/ | ||
public CreationOptions<Slot> getCreationOptions(); | ||
|
||
/** | ||
* Get the title of this InventoryView. | ||
* @return the title | ||
*/ | ||
public String getTitle(); | ||
|
||
/** | ||
* Get the mirror the {@link SpectatorInventory} is viewed through. | ||
* @return the mirror | ||
* @see <a href="https://github.com/Jannyboy11/InvSee-plus-plus/wiki/Customising-spectator-inventories#mirror">Mirror explanation in the InvSee++ wiki</a> | ||
*/ | ||
public Mirror<Slot> getMirror(); | ||
|
||
/** | ||
* Get the target of the {@link SpectatorInventory}. | ||
* @return the target | ||
*/ | ||
public Target getTarget(); | ||
|
||
} |
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
4 changes: 3 additions & 1 deletion
4
InvSee++_Common/src/main/java/com/janboerman/invsee/spigot/api/logging/LogGranularity.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
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
1 change: 0 additions & 1 deletion
1
...Common/src/main/java/com/janboerman/invsee/spigot/api/placeholder/PlaceholderPalette.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
2 changes: 1 addition & 1 deletion
2
InvSee++_Common/src/main/java/com/janboerman/invsee/spigot/api/response/OpenResponse.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
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
1 change: 0 additions & 1 deletion
1
...main/java/com/janboerman/invsee/spigot/internal/placeholder/SimplePlaceholderPalette.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
Oops, something went wrong.