mirror of
https://github.com/ArchipelagoMW/Archipelago.git
synced 2026-08-04 10:06:16 -07:00
Core: Remove worlds.generic.PlandoItem (#6035)
This commit is contained in:
@@ -450,13 +450,10 @@ safe_builtins = frozenset((
|
|||||||
|
|
||||||
|
|
||||||
class RestrictedUnpickler(pickle.Unpickler):
|
class RestrictedUnpickler(pickle.Unpickler):
|
||||||
generic_properties_module: Optional[object]
|
|
||||||
|
|
||||||
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||||
super(RestrictedUnpickler, self).__init__(*args, **kwargs)
|
super(RestrictedUnpickler, self).__init__(*args, **kwargs)
|
||||||
self.options_module = importlib.import_module("Options")
|
self.options_module = importlib.import_module("Options")
|
||||||
self.net_utils_module = importlib.import_module("NetUtils")
|
self.net_utils_module = importlib.import_module("NetUtils")
|
||||||
self.generic_properties_module = None
|
|
||||||
|
|
||||||
def find_class(self, module: str, name: str) -> type:
|
def find_class(self, module: str, name: str) -> type:
|
||||||
if module == "builtins" and name in safe_builtins:
|
if module == "builtins" and name in safe_builtins:
|
||||||
@@ -470,10 +467,6 @@ class RestrictedUnpickler(pickle.Unpickler):
|
|||||||
"SlotType", "NetworkSlot", "HintStatus"}:
|
"SlotType", "NetworkSlot", "HintStatus"}:
|
||||||
return getattr(self.net_utils_module, name)
|
return getattr(self.net_utils_module, name)
|
||||||
# Options and Plando are unpickled by WebHost -> Generate
|
# Options and Plando are unpickled by WebHost -> Generate
|
||||||
if module == "worlds.generic" and name == "PlandoItem":
|
|
||||||
if not self.generic_properties_module:
|
|
||||||
self.generic_properties_module = importlib.import_module("worlds.generic")
|
|
||||||
return getattr(self.generic_properties_module, name)
|
|
||||||
# pep 8 specifies that modules should have "all-lowercase names" (options, not Options)
|
# pep 8 specifies that modules should have "all-lowercase names" (options, not Options)
|
||||||
if module.lower().endswith("options"):
|
if module.lower().endswith("options"):
|
||||||
if module == "Options":
|
if module == "Options":
|
||||||
|
|||||||
@@ -52,24 +52,3 @@ class GenericWorld(World):
|
|||||||
if name == "Nothing":
|
if name == "Nothing":
|
||||||
return Item(name, ItemClassification.filler, -1, self.player)
|
return Item(name, ItemClassification.filler, -1, self.player)
|
||||||
raise InvalidItemError(name)
|
raise InvalidItemError(name)
|
||||||
|
|
||||||
@deprecated("worlds.generic.PlandoItem is deprecated and will be removed in the next version. "
|
|
||||||
"Use Options.PlandoItem(s) instead.")
|
|
||||||
class PlandoItem(NamedTuple):
|
|
||||||
item: str
|
|
||||||
location: str
|
|
||||||
world: Union[bool, str] = False # False -> own world, True -> not own world
|
|
||||||
from_pool: bool = True # if item should be removed from item pool
|
|
||||||
force: str = 'silent' # false -> warns if item not successfully placed. true -> errors out on failure to place item.
|
|
||||||
|
|
||||||
def warn(self, warning: str):
|
|
||||||
if self.force in ['true', 'fail', 'failure', 'none', 'false', 'warn', 'warning']:
|
|
||||||
logging.warning(f'{warning}')
|
|
||||||
else:
|
|
||||||
logging.debug(f'{warning}')
|
|
||||||
|
|
||||||
def failed(self, warning: str, exception=Exception):
|
|
||||||
if self.force in ['true', 'fail', 'failure']:
|
|
||||||
raise exception(warning)
|
|
||||||
else:
|
|
||||||
self.warn(warning)
|
|
||||||
|
|||||||
Reference in New Issue
Block a user