use of org.cubeengine.module.signmarket.data.MarketSignData in project modules-extra by CubeEngine.
the class EditModeCommand method demand.
@Command(desc = "Changes the demand of a sign")
public void demand(Player context, Integer demand) {
MarketSignData data = manager.getCurrentData(context);
if (data == null) {
i18n.send(context, NEGATIVE, "No active sign!");
return;
}
if (data.getSignType() == null) {
data.setSignType(SignType.SELL);
} else if (data.getSignType() == SignType.BUY) {
i18n.send(context, NEGATIVE, "Buy signs cannot have a demand!");
return;
}
data.setDemand(demand);
Location<World> loc = manager.updateData(data, context);
manager.executeShowInfo(data, context, loc);
}
use of org.cubeengine.module.signmarket.data.MarketSignData in project modules-extra by CubeEngine.
the class EditModeCommand method amount.
@Command(desc = "Sets the amount")
public void amount(Player context, Integer amount) {
if (amount < 0) {
i18n.send(context, NEGATIVE, "Negative amounts could be unfair! Just sayin'");
return;
}
MarketSignData data = manager.getCurrentData(context);
if (data == null) {
i18n.send(context, NEGATIVE, "No active sign!");
return;
}
data.setAmount(amount);
Location<World> loc = manager.updateData(data, context);
manager.executeShowInfo(data, context, loc);
}
use of org.cubeengine.module.signmarket.data.MarketSignData in project modules-extra by CubeEngine.
the class EditModeCommand method buy.
@Command(desc = "Changes the sign to a buy-sign")
public void buy(Player context) {
// TODO perms for sell/Buy maybe?
MarketSignData data = manager.getCurrentData(context);
if (data == null) {
i18n.send(context, NEGATIVE, "No active sign!");
return;
}
data.setSignType(SignType.BUY);
Location<World> loc = manager.updateData(data, context);
manager.executeShowInfo(data, context, loc);
}
use of org.cubeengine.module.signmarket.data.MarketSignData in project modules-extra by CubeEngine.
the class EditModeCommand method item.
@Command(desc = "Sets the item")
public void item(Player context, ItemStack item) {
MarketSignData data = manager.getCurrentData(context);
if (data == null) {
i18n.send(context, NEGATIVE, "No active sign!");
return;
}
if (!data.isAdminOwner() && data.getStock() != 0) {
i18n.send(context, NEGATIVE, "You have to take all items out of the market-sign to be able to change the item in it!");
return;
}
data.setItem(item, false);
Location<World> loc = manager.updateData(data, context);
manager.executeShowInfo(data, context, loc);
}
use of org.cubeengine.module.signmarket.data.MarketSignData in project modules-extra by CubeEngine.
the class MarketSignListener method onSignPlace.
@Listener(order = Order.POST)
public void onSignPlace(ChangeBlockEvent.Place event, @First Player player) {
if (event.getTransactions().size() > 1 || !module.getEditModeCommand().hasUser(player)) {
return;
}
for (Transaction<BlockSnapshot> trans : event.getTransactions()) {
BlockType type = trans.getFinal().getState().getType();
if (// placed sign
type == BlockTypes.STANDING_SIGN || type == BlockTypes.WALL_SIGN) {
if (!player.hasPermission(module.perms().EDIT_USE.getId())) {
event.setCancelled(true);
i18n.send(player, NEGATIVE, "You are not allowed to create market signs!");
return;
}
MarketSignData data = new MarketSignData();
data.setID(UUID.randomUUID());
data.setOwner(player.getUniqueId());
Location<World> loc = trans.getFinal().getLocation().get();
loc.offer(data);
manager.setSign(loc, player);
Sponge.getCauseStackManager().pushCause(player);
player.closeInventory();
}
}
}
Aggregations