mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-22 16:11:22 +01:00
[trunk] Infinite placement of blocks, egg throws, buckets
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1100 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
parent
8539f28146
commit
20d51e3311
@ -162,6 +162,8 @@ public class Essentials extends JavaPlugin
|
||||
pm.registerEvent(Type.PLAYER_LOGIN, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_EGG_THROW, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.High, this);
|
||||
|
||||
blockListener = new EssentialsBlockListener(this);
|
||||
pm.registerEvent(Type.SIGN_CHANGE, blockListener, Priority.Low, this);
|
||||
|
@ -1,10 +1,13 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.media.jai.operator.MeanDescriptor;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsBlockListener extends BlockListener
|
||||
@ -163,6 +166,59 @@ public class EssentialsBlockListener extends BlockListener
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Essentials.getSettings().isInfinitePlacingEnabled()) {
|
||||
final User user = User.get(event.getPlayer());
|
||||
if (user.isAuthorized("essentials.infinite.placing")) {
|
||||
final ItemStack is = event.getItemInHand();
|
||||
if (is.getType() == Material.AIR) {
|
||||
is.setType(event.getBlockPlaced().getType());
|
||||
}
|
||||
switch(is.getType()) {
|
||||
case WOODEN_DOOR:
|
||||
is.setType(Material.WOOD_DOOR);
|
||||
break;
|
||||
case IRON_DOOR_BLOCK:
|
||||
is.setType(Material.IRON_DOOR);
|
||||
break;
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
is.setType(Material.SIGN);
|
||||
break;
|
||||
case CROPS:
|
||||
is.setType(Material.SEEDS);
|
||||
break;
|
||||
case CAKE_BLOCK:
|
||||
is.setType(Material.CAKE);
|
||||
break;
|
||||
case BED_BLOCK:
|
||||
is.setType(Material.BED);
|
||||
break;
|
||||
case REDSTONE_WIRE:
|
||||
is.setType(Material.REDSTONE);
|
||||
break;
|
||||
case REDSTONE_TORCH_OFF:
|
||||
is.setType(Material.REDSTONE_TORCH_ON);
|
||||
break;
|
||||
case DIODE_BLOCK_OFF:
|
||||
case DIODE_BLOCK_ON:
|
||||
is.setType(Material.DIODE);
|
||||
break;
|
||||
}
|
||||
List<Integer> whitelist = Essentials.getSettings().getInfiniteWhitelist();
|
||||
if (whitelist.isEmpty() || whitelist.contains(is.getTypeId()) ||
|
||||
user.isAuthorized("essentials.infinite.whitelist.override")) {
|
||||
is.setAmount(1);
|
||||
Essentials.getStatic().getScheduler().scheduleSyncDelayedTask(Essentials.getStatic(),
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasAdjacentChest(Block block)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.InventoryPlayer;
|
||||
import org.bukkit.*;
|
||||
@ -394,4 +395,36 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
user.sendMessage("§cError: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerEggThrow(PlayerEggThrowEvent event) {
|
||||
if (Essentials.getSettings().isInfiniteEggThrowEnabled()) {
|
||||
User user = User.get(event.getPlayer());
|
||||
if (user.isAuthorized("essentials.infinite.eggthrow")) {
|
||||
user.getInventory().addItem(new ItemStack(Material.EGG, 1));
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||
if (Essentials.getSettings().isInfiniteBucketsEnabled()) {
|
||||
final User user = User.get(event.getPlayer());
|
||||
if (user.isAuthorized("essentials.infinite.buckets")) {
|
||||
List<Integer> whitelist = Essentials.getSettings().getInfiniteWhitelist();
|
||||
if (whitelist.isEmpty() || whitelist.contains(event.getBucket().getId()) ||
|
||||
user.isAuthorized("essentials.infinite.whitelist.override")) {
|
||||
event.getItemStack().setType(event.getBucket());
|
||||
Essentials.getStatic().getScheduler().scheduleSyncDelayedTask(Essentials.getStatic(),
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
user.updateInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -433,4 +433,35 @@ public class Settings implements IConf
|
||||
}
|
||||
return epBreakList;
|
||||
}
|
||||
|
||||
boolean isInfinitePlacingEnabled() {
|
||||
return config.getBoolean("infinite.placing",false);
|
||||
}
|
||||
|
||||
boolean isInfiniteEggThrowEnabled() {
|
||||
return config.getBoolean("infinite.eggthrow",false);
|
||||
}
|
||||
|
||||
boolean isInfiniteBucketsEnabled() {
|
||||
return config.getBoolean("infinite.buckets",false);
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getInfiniteWhitelist()
|
||||
{
|
||||
ArrayList<Integer> infiniteWhitelist = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("infinite.whitelist", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
infiniteWhitelist.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Unknown item " + itemName + " in infinite whitelist.");
|
||||
}
|
||||
}
|
||||
return infiniteWhitelist;
|
||||
}
|
||||
}
|
||||
|
@ -155,6 +155,20 @@ per-warp-permission: false
|
||||
# Sort output of /list command by groups
|
||||
sort-list-by-groups: false
|
||||
|
||||
# Infinite placement of blocks, throwing of eggs, using of buckets
|
||||
infinite:
|
||||
# Players need also permission essentials.infinite.placing
|
||||
placing: false
|
||||
# permission essentials.infinite.eggthrow
|
||||
eggthrow: false
|
||||
# permission essentials.infinite.buckets
|
||||
buckets: false
|
||||
# Use this whitelist the restrict the use of infinite placing and buckets
|
||||
# Permission essentials.infinite.whitelist.override let players ignore this list
|
||||
whitelist:
|
||||
# example: (You can use ids or names from items.csv)
|
||||
# whitelist: cobblestone, dirt, waterbucket
|
||||
|
||||
############################################################
|
||||
# +------------------------------------------------------+ #
|
||||
# | EssentialsHome | #
|
||||
|
Loading…
Reference in New Issue
Block a user