Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plib.version>1.4-SNAPSHOT</plib.version>
<bukkit.version>1.9-SNAPSHOT</bukkit.version>
<bukkit.version>1.9.4-R0.1-SNAPSHOT</bukkit.version>
</properties>

<scm>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public String toString() {
}

public void block(Block block, Player player) {
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
if (player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
block(block.getLocation(), block.getType());
} else {
// doesn't include silktouch
for (ItemStack i : block.getDrops(player.getItemInHand())) {
for (ItemStack i : block.getDrops(player.getInventory().getItemInMainHand())) {
block(block.getLocation(), i.getType());
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.jaschastarke.minecraft.limitedcreative.blockstate;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -144,19 +143,15 @@ public void onPistionExtend(BlockPistonExtendEvent event) {
return;
event.getBlock().setMetadata("LCBS_pistonIsAlreadyExtended", blockAlreadExtended);

Block source = event.getBlock().getRelative(event.getDirection());
/*if (mod.isDebug())
mod.getLog().debug("PistonExtend "+source.getType()+" "+source.getLocation()+" "+event.getDirection());*/

List<Block> movedBlocks = new ArrayList<Block>();
while (source != null && source.getType() != Material.AIR) {
movedBlocks.add(0, source); // put on top, so iterating the
source = source.getRelative(event.getDirection());
}
List<Block> movedBlocks = event.getBlocks();

if (movedBlocks.size() > 0) {
DBTransaction update = mod.getModel().groupUpdate();
for (Block sblock : movedBlocks) {
for(int count = movedBlocks.size()-1; count >= 0; count--){
Block sblock = movedBlocks.get(count);
Block dest = sblock.getRelative(event.getDirection());
if (mod.isDebug())
mod.getLog().debug("PistionExtend moves "+sblock.getType()+"-Block from "+sblock.getLocation()+" to "+dest.getLocation());
Expand All @@ -173,12 +168,19 @@ public void onPistionRetract(BlockPistonRetractEvent event) {
return;
event.getBlock().removeMetadata("LCBS_pistonIsAlreadyExtended", mod.getPlugin());

Block dest = event.getBlock().getRelative(event.getDirection());
Block source = dest.getRelative(event.getDirection());
if (event.isSticky() && source.getType() != Material.AIR) {
if (mod.isDebug())
mod.getLog().debug("PistionRetract moves "+source.getType()+"-Block from "+source.getLocation()+" to "+dest.getLocation());
mod.getModel().moveState(source, source.getRelative(event.getDirection().getOppositeFace()));
List<Block> movedBlocks = event.getBlocks();
if(movedBlocks.size() > 0)
{
DBTransaction update = mod.getModel().groupUpdate();
for(int count = movedBlocks.size()-1; count >= 0; count--){
Block sblock = movedBlocks.get(count);
Block dest = sblock.getRelative(event.getDirection());
if (mod.isDebug())
mod.getLog().debug("PistionRetract moves "+sblock.getType()+"-Block from "+sblock.getLocation()+" to "+dest.getLocation());

update.moveState(sblock, dest);
}
update.finish();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package de.jaschastarke.minecraft.limitedcreative.blockstate;

import java.util.Date;
import java.util.UUID;

import javax.persistence.Column;
//import javax.persistence.EmbeddedId;
Expand Down Expand Up @@ -37,7 +38,7 @@ public static enum Source {
private GameMode gameMode;

@Column(name = "player")
private String playerName;
private UUID uuid;

@NotNull
@Column(name = "cdate")
Expand All @@ -51,7 +52,7 @@ public BlockState() {
public BlockState(BlockState copy) {
this.location = copy.location;
this.gameMode = copy.gameMode;
this.playerName = copy.playerName;
this.uuid = copy.uuid;
this.date = copy.date;
this.source = copy.source;
}
Expand All @@ -72,24 +73,29 @@ public void setGameMode(GameMode gm) {
this.gameMode = gm;
}

public UUID getPlayerUUID() {
return uuid;
}

public String getPlayerName() {
return playerName;
return Bukkit.getOfflinePlayer(uuid).getName();
}

//TODO Rename
public void setPlayerName(String s) {
playerName = s;
uuid = UUID.fromString(s);
}

public OfflinePlayer getPlayer() {
OfflinePlayer p = Bukkit.getPlayerExact(playerName);
OfflinePlayer p = Bukkit.getPlayer(uuid);
if (p == null)
p = Bukkit.getOfflinePlayer(playerName);
p = Bukkit.getOfflinePlayer(uuid);
return p;
}

public void setPlayer(OfflinePlayer player) {
setSource(Source.PLAYER);
this.playerName = player.getName();
this.uuid = player.getUniqueId();
if (player instanceof Player) {
setGameMode(((Player) player).getGameMode());
}
Expand Down Expand Up @@ -119,6 +125,7 @@ public boolean isRestricted() {

@Override
public String toString() {
String playerName = Bukkit.getOfflinePlayer(uuid).getName();
//return blockLocation.toString() + " by " +
return location.toString() + " by " +
(source == Source.PLAYER ? playerName : (source.toString() + (playerName != null ? "(" + playerName + ")" : ""))) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitRunnable;

import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.bukkit.selections.Selection;

Expand Down Expand Up @@ -105,7 +103,7 @@ public boolean cleanupDatabase(final CommandContext context, String... args) thr
if (mod.getConfig().getLogSurvival()) {
context.responseFormatted(ChatFormattings.INFO, L("command.blockstate.nothing_to_cleanup"));
} else {
mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new BukkitRunnable() {
mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() {
@Override
public void run() {
int countDeleted = mod.getModel().cleanUp(DBModel.Cleanup.SURVIVAL);
Expand Down Expand Up @@ -168,7 +166,7 @@ else if (gm.equals("2") || gm.equals("a") || gm.equals("adventure"))
final Location min = selection.getMinimumPoint();
final Location max = selection.getMaximumPoint();

mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new BukkitRunnable() {
mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() {
@Override
public void run() {
if (mod.isDebug())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ else if (db.getType() == Type.MySQL)
update.setString(1, s.getGameMode().name());
else
update.setInt(1, s.getGameMode().getValue());
update.setString(2, s.getPlayerName());
update.setString(2, s.getPlayerUUID().toString());
update.setTimestamp(3, new java.sql.Timestamp(s.getDate().getTime()));
if (db.getType() == Type.MySQL)
update.setString(4, s.getSource().name());
Expand Down Expand Up @@ -207,7 +207,7 @@ else if (db.getType() == Type.MySQL)
insert.setString(5, s.getGameMode().name());
else
insert.setInt(5, s.getGameMode().getValue());
insert.setString(6, s.getPlayerName());
insert.setString(6, s.getPlayerUUID().toString());
insert.setTimestamp(7, new java.sql.Timestamp(s.getDate().getTime()));
if (db.getType() == Type.MySQL)
insert.setString(8, s.getSource().name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.hanging.HangingBreakEvent;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public PlayerListener(ModBlockStates mod) {
public void onInteract(PlayerInteractEvent event) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
Block b = event.getClickedBlock();
if (b != null && event.getPlayer().getItemInHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
if (b != null && event.getPlayer().getInventory().getItemInMainHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
if (mod.getConfig().getIgnoredWorlds().contains(event.getClickedBlock().getWorld().getName())) {
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("command.blockstate.world_ignored", event.getClickedBlock().getWorld().getName()));
} else {
Expand All @@ -41,7 +41,7 @@ public void onInteract(PlayerInteractEvent event) {
@EventHandler(priority = EventPriority.HIGH)
public void onInteractEntity(PlayerInteractEntityEvent event) {
Entity e = event.getRightClicked();
if (e != null && e instanceof ItemFrame && event.getPlayer().getItemInHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
if (e != null && e instanceof ItemFrame && event.getPlayer().getInventory().getItemInMainHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
if (mod.getConfig().getIgnoredWorlds().contains(e.getWorld().getName())) {
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("command.blockstate.world_ignored", e.getWorld().getName()));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected void onBlockChange(Vector pt, BaseBlock newBlock) {
s.setLocation(loc);
}
s.setGameMode(null);
s.setPlayerName(player.getName());
s.setPlayerName(player.getUniqueId().toString());
s.setDate(new Date());
s.setSource(Source.EDIT);
if (mod.isDebug())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public Items(PlayerInventory pi) {
@Override
public void store(ConfigurationSection section) {
for (int i = 0; i < inv.getSize(); i++) {
if (inv.getItem(i) != null && inv.getItem(i).getTypeId() != 0)
if (inv.getItem(i) != null && !inv.getItem(i).getType().equals(Material.AIR))
sectionSetItem(section, String.valueOf(i), inv.getItem(i));
}
}
Expand Down Expand Up @@ -97,7 +97,7 @@ public static ItemStack sectionGetItem(ConfigurationSection section, String path
public static Map<Integer, ItemStack> storeInventory(PlayerInventory inv) {
Map<Integer, ItemStack> map = new HashMap<Integer, ItemStack>();
for (int i = 0; i < inv.getSize(); i++) {
if (inv.getItem(i) != null && inv.getItem(i).getTypeId() != 0) {
if (inv.getItem(i) != null && !inv.getItem(i).getType().equals(Material.AIR)) {
map.put(i, inv.getItem(i));
}
}
Expand Down Expand Up @@ -133,13 +133,13 @@ public Armor(PlayerInventory pi) {

@Override
public void store(ConfigurationSection section) {
if (inv.getHelmet() != null && inv.getHelmet().getTypeId() != 0)
if (inv.getHelmet() != null && !inv.getHelmet().getType().equals(Material.AIR))
Items.sectionSetItem(section, "helmet", inv.getHelmet());
if (inv.getChestplate() != null && inv.getChestplate().getTypeId() != 0)
if (inv.getChestplate() != null && !inv.getChestplate().getType().equals(Material.AIR))
Items.sectionSetItem(section, "chestplate", inv.getChestplate());
if (inv.getLeggings() != null && inv.getLeggings().getTypeId() != 0)
if (inv.getLeggings() != null && !inv.getLeggings().getType().equals(Material.AIR))
Items.sectionSetItem(section, "leggins", inv.getLeggings());
if (inv.getBoots() != null && inv.getBoots().getTypeId() != 0)
if (inv.getBoots() != null && !inv.getBoots().getType().equals(Material.AIR))
Items.sectionSetItem(section, "boots", inv.getBoots());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ public boolean contains(Inventory pinv, Target target) {

protected File getFile(Inventory pinv, Target target) {
if (target != default_target) {
return new File(dir, pinv.getPlayer().getName() + "_" + target.toString().toLowerCase() + SUFFIX);
return new File(dir, pinv.getPlayer().getUniqueId() + "_" + target.toString().toLowerCase() + SUFFIX);
} else {
return new File(dir, pinv.getPlayer().getName() + SUFFIX);
return new File(dir, pinv.getPlayer().getUniqueId() + SUFFIX);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public boolean matches(ItemStack item) {
}
public boolean matches(Block block) {
if (hasData) {
return md.equals(new MaterialData(block.getType(), block.getData()));
return md.equals(block.getState().getData());
} else {
return block.getType().equals(md.getItemType());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public Blacklisted(String rep) throws InvalidValueException {
type = null;
}
if (type == null)
type = EntityType.fromName(rep);
type = EntityType.valueOf(rep);
try {
if (type == null)
type = EntityType.valueOf(rep);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ public static IDynamicPermission INVENTORY(InventoryType invtype) {
return new InventoryPermission(CHEST, invtype);
}
public static IDynamicPermission INTERACT(Block block) {
return new MaterialPermission(BASE_INTERACT, new MaterialData(block.getType(), block.getData()));
return new MaterialPermission(BASE_INTERACT, block.getState().getData());
}
public static IDynamicPermission USE(Block block) {
return new MaterialPermission(BASE_USE, new MaterialData(block.getType(), block.getData()));
return new MaterialPermission(BASE_USE, block.getState().getData());
}
public static IDynamicPermission USE(MaterialData m) {
return new MaterialPermission(BASE_USE, m);
}
public static IDynamicPermission BREAK(Block block) {
return new MaterialPermission(BASE_BREAK, new MaterialData(block.getType(), block.getData()));
return new MaterialPermission(BASE_BREAK, block.getState().getData());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ public void onPlayerInteract(PlayerInteractEvent event) {
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (!event.isCancelled() && event.getPlayer().getGameMode() == GameMode.CREATIVE) {
if (mod.getConfig().getBlockUse().isListed(event.getPlayer().getItemInHand())) {
if (!checkPermission(event, NoLimitPermissions.USE(event.getPlayer().getItemInHand().getData()))) {
if (mod.getConfig().getBlockUse().isListed(event.getPlayer().getInventory().getItemInMainHand())) {
if (!checkPermission(event, NoLimitPermissions.USE(event.getPlayer().getInventory().getItemInMainHand().getData()))) {
event.setCancelled(true);
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("blocked.use"));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public List<String> get(Context context, String arg) {
if (idx > -1 && context.getArgument(idx) != null)
w = Bukkit.getWorld(context.getArgument(idx));
if (w != null) {
RegionManager mgr = getWorldGuard().getGlobalRegionManager().get(w);
RegionManager mgr = getWorldGuard().getRegionManager(w);
if (mgr != null) {
List<String> hints = new ArrayList<String>();
for (String rId : mgr.getRegions().keySet()) {
Expand Down Expand Up @@ -174,7 +174,7 @@ public boolean setFlag(CommandContext context, String... args) throws CommandExc
if (w == null)
throw new CommandException(L("command.worldguard.world_not_found"));

RegionManager mgr = getWorldGuard().getGlobalRegionManager().get(w);
RegionManager mgr = getWorldGuard().getRegionManager(w);
ProtectedRegion region = mgr.getRegion(params.getArgument(0));
if (region == null && params.getArgument(0).equalsIgnoreCase("__global__")) {
region = new GlobalProtectedRegion(params.getArgument(0));
Expand Down Expand Up @@ -238,16 +238,16 @@ public boolean getInfo(CommandContext context, String... args) throws CommandExc

ProtectedRegion region = null;
if (params.getArgumentCount() == 0 && context.isPlayer()) {
RegionManager mgr = getWorldGuard().getGlobalRegionManager().get(context.getPlayer().getWorld());
RegionManager mgr = getWorldGuard().getRegionManager(context.getPlayer().getWorld());
ApplicableRegionSet set = mgr.getApplicableRegions(context.getPlayer().getLocation());
if (set.size() > 0) {
region = set.iterator().next();
} else {
region = getWorldGuard().getGlobalRegionManager().get(w).getRegion(GLOBAL_REGION);
region = getWorldGuard().getRegionManager(w).getRegion(GLOBAL_REGION);
}
} else {
int rpc = params.getArgumentCount() > 1 ? 1 : 0;
RegionManager mgr = getWorldGuard().getGlobalRegionManager().get(w);
RegionManager mgr = getWorldGuard().getRegionManager(w);
region = mgr.getRegion(params.getArgument(rpc));
if (region == null && params.getArgument(rpc).equalsIgnoreCase(GLOBAL_REGION)) {
region = new GlobalProtectedRegion(params.getArgument(rpc));
Expand Down
Loading