Hard-coded a list of items that can be used for WorldEdit.

Dieser Commit ist enthalten in:
sk89q 2010-10-02 01:36:33 -07:00
Ursprung c8054b95fe
Commit 6eaf5895e4
2 geänderte Dateien mit 56 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -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 {
}

Datei anzeigen

@ -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);