Forgot fluid grid handler permissions

This commit is contained in:
Raoul Van den Berge
2016-12-16 21:11:49 +01:00
parent 482cefffa6
commit f4d2a41f43
7 changed files with 18 additions and 13 deletions

View File

@@ -14,11 +14,11 @@ public interface IFluidGridHandler {
/**
* Called when a player tries to extract a fluid from the grid.
*
* @param player the player that is attempting the extraction
* @param hash the hash of the fluid we're trying to extract, see {@link IRSAPI#getFluidStackHashCode(FluidStack)}
* @param shift true if shift click was used, false otherwise
* @param player the player that is attempting the extraction
*/
void onExtract(int hash, boolean shift, EntityPlayerMP player);
void onExtract(EntityPlayerMP player, int hash, boolean shift);
/**
* Called when a player tries to insert fluids in the grid.
@@ -27,7 +27,7 @@ public interface IFluidGridHandler {
* @return the remainder, or null if there is no remainder
*/
@Nullable
ItemStack onInsert(ItemStack container);
ItemStack onInsert(EntityPlayerMP player, ItemStack container);
/**
* Called when a player is trying to insert a fluid that it is holding in their hand in the GUI.

View File

@@ -17,11 +17,11 @@ public interface IItemGridHandler {
/**
* Called when a player tries to extract an item from the grid.
*
* @param player the player that is attempting the extraction
* @param hash the hash of the item we're trying to extract, see {@link IRSAPI#getItemStackHashCode(ItemStack)}
* @param flags how we are extracting
* @param player the player that is attempting the extraction
*/
void onExtract(int hash, int flags, EntityPlayerMP player);
void onExtract(EntityPlayerMP player, int hash, int flags);
/**
* Called when a player tries to insert an item in the grid.

View File

@@ -2,6 +2,7 @@ package com.raoulvdberge.refinedstorage.apiimpl.network.grid;
import com.raoulvdberge.refinedstorage.RSUtils;
import com.raoulvdberge.refinedstorage.api.network.INetworkMaster;
import com.raoulvdberge.refinedstorage.api.network.Permission;
import com.raoulvdberge.refinedstorage.api.network.grid.IFluidGridHandler;
import com.raoulvdberge.refinedstorage.apiimpl.API;
import net.minecraft.entity.player.EntityPlayerMP;
@@ -23,10 +24,10 @@ public class FluidGridHandler implements IFluidGridHandler {
}
@Override
public void onExtract(int hash, boolean shift, EntityPlayerMP player) {
public void onExtract(EntityPlayerMP player, int hash, boolean shift) {
FluidStack stack = network.getFluidStorageCache().getList().get(hash);
if (stack == null || stack.amount < Fluid.BUCKET_VOLUME) {
if (stack == null || stack.amount < Fluid.BUCKET_VOLUME || !network.hasPermission(Permission.EXTRACT, player)) {
return;
}
@@ -66,7 +67,11 @@ public class FluidGridHandler implements IFluidGridHandler {
@Nullable
@Override
public ItemStack onInsert(ItemStack container) {
public ItemStack onInsert(EntityPlayerMP player, ItemStack container) {
if (!network.hasPermission(Permission.INSERT, player)) {
return container;
}
Pair<ItemStack, FluidStack> result = RSUtils.getFluidFromStack(container, true);
if (result.getValue() != null && network.insertFluid(result.getValue(), result.getValue().amount, true) == null) {
@@ -82,7 +87,7 @@ public class FluidGridHandler implements IFluidGridHandler {
@Override
public void onInsertHeldContainer(EntityPlayerMP player) {
player.inventory.setItemStack(RSUtils.getStack(onInsert(player.inventory.getItemStack())));
player.inventory.setItemStack(RSUtils.getStack(onInsert(player, player.inventory.getItemStack())));
player.updateHeldItem();
}
}

View File

@@ -29,7 +29,7 @@ public class ItemGridHandler implements IItemGridHandler {
}
@Override
public void onExtract(int hash, int flags, EntityPlayerMP player) {
public void onExtract(EntityPlayerMP player, int hash, int flags) {
ItemStack item = network.getItemStorageCache().getList().get(hash);
if (item == null || !network.hasPermission(Permission.EXTRACT, player)) {

View File

@@ -132,7 +132,7 @@ public class ContainerGrid extends ContainerBase {
if (grid.getType() != EnumGridType.FLUID && grid.getItemHandler() != null) {
slot.putStack(RSUtils.getStack(grid.getItemHandler().onInsert((EntityPlayerMP) player, slot.getStack())));
} else if (grid.getType() == EnumGridType.FLUID && grid.getFluidHandler() != null) {
slot.putStack(RSUtils.getStack(grid.getFluidHandler().onInsert(slot.getStack())));
slot.putStack(RSUtils.getStack(grid.getFluidHandler().onInsert((EntityPlayerMP) player, slot.getStack())));
}
detectAndSendChanges();

View File

@@ -39,7 +39,7 @@ public class MessageGridFluidPull extends MessageHandlerPlayerToServer<MessageGr
IFluidGridHandler handler = ((ContainerGrid) container).getGrid().getFluidHandler();
if (handler != null) {
handler.onExtract(message.hash, message.shift, player);
handler.onExtract(player, message.hash, message.shift);
}
}
}

View File

@@ -39,7 +39,7 @@ public class MessageGridItemPull extends MessageHandlerPlayerToServer<MessageGri
IItemGridHandler handler = ((ContainerGrid) container).getGrid().getItemHandler();
if (handler != null) {
handler.onExtract(message.hash, message.flags, player);
handler.onExtract(player, message.hash, message.flags);
}
}
}