-
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.
Showing
54 changed files
with
1,811 additions
and
913 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
17 changes: 0 additions & 17 deletions
17
src/main/java/me/opkarol/opc/api/database/manager/AbstractDatabase.java
This file was deleted.
Oops, something went wrong.
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
31 changes: 31 additions & 0 deletions
31
src/main/java/me/opkarol/opc/api/events/OpCancellableEventExtender.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,31 @@ | ||
package me.opkarol.opc.api.events; | ||
|
||
import org.bukkit.event.Cancellable; | ||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class OpCancellableEventExtender extends Event implements Cancellable { | ||
private static final HandlerList HANDLERS = new HandlerList(); | ||
private boolean cancelled; | ||
|
||
@NotNull | ||
@Override | ||
public HandlerList getHandlers() { | ||
return HANDLERS; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLERS; | ||
} | ||
|
||
@Override | ||
public boolean isCancelled() { | ||
return cancelled; | ||
} | ||
|
||
@Override | ||
public void setCancelled(boolean cancel) { | ||
this.cancelled = cancel; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/me/opkarol/opc/api/events/OpEventExtender.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 me.opkarol.opc.api.events; | ||
|
||
import org.bukkit.event.Event; | ||
import org.bukkit.event.HandlerList; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class OpEventExtender extends Event { | ||
private static final HandlerList HANDLERS = new HandlerList(); | ||
|
||
@NotNull | ||
@Override | ||
public HandlerList getHandlers() { | ||
return HANDLERS; | ||
} | ||
|
||
public static HandlerList getHandlerList() { | ||
return HANDLERS; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -42,7 +42,6 @@ public String getValue(String path) { | |
map.set(path, str); | ||
return str; | ||
} | ||
|
||
return object.toString(); | ||
} | ||
|
||
|
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,49 @@ | ||
package me.opkarol.opc.api.gui; | ||
|
||
import me.opkarol.opc.api.gui.events.InventoryListener; | ||
import me.opkarol.opc.api.gui.replacement.ReplacementInventoryImpl; | ||
import me.opkarol.opc.api.map.OpMap; | ||
|
||
import java.util.*; | ||
|
||
import static me.opkarol.opc.api.utils.VariableUtil.getOrDefault; | ||
|
||
public class InventoryCache { | ||
private static InventoryCache cache; | ||
private final OpMap<UUID, ReplacementInventoryImpl> activeInventories = new OpMap<>(); | ||
private final Set<UUID> inventoriesOpened = new HashSet<>(); | ||
|
||
public InventoryCache() { | ||
cache = this; | ||
new InventoryListener(this); | ||
} | ||
|
||
public void setActiveInventory(UUID uuid, ReplacementInventoryImpl inventory) { | ||
activeInventories.set(uuid, inventory); | ||
inventoriesOpened.add(uuid); | ||
} | ||
|
||
public Optional<ReplacementInventoryImpl> getActiveInventory(UUID uuid) { | ||
return activeInventories.getByKey(uuid); | ||
} | ||
|
||
public void removeActiveInventory(UUID uuid) { | ||
activeInventories.remove(uuid); | ||
} | ||
|
||
public void removeInventoryOpen(UUID uuid) { | ||
inventoriesOpened.remove(uuid); | ||
} | ||
|
||
public boolean hasSavedInventory(UUID uuid) { | ||
return inventoriesOpened.contains(uuid); | ||
} | ||
|
||
public static InventoryCache getCache() { | ||
return getOrDefault(cache, new InventoryCache()); | ||
} | ||
|
||
public String getInventoriesOpened() { | ||
return Arrays.toString(inventoriesOpened.toArray()); | ||
} | ||
} |
73 changes: 0 additions & 73 deletions
73
src/main/java/me/opkarol/opc/api/gui/InventoryListener.java
This file was deleted.
Oops, something went wrong.
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,38 @@ | ||
package me.opkarol.opc.api.gui; | ||
|
||
import me.opkarol.opc.api.gui.database.InvHolderImpl; | ||
import me.opkarol.opc.api.gui.events.chest.OnInventoryClose; | ||
import me.opkarol.opc.api.gui.holder.inventory.InventoryEventExtender; | ||
import me.opkarol.opc.api.gui.holder.inventory.InventoryEventHolder; | ||
import me.opkarol.opc.api.gui.inventory.AbstractInventory; | ||
import me.opkarol.opc.api.gui.inventory.IInventoryIdentification; | ||
import me.opkarol.opc.api.gui.items.InventoryItem; | ||
import me.opkarol.opc.api.gui.replacement.ReplacementInventoryImpl; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public final class OpInventory extends ReplacementInventoryImpl { | ||
public <K extends AbstractInventory<?, ?> & IInventoryIdentification> OpInventory(K factory, Consumer<OnInventoryClose> action) { | ||
super(new InvHolderImpl(factory.getType(), factory, new InventoryEventExtender(action))); | ||
} | ||
|
||
public <K extends AbstractInventory<?, ?> & IInventoryIdentification> OpInventory(K factory, InventoryEventHolder action) { | ||
super(new InvHolderImpl(factory.getType(), factory, action)); | ||
} | ||
|
||
public <K extends AbstractInventory<?, ?> & IInventoryIdentification> OpInventory(K factory) { | ||
super(new InvHolderImpl(factory.getType(), factory, null)); | ||
} | ||
|
||
public void setGlobalItem(InventoryItem item, int slot) { | ||
setInPagesRange(getMaxPages(), item, slot); | ||
} | ||
|
||
public void setGlobalItem(int globalRange, InventoryItem item, int slot) { | ||
setInPagesRange(globalRange, item, slot); | ||
} | ||
|
||
public void setAutoBuild(boolean autoBuild) { | ||
getInventoryHolder().getHolder().setAutoBuild(autoBuild); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/main/java/me/opkarol/opc/api/gui/database/DefaultInvHolder.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,11 @@ | ||
package me.opkarol.opc.api.gui.database; | ||
|
||
import me.opkarol.opc.api.gui.inventory.AbstractInventory; | ||
import me.opkarol.opc.api.gui.items.InventoryItem; | ||
|
||
public class DefaultInvHolder extends InvHolder<InventoryItem> { | ||
|
||
public DefaultInvHolder(AbstractInventory<Integer, InventoryItem> inventory) { | ||
super(inventory); | ||
} | ||
} |
Oops, something went wrong.