mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 02:25:41 +01:00
Commit paginated changes, Add PermissionsTools
This commit is contained in:
parent
562de0f002
commit
803eb84f3f
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
||||
|
@ -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.");
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user