Skip to content

Commit

Permalink
* Added the "toJSON" method to the "SerializeUtil" interface and used…
Browse files Browse the repository at this point in the history
… it as a replacement for the entire packet setup.

* Added the "isBeingEdited" and "setBeingEdited" methods to the "Shop" interface. This value is now used for the shops during the editing process.
* Added the "ShopEditEvent" event which is fired whenever a player opens the edit menu. It is also used by the plugin on the LOWEST priority so it can set the new shop editing value and perform actions.

Signed-off-by: XZot1K <[email protected]>
  • Loading branch information
XZot1K committed Sep 22, 2020
1 parent a9cb84e commit a342661
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 28 deletions.
2 changes: 1 addition & 1 deletion API Version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
## API-VERSION 1.1.6 ##
## API-VERSION 1.1.7 ##
6 changes: 1 addition & 5 deletions src/xzot1k/plugins/ds/DisplayShops.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@ public class DisplayShops extends JavaPlugin implements DisplayShopsAPI {
private static DisplayShops pluginInstance;

public DisplayShops() {
setPluginInstance(this);
DisplayShops.pluginInstance = this;
}

public static DisplayShops getPluginInstance() {
return pluginInstance;
}

private static void setPluginInstance(DisplayShops pluginInstance) {
DisplayShops.pluginInstance = pluginInstance;
}

@Override
public void onEnable() {}

Expand Down
3 changes: 0 additions & 3 deletions src/xzot1k/plugins/ds/api/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import xzot1k.plugins.ds.api.events.EconomyCallEvent;
import xzot1k.plugins.ds.api.events.EconomyCallType;
import xzot1k.plugins.ds.api.handlers.ActionBarHandler;
import xzot1k.plugins.ds.api.handlers.JItemHandler;
import xzot1k.plugins.ds.api.handlers.ParticleHandler;
import xzot1k.plugins.ds.api.handlers.SerializeUtil;
import xzot1k.plugins.ds.api.objects.DataPack;
Expand Down Expand Up @@ -444,8 +443,6 @@ public interface Manager {

ParticleHandler getParticleHandler();

JItemHandler getJItemHandler();

ActionBarHandler getActionBarHandler();

SerializeUtil getSerializeUtil();
Expand Down
52 changes: 52 additions & 0 deletions src/xzot1k/plugins/ds/api/events/ShopEditEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Copyright (c) 2020 XZot1K, All rights reserved.
*/

package xzot1k.plugins.ds.api.events;

import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import xzot1k.plugins.ds.api.objects.Shop;

public class ShopEditEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final Player player;
private final Shop shop;
private boolean cancelled;

public ShopEditEvent(Player player, Shop shop) {
this.player = player;
this.shop = shop;
}

// getters & setters
public static HandlerList getHandlerList() {
return handlers;
}

@Override
public HandlerList getHandlers() {
return handlers;
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}

public Player getPlayer() {
return player;
}

public Shop getShop() {
return shop;
}

}
19 changes: 0 additions & 19 deletions src/xzot1k/plugins/ds/api/handlers/JItemHandler.java

This file was deleted.

8 changes: 8 additions & 0 deletions src/xzot1k/plugins/ds/api/handlers/SerializeUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,12 @@ public interface SerializeUtil {
*/
ItemStack toItem(String itemString);

/**
* Convert an item to a JSON string format for in-game messages.
*
* @param itemStack The item to convert.
* @return The JSON string (can return 'NULL').
*/
String toJSON(ItemStack itemStack);

}
29 changes: 29 additions & 0 deletions src/xzot1k/plugins/ds/api/objects/Shop.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,33 @@ public interface Shop {
int getDynamicSellCounter();

void setDynamicSellCounter(int dynamicPriceCounter);

/**
* Checks if the shop is being edited.
*
* @return Whether shop is undergoing edits.
*/
boolean isBeingEdited();

/**
* Sets whether shop is being edited.
*
* @param beingEdited Whether the shop is being edited.
*/
void setBeingEdited(boolean beingEdited);

/**
* Gets the current editor.
*
* @return The editor UUID.
*/
UUID getCurrentEditor();

/**
* Sets the current editor.
*
* @param currentEditor The current editor UUID.
*/
void setCurrentEditor(UUID currentEditor);

}

0 comments on commit a342661

Please sign in to comment.