mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-22 17:27:38 +00:00
Hard-coded a list of items that can be used for WorldEdit.
This commit is contained in:
parent
c8054b95fe
commit
6eaf5895e4
26
src/DisallowedItemException.java
Normal file
26
src/DisallowedItemException.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// $Id$
|
||||||
|
/*
|
||||||
|
* WorldEdit
|
||||||
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author sk89q
|
||||||
|
*/
|
||||||
|
public class DisallowedItemException extends Exception {
|
||||||
|
|
||||||
|
}
|
@ -93,17 +93,38 @@ public class WorldEdit extends Plugin {
|
|||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
* @throws UnknownItemException
|
* @throws UnknownItemException
|
||||||
|
* @throws DisallowedItemException
|
||||||
*/
|
*/
|
||||||
private int getItem(String id) throws UnknownItemException {
|
private int getItem(String id) throws UnknownItemException,
|
||||||
|
DisallowedItemException {
|
||||||
|
int foundID;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt(id);
|
foundID = Integer.parseInt(id);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
try {
|
try {
|
||||||
return etc.getInstance().getDataSource().getItem(id);
|
foundID = etc.getInstance().getDataSource().getItem(id);
|
||||||
} catch (NumberFormatException e2) {
|
} catch (NumberFormatException e2) {
|
||||||
throw new UnknownItemException();
|
throw new UnknownItemException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((foundID >= 0 && foundID <= 5) ||
|
||||||
|
(foundID >= 7 && foundID <= 20) ||
|
||||||
|
foundID == 35 ||
|
||||||
|
(foundID >= 41 && foundID <= 45) ||
|
||||||
|
(foundID >= 47 && foundID <= 49) ||
|
||||||
|
(foundID >= 52 && foundID <= 54) ||
|
||||||
|
(foundID >= 56 && foundID <= 58) ||
|
||||||
|
(foundID >= 60 && foundID <= 62) ||
|
||||||
|
foundID == 67 ||
|
||||||
|
foundID == 73 ||
|
||||||
|
(foundID >= 78 && foundID <= 82) ||
|
||||||
|
foundID == 85) {
|
||||||
|
return foundID;
|
||||||
|
} else {
|
||||||
|
throw new DisallowedItemException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -165,8 +186,11 @@ public class WorldEdit extends Plugin {
|
|||||||
} catch (UnknownItemException e3) {
|
} catch (UnknownItemException e3) {
|
||||||
player.sendMessage(Colors.Rose + "Unknown item.");
|
player.sendMessage(Colors.Rose + "Unknown item.");
|
||||||
return true;
|
return true;
|
||||||
} catch (InsufficientArgumentsException e4) {
|
} catch (DisallowedItemException e4) {
|
||||||
player.sendMessage(Colors.Rose + e4.getMessage());
|
player.sendMessage(Colors.Rose + "Disallowed item.");
|
||||||
|
return true;
|
||||||
|
} catch (InsufficientArgumentsException e5) {
|
||||||
|
player.sendMessage(Colors.Rose + e5.getMessage());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -186,7 +210,7 @@ public class WorldEdit extends Plugin {
|
|||||||
|
|
||||||
private boolean handleEditCommand(Player player, String[] split)
|
private boolean handleEditCommand(Player player, String[] split)
|
||||||
throws UnknownItemException, IncompleteRegionException,
|
throws UnknownItemException, IncompleteRegionException,
|
||||||
InsufficientArgumentsException
|
InsufficientArgumentsException, DisallowedItemException
|
||||||
{
|
{
|
||||||
WorldEditSession session = getSession(player);
|
WorldEditSession session = getSession(player);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user