Commit paginated changes, Add PermissionsTools

This commit is contained in:
Eric Stokes 2011-11-27 01:42:18 -07:00
parent 562de0f002
commit 803eb84f3f
8 changed files with 45 additions and 18 deletions

View File

@ -18,7 +18,7 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
public class HelpCommand extends PaginatedCommand<Command> {
public class HelpCommand extends PaginatedCoreCommand<Command> {
public HelpCommand(MultiverseCore plugin) {
super(plugin);

View File

@ -19,7 +19,7 @@ import org.bukkit.permissions.PermissionDefault;
import java.util.ArrayList;
import java.util.List;
public class ListCommand extends PaginatedCommand<String> {
public class ListCommand extends PaginatedCoreCommand<String> {
public ListCommand(MultiverseCore plugin) {
super(plugin);

View File

@ -7,13 +7,11 @@
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.pneumaticraft.commandhandler.Command;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.ArrayList;
import java.util.List;
/**
@ -21,11 +19,11 @@ import java.util.List;
*
* @author fernferret
*/
public abstract class PaginatedCommand<T> extends MultiverseCommand {
public abstract class PaginatedCommand<T> extends Command {
protected int ITEMS_PER_PAGE = 9;
public PaginatedCommand(MultiverseCore plugin) {
public PaginatedCommand(JavaPlugin plugin) {
super(plugin);
}

View File

@ -0,0 +1,24 @@
/******************************************************************************
* Multiverse 2 Copyright (c) the Multiverse Team 2011. *
* Multiverse 2 is licensed under the BSD License. *
* For more information please check the README.md file included *
* with this project. *
******************************************************************************/
package com.onarandombox.MultiverseCore.commands;
import com.onarandombox.MultiverseCore.MultiverseCore;
/**
* Multiverse 2
*
* @author fernferret
*/
public abstract class PaginatedCoreCommand<T> extends PaginatedCommand<T> {
protected MultiverseCore plugin;
public PaginatedCoreCommand(MultiverseCore plugin) {
super(plugin);
this.plugin = plugin;
}
}

View File

@ -10,15 +10,15 @@ package com.onarandombox.MultiverseCore.listeners;
import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
import com.onarandombox.MultiverseCore.utils.WorldManager;
import com.onarandombox.MultiverseCore.utils.PermissionTools;
import com.onarandombox.MultiverseCore.utils.SafeTTeleporter;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.*;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.*;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.EntityRegainHealthEvent;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import java.util.List;
import java.util.logging.Level;
@ -29,10 +29,12 @@ public class MVEntityListener extends EntityListener {
private MultiverseCore plugin;
private MVWorldManager worldManager;
private PermissionTools pt;
public MVEntityListener(MultiverseCore plugin) {
this.plugin = plugin;
this.worldManager = plugin.getMVWorldManager();
this.pt = new PermissionTools(this.plugin);
}
@Override
@ -52,6 +54,7 @@ public class MVEntityListener extends EntityListener {
}
}
@Override
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
if (event.isCancelled()) {
@ -64,7 +67,9 @@ public class MVEntityListener extends EntityListener {
}
}
/** Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit. */
/**
* Handle Animal/Monster Spawn settings, seems like a more concrete method than using CraftBukkit.
*/
@Override
public void onCreatureSpawn(CreatureSpawnEvent event) {

View File

@ -144,7 +144,7 @@ public class MVPlayerListener extends PlayerListener {
}
// TODO: Refactor these lines.
// Charge the teleporter
event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, teleporter, teleportee));
event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, teleporter, teleportee, true));
if (event.isCancelled() && teleporter != null) {
this.plugin.log(Level.FINE, "Player '" + teleportee.getName() + "' was DENIED ACCESS to '" + event.getTo().getWorld().getName() +
"' because '" + teleporter.getName() + "' don't have the FUNDS required to enter it.");
@ -190,7 +190,7 @@ public class MVPlayerListener extends PlayerListener {
this.plugin.log(Level.FINER, "Player '" + event.getPlayer().getName() + "' is portaling to the same world.");
return;
}
event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, event.getPlayer(), event.getPlayer()));
event.setCancelled(!pt.playerHasMoneyToEnter(fromWorld, toWorld, event.getPlayer(), event.getPlayer(), true));
if (event.isCancelled()) {
this.plugin.log(Level.FINE, "Player '" + event.getPlayer().getName() + "' was DENIED ACCESS to '" + event.getTo().getWorld().getName() +
"' because they don't have the FUNDS required to enter.");

View File

@ -23,7 +23,7 @@ import java.util.Map;
public class MVMessaging {
private MultiverseCore plugin;
private Map<String, Date> sentList;
private int cooldown = 0;
private int cooldown = 1000;
public MVMessaging(MultiverseCore plugin) {
this.plugin = plugin;

View File

@ -79,7 +79,7 @@ public class PermissionTools {
return returnString + "*";
}
public boolean playerHasMoneyToEnter(MultiverseWorld fromWorld, MultiverseWorld toWorld, Player teleporter, Player teleportee) {
public boolean playerHasMoneyToEnter(MultiverseWorld fromWorld, MultiverseWorld toWorld, Player teleporter, Player teleportee, boolean pay) {
if (teleporter == null) {
return true;
}
@ -96,7 +96,7 @@ public class PermissionTools {
}
if (!bank.hasEnough(teleporter, toWorld.getPrice(), toWorld.getCurrency(), errString)) {
return false;
} else {
} else if(pay) {
bank.pay(teleporter, toWorld.getPrice(), toWorld.getCurrency());
}
}